Moodle

Quiz grade reports need to be hidden from tutors while the quiz is open

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 1.9
  • Component/s: Gradebook, Quiz
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

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)
}

Activity

Hide
Tim Hunt added a comment -

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?

Show
Tim Hunt added a comment - 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?
Hide
Tim Hunt added a comment -

Oh, and I think it should be has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_MODULE, $cm->id)), to allow maximum customisability, but you already have the context available in quiz_get_reviewoptions.

Show
Tim Hunt added a comment - Oh, and I think it should be has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_MODULE, $cm->id)), to allow maximum customisability, but you already have the context available in quiz_get_reviewoptions.
Hide
Yu Zhang added a comment -

Hi Tim,

If we do that, then outside OU if people have a teacher role without viewhidden capability then those teachers will be forced to use the "studentish" logic isn't it? I think we might need that flag Martin is suggesting.

Cheers,

Yu

Show
Yu Zhang added a comment - Hi Tim, If we do that, then outside OU if people have a teacher role without viewhidden capability then those teachers will be forced to use the "studentish" logic isn't it? I think we might need that flag Martin is suggesting. Cheers, Yu
Hide
Tim Hunt added a comment -

I agree that, with my suggestion, people who are not allowed to see hidden grades are not allowed to see hidden grades! This is a change to how things currently work, but that sounds like a good change to me!

Show
Tim Hunt added a comment - I agree that, with my suggestion, people who are not allowed to see hidden grades are not allowed to see hidden grades! This is a change to how things currently work, but that sounds like a good change to me!
Hide
Yu Zhang added a comment -

Code is in CVS please review. This needs the $CFG->openuniversityhacks = true in config.php to work properly. Cheers, Yu

Show
Yu Zhang added a comment - Code is in CVS please review. This needs the $CFG->openuniversityhacks = true in config.php to work properly. Cheers, Yu
Hide
Tim Hunt added a comment -

In my role as quiz maintainer, I think it is entirely correct that the quiz respects the moodle/grade:viewhidden capability, so I am taking out the openuniversityhacks condition.

I also fixed quiz_get_reviewoptions so that the variable $quiz_state_mask is defined before it is used.

I took out the MDL-11580 comments - they just clutter the code. If you want history and bug numbers, look in CVS history, let's keep the comments in the code to explain what the code is doing.

Reviewing this made me realise that overview/report.php was a mess. I took the opportunity to clean it up a bit. Expect a commit soon.

Show
Tim Hunt added a comment - In my role as quiz maintainer, I think it is entirely correct that the quiz respects the moodle/grade:viewhidden capability, so I am taking out the openuniversityhacks condition. I also fixed quiz_get_reviewoptions so that the variable $quiz_state_mask is defined before it is used. I took out the MDL-11580 comments - they just clutter the code. If you want history and bug numbers, look in CVS history, let's keep the comments in the code to explain what the code is doing. Reviewing this made me realise that overview/report.php was a mess. I took the opportunity to clean it up a bit. Expect a commit soon.
Hide
Martin Dougiamas added a comment -

I'm happy if it's possible to code this in such a way to use those quiz review options so that OU gets it working exactly as they like without the special variable.

We just need to be sure that the wierd condition doesn't create surprises for other users.

Based on the chat we had in Skype, Petr's going to work on setting hideuntil flags automatically in the grade_item so that the viewhidden capability works as expected in the quiz.

Show
Martin Dougiamas added a comment - I'm happy if it's possible to code this in such a way to use those quiz review options so that OU gets it working exactly as they like without the special variable. We just need to be sure that the wierd condition doesn't create surprises for other users. Based on the chat we had in Skype, Petr's going to work on setting hideuntil flags automatically in the grade_item so that the viewhidden capability works as expected in the quiz.
Hide
Tim Hunt added a comment -

OK, my changes checked in now.

Show
Tim Hunt added a comment - OK, my changes checked in now.
Hide
Petr Škoda (skodak) added a comment -

part 1 (committed) - support for hidden state modification in gradebook from activities (quiz now only)

part 2 (TODO) - the hiding/unhiding should be IMO locked in gradebook UI when activity overrides it

Show
Petr Škoda (skodak) added a comment - part 1 (committed) - support for hidden state modification in gradebook from activities (quiz now only) part 2 (TODO) - the hiding/unhiding should be IMO locked in gradebook UI when activity overrides it
Hide
Tim Hunt added a comment -

On a quick look, the part one changes look right.

Show
Tim Hunt added a comment - On a quick look, the part one changes look right.
Hide
Philip Butcher added a comment -

I have just talked this through with Tim and we have agreed that what he has done to the Quiz report (hide scores) should be extended to the various feedback options too. In other words tutors who cannot view hidden grades will obtain the same view of the quiz review that students see prior to results being released.

Show
Philip Butcher added a comment - I have just talked this through with Tim and we have agreed that what he has done to the Quiz report (hide scores) should be extended to the various feedback options too. In other words tutors who cannot view hidden grades will obtain the same view of the quiz review that students see prior to results being released.
Hide
Martin Dougiamas added a comment -

Can we work on making those "feedback options" clearer? Currently, they appear to only apply to Students, not Tutors. How are other Moodle users going to know or specify that these settings are going to apply to other roles besides Students?

Show
Martin Dougiamas added a comment - Can we work on making those "feedback options" clearer? Currently, they appear to only apply to Students, not Tutors. How are other Moodle users going to know or specify that these settings are going to apply to other roles besides Students?
Hide
Tim Hunt added a comment -

Martin, they will know once I fix MDL-11617.

Show
Tim Hunt added a comment - Martin, they will know once I fix MDL-11617.
Hide
Tim Hunt added a comment -

I think that we have done enough on this for 1.9, so we can take it off the 1.9 todo list and revisit the only remaining bit (the TODO in Petr's last comment) for 2.0.

Show
Tim Hunt added a comment - I think that we have done enough on this for 1.9, so we can take it off the 1.9 todo list and revisit the only remaining bit (the TODO in Petr's last comment) for 2.0.
Hide
Martin Dougiamas added a comment -

OK, marking this as resolved.

Show
Martin Dougiamas added a comment - OK, marking this as resolved.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: