diff --git a/mod/quiz/lang/en/quiz.php b/mod/quiz/lang/en/quiz.php index a10474f141b..680437f19b3 100644 --- a/mod/quiz/lang/en/quiz.php +++ b/mod/quiz/lang/en/quiz.php @@ -407,6 +407,7 @@ $string['gradesdeleted'] = 'Quiz grades deleted'; $string['gradesofar'] = '{$a->method}: {$a->mygrade} / {$a->quizgrade}.'; $string['gradetopassnotset'] = 'This quiz does not yet have a grade to pass set. It may be set in the Grade section of the quiz settings.'; $string['gradetopassmustbeset'] = 'Grade to pass cannot be zero as this quiz has its completion method set to require passing grade. Please set a non-zero value.'; +$string['gradetopassoutof'] = 'Grade to pass: {$a->grade} out of {$a->maxgrade}'; $string['gradingdetails'] = 'Marks for this submission: {$a->raw}/{$a->max}.'; $string['gradingdetailsadjustment'] = 'With previous penalties this gives {$a->cur}/{$a->max}.'; $string['gradingdetailspenalty'] = 'This submission attracted a penalty of {$a}.'; diff --git a/mod/quiz/tests/behat/info_page.feature b/mod/quiz/tests/behat/info_page.feature new file mode 100644 index 00000000000..3a9d45cef7f --- /dev/null +++ b/mod/quiz/tests/behat/info_page.feature @@ -0,0 +1,32 @@ +@mod @mod_quiz +Feature: Display of information before starting a quiz + As a student + In order to start a quiz with confidence + I need information about the quiz settings before I start an attempt + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student | Student | One | student@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student | C1 | student | + And the following "question categories" exist: + | contextlevel | reference | name | + | Course | C1 | Test questions | + And the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | TF1 | Text of the first question | + + Scenario: Check the pass grade is displayed + Given the following "activities" exist: + | activity | name | intro | course | idnumber | gradepass | + | quiz | Quiz 1 | Quiz 1 description | C1 | quiz1 | 60.00 | + And quiz "Quiz 1" contains the following questions: + | question | page | + | TF1 | 1 | + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" + Then I should see "Grade to pass: 60.00 out of 100.00" diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 4f8c0861b07..a8137c9b613 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -122,6 +122,8 @@ if (!$canpreview) { $mygradeoverridden = false; $gradebookfeedback = ''; +$item = null; + $grading_info = grade_get_grades($course->id, 'mod', 'quiz', $quiz->id, $USER->id); if (!empty($grading_info->items)) { $item = $grading_info->items[0]; @@ -185,6 +187,13 @@ if ($quiz->attempts != 1) { quiz_get_grading_option_name($quiz->grademethod)); } +if ($item && $item->gradepass) { + $a = new stdClass(); + $a->grade = quiz_format_grade($quiz, $item->gradepass); + $a->maxgrade = quiz_format_grade($quiz, $quiz->grade); + $viewobj->infomessages[] = get_string('gradetopassoutof', 'quiz', $a); +} + // Determine wheter a start attempt button should be displayed. $viewobj->quizhasquestions = $quizobj->has_questions(); $viewobj->preventmessages = array();