UQM 2.0 - Predictions Extensions

All web design discussion, including Ultimate Quiz MOD support.

Moderator: CricketMX Forum Moderators

Re: UQM 2.0 - Predictions Extensions

Postby subvertbeats » Wed Feb 03, 2010 1:15 pm

EDIT: Well, whilst my logic above seems sound to me, reverting that change has got things working !

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

Re: UQM 2.0 - Predictions Extensions

Postby battye » Wed Feb 03, 2010 1:27 pm

Instead of having that "cancelled" bit inside the while loop (still not quite sure why this wasn't working for you because you said you didn't try and cancel the question, but regardless... :)) try an if statement inside the while loop.

So find the while loop and take out that "$question_id_set..." but (presumably you have already done this), and after the curly brace ( { ) add:

Code: Select all
if(  $_POST['question' . $question_id_set[$i]] != 'cancelled' )
{


Then at the end of the while loop, which I believe (double check this though as I only looked quickly) is:
Code: Select all
                     $users_information[$row['quiz_player']]['info'] = 'Question ' . $question_id_set[$i] . ' incorrect (' . $row['quiz_answer'] . ')';
                  }


After that, add:

Code: Select all
}


If you want to stay on the safe side, don't do this until you actually do have a cancelled question though :lol:
CricketMX.com.. home of bat's, rat's and other farmyard animals...
My articles: view all articles by battye

"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: 14253
Joined: Sun Jan 11, 2004 8:26 am
Location: Victoria Falls, Zimbabwe

Re: UQM 2.0 - Predictions Extensions

Postby subvertbeats » Wed Feb 03, 2010 2:08 pm

Thanks battye, whats your advise ref beta 4, and even the forthcoming final release?

should I try and keep up to date and patch accordingly?
Or should I just lok out for any important security related changes?

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

Re: UQM 2.0 - Predictions Extensions

Postby battye » Wed Feb 03, 2010 2:33 pm

I suggest upgrading to every new release if possible, there are some great new features in Beta 4.

How many changes did I say you should make to quiz.php? If I recall it was only commenting out one of the SQL queries? Is so, just comment out the same line in the new quiz.php - there are no database structure changes (a few new config rows only) and nothing should affect your control_quiz.php file.
CricketMX.com.. home of bat's, rat's and other farmyard animals...
My articles: view all articles by battye

"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: 14253
Joined: Sun Jan 11, 2004 8:26 am
Location: Victoria Falls, Zimbabwe

Re: UQM 2.0 - Predictions Extensions

Postby subvertbeats » Wed Feb 03, 2010 2:35 pm

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

Re: UQM 2.0 - Predictions Extensions

Postby battye » Sat Feb 06, 2010 7:20 am

In answer to your PM... yes leaving that line commented out could have some pretty funky effects. It might explain that strange behaviour you were having before.

I've been looking at a lot of code over the past week so I can't remember everything I've written for you, but that quiz you ran probably won't work (if that line has been commented out I imagine that no statistics have been recorded... look in the phpbb_quiz_statistics table, do you see any answers for this quiz submitted by users). You could still try doing the enter_answers to see what happens though. Worst case scenario is you delete the quiz, re-enter it and ask the users to resubmit their predictions.
CricketMX.com.. home of bat's, rat's and other farmyard animals...
My articles: view all articles by battye

"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: 14253
Joined: Sun Jan 11, 2004 8:26 am
Location: Victoria Falls, Zimbabwe

Re: UQM 2.0 - Predictions Extensions

Postby subvertbeats » Sat Feb 06, 2010 8:51 am

thanks battye...thought that might be the case..
subvertbeats
Know-It-All
Know-It-All
 
Posts: 113
Joined: Thu Jan 14, 2010 6:07 pm

Re: UQM 2.0 - Predictions Extensions

Postby subvertbeats » Thu May 20, 2010 12:33 pm

Battye

Quick Q - do you know of any way for a given quiz I can get a dump of all the answers that each user submitted?
subvertbeats
Know-It-All
Know-It-All
 
Posts: 113
Joined: Thu Jan 14, 2010 6:07 pm

Re: UQM 2.0 - Predictions Extensions

Postby battye » Fri May 21, 2010 12:37 pm

Try running this SQL code in phpMyAdmin:

(replace XXX with the quiz id)
Code: Select all
SELECT *
FROM phpbb_quiz_statistics
WHERE quiz_id = XXX
ORDER BY quiz_player
CricketMX.com.. home of bat's, rat's and other farmyard animals...
My articles: view all articles by battye

"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: 14253
Joined: Sun Jan 11, 2004 8:26 am
Location: Victoria Falls, Zimbabwe

Re: UQM 2.0 - Predictions Extensions

Postby subvertbeats » Fri May 21, 2010 6:12 pm

Thanks Battye, that did the trick.

Ive found an issue (dont know if it affects the core UQM too) whereby if a correct quiz answer has non alphanumeric characters in it eg quotation marks, then it is not counted correctly when the quiz answers are submitted.

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

Re: UQM 2.0 - Predictions Extensions

Postby battye » Sat May 22, 2010 3:03 am

It doesn't appear to be affecting an un-modded UQM, see quiz.php?mode=play&q=27 (answers are $2 and "$6" respectively, and it counts them correctly).
CricketMX.com.. home of bat's, rat's and other farmyard animals...
My articles: view all articles by battye

"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: 14253
Joined: Sun Jan 11, 2004 8:26 am
Location: Victoria Falls, Zimbabwe

Re: UQM 2.0 - Predictions Extensions

Postby subvertbeats » Sat May 29, 2010 9:49 am

battye wrote:It doesn't appear to be affecting an un-modded UQM, see quiz.php?mode=play&q=27 (answers are $2 and "$6" respectively, and it counts them correctly).


Interesting.....its definitely that. If I edit the question options, and change all the users answers for that question in the DB to remove the quotes, then re-enter the answers the correct/incorrect counts are done as expected.

Any ideas? Its not too important since we can just avoid using quotes in question answers, but would be nice to work it out some time.
subvertbeats
Know-It-All
Know-It-All
 
Posts: 113
Joined: Thu Jan 14, 2010 6:07 pm

Re: UQM 2.0 - Predictions Extensions

Postby subvertbeats » Fri Jun 24, 2011 10:54 am

hey battye I hope all is well with you?

Ive had requests for a modification of the system such that it sends a forum PM to the user with details of their answers when they successfully submit a quiz/competition.

any thoughts on the simplest way to do this?

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

Re: UQM 2.0 - Predictions Extensions

Postby subvertbeats » Mon Jun 27, 2011 1:05 pm

Hi battye

OK, so I figured out sending PMs on successful submission of a quiz.

I'll post the code here when complete.

What I would like to do is add to the PM content the list of questions, with the answer chosen by the user for each question

So I need to know how to iterate over all questions in the current quiz and build a string that includes:

- question name
- answer given by user for that question

Could you let me know how to access that info?

Many thanks!




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

Re: UQM 2.0 - Predictions Extensions

Postby battye » Mon Jun 27, 2011 4:16 pm

I don't have access to the computer right where I keep my local running copy of the UQM database so I can't test the query at the moment but I believe it would be, roughly:

Code: Select all
// assume $quiz_id is initialised earlier
$sql = "SELECT * FROM " . QUIZ_STATISTICS_TABLE . " s, " . QUIZ_TABLE . " q, " . QUIZ_QUESTIONS_TABLE . " t
WHERE t.question_quiz = " . (int) $quiz_id . "
AND s.quiz_question_id = t.question_id
AND s.quiz_user = " . (int) $user->data['user_id'];


That is just if you need to get the info from the database though. Assuming you are putting your submit_pm code (I believe there is plenty of information on how to do that at phpBB.com - http://www.google.com/search?hl=en&sour ... 5&aql=&oq=) in quiz.php you may not even need to access the database another time though. You could probably hook into some of the existing code.

For instance in quiz.php look for this code:

Code: Select all
            foreach( $play_quiz as $question )
            {
                // Get the actual information
                $actual_answer         = $question->show_correct();
                $question_answers     = $question->show_answers(); 


And below that is $db_answer, so you have the actual answer and $db_answer which is whatever the user submitted. By using $question->show_question() you can obtain the question name.

Good luck!
CricketMX.com.. home of bat's, rat's and other farmyard animals...
My articles: view all articles by battye

"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: 14253
Joined: Sun Jan 11, 2004 8:26 am
Location: Victoria Falls, Zimbabwe

PreviousNext

Return to Web Design

Who is online

Users browsing this forum: No registered users and 3 guests

cron