MDL-74302 mod_quiz: preview cap has higher priority than the attempt cap

This commit is contained in:
Shamim Rezaie
2022-04-04 19:03:20 +10:00
parent efda17d3b0
commit 3a25a52375
2 changed files with 14 additions and 11 deletions
+6 -1
View File
@@ -54,9 +54,14 @@ Feature: Preview a quiz as a teacher
And I follow "Finish review"
And "Review" "link" in the "Preview" "table_row" should be visible
@javascript
Scenario: Preview the quiz
Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "teacher"
When I press "Preview quiz"
Then I should see "Question 1"
And "Start a new preview" "button" should exist
Scenario: Admins should be able to preview a quiz
Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "admin"
When I press "Preview quiz"
Then I should see "Question 1"
And "Start a new preview" "button" should exist
+8 -10
View File
@@ -208,14 +208,15 @@ if (!$viewobj->quizhasquestions) {
} else {
if ($unfinished) {
if ($canattempt) {
$viewobj->buttontext = get_string('continueattemptquiz', 'quiz');
} else if ($canpreview) {
if ($canpreview) {
$viewobj->buttontext = get_string('continuepreview', 'quiz');
} else if ($canattempt) {
$viewobj->buttontext = get_string('continueattemptquiz', 'quiz');
}
} else {
if ($canattempt) {
if ($canpreview) {
$viewobj->buttontext = get_string('previewquizstart', 'quiz');
} else if ($canattempt) {
$viewobj->preventmessages = $viewobj->accessmanager->prevent_new_attempt(
$viewobj->numattempts, $viewobj->lastfinishedattempt);
if ($viewobj->preventmessages) {
@@ -225,15 +226,12 @@ if (!$viewobj->quizhasquestions) {
} else {
$viewobj->buttontext = get_string('reattemptquiz', 'quiz');
}
} else if ($canpreview) {
$viewobj->buttontext = get_string('previewquizstart', 'quiz');
}
}
// If, so far, we think a button should be printed, so check if they will be
// 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 ($viewobj->buttontext) {
if (!$canpreview && $viewobj->buttontext) {
if (!$viewobj->moreattempts) {
$viewobj->buttontext = '';
} else if ($canattempt