Details
Description
To reproduce: Using the latest 1.9 build ( cvs -z3 -d:pserver:anonymous@eu.cvs.moodle.org:/cvsroot/moodle co -P -r MOODLE_19_STABLE moodle )
1) Login as an instructor
2) Create a course
3) Create a new quiz, with no "close" date
4) View the quiz
Expected result: I expect the "preview quiz now" button to appear.
Actual result: The message "This quiz closed on " appears, with the date of the UNIX epoch listed as the close date.
5) Change the "close" date to sometime in the future
6) View the quiz
Expected result: I expect the "preview quiz now" button to appear, accompanied by the closing date of the quiz.
Actual result: The message "This quiz closed on " appears, with the correct (future) closing date of the quiz.
This appears to be a result of a code change to mod/quiz/view.php at line 108, which ANDs the quiz open/close times with the has_capability('mod/quiz:attempt'). This capability will (correctly) be missing for instructors, as they can only preview the quiz, not attempt it.
My fix was to OR that capability has_capability('mod/quiz:manage') so lines 105-108 now appear as:
// Print information about timings.
$timenow = time();
$available = ($quiz->timeopen < $timenow and ($timenow < $quiz->timeclose or !$quiz->timeclose)) &&
(has_capability('mod/quiz:attempt', $context) || has_capability('mod/quiz:manage', $context));
Attachments
Issue Links
| This issue is duplicated by: | ||||
| MDL-18064 | Janauary 1970 quiz close date date shown when switching role to Teacher |
|
|
|
You are right. The logic is wrong there. I can't believe no one noticed before. Well done! Thanks.
The good news is that the part of the code was completely refactored for Moodle 2.0, so this problem will go away in due course. However, we need to fix it on the 1.9 branch.
I don't think your solution is quite right. (It should probably be mod/quiz:preview, not manage.) However, I think the real issue is mixing up the bit of code that checks times with the bit that checks capabilities.