Skip to content

Commit

Permalink
MDL-71181 Quiz: Pass grade not displayed on front page
Browse files Browse the repository at this point in the history
  • Loading branch information
ettolrah committed Mar 23, 2021
1 parent 295901e commit 32eec4b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions mod/quiz/lang/en/quiz.php
Expand Up @@ -407,6 +407,7 @@
$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 <strong>{$a->cur}/{$a->max}</strong>.';
$string['gradingdetailspenalty'] = 'This submission attracted a penalty of {$a}.';
Expand Down
32 changes: 32 additions & 0 deletions 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"
9 changes: 9 additions & 0 deletions mod/quiz/view.php
Expand Up @@ -122,6 +122,8 @@
$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];
Expand Down Expand Up @@ -185,6 +187,13 @@
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();
Expand Down

0 comments on commit 32eec4b

Please sign in to comment.