Location: PHPKode > projects > Nukequiz > html/blocks/block-NQ_Random_Side_Top_Scorer.php
<?php
/*****************************************************************/
/* Nukequiz (tm)    v 3.1.0                                		 */
/* By: Kissoftware (hide@address.com)      		     */
/* http://www.kissoftware.org.uk                           		 */
/* http://www.kissoftware.co.uk                       		     */
/* Copyright © 2003-2008 by Kissoftware         				 */
/* See Docs For Information & Credits                 			 */
/* For More information Visit Forums Or The Online Help Manual	 */
/*****************************************************************/
/* Block To Show Random Top Scorer In Each Active Quiz			 */
/* ***************************************************************/
if(!defined('NUKE_FILE') && !defined('BLOCK_FILE')) { die('You can\'t access this file directly...'); }
global $prefix, $db, $currentlang;
$module_name="Nukequiz";
include_once("modules/$module_name/language/lang-".$currentlang.".php");
$configresult = $db->sql_query("SELECT config_name, config_value FROM ".$prefix."_nquiz_config");
while (list($config_name, $config_value) = $db->sql_fetchrow($configresult)) {
$config[$config_name] = $config_value;
$name_len = $config['cutoff'];
$height = intval($config['scrollheight']);
$dateformat = $config['dateformat'];
}
$sid = intval($sid);
$qid = intval($qid);
$content .= "<table width='100%' border='0' cellpadding='2' cellspacing='2'><tr>";
$result = $db->sql_query("select qid, sid, active, title FROM ".$prefix."_nquiz_quiz  WHERE active >'0' ORDER BY rand() LIMIT 0,1");
while(list($qid, $sid, $active, $title) = $db->sql_fetchrow($result)){
if (strlen($title) > '20')
$title = substr($title, 0, (20))."...";
$content .= "<td align='center'><br><a href='modules.php?name=$module_name&op=startquiz&amp;qid=$qid'>$title</a></b></td></tr>";
$scores = $db->sql_query("SELECT username, perc, date, ttime FROM ".$prefix."_nquiz_scoreboard WHERE qid='$qid' AND score >'0' ORDER BY perc DESC LIMIT 0,1");
if ($db->sql_numrows($scores)==""){
$content .="<tr><td align='center'>"._NQ_NOSCORESENT."<br><b>&ndash;&nbsp;&ndash;&nbsp;&loz;&nbsp;&loz;&nbsp;&ndash;&nbsp;&ndash;</b></td></tr>";
}
else{
$content .= "<tr><td align='center'>"._NQ_TOPSCORER."</td></tr>";
$content .= "<tr>";
while(list($username,$perc, $date, $ttime) = $db->sql_fetchrow($scores)){
if (strlen($username) > $name_len)
$username = substr($username, 0, ($name_len-2))."...";
$date = date($dateformat,$date);
$content .= "<td align='center'><b>$username</b></td></tr><tr><td align='center'>"._NQ_SCORED."&nbsp;<b>$perc%</b></td></tr><tr><td align='center'>"._NQ_TTAKEN."<br><b>$ttime</b><br>("._NQ_MINS."&nbsp;:&nbsp;"._NQ_SECS.")</td></tr><tr><td align='center'>"._NQ_SUBMITTED."<br>$date<br><b>&ndash;&nbsp;&ndash;&nbsp;&loz;&nbsp;&loz;&nbsp;&ndash;&nbsp;&ndash;</b></td></tr>";
}
}
}
$content .= "</table><br>";
//* Please Leave this Copyright Link In Here - Fair is Fair. Thanks */
$content .="<div align=\"right\"><a href=\"http://www.kissoftware.org.uk/\" target=\"_blank\"><img src=\"modules/$module_name/images/kiss.gif\"></a>&nbsp;";
?>
Return current item: Nukequiz