diff --git a/mod/quiz/tests/behat/preview.feature b/mod/quiz/tests/behat/preview.feature index dde7286d05a..39c23ef756a 100644 --- a/mod/quiz/tests/behat/preview.feature +++ b/mod/quiz/tests/behat/preview.feature @@ -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 diff --git a/mod/quiz/view.php b/mod/quiz/view.php index f7cf0a471ec..6cf361c6296 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -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