UQM 2.0 - Predictions Extensions

All web design discussion, including Ultimate Quiz MOD support.

Moderator: CricketMX Forum Moderators

subvertbeats
Know-It-All
Know-It-All
Posts: 113
Joined: Thu Jan 14, 2010 6:07 pm

Hey battye :)

Before the headers warning, this is output:
12
4
Which looks correct to me.
12 questions in the set, first question in the set with id 4
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Okay, now find:

Code: Select all

				for($i = 0; $i < $question_id_set_count; $i++ )
				{
AFTER ADD:

Code: Select all

echo 'I: ' . $i . '<br />';
echo 'RES: ' . $question_id_set[$i] . '<br /><br />';
Let me know the result
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)
subvertbeats
Know-It-All
Know-It-All
Posts: 113
Joined: Thu Jan 14, 2010 6:07 pm

12
4I: 0
RES: 4

I: 1
RES: 5

I: 2
RES: 6

I: 3
RES: 7

I: 4
RES: 8

I: 5
RES: 9

I: 6
RES: 10

I: 7
RES: 11

I: 8
RES: 12

I: 9
RES: 13

I: 10
RES: 14

I: 11
RES:

As per that extra comma, seems like the code is trying to find a 12th question that doesnt exist with a NULL index?
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Yep, I think we've found the culprit. Okay, you can remove all of those testing lines now and replace:

Code: Select all

				$question_id_set_count = sizeof($question_id_set);
With

Code: Select all

				$question_id_set_count = sizeof($question_id_set) - 1;
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)
subvertbeats
Know-It-All
Know-It-All
Posts: 113
Joined: Thu Jan 14, 2010 6:07 pm

Ok, now we're moving!

I made a simple 3 question quiz yesterday for a boxing event, and had a few forum mods do some dummy answers for testing.

So now we get:
User 377 answered question 1 CORRECTLYUser 377 answered question 1 CORRECTLYUser 55 answered question 1 CORRECTLYUser 88 answered question 1 INCORRECTLY. They entered the answer Fighter B.User 945 answered question 1 CORRECTLYUser 2 answered question 1 CORRECTLYUser 967 answered question 1 CORRECTLYUser 377 answered question 2 INCORRECTLY. They entered the answer Fighter C.User 377 answered question 2 INCORRECTLY. They entered the answer Fighter C.User 55 answered question 2 INCORRECTLY. They entered the answer Draw.User 88 answered question 2 CORRECTLYUser 945 answered question 2 INCORRECTLY. They entered the answer Fighter C.User 2 answered question 2 CORRECTLYUser 967 answered question 2 INCORRECTLY. They entered the answer Fighter C.User 377 answered question 3 INCORRECTLY. They entered the answer Fighter F.User 377 answered question 3 INCORRECTLY. They entered the answer Fighter F.User 55 answered question 3 INCORRECTLY. They entered the answer Fighter F.User 88 answered question 3 INCORRECTLY. They entered the answer Fighter F.User 945 answered question 3 INCORRECTLY. They entered the answer Fighter E.User 2 answered question 3 CORRECTLYUser 967 answered question 3 INCORRECTLY. They entered the answer Fighter E.
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Okay, next up is the multiple choice boxes.

FIND:

Code: Select all

echo 'Correct answer: <input type="text" name="question' . $row['quiz_question_id'] . '" />';
REPLACE WITH:

Code: Select all

				echo 'Correct answer:';

				$ans = 'SELECT quiz_answer FROM ' . QUIZ_DATA_TABLE . '
						WHERE quiz_question_id = ' . $row['quiz_question_id'];
				$ans_res = $db->sql_query($ans);
				while( $ans_row = $db->sql_fetchrow($ans_res) )
				{
					echo '<input type="radio" value="' . $ans_row['quiz_answer'] . '" name="question' . $row['quiz_question_id'] . '" /> ' . $ans_row['quiz_answer'] . '&nbsp;&nbsp;&nbsp;';
				} 


I wouldn't mind you trying this file though, as I want to make sure you've got exactly what I've got.

Code: Select all

<?php
// subvertbeats_quiz.php

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_quiz.' . $phpEx);
include($phpbb_root_path . 'includes/quiz_stats_class.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);

    if( !$auth->acl_get('a_') )
    {
        die('No access');
    }

    else
    {
        if( $_GET['mode'] == 'deactivate' )
        {
            $deactivate_id = (int) $_GET['id'];

            $sql = "UPDATE " . QUIZ_TABLE . " SET quiz_deactivate = 1
                    WHERE quiz_id = $deactivate_id";
            $db->sql_query($sql);
            die('Quiz id ' . $deactivate_id . ' has been deactivated');
        }

        if( $_GET['mode'] == 'activate' )
        {
            $activate_id = (int) $_GET['id'];

            $sql = "UPDATE " . QUIZ_TABLE . " SET quiz_deactivate = 0
                    WHERE quiz_id = $activate_id";
            $db->sql_query($sql);
            die('Quiz id ' . $activate_id . ' has been activated');
        }

        if( $_GET['mode'] == 'enter_answers' )
        {
            if( $_GET['a'] == 'submit' )
            {
                $question_id_hidden = $_POST['questions'];
                $question_id_set = explode(',', $question_id_hidden);
                $question_id_set_count = sizeof($question_id_set) - 1;

                $users = array();
                $users_information = array();

                for($i = 0; $i < $question_id_set_count; $i++ )
                {
                    $sql = 'SELECT * FROM ' . QUIZ_STATISTICS_TABLE . '
                            WHERE quiz_question_id = ' . $question_id_set[$i];
                    $result = $db->sql_query($sql);
                    while( $row = $db->sql_fetchrow($result) )
                    {
                        $users[$i] = $row['quiz_player'];

                        if( $row['quiz_answer'] == $_POST['question' . $question_id_set[$i]] )
                        {
                            echo 'User <strong>' . $row['quiz_player'] . '</strong> answered question <strong>' . $question_id_set[$i] . '</strong> CORRECTLY';
            
                            $users_information[$row['quiz_player']][] = 'Question ' . $question_id_set[$i] . ' correct';
                        }

                        else
                        {
                            echo 'User <strong>' . $row['quiz_player'] . '</strong> answered question <strong>' . $question_id_set[$i] . '</strong> INCORRECTLY. They entered the answer <strong>' . $row['quiz_answer'] . '</strong>.';
                            $users_information[$row['quiz_player']][] = 'Question ' . $question_id_set[$i] . ' incorrect (' . $row['quiz_answer'] . ')';
                        }
                    }
                }

                die();
            }

            $quiz_id = (int) $_GET['id'];
            $sql = 'SELECT * FROM ' . QUIZ_QUESTIONS_TABLE . '
                    WHERE quiz_related_id = ' . $quiz_id;
            $result = $db->sql_query($sql);
            echo '<form action="subvertbeats_quiz.php?mode=enter_answers&id=' . $quiz_id . '&a=submit" method="post">';
            $question_id_hidden = '';
            while( $row = $db->sql_fetchrow($result) )
            {    
                $question_id_hidden .= $row['quiz_question_id'] . ',';
                echo '<strong>Question: ' . $row['quiz_question'] . '</strong><br />';
                // echo 'Correct answer: <input type="text" name="question' . $row['quiz_question_id'] . '" />';
                echo 'Correct answer:';

                $ans = 'SELECT quiz_answer FROM ' . QUIZ_DATA_TABLE . '
                        WHERE quiz_question_id = ' . $row['quiz_question_id'];
                $ans_res = $db->sql_query($ans);
        while( $ans_row = $db->sql_fetchrow($ans_res) )
                {
                    echo '<input type="radio" value="' . $ans_row['quiz_answer'] . '" name="question' . $row['quiz_question_id'] . '" /> ' . $ans_row['quiz_answer'] . '&nbsp;&nbsp;&nbsp;';
                } 

                echo '<br /><br />';
            }
            echo '<input type="hidden" value="' . $question_id_hidden . '" name="questions" />';
            echo '<input type="submit" value="Submit" name="submit" />';
            echo '</form>';

            die(); // new
        }

        else
        {
            echo 'Mode types:<br />
                <strong>subvertbeats_quiz.php?mode=deactivate&id=XXX</strong><br />
                <strong>subvertbeats_quiz.php?mode=activate&id=XXX</strong><br />
                <strong>subvertbeats_quiz.php?mode=enter_answers&id=XXX</strong>';
            die();
        }
    }
?>
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)
subvertbeats
Know-It-All
Know-It-All
Posts: 113
Joined: Thu Jan 14, 2010 6:07 pm

Works perfectly. Same result set.

The only diffs shown were where I had modified the name of the file and references throughout the code, but I took your file and used that regardless.
subvertbeats
Know-It-All
Know-It-All
Posts: 113
Joined: Thu Jan 14, 2010 6:07 pm

Next I guess would be to update statistics table?
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Okay, great. I'll just address this, as it would look nicer if these are on new lines...
subvertbeats wrote:Ok, now we're moving!

I made a simple 3 question quiz yesterday for a boxing event, and had a few forum mods do some dummy answers for testing.

So now we get:
User 377 answered question 1 CORRECTLYUser 377 answered question 1 CORRECTLYUser 55 answered question 1 CORRECTLYUser 88 answered question 1 INCORRECTLY. They entered the answer Fighter B.User 945 answered question 1 CORRECTLYUser 2 answered question 1 CORRECTLYUser 967 answered question 1 CORRECTLYUser 377 answered question 2 INCORRECTLY. They entered the answer Fighter C.User 377 answered question 2 INCORRECTLY. They entered the answer Fighter C.User 55 answered question 2 INCORRECTLY. They entered the answer Draw.User 88 answered question 2 CORRECTLYUser 945 answered question 2 INCORRECTLY. They entered the answer Fighter C.User 2 answered question 2 CORRECTLYUser 967 answered question 2 INCORRECTLY. They entered the answer Fighter C.User 377 answered question 3 INCORRECTLY. They entered the answer Fighter F.User 377 answered question 3 INCORRECTLY. They entered the answer Fighter F.User 55 answered question 3 INCORRECTLY. They entered the answer Fighter F.User 88 answered question 3 INCORRECTLY. They entered the answer Fighter F.User 945 answered question 3 INCORRECTLY. They entered the answer Fighter E.User 2 answered question 3 CORRECTLYUser 967 answered question 3 INCORRECTLY. They entered the answer Fighter E.

FIND

Code: Select all

							echo 'User <strong>' . $row['quiz_player'] . '</strong> answered question <strong>' . $question_id_set[$i] . '</strong> CORRECTLY';
REPLACE WITH

Code: Select all

							echo 'User <strong>' . $row['quiz_player'] . '</strong> answered question <strong>' . $question_id_set[$i] . '</strong> CORRECTLY<br />';
FIND

Code: Select all

							echo 'User <strong>' . $row['quiz_player'] . '</strong> answered question <strong>' . $question_id_set[$i] . '</strong> INCORRECTLY. They entered the answer <strong>' . $row['quiz_answer'] . '</strong>.';
REPLACE WITH

Code: Select all

							echo 'User <strong>' . $row['quiz_player'] . '</strong> answered question <strong>' . $question_id_set[$i] . '</strong> INCORRECTLY. They entered the answer <strong>' . $row['quiz_answer'] . '</strong>.<br />';

Just to confirm, this information about right/wrong answers appears to be correct?
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)
subvertbeats
Know-It-All
Know-It-All
Posts: 113
Joined: Thu Jan 14, 2010 6:07 pm

Yes looks good. Would be nice if we could print forum user name instead of user ID.
User 377 answered question 1 INCORRECTLY. They entered the answer Fighter A.
User 377 answered question 1 INCORRECTLY. They entered the answer Fighter A.
User 55 answered question 1 INCORRECTLY. They entered the answer Fighter A.
User 88 answered question 1 CORRECTLY
User 945 answered question 1 INCORRECTLY. They entered the answer Fighter A.
User 2 answered question 1 INCORRECTLY. They entered the answer Fighter A.
User 967 answered question 1 INCORRECTLY. They entered the answer Fighter A.
User 377 answered question 2 INCORRECTLY. They entered the answer Fighter C.
User 377 answered question 2 INCORRECTLY. They entered the answer Fighter C.
User 55 answered question 2 INCORRECTLY. They entered the answer Draw.
User 88 answered question 2 CORRECTLY
User 945 answered question 2 INCORRECTLY. They entered the answer Fighter C.
User 2 answered question 2 CORRECTLY
User 967 answered question 2 INCORRECTLY. They entered the answer Fighter C.
User 377 answered question 3 INCORRECTLY. They entered the answer Fighter F.
User 377 answered question 3 INCORRECTLY. They entered the answer Fighter F.
User 55 answered question 3 INCORRECTLY. They entered the answer Fighter F.
User 88 answered question 3 INCORRECTLY. They entered the answer Fighter F.
User 945 answered question 3 INCORRECTLY. They entered the answer Fighter E.
User 2 answered question 3 CORRECTLY
User 967 answered question 3 INCORRECTLY. They entered the answer Fighter E.

Im user 377 here, and as you can see there are duplicate entries.
I believe this is not an issue with what we're doing her, but instead related to the duplicate statistics issue I reported in the main thread.
Just to confirm Ive never had the flag on to allow multiple submissions.
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Regarding the multiple submissions problem you are reporting, can you try and replicate the problem at http://forums.cricketmx.com/quiz.php ? I have switched on "play quiz once" - please continue this discussion in the other thread though :)

Okay, I have included the username instead of the user_id in this code:
There are some SQL queries in loops, which isn't very efficient but for the purposes of what we are doing it's quicker than building temporary arrays, etc, etc.

Code: Select all

<?php
// subvertbeats_quiz.php

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_quiz.' . $phpEx);
include($phpbb_root_path . 'includes/quiz_stats_class.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);

	if( !$auth->acl_get('a_') )
	{
		die('No access');
	}

	else
	{
		if( $_GET['mode'] == 'deactivate' )
		{
			$deactivate_id = (int) $_GET['id'];

			$sql = "UPDATE " . QUIZ_TABLE . " SET quiz_deactivate = 1
					WHERE quiz_id = $deactivate_id";
			$db->sql_query($sql);
			die('Quiz id ' . $deactivate_id . ' has been deactivated');
		}

		if( $_GET['mode'] == 'activate' )
		{
			$activate_id = (int) $_GET['id'];

			$sql = "UPDATE " . QUIZ_TABLE . " SET quiz_deactivate = 0
					WHERE quiz_id = $activate_id";
			$db->sql_query($sql);
			die('Quiz id ' . $activate_id . ' has been activated');
		}

		if( $_GET['mode'] == 'enter_answers' )
		{
			if( $_GET['a'] == 'submit' )
			{
				$question_id_hidden = $_POST['questions'];
				$question_id_set = explode(',', $question_id_hidden);
				$question_id_set_count = sizeof($question_id_set) - 1;

				$users = array();
				$users_information = array();

				for($i = 0; $i < $question_id_set_count; $i++ )
				{
					$sql = 'SELECT * FROM ' . QUIZ_STATISTICS_TABLE . '
							WHERE quiz_question_id = ' . $question_id_set[$i];
					$result = $db->sql_query($sql);
					while( $row = $db->sql_fetchrow($result) )
					{
						$users[$i] = $row['quiz_player'];

						$user_sql = 'SELECT username FROM ' . USERS_TABLE . '
									 WHERE user_id = ' . $row['quiz_player'];
						$user_result = $db->sql_query($user_sql);
						$user_name_fetch = $db->sql_fetchfield('username');
						$db->sql_freeresult($user_result);

						if( $row['quiz_answer'] == $_POST['question' . $question_id_set[$i]] )
						{
							echo 'User <strong>' . $user_name_fetch . '</strong> answered question <strong>' . $question_id_set[$i] . '</strong> CORRECTLY<br />';
			
							$users_information[$row['quiz_player']][] = 'Question ' . $question_id_set[$i] . ' correct';
						}

						else
						{
							echo 'User <strong>' . $user_name_fetch . '</strong> answered question <strong>' . $question_id_set[$i] . '</strong> INCORRECTLY. They entered the answer <strong>' . $row['quiz_answer'] . '</strong>.<br />';
							$users_information[$row['quiz_player']][] = 'Question ' . $question_id_set[$i] . ' incorrect (' . $row['quiz_answer'] . ')';
						}
					}
				}

				die();
			}

			$quiz_id = (int) $_GET['id'];
			$sql = 'SELECT * FROM ' . QUIZ_QUESTIONS_TABLE . '
					WHERE quiz_related_id = ' . $quiz_id;
			$result = $db->sql_query($sql);
			echo '<form action="subvertbeats_quiz.php?mode=enter_answers&id=' . $quiz_id . '&a=submit" method="post">';
			$question_id_hidden = '';
			while( $row = $db->sql_fetchrow($result) )
			{	
				$question_id_hidden .= $row['quiz_question_id'] . ',';
				echo '<strong>Question: ' . $row['quiz_question'] . '</strong><br />';
				// echo 'Correct answer: <input type="text" name="question' . $row['quiz_question_id'] . '" />';
				echo 'Correct answer:';

				$ans = 'SELECT quiz_answer FROM ' . QUIZ_DATA_TABLE . '
						WHERE quiz_question_id = ' . $row['quiz_question_id'];
				$ans_res = $db->sql_query($ans);
				while( $ans_row = $db->sql_fetchrow($ans_res) )
				{
					echo '<input type="radio" value="' . $ans_row['quiz_answer'] . '" name="question' . $row['quiz_question_id'] . '" /> ' . $ans_row['quiz_answer'] . '&nbsp;&nbsp;&nbsp;';
				} 

				echo '<br /><br />';
			}
			echo '<input type="hidden" value="' . $question_id_hidden . '" name="questions" />';
			echo '<input type="submit" value="Submit" name="submit" />';
			echo '</form>';

			die(); // new
		}

		else
		{
			echo 'Mode types:<br />
				<strong>subvertbeats_quiz.php?mode=deactivate&id=XXX</strong><br />
				<strong>subvertbeats_quiz.php?mode=activate&id=XXX</strong><br />
				<strong>subvertbeats_quiz.php?mode=enter_answers&id=XXX</strong>';
			die();
		}
	}
?>
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)
subvertbeats
Know-It-All
Know-It-All
Posts: 113
Joined: Thu Jan 14, 2010 6:07 pm

Yep will, do - just wanted to highlight the suspected reason for those duplicate entries instead of you thinking there was a potential issue with the results display code in here.

New code shows usernames - output looks great :)
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

This is a bit of a test I did for displaying the answers, please let me know the output of this:

Code: Select all

<?php
// subvertbeats_quiz.php

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_quiz.' . $phpEx);
include($phpbb_root_path . 'includes/quiz_stats_class.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);

	if( !$auth->acl_get('a_') )
	{
		die('No access');
	}

	else
	{
		if( $_GET['mode'] == 'deactivate' )
		{
			$deactivate_id = (int) $_GET['id'];

			$sql = "UPDATE " . QUIZ_TABLE . " SET quiz_deactivate = 1
					WHERE quiz_id = $deactivate_id";
			$db->sql_query($sql);
			die('Quiz id ' . $deactivate_id . ' has been deactivated');
		}

		if( $_GET['mode'] == 'activate' )
		{
			$activate_id = (int) $_GET['id'];

			$sql = "UPDATE " . QUIZ_TABLE . " SET quiz_deactivate = 0
					WHERE quiz_id = $activate_id";
			$db->sql_query($sql);
			die('Quiz id ' . $activate_id . ' has been activated');
		}

		if( $_GET['mode'] == 'enter_answers' )
		{
			if( $_GET['a'] == 'submit' )
			{
				$question_id_hidden = $_POST['questions'];
				$question_id_set = explode(',', $question_id_hidden);
				$question_id_set_count = sizeof($question_id_set) - 1;

				$users = array();
				$users_information = array();

				for($i = 0; $i < $question_id_set_count; $i++ )
				{
					$sql = 'SELECT * FROM ' . QUIZ_STATISTICS_TABLE . '
							WHERE quiz_question_id = ' . $question_id_set[$i];
					$result = $db->sql_query($sql);
					while( $row = $db->sql_fetchrow($result) )
					{
						$users[$i] = $row['quiz_player'];

						$user_sql = 'SELECT username FROM ' . USERS_TABLE . '
									 WHERE user_id = ' . $row['quiz_player'];
						$user_result = $db->sql_query($user_sql);
						$user_name_fetch = $db->sql_fetchfield('username');
						$db->sql_freeresult($user_result);

						$users[$i]['name'] = $user_name_fetch;

						if( $row['quiz_answer'] == $_POST['question' . $question_id_set[$i]] )
						{
							echo 'User <strong>' . $user_name_fetch . '</strong> answered question <strong>' . $question_id_set[$i] . '</strong> CORRECTLY<br />';
			
							$users_information[$row['quiz_player']][] = 'Question ' . $question_id_set[$i] . ' correct';
						}

						else
						{
							echo 'User <strong>' . $user_name_fetch . '</strong> answered question <strong>' . $question_id_set[$i] . '</strong> INCORRECTLY. They entered the answer <strong>' . $row['quiz_answer'] . '</strong>.<br />';
							$users_information[$row['quiz_player']][] = 'Question ' . $question_id_set[$i] . ' incorrect (' . $row['quiz_answer'] . ')';
						}
					}
				}

				$size_users = sizeof($users);
				for($j = 0; $j < $size_users; $j++ )
				{
					echo '<strong>' . $users[$j]['name'] . '</strong>';
					$size_users_answers = sizeof($users_information[$users[$j]]);
					for($k = 0; $k < $size_users_answers; $k++ )
					{
						echo $users_information[$users[$j]][$k] . '<br />';
					}
					echo '<br /><br />';
				}

				die();
			}

			$quiz_id = (int) $_GET['id'];
			$sql = 'SELECT * FROM ' . QUIZ_QUESTIONS_TABLE . '
					WHERE quiz_related_id = ' . $quiz_id;
			$result = $db->sql_query($sql);
			echo '<form action="subvertbeats_quiz.php?mode=enter_answers&id=' . $quiz_id . '&a=submit" method="post">';
			$question_id_hidden = '';
			while( $row = $db->sql_fetchrow($result) )
			{	
				$question_id_hidden .= $row['quiz_question_id'] . ',';
				echo '<strong>Question: ' . $row['quiz_question'] . '</strong><br />';
				// echo 'Correct answer: <input type="text" name="question' . $row['quiz_question_id'] . '" />';
				echo 'Correct answer:';

				$ans = 'SELECT quiz_answer FROM ' . QUIZ_DATA_TABLE . '
						WHERE quiz_question_id = ' . $row['quiz_question_id'];
				$ans_res = $db->sql_query($ans);
				while( $ans_row = $db->sql_fetchrow($ans_res) )
				{
					echo '<input type="radio" value="' . $ans_row['quiz_answer'] . '" name="question' . $row['quiz_question_id'] . '" /> ' . $ans_row['quiz_answer'] . '&nbsp;&nbsp;&nbsp;';
				} 

				echo '<br /><br />';
			}
			echo '<input type="hidden" value="' . $question_id_hidden . '" name="questions" />';
			echo '<input type="submit" value="Submit" name="submit" />';
			echo '</form>';

			die(); // new
		}

		else
		{
			echo 'Mode types:<br />
				<strong>subvertbeats_quiz.php?mode=deactivate&id=XXX</strong><br />
				<strong>subvertbeats_quiz.php?mode=activate&id=XXX</strong><br />
				<strong>subvertbeats_quiz.php?mode=enter_answers&id=XXX</strong>';
			die();
		}
	}
?>
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)
subvertbeats
Know-It-All
Know-It-All
Posts: 113
Joined: Thu Jan 14, 2010 6:07 pm

Same outout except the output is followed by:
D

D

D
User avatar
battye
Site Admin
Site Admin
Posts: 14391
Joined: Sun Jan 11, 2004 8:26 am
Location: Australia
Contact:

Okay try this.

FIND:

Code: Select all

				for($j = 0; $j < $size_users; $j++ )
				{
					echo '<strong>' . $users[$j]['name'] . '</strong>';
					$size_users_answers = sizeof($users_information[$users[$j]]);
					for($k = 0; $k < $size_users_answers; $k++ )
					{
						echo $users_information[$users[$j]][$k] . '<br />';
					}
					echo '<br /><br />';
				}
AFTER ADD

Code: Select all

print_r($users_information);
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)
Post Reply