MDL-74302 mod_quiz: Users with preview cap should see prevent messages

This commit is contained in:
Shamim Rezaie
2022-04-04 19:03:20 +10:00
parent 2b5be06b68
commit abbb55eadf
2 changed files with 11 additions and 6 deletions
+1
View File
@@ -69,6 +69,7 @@ Feature: Preview a quiz as a teacher
| TF1 | 1 | |
| TF2 | 1 | 3.0 |
When I am on the "Quiz 2" "mod_quiz > View" page logged in as "admin"
And I should see "This quiz is not currently available"
And I press "Preview quiz"
Then I should see "if this were a real attempt, you would be blocked" in the ".alert-warning" "css_element"
+10 -6
View File
@@ -229,14 +229,18 @@ if (!$viewobj->quizhasquestions) {
}
}
// If this is not a preview and, so far, we think a button should be printed, so check if they will be
// allowed to access it.
if (!$canpreview && $viewobj->buttontext) {
// Users who can preview the quiz should be able to see all messages for not being able to access the quiz.
if ($canpreview) {
$viewobj->preventmessages = $viewobj->accessmanager->prevent_access();
} else if ($viewobj->buttontext) {
// If, so far, we think a button should be printed, so check if they will be allowed to access it.
if (!$viewobj->moreattempts) {
$viewobj->buttontext = '';
} else if ($canattempt
&& $viewobj->preventmessages = $viewobj->accessmanager->prevent_access()) {
$viewobj->buttontext = '';
} else if ($canattempt) {
$viewobj->preventmessages = $viewobj->accessmanager->prevent_access();
if ($viewobj->preventmessages) {
$viewobj->buttontext = '';
}
}
}
}