Looking for Additions

All web design discussion, including Ultimate Quiz MOD support.

Moderator: CricketMX Forum Moderators

User avatar
DakotaSurfer
Greenhorn
Greenhorn
Posts: 15
Joined: Thu Mar 20, 2008 10:54 pm
Location: Illinois, U.S.A.
Contact:

If you read my Intro post you see that I have a forum that just loves this Quiz mod... and as Administrator it's not that hard of a mod to handle but there are a couple things I'd like to see done or added or made available on this Quiz mod.

First would be a sorting function on the Quiz Stats page. Some of the options would be sort by Quiz or Quiz Participant. I plan on awarding prizes and being able to sort them by user ID or Quiz would be nice. I did notice that under the stats your second column says Quiz Author but it should be Quiz Participant since I author all the Quizzes. Along with the sorting option, it would be nice to be able to sort Ascending or Descending.

Secondly, I would like to be able to see additional pages of attempts. Right now we can set how many statistics will be displayed for each module? I plan on having probably over 200 Quizzes eventually and rather than setting the number to 200 maybe if there could be pages of stats like there are in a thread when there are several pages of posts in a thread. Hope I'm not losing anyone yet.

Last but not least, I think it would be nice if there was a section under the member's profiles where it could show a Quiz Stats Summary for each member. It could show:

Quizzes Taken | Total Questions | Total Correct | Total Incorrect | Total Percentage
.......25...................50...................40...............10.................80%

If you could come up with these additions to your Mod John Wayne fans would be forever grateful.

Thanks Pilgrims!!!
Michael
a.k.a. DakotaSurfer
Official John Wayne Message Board
Site Administrator
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Like I said in this topic - http://forums.cricketmx.com/viewtopic.p ... 578#p88578 - I have seen this and I will reply on the weekend.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Can you post the file "quiz_stats.php" into your next post (within

Code: Select all

 tags :)) and I'll see what I can whip up for you :)
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
DakotaSurfer
Greenhorn
Greenhorn
Posts: 15
Joined: Thu Mar 20, 2008 10:54 pm
Location: Illinois, U.S.A.
Contact:

Sorry... I've been gone for a few days... Here is the quiz_stats.php file. Thanks!

Code: Select all

<?php
/***************************************************************************
 *                               quiz_stats.php
 *                            -------------------
 *   begin                : Fri, Nov 18, 2005
 *   copyright          : (C) 2005 Battye @ CricketMX.com
 *   email                : cricketmx@hotmail.com
 *
 *   $Id: quiz_stats.php, v1 (Nov 2005) battye Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
include($phpbb_root_path . 'includes/functions_quiz.'.$phpEx);

	$language = $board_config['default_lang'];
	
	if (!file_exists($phpbb_root_path . 'language/lang_' . $language . '/lang_quiz.' . $phpEx))
	{
		$language = 'english';
	}
	
	include($phpbb_root_path . 'language/lang_' . $language . '/lang_quiz.' . $phpEx);
	
	// Statistical functions
	function qs_convert_quiz($quiz_id)
	{
	global $db;
	
	$sql = "SELECT quiz_name FROM " . QUIZ_GENERAL_TABLE . " WHERE quiz_id = " . intval($quiz_id);
		
		if(!$result = $db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, '', 'Could not obtain quiz name', __LINE__, __FILE__, $sql);
		}
	
		$row = $db->sql_fetchrow($result);
		
	return $row['quiz_name'];	
	}

	function qs_convert_userid($user_id)
	{
	global $db, $board_config;
	
	$sql = "SELECT username FROM " . USERS_TABLE . " WHERE user_id = " . intval($user_id);
		
		if(!$result = $db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, '', 'Could not obtain username', __LINE__, __FILE__, $sql);
		}
	
		$row = $db->sql_fetchrow($result);
		
	return $row['username'];	
	}
	
$userdata = session_pagestart($user_ip, PAGE_QUIZ);
init_userprefs($userdata);

$mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : '';

	if( $mode == '' || isset($HTTP_GET_VARS[POST_QUIZ_URL]) )
	{
	$page_title = $lang['Quiz_stats'];
	include($phpbb_root_path . "includes/page_header.$phpEx");
	$template->set_filenames(array("quiz_stats" => 'quiz_statistics_body.tpl'));

		$template->assign_vars( array(
		"L_MP_QUIZ" => $lang['Quiz_stats_most_plays'],
		"L_MP_PLAYS" => $lang['Quiz_stats_plays'],
		
		"L_QUIZ" => $lang['Quiz'],
		"L_CORRECT" => $lang['Quiz_stats_correct'],
		"L_INCORRECT" => $lang['Quiz_stats_incorrect'],
		"L_PERCENTAGE" => $lang['Quiz_stats_percentage'],
		"L_AUTHOR" => $lang['Quiz_stats_author'],
		"L_ALL_TIME_HI" => $lang['Quiz_stats_all_time_highest'],
		"L_STATS" => $lang['Quiz_stats']));

		if( isset($HTTP_GET_VARS[POST_QUIZ_URL]) )
		{
		$template->set_filenames(array("quiz_i_stats" => 'quiz_statistics_particular_body.tpl'));
		$quiz_statistics_name = qs_convert_quiz(  $HTTP_GET_VARS[POST_QUIZ_URL]  );
		
		$template->assign_vars( array(
		"U_I_QUIZ" => sprintf($lang['Quiz_stats_individual_high'], qs_convert_quiz($HTTP_GET_VARS[POST_QUIZ_URL]))));
		
			$hi_sql = "SELECT * FROM " . QUIZ_STATISTICS_TABLE . " WHERE quiz_id = " . intval($HTTP_GET_VARS[POST_QUIZ_URL]) . " ORDER BY stats_correct DESC LIMIT " .  $board_config['Quiz_Stats_Display'];
		
			if(!$hi_result = $db->sql_query($hi_sql))
			{
				message_die(GENERAL_ERROR, '', 'Could not obtain highest scores', __LINE__, __FILE__, $hi_sql);
			}
			
			if( $db->sql_numrows($hi_result) == 0 )
			{
				$template->assign_block_vars("qs_no_stats_row", array(
				"L_NOSTATS" => $lang['Quiz_stats_none']));
			}
			
			while( $hi_row = $db->sql_fetchrow($hi_result) )
			{
				$template->assign_block_vars("qs_i_highestscores_row", array(
				"U_USER" => "<a href='" . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $hi_row['user_id'] . "") . "'>" . qs_convert_userid($hi_row['user_id']) . "</a>",
				"U_CORRECT" => intval($hi_row['stats_correct']),
				"U_INCORRECT" => intval($hi_row['stats_incorrect']),
				"U_PERCENTAGE" => intval($hi_row['stats_percentage']) . '%'));
			}
		
		$template->pparse("quiz_i_stats");
		include($phpbb_root_path . "includes/page_tail.$phpEx");
		}
		
	$template->set_filenames(array("quiz_stats" => 'quiz_statistics_body.tpl'));
		
   $hi_sql = "SELECT * FROM " . QUIZ_STATISTICS_TABLE . " ORDER BY stats_correct DESC LIMIT " .  $board_config['Quiz_Stats_Display'];
	
	if(!$hi_result = $db->sql_query($hi_sql))
	{
		message_die(GENERAL_ERROR, '', 'Could not obtain highest scores', __LINE__, __FILE__, $hi_sql);
	}
		
		while( $hi_row = $db->sql_fetchrow($hi_result) )
		{
			$template->assign_block_vars("qshighestscores_row", array(
			"U_QUIZ" => "<a href='" . append_sid("quiz.$phpEx?" . POST_QUIZ_URL . "=" . $hi_row['quiz_id'] . "") . "'>" . qs_convert_quiz($hi_row['quiz_id']) . "</a>",
			"U_USER" => "<a href='" . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $hi_row['user_id'] . "") . "'>" . qs_convert_userid($hi_row['user_id']) . "</a>",
			"U_CORRECT" => intval($hi_row['stats_correct']),
			"U_INCORRECT" => intval($hi_row['stats_incorrect']),
			"U_PERCENTAGE" => intval($hi_row['stats_percentage']) . '%'));
		}
		
	$plays_sql = "SELECT * FROM " . QUIZ_GENERAL_TABLE . " ORDER BY quiz_plays DESC LIMIT " .  $board_config['Quiz_Stats_Display'];
		
	if(!$plays_result = $db->sql_query($plays_sql))
	{
		message_die(GENERAL_ERROR, '', 'Could not obtain most played quizzes', __LINE__, __FILE__, $plays_sql);
	}
		
		while( $plays_row = $db->sql_fetchrow($plays_result) )
		{
			$template->assign_block_vars("qsmostplays_row", array(
			"U_QUIZ" => "<a href='" . append_sid("quiz.$phpEx?" . POST_QUIZ_URL . "=" . $plays_row['quiz_id'] . "") . "'>" . qs_convert_quiz($plays_row['quiz_id']) . "</a>",
			"U_PLAYS" => intval($plays_row['quiz_plays'])));
		}
	
			
	$template->pparse("quiz_stats");
	include($phpbb_root_path . "includes/page_tail.$phpEx");
	}
?>
Michael
a.k.a. DakotaSurfer
Official John Wayne Message Board
Site Administrator
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

If you find

Code: Select all

 $hi_sql = "SELECT * FROM " . QUIZ_STATISTICS_TABLE . " WHERE quiz_id = " . intval($HTTP_GET_VARS[POST_QUIZ_URL]) . " ORDER BY stats_correct DESC LIMIT " .  $board_config['Quiz_Stats_Display'];
and replace with

Code: Select all

if( $HTTP_GET_VARS['sortoption'] == 'quiz' )
{
$sort_option = 'quiz_id';
}

else
{
$sort_option = 'stats_correct';
}

 $hi_sql = "SELECT * FROM " . QUIZ_STATISTICS_TABLE . " WHERE quiz_id = " . intval($HTTP_GET_VARS[POST_QUIZ_URL]) . " ORDER BY $sort_option DESC LIMIT " .  $board_config['Quiz_Stats_Display'];
And then go to quiz_stats.php?sortoption=quiz does it display differently?
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
DakotaSurfer
Greenhorn
Greenhorn
Posts: 15
Joined: Thu Mar 20, 2008 10:54 pm
Location: Illinois, U.S.A.
Contact:

I tried it and it didn't do a thing... no change at all.
Michael
a.k.a. DakotaSurfer
Official John Wayne Message Board
Site Administrator
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

It's going to be too hard to help you by posting potential changes and you testing them, because I don't have this MOD set up anywhere. My boards are on phpBB3 now.

So what I might need to do is use your installation. If you could PM me your FTP username and password (or create a new FTP account I can use) I will do the changes directly to your installation of the Quiz MOD :)
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

If we have a member that is active and answers a few quizzes but then we dump him and delete his account. It still shows the Quiz name with no name next to it but it still has the stats for it as well.

Where the blank spaces are is where the members name used to be at. Can these be purged or are we stuck with them until that quiz is deleted? Thanks for any help.
This one should be a simple SQL query to purge the statistics. The user that you deleted, do you remember his user_id number (ie. which number his account was). If so, all of his entries can be removed in one swift step through phpMyAdmin (do you have phpMyAdmin installed?).
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
DakotaSurfer
Greenhorn
Greenhorn
Posts: 15
Joined: Thu Mar 20, 2008 10:54 pm
Location: Illinois, U.S.A.
Contact:

Yes, but unfortunately I have no access. I told you, these people are really strict on access. Eventually I will dump the quizzes as they get old so the blanks will leave then I guess.
Michael
a.k.a. DakotaSurfer
Official John Wayne Message Board
Site Administrator
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

DakotaSurfer wrote:Yes, but unfortunately I have no access. I told you, these people are really strict on access. Eventually I will dump the quizzes as they get old so the blanks will leave then I guess.
Okay. What about FTP access? If I gave you a file with which to run containing this SQL query, would you be able to upload it, and then execute it?
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
DakotaSurfer
Greenhorn
Greenhorn
Posts: 15
Joined: Thu Mar 20, 2008 10:54 pm
Location: Illinois, U.S.A.
Contact:

battye wrote:
DakotaSurfer wrote:Yes, but unfortunately I have no access. I told you, these people are really strict on access. Eventually I will dump the quizzes as they get old so the blanks will leave then I guess.
Okay. What about FTP access? If I gave you a file with which to run containing this SQL query, would you be able to upload it, and then execute it?
Yes, that I do have. I run SQL updates when I install mods and have to put a db_update.php file on the server then run it from my browser. That would work. And it's user #738. If you put that in then I'd know where to put the next number if it happens again.
Michael
a.k.a. DakotaSurfer
Official John Wayne Message Board
Site Administrator
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Here is the file:

Look for these:

// Edit these
$q_user_id = 738;
$q_quiz_table = 'phpbb_quiz_statistics';

Edit the number to change the user_id, and if you use a table prefix other than phpbb_ you can change the $q_quiz_table variable to reflect this. :)

Code: Select all

<?php
/***************************************************************************
 *                               db_update.php
 *                            -------------------
 *
 *   copyright            : ©2003 Freakin' Booty ;-P & Antony Bailey
 *   project              : http://sourceforge.net/projects/dbgenerator
 *   Website              : http://freakingbooty.no-ip.com/ & http://www.rapiddr3am.net
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

// Edit these
$q_user_id = 738;
$q_quiz_table = 'phpbb_quiz_statistics';

if( !$userdata['session_logged_in'] )
{
    $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
    header($header_location . append_sid("login.$phpEx?redirect=db_update.$phpEx", true));
    exit;
}

if( $userdata['user_level'] != ADMIN )
{
    message_die(GENERAL_MESSAGE, 'You are not authorised to access this page');
}


$page_title = 'Updating the database';
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">';
echo '<tr><th>Updating the database</th></tr><tr><td><span class="genmed"><ul type="circle">';


$sql = array();
$sql[] = "DELETE FROM $q_quiz_table WHERE user_id = $q_user_id";

for( $i = 0; $i < count($sql); $i++ )
{
    if( !$result = $db->sql_query ($sql[$i]) )
    {
        $error = $db->sql_error();

        echo '<li>' . $sql[$i] . '<br /> +++ <font color="#FF0000"><b>Error:</b></font> ' . $error['message'] . '</li><br />';
    }
    else
    {
        echo '<li>' . $sql[$i] . '<br /> +++ <font color="#00AA00"><b>Successful</b></font></li><br />';
    }
}


echo '</ul></span></td></tr><tr><td class="catBottom" height="28">&nbsp;</td></tr>';

echo '<tr><th>Installation Complete</th></tr><tr><td><span class="genmed">Please be sure to delete this file now.<br />If you require any further assistance, please visit the <a href="http://www.phpbbhacks.com/forums">phpBBHacks.com Support Forums</a>.</span></td></tr>';
echo '<tr><td class="catBottom" height="28" align="center"><span class="genmed"><a href="' . append_sid("index.$phpEx") . '">Go back to your index page</a>.</span></td></table>';

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
As always when deleting data, it is advisable to create a database backup first.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
DakotaSurfer
Greenhorn
Greenhorn
Posts: 15
Joined: Thu Mar 20, 2008 10:54 pm
Location: Illinois, U.S.A.
Contact:

battye wrote:Here is the file:

Look for these:

// Edit these
$q_user_id = 738;
$q_quiz_table = 'phpbb_quiz_statistics';

Edit the number to change the user_id, and if you use a table prefix other than phpbb_ you can change the $q_quiz_table variable to reflect this. :)

As always when deleting data, it is advisable to create a database backup first.
You da man... it worked perfectly. I'm sure I'm not the only one that would like this option. It's perfect for when you need to delete a member and it leaves the blank stats behind. Thanks a bunch.
Michael
a.k.a. DakotaSurfer
Official John Wayne Message Board
Site Administrator
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

DakotaSurfer wrote:
battye wrote:Here is the file:

Look for these:

// Edit these
$q_user_id = 738;
$q_quiz_table = 'phpbb_quiz_statistics';

Edit the number to change the user_id, and if you use a table prefix other than phpbb_ you can change the $q_quiz_table variable to reflect this. :)

As always when deleting data, it is advisable to create a database backup first.
You da man... it worked perfectly. I'm sure I'm not the only one that would like this option. It's perfect for when you need to delete a member and it leaves the blank stats behind. Thanks a bunch.
Good to hear it worked! :)
I'll link to that post in the announcement at the top of this forum so others can find it easily if they look for it.
CricketMX.com in 2022: Still the home of bat's, rat's and other farmyard animals!

"OK, life [as you chose to define it] repeats until there are no more lessons to be learned." - nrnoble (June 12, 2005)
"the new forum looks awesome, it's getting bigger & better" - p2p-sharing-rules (11 Jan, 2008)
"Looks like CMX is not only getting bigger...but, also getting better!!" - moongirl (14 Dec, 2007)
User avatar
DakotaSurfer
Greenhorn
Greenhorn
Posts: 15
Joined: Thu Mar 20, 2008 10:54 pm
Location: Illinois, U.S.A.
Contact:

I have another option for you... what if someone make a valid mistake and hit "Enter" before they were done with a quiz. Now I know he quiz gets assigned a number. If I wanted to delete quiz #4 or q=4 for user# 738 or $q_user_id = 738, could that be put in that SQL deletion routine so I can only delete the info for one quiz on a specific member using a php file? (here's hoping)
Michael
a.k.a. DakotaSurfer
Official John Wayne Message Board
Site Administrator
Post Reply