Page 11 of 12
Re: UQM 2.0 - Predictions Extensions
Posted: Wed Feb 03, 2010 1:15 pm
by subvertbeats
EDIT: Well, whilst my logic above seems sound to me, reverting that change has got things working !
Hmmm......
Re: UQM 2.0 - Predictions Extensions
Posted: Wed Feb 03, 2010 1:27 pm
by battye
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:
If you want to stay on the safe side, don't do this until you actually do have a cancelled question though
Re: UQM 2.0 - Predictions Extensions
Posted: Wed Feb 03, 2010 2:08 pm
by subvertbeats
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
Re: UQM 2.0 - Predictions Extensions
Posted: Wed Feb 03, 2010 2:33 pm
by battye
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.
Re: UQM 2.0 - Predictions Extensions
Posted: Wed Feb 03, 2010 2:35 pm
by subvertbeats
awesome, thanks battye!
Re: UQM 2.0 - Predictions Extensions
Posted: Sat Feb 06, 2010 7:20 am
by battye
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.
Re: UQM 2.0 - Predictions Extensions
Posted: Sat Feb 06, 2010 8:51 am
by subvertbeats
thanks battye...thought that might be the case..
Re: UQM 2.0 - Predictions Extensions
Posted: Thu May 20, 2010 12:33 pm
by subvertbeats
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?
Re: UQM 2.0 - Predictions Extensions
Posted: Fri May 21, 2010 12:37 pm
by battye
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
Re: UQM 2.0 - Predictions Extensions
Posted: Fri May 21, 2010 6:12 pm
by subvertbeats
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?
Re: UQM 2.0 - Predictions Extensions
Posted: Sat May 22, 2010 3:03 am
by battye
It doesn't appear to be affecting an un-modded UQM, see
http://forums.cricketmx.com/quiz.php?mode=play&q=27 (answers are $2 and "$6" respectively, and it counts them correctly).
Re: UQM 2.0 - Predictions Extensions
Posted: Sat May 29, 2010 9:49 am
by subvertbeats
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.
Re: UQM 2.0 - Predictions Extensions
Posted: Fri Jun 24, 2011 10:54 am
by subvertbeats
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
Re: UQM 2.0 - Predictions Extensions
Posted: Mon Jun 27, 2011 1:05 pm
by subvertbeats
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!
-
Re: UQM 2.0 - Predictions Extensions
Posted: Mon Jun 27, 2011 4:16 pm
by battye
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!