Need help to fix/shore up a few Quiz things in CVS

Need help to fix/shore up a few Quiz things in CVS

by John Papaioannou -
Number of replies: 1
Friendly disclaimer: This post is all about requesting some specific technical information, so if you are not Gustav or one of his team then please do not waste your time by paying attention to me. cool

Currently, there is a problem in Quiz's attempts.php which stems from invalid SQL but may have far-reaching consequences. Therefore it's imperative to decide how and what to fix ASAP, but unfortunately with all the latest goodies you people have built into Quiz I hardly understand what's going on anymore. smile

To start from the beginning:

A few days ago Patrick Li from Catalyst NZ reported this bug (the bug is in Assignment, but the Assignment code was copied over from Quiz) caused by invalid SQL in the attempts review code I wrote a couple of months ago. The bug wasn't noticed thus far because MySQL accepted the non-deterministic SQL (first problem here: invalid SQL needs to be fixed) and it even worked in a deterministic manner because of a workaround I put in there without completely realizing what was going on (second problem: after the refactoring, my workaround no longer works around).

Therefore, Quiz attempts.php does not work at all in Postgres and under specific circumstances does not even work correctly in MySQL. Specifically, the attempts table doesn't sort correctly by question grade.

I 'm currently doing R & D to rewrite it in a correct manner to solve both issues. However, I 've hit a wall and need this information to go on:

In mdl_quiz_states, which possible values of "event" denote rows where a question grade is present? What's the logic which will allow me to get the "definitive" question grade for each attempt? How do I know that a question hasn't been attempted at all?

Plus, there is something alarming I found that looks like a bug:

For the above questions, an obvious partial answer is that rows with event = 6 (QUIZ_EVENTCLOSE) mark questions that have been graded and rows with event = 0 (QUIZ_EVENTOPEN) carry no grades. However, I noticed that for quizzes performed before the major Quiz upgrade, the rows created in mdl_quiz_states carry grades but have event = 0. I strongly suspect that this will make it impossible to give a definite answer to my questions above, as rows created after the upgrade never carry a grade when event = 0. Therefore, the Quiz upgrade procedure needs to be "corrected" before the Beta. I don't exactly know how (setting event = 6 on those rows might give other problems I wouldn't know about) but you guys probably will.

Jon
Average of ratings: -
In reply to John Papaioannou

Re: Need help to fix/shore up a few Quiz things in CVS

by Gustav W Delius -
Hi Jon,

you are asking how you can find the grade from the last graded state of a question in the database. As you know the grade will be in a record in quiz_states. You need to know which record because in the new quiz module which allows adaptive items there can be a lot of states. The answer lies in the quiz_newest_states table. It is indexed by 'attemptid' and 'questionid' and its field 'newgraded' contains the id of the last graded state. You want the 'grade' field of that state in quiz_states.

By the way: asking me questions on the forums is not 100% reliable because I do tend to miss a lot of posts. Any bug report in the bug tracker however is guaranteed to reach me.