Details
Description
After some thought, we need to hack the quiz with an open-university-specific hack. We can control this using a $CFG->openuniversityhacks = true in config.php
The idea is to disallow "tutors" from seeing all the grades (reports) in a quiz until the quiz has finished.
So, we basically need to add a bit of logic like this:
$canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->course->id));
if (isset($CFG->openuniversityhacks) && !$canviewhidden && $quiz->timeclose && $quiz->timeclose > time() ) {
// FORCE THE QUIZ TO APPEAR AS FOR A STUDENT (NO EDIT, NO GRADE VIEW, NO REPORTS etc)
}
I like the idea of using the moodle/grade:viewhidden capability to control the ability to see quiz scores before they are released to students.
The key function to know about is quiz_get_reviewoptions from mod/quiz/locallib.php
I would edit the first branch of the if, (the teacher-ish one) so that $options->scores is set according to more complicated logic. If the user has capability moodle/grade:viewhidden then set it to true, otherwise, set it according to logic like the logic in the else.
Doing that should take care of whether scores are shown to tutors on mod/quiz/review.php.
On mod/quiz/report/overview.php, you will need to add a call to quiz_get_reviewoptions. To do that you will have to make up a fake $attempt object to stand for a generic student attempt ($attempt->preview = false, $attempt->timefinish = $quiz->timeopen should do it). Then check $options->scores where necessary as generating the report. Add a note about this funny call as a comment in the function.
Does that cover everything?