Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke(tm) v2.5x
Author Message
kenspa
Hangin' Around



Joined: Sep 24, 2005
Posts: 48
Location: Spain

PostPosted: Sat Jul 18, 2015 8:47 am Reply with quote

I installed nuke quiz versión: 3.2.0a on RN 2.5.1 and it ran perfectly and everything works fine, except for the following piece of code that comes in the index.php to retrieve certain number of players/ contestants, with their scores and percentages.

php Code:
$r = $db->sql_query("SELECT qid, title, hit_count FROM ".$prefix."_nquiz_quiz ORDER BY rand() LIMIT 0,1");

list($qid, $title, $main_total) = $db->sql_fetchrow($r);
$statistics = $db->sql_query("SELECT * FROM ".$prefix."_nquiz_scoreboard WHERE qid='$qid' ORDER BY perc DESC LIMIT 0,$pagenum");
OpenTable();
echo "<br><center><b>"._NQ_TOP." $pagenum "._NQ_LISTSCORE."";
echo " "._NQ_CPLAYERSBY." : $main_total "._NQ_PLAYERS."<br>";
echo "$title</b></center><br>";
echo"<center><table width='98%' border='1' cellpadding='2' cellspacing='2'><tr>";
echo"<th width='5%'>#</th><th width='30%'>"._NQ_UNAME."</th><th width='10%'>"._NQ_PERCENT."</th><th width='20%'>"._NQ_TTAKEN."</th><th width='35%'>"._NQ_DATETAKEN."</th></tr>";
if ($db->sql_numrows($statistics)==''){
echo "<td colspan='6'></td></tr><tr><td align='center' colspan='6'><b>"._NQ_NORESULTS."</b></td></tr>";
}
else {
$rowcount = $min+1;
while($astatistics = mysql_fetch_array($statistics)){
$setid = $db->sql_query("SELECT * FROM ".$prefix."_nquiz_quiz WHERE qid='$qid'");
$setid = mysql_fetch_array($setid);
$user = $astatistics['username'];
$name_len = $nq_config['cutoff'];
if (strlen($user) > $name_len){$user = substr($user, 0, ($name_len-2))."...";}
$score = $astatistics['score'];
$perc = $astatistics['perc'];
$date = $astatistics['date'];
$date = date($dateformat,$date );
$ttime = $astatistics['ttime'];
echo "<tr><td class='row1' align='center'>$rowcount</td><td class='row1' align='left'>$user</td><td align='center' class='row1'>$perc %</td class='row1'><td class='row1' align='center'>$ttime</td><td class='row1' align='center'>$date</td></tr>";
$rowcount++;
}
}
echo "</table><br>";


I tried around this snippet and couldn't find where the call breaks, because it returns no results even though the nquiz_scoreboard sql has rows in it!!

Thanks for any help.
 
View user's profile Send private message
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1772

PostPosted: Sat Jul 18, 2015 10:01 am Reply with quote

try this...

php Code:
$r = $db->sql_query('SELECT `qid`, `title`, `hit_count` FROM `' . $prefix . '_nquiz_quiz` ORDER BY rand() LIMIT 0,1');

list($qid, $title, $main_total) = $db->sql_fetchrow($r);
$statistics = $db->sql_query('SELECT * FROM `' . $prefix . '_nquiz_scoreboard` WHERE `qid` = \'' . $qid . '\' ORDER BY `perc` DESC LIMIT 0, ' . $pagenum . '');
OpenTable();
echo '<div class="t-center thick">' , _NQ_TOP , ' ' , $pagenum , ' ' , _NQ_LISTSCORE , ' ' , _NQ_CPLAYERSBY , ' : ' , $main_total , ' ' , _NQ_PLAYERS , '<br /> ' , htmlspecialchars($title, ENT_QUOTES, _CHARSET) , '</div><br />' , PHP_EOL
, '<table width="98%" border="1" class="centered" cellpadding="2" cellspacing="2">' , PHP_EOL
, '<tr>' , PHP_EOL
, '<th width="5%">#</th>' , PHP_EOL
, '<th width="30%">' , _NQ_UNAME , '</th>' , PHP_EOL
, '<th width="10%">' , _NQ_PERCENT , '</th>' , PHP_EOL
, '<th width="20%">' , _NQ_TTAKEN , '</th>' , PHP_EOL
, '<th width="35%">' , _NQ_DATETAKEN , '</th>' , PHP_EOL
, '</tr>' , PHP_EOL;
if ($db->sql_numrows($statistics) == '') {
echo '<td colspan="6">&nbsp;</td>' , PHP_EOL
, '</tr>' , PHP_EOL
, '<tr>' , PHP_EOL
, '<td class="text-center thick" colspan="6"> ' , _NQ_NORESULTS , '</td>' , PHP_EOL
, '</tr>' , PHP_EOL;
} else {
$rowcount = $min+1;
while ($astatistics = $db->sql_fetchrow($statistics)) {
$setid = $db->sql_fetchrow($db->sql_query('SELECT * FROM `' . $prefix . '_nquiz_quiz` WHERE `qid` = \'' . $qid . '\''));
$user = $astatistics['username'];
$name_len = $nq_config['cutoff'];
if (strlen($user) > $name_len){
$user = substr($user, 0, ($name_len-2)) . '...';
}
$score = $astatistics['score'];
$perc = $astatistics['perc'];
$date = $astatistics['date'];
$date = date($dateformat,$date );
$ttime = $astatistics['ttime'];
echo '<tr>' , PHP_EOL
, '<td class="row1" class="text-center">' , $rowcount , '</td>' , PHP_EOL
, '<td class="row1" class="text-left">' , htmlspecialchars($user, ENT_QUOTES, _CHARSET) , '</td>' , PHP_EOL
, '<td class="row1" class="text-center"> ' , $perc , ' %</td>' , PHP_EOL
, '<td class="row1" class="text-center">' , $ttime , '</td>' , PHP_EOL
, '<td class="row1" class="text-center">' , $date , '</td>' , PHP_EOL
, '</tr>' , PHP_EOL;
$rowcount++;
} # end of while
}
echo '</table><br />' , PHP_EOL;

_________________
Github: RavenNuke

Last edited by neralex on Sun Jul 19, 2015 8:51 pm; edited 1 time in total 
View user's profile Send private message
kenspa







PostPosted: Sun Jul 19, 2015 7:03 am Reply with quote

YES!!! Thanks neralex, that's fixed it. Very Happy

BTW, looking at the changes you've done to this snippet, and although this version is not that old (2011), there could be a need to change quite a few lines like you did, around the index.php especially the sql calls, although everything seems to be working.
There is another point more related to java, which is not working in this mod on the admin panel: The blue info buttons don't display info when hoovering over them.

Image

The code used for that is:
php Code:
//#############################//

//## Kissoftware Help System ##//
//#############################//
function kishelp_img($info) {
global $help_bgcolor, $help_txtcolor, $help_fgcolor;
if (!isset($help_bgcolor)){$help_bgcolor='#FF9900';}
if (!isset($help_fgcolor)){$help_fgcolor='#FFFFFF';}
if (!isset($help_txtcolor)){$help_txtcolor='#000000';}
$kisimage = kisimage("info.png");
return "<a href=\"javascript:void(0);\" onmouseover=\"return overlib( '$info', BELOW, LEFT, CAPTION, '&nbsp;"._HELP."', STATUS, '&nbsp;"._HELP."', WIDTH, 300, OFFSETY, 20, CAPICON, '$kisimage', FGCOLOR, '$help_fgcolor', BGCOLOR, '$help_bgcolor', TEXTCOLOR, '$help_txtcolor', CAPCOLOR, '$help_txtcolor', BORDER, '1');\" onmouseout=\"return nd();\"><img src='$kisimage' border='0' align='absmiddle'></a>";
}


Another big error, just for accessing the mod a new row will be added to db nquiz_league with username in blank.
in nuquiz_functions.php there is a function that might be creating this. The code:
php Code:
//##################################//

//## Keep League Tables Upto Date ##//
//##################################//
function kisupdateleague(){
global $prefix, $db, $nq_config;
$update = time();
$last = $nq_config['league_update'];
if ($last+3600 < $update){
$j = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_nquiz_league"));
for ($i=1; $i < $j+1; $i++) {
$leagueuser = $db->sql_query("SELECT username, count FROM ".$prefix."_nquiz_league WHERE nqlid='$i'");
list($username, $count) = $db->sql_fetchrow($leagueuser);
if ($count == ''){$count = '1';}
$result = $db->sql_query("SELECT qid FROM ".$prefix."_nquiz_scoreboard WHERE username='$username'");
while ($row = $db->sql_fetchrow($result)) {
$qid = $row['qid'];
$resultpoints = $db->sql_query("SELECT points_total, maxqnum FROM ".$prefix."_nquiz_quiz WHERE qid='$qid'");
while ($row = $db->sql_fetchrow($resultpoints)) {
$point = intval($row['points_total']);
$grandtotal=$point+$grandtotal;
$ques = $row['maxqnum'];
$gquestotal=$ques+$gquestotal;
}
}
$resulttotal = $db->sql_query("SELECT sum(score) as totalscore FROM ".$prefix."_nquiz_scoreboard WHERE username='$username'");
list($totalscore) = $db->sql_fetchrow($resulttotal);
$bonustotal = $db->sql_query("SELECT sum(bonus) as totalbonus FROM ".$prefix."_nquiz_scoreboard WHERE username='$username'");
list($totalbonus) = $db->sql_fetchrow($bonustotal);
if ($totalscore == ''){
$db->sql_query("DELETE FROM ".$prefix."_nquiz_scoreboard WHERE username='$username'");
$db->sql_query("OPTIMIZE TABLE ".$prefix."_nquiz_scoreboard");
}
else {
if ($grandtotal =='0'){$grandtotal ='1';}
$cal = ($totalscore/$grandtotal);
$perc = round($cal*100,2);
$average = ($totalscore/$count);
$avg = round($average, 0);
$db->sql_query("UPDATE ".$prefix."_nquiz_league SET count='$count', score = '$totalscore', bonus='$totalbonus', average = '$avg', total ='$grandtotal', totalques='$gquestotal', perc ='$perc', updated = '1' WHERE username='$username'");
$grandtotal = $gquestotal = $perc = $average="";
}
$db->sql_query("UPDATE ".$prefix."_nquiz_config SET config_value = '$update' WHERE config_name='league_update'");
}
}
}


Unfortunately, kissoftware, author of this mod, is no longer available to develop it and make it fully compliant!!

Thanks again for your help, I really appreciate it!! Smile
 
neralex







PostPosted: Sun Jul 19, 2015 8:48 pm Reply with quote

to your first snippet:

Maybe somewhere before is a codeline to load an external javascript file (.js) that is needed to use your posted javascript.

to your 2nd snippet:

There is no sql INSERT for a new row, so you have to look for it.
 
kenspa







PostPosted: Wed Jul 22, 2015 1:37 pm Reply with quote

Cheers neralex!

As for the java, and overlib, the path for overlib.js in includes/javascript.php was incorrect. it should be:
php Code:
echo "<script type=\"text/javascript\" src=\"includes/overlib/overlib.js\"><!-- overLIB (c) Erik Bosrup --></script>\n";


As for the sql, I removed all the nukequiz db, and installed it again. It seems to work except for some minor issues I'm on their track now.
Thanks again Smile
 
hicuxunicorniobestbuildpc
The Mouse Is Extension Of Arm



Joined: Aug 13, 2009
Posts: 1122

PostPosted: Fri Jul 24, 2015 3:02 pm Reply with quote

Is it working fine now?
 
View user's profile Send private message
kenspa







PostPosted: Sun Jul 26, 2015 12:31 pm Reply with quote

It looks fine now, I only tested the functionality on one quiz for a couple of times though. Next week I will give it more tries with more users and quizzes to see if the sql thing is sorted! Smile
Cheers
 
rovshan
Hangin' Around



Joined: Nov 26, 2005
Posts: 39

PostPosted: Fri Apr 15, 2016 5:57 am Reply with quote

kenspa wrote:
I installed nuke quiz versión: 3.2.0a on RN 2.5.1 and it ran perfectly and everything works fine, .


Could you please share this module with me. I could not find this version.
Thank you.
 
View user's profile Send private message
kenspa







PostPosted: Sun Sep 25, 2016 12:56 pm Reply with quote

sorry for the late reply. I'll have to find the package and let you know asap if you're still intrested in this mod.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> RavenNuke(tm) v2.5x

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©