From 8164fad49dbd86252d6350631bd5cfc2f8477d30 Mon Sep 17 00:00:00 2001 From: Gregory Faller Date: Wed, 11 Feb 2015 12:42:38 +1030 Subject: [PATCH 1/2] MDL-13831 course: add gradepass field to mod_form --- course/modedit.php | 4 ++ course/modlib.php | 8 +++ course/moodleform_mod.php | 21 +++++++ grade/tests/behat/grade_to_pass.feature | 76 +++++++++++++++++++++++++ lang/en/grades.php | 1 + mod/upgrade.txt | 3 + mod/workshop/lang/en/workshop.php | 2 + mod/workshop/lib.php | 8 +++ mod/workshop/mod_form.php | 24 ++++++++ 9 files changed, 147 insertions(+) create mode 100644 grade/tests/behat/grade_to_pass.feature diff --git a/course/modedit.php b/course/modedit.php index 234e3ad13a0..aaa87e9e5fb 100644 --- a/course/modedit.php +++ b/course/modedit.php @@ -189,6 +189,10 @@ if (!empty($add)) { 'iteminstance'=>$data->instance, 'courseid'=>$course->id))) { // add existing outcomes foreach ($items as $item) { + if (!empty($item->gradepass)) { + $decimalpoints = $item->get_decimals(); + $data->gradepass = format_float($item->gradepass, $decimalpoints); + } if (!empty($item->outcomeid)) { $data->{'outcome_'.$item->outcomeid} = 1; } diff --git a/course/modlib.php b/course/modlib.php index 9a44714785e..ed653ce698c 100644 --- a/course/modlib.php +++ b/course/modlib.php @@ -191,8 +191,16 @@ function edit_module_post_actions($moduleinfo, $course) { // Sync idnumber with grade_item. if ($hasgrades && $grade_item = grade_item::fetch(array('itemtype'=>'mod', 'itemmodule'=>$moduleinfo->modulename, 'iteminstance'=>$moduleinfo->instance, 'itemnumber'=>0, 'courseid'=>$course->id))) { + $gradeupdate = false; if ($grade_item->idnumber != $moduleinfo->cmidnumber) { $grade_item->idnumber = $moduleinfo->cmidnumber; + $gradeupdate = true; + } + if (isset($moduleinfo->gradepass) && $grade_item->gradepass != $moduleinfo->gradepass) { + $grade_item->gradepass = $moduleinfo->gradepass; + $gradeupdate = true; + } + if ($gradeupdate) { $grade_item->update(); } } diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php index 6a3a845ff3e..8941cf3f662 100644 --- a/course/moodleform_mod.php +++ b/course/moodleform_mod.php @@ -299,6 +299,19 @@ abstract class moodleform_mod extends moodleform { $errors['assessed'] = get_string('scaleselectionrequired', 'rating'); } + // Grade to pass: ensure that the grade to pass is valid for points and scales. + // If we are working with a scale, convert into a positive number for validation. + if (isset($data['grade'])) { + if ($data['grade'] < 0) { + $grade = $data['grade'] * -1; + } else { + $grade = $data['grade']; + } + if (isset($data['gradepass']) && $data['gradepass'] > $grade) { + $errors['gradepass'] = get_string('gradepassgreaterthangrade', 'grades'); + } + } + // Completion: Don't let them choose automatic completion without turning // on some conditions. Ignore this check when completion settings are // locked, as the options are then disabled. @@ -645,6 +658,14 @@ abstract class moodleform_mod extends moodleform { grade_get_categories_menu($COURSE->id, $this->_outcomesused)); $mform->addHelpButton('gradecat', 'gradecategoryonmodform', 'grades'); } + if (!empty($this->current->gradepass)) { + $mform->addElement('text', 'gradepass', get_string('gradepass', 'grades')); + $mform->addHelpButton('gradepass', 'gradepass', 'grades'); + $mform->setDefault('gradepass', ''); + $mform->setType('gradepass', PARAM_FLOAT); + $mform->addRule('gradepass', null, 'numeric', null, 'client'); + $mform->disabledIf('gradepass', 'grade[modgrade_type]', 'eq', 'none'); + } } } diff --git a/grade/tests/behat/grade_to_pass.feature b/grade/tests/behat/grade_to_pass.feature new file mode 100644 index 00000000000..04bb39927fc --- /dev/null +++ b/grade/tests/behat/grade_to_pass.feature @@ -0,0 +1,76 @@ +@core @core_grades +Feature: We can set the grade to pass value + In order to set the grade to pass value + As a teacher + I assign a grade to pass to an activity while editing the activity. + I need to ensure that the grade to pass is visible in the gradebook. + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@asd.com | + And the following "courses" exist: + | fullname | shortname | format | numsections | + | Course 1 | C1 | weeks | 5 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I add a "Assignment" to section "1" and I fill the form with: + | Assignment name | Test Assignment 1 | + | Description | Submit your online text | + | assignsubmission_onlinetext_enabled | 1 | + + @javascript + Scenario: Validate that switching the type of grading used correctly disables grade to pass + When I follow "Test Assignment 1" + And I follow "Edit settings" + And I expand all fieldsets + And I set the field "grade[modgrade_type]" to "Point" + Then the "Grade to pass" "field" should be enabled + And I set the field "grade[modgrade_type]" to "None" + Then the "Grade to pass" "field" should be disabled + And I press "Save and return to course" + + @javascript + Scenario: Create an activity with a Grade to pass value greater than the maximum grade + When I follow "Test Assignment 1" + And I follow "Edit settings" + And I expand all fieldsets + And I set the field "grade[modgrade_type]" to "Point" + And I set the field "grade[modgrade_point]" to "50" + And I press "Save and display" + And I follow "Edit settings" + And I expand all fieldsets + And I set the field "Grade to pass" to "100" + And I press "Save and display" + Then I should see "The grade to pass is greater than the grade" + And I press "Cancel" + + @javascript + Scenario: Set a valid grade to pass for an assignment and workshop activity + When I follow "Test Assignment 1" + And I follow "Edit settings" + And I expand all fieldsets + And I set the field "grade[modgrade_type]" to "point" + And I set the field "grade[modgrade_point]" to "50" + And I set the field "Grade to pass" to "25" + And I press "Save and display" + And I follow "View gradebook" + And I turn editing mode on + And I click on "Edit assign Test Assignment 1" "link" + Then I should see "Edit grade item" + Then the field "Grade to pass" matches value "25" + And I follow "Course 1" + And I add a "Workshop" to section "1" and I fill the form with: + | Workshop name | Test Workshop 1 | + | Description | Test workshop | + | grade | 80 | + | Grade to pass for submission | 40 | + | gradinggrade | 20 | + | Grade to pass for assessment | 10 | + And I follow "Grades" + And I click on "Edit workshop Test Workshop 1 (submission)" "link" + Then the field "Grade to pass" matches value "40" diff --git a/lang/en/grades.php b/lang/en/grades.php index e80d92e8bff..0a334dfea9f 100644 --- a/lang/en/grades.php +++ b/lang/en/grades.php @@ -296,6 +296,7 @@ $string['gradeoutcomes'] = 'Outcomes'; $string['gradeoutcomescourses'] = 'Course outcomes'; $string['gradepass'] = 'Grade to pass'; $string['gradepass_help'] = 'This setting determines the minimum grade required to pass. The value is used in activity and course completion, and in the gradebook, where pass grades are highlighted in green and fail grades in red.'; +$string['gradepassgreaterthangrade'] = 'The grade to pass entered is greater than the maximum grade'; $string['gradepointdefault'] = 'Grade point default'; $string['gradepointdefault_help'] = 'This setting determines the default value for the grade point value available in an activity.'; $string['gradepointdefault_validateerror'] = 'This setting must be an integer between 1 and the grade point maximum.'; diff --git a/mod/upgrade.txt b/mod/upgrade.txt index d380281885f..7985d9d3c45 100644 --- a/mod/upgrade.txt +++ b/mod/upgrade.txt @@ -1,6 +1,9 @@ This files describes API changes in /mod/* - activity modules, information provided here is intended especially for developers. +=== 2.9 === +* Added Grade to pass field to mod_form for activities that support grading. + === 2.8 === * Constant FEATURE_GROUPMEMBERSONLY is deprecated. Modules should remove this diff --git a/mod/workshop/lang/en/workshop.php b/mod/workshop/lang/en/workshop.php index d7085c82a11..a3cda79cb4b 100644 --- a/mod/workshop/lang/en/workshop.php +++ b/mod/workshop/lang/en/workshop.php @@ -154,6 +154,8 @@ $string['gradeover'] = 'Override grade for submission'; $string['gradesreport'] = 'Workshop grades report'; $string['gradereceivedfrom'] = '<'; $string['gradeinfo'] = 'Grade: {$a->received} of {$a->max}'; +$string['gradetopasssubmission'] = 'Submission grade to pass'; +$string['gradetopassgrading'] = 'Assessment grade to pass'; $string['gradinggrade'] = 'Grade for assessment'; $string['gradinggrade_help'] = 'This setting specifies the maximum grade that may be obtained for submission assessment.'; $string['gradinggradecalculated'] = 'Calculated grade for assessment'; diff --git a/mod/workshop/lib.php b/mod/workshop/lib.php index faa01f0534d..8ad5a585fd7 100644 --- a/mod/workshop/lib.php +++ b/mod/workshop/lib.php @@ -1140,10 +1140,18 @@ function workshop_grade_item_category_update($workshop) { if (!empty($gradeitems)) { foreach ($gradeitems as $gradeitem) { if ($gradeitem->itemnumber == 0) { + if ($gradeitem->gradepass != $workshop->submissiongradepass) { + $gradeitem->gradepass = $workshop->submissiongradepass; + $gradeitem->update(); + } if ($gradeitem->categoryid != $workshop->gradecategory) { $gradeitem->set_parent($workshop->gradecategory); } } else if ($gradeitem->itemnumber == 1) { + if ($gradeitem->gradepass != $workshop->gradinggradepass) { + $gradeitem->gradepass = $workshop->gradinggradepass; + $gradeitem->update(); + } if ($gradeitem->categoryid != $workshop->gradinggradecategory) { $gradeitem->set_parent($workshop->gradinggradecategory); } diff --git a/mod/workshop/mod_form.php b/mod/workshop/mod_form.php index 8489fe7105f..ec29acdce4a 100644 --- a/mod/workshop/mod_form.php +++ b/mod/workshop/mod_form.php @@ -97,6 +97,12 @@ class mod_workshop_mod_form extends moodleform_mod { $mform->setDefault('grade', $workshopconfig->grade); $mform->addHelpButton('submissiongradegroup', 'submissiongrade', 'workshop'); + $mform->addElement('text', 'submissiongradepass', get_string('gradetopasssubmission', 'workshop')); + $mform->addHelpButton('submissiongradepass', 'gradepass', 'grades'); + $mform->setDefault('submissiongradepass', ''); + $mform->setType('submissiongradepass', PARAM_FLOAT); + $mform->addRule('submissiongradepass', null, 'numeric', null, 'client'); + $label = get_string('gradinggrade', 'workshop'); $mform->addGroup(array( $mform->createElement('select', 'gradinggrade', '', $grades), @@ -105,6 +111,12 @@ class mod_workshop_mod_form extends moodleform_mod { $mform->setDefault('gradinggrade', $workshopconfig->gradinggrade); $mform->addHelpButton('gradinggradegroup', 'gradinggrade', 'workshop'); + $mform->addElement('text', 'gradinggradepass', get_string('gradetopassgrading', 'workshop')); + $mform->addHelpButton('gradinggradepass', 'gradepass', 'grades'); + $mform->setDefault('gradinggradepass', ''); + $mform->setType('gradinggradepass', PARAM_FLOAT); + $mform->addRule('gradinggradepass', null, 'numeric', null, 'client'); + $options = array(); for ($i=5; $i>=0; $i--) { $options[$i] = $i; @@ -296,7 +308,10 @@ class mod_workshop_mod_form extends moodleform_mod { foreach ($gradeitems as $gradeitem) { // here comes really crappy way how to set the value of the fields // gradecategory and gradinggradecategory - grrr QuickForms + $decimalpoints = $gradeitem->get_decimals(); if ($gradeitem->itemnumber == 0) { + $submissiongradepass = $mform->getElement('submissiongradepass'); + $submissiongradepass->setValue(format_float($gradeitem->gradepass, $decimalpoints)); $group = $mform->getElement('submissiongradegroup'); $elements = $group->getElements(); foreach ($elements as $element) { @@ -305,6 +320,8 @@ class mod_workshop_mod_form extends moodleform_mod { } } } else if ($gradeitem->itemnumber == 1) { + $gradinggradepass = $mform->getElement('gradinggradepass'); + $gradinggradepass->setValue(format_float($gradeitem->gradepass, $decimalpoints)); $group = $mform->getElement('gradinggradegroup'); $elements = $group->getElements(); foreach ($elements as $element) { @@ -355,6 +372,13 @@ class mod_workshop_mod_form extends moodleform_mod { } } + if ($data['submissiongradepass'] > $data['grade']) { + $errors['submissiongradepass'] = get_string('gradepassgreaterthangrade', 'grades'); + } + if ($data['gradinggradepass'] > $data['gradinggrade']) { + $errors['gradinggradepass'] = get_string('gradepassgreaterthangrade', 'grades'); + } + return $errors; } } From c977b350593229518b49ac80c583623af9e74946 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Mon, 16 Mar 2015 14:57:33 +0800 Subject: [PATCH 2/2] MDL-13831 grades: allow to set gradepass in mod_form --- course/moodleform_mod.php | 35 ++-- grade/tests/behat/grade_to_pass.feature | 237 ++++++++++++++++++++---- lang/en/grades.php | 2 +- mod/workshop/mod_form.php | 4 +- 4 files changed, 232 insertions(+), 46 deletions(-) diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php index 8941cf3f662..ef638b38d76 100644 --- a/course/moodleform_mod.php +++ b/course/moodleform_mod.php @@ -301,14 +301,17 @@ abstract class moodleform_mod extends moodleform { // Grade to pass: ensure that the grade to pass is valid for points and scales. // If we are working with a scale, convert into a positive number for validation. - if (isset($data['grade'])) { - if ($data['grade'] < 0) { - $grade = $data['grade'] * -1; + + if (isset($data['gradepass']) && (isset($data['grade']) || isset($data['scale']))) { + $scale = isset($data['grade']) ? $data['grade'] : $data['scale']; + if ($scale < 0) { + $scalevalues = $DB->get_record('scale', array('id' => -$scale)); + $grade = count(explode(',', $scalevalues->scale)); } else { - $grade = $data['grade']; + $grade = $scale; } - if (isset($data['gradepass']) && $data['gradepass'] > $grade) { - $errors['gradepass'] = get_string('gradepassgreaterthangrade', 'grades'); + if ($data['gradepass'] > $grade) { + $errors['gradepass'] = get_string('gradepassgreaterthangrade', 'grades', $grade); } } @@ -637,6 +640,9 @@ abstract class moodleform_mod extends moodleform { $mform->addElement('select', 'advancedgradingmethod_'.$areaname, get_string('gradingmethod', 'core_grading'), $this->current->_advancedgradingdata['methods']); $mform->addHelpButton('advancedgradingmethod_'.$areaname, 'gradingmethod', 'core_grading'); + if (!$this->_features->rating) { + $mform->disabledIf('advancedgradingmethod_'.$areaname, 'grade[modgrade_type]', 'eq', 'none'); + } } else { // the module defines multiple gradable areas, display a selector @@ -657,13 +663,18 @@ abstract class moodleform_mod extends moodleform { get_string('gradecategoryonmodform', 'grades'), grade_get_categories_menu($COURSE->id, $this->_outcomesused)); $mform->addHelpButton('gradecat', 'gradecategoryonmodform', 'grades'); + if (!$this->_features->rating) { + $mform->disabledIf('gradecat', 'grade[modgrade_type]', 'eq', 'none'); + } } - if (!empty($this->current->gradepass)) { - $mform->addElement('text', 'gradepass', get_string('gradepass', 'grades')); - $mform->addHelpButton('gradepass', 'gradepass', 'grades'); - $mform->setDefault('gradepass', ''); - $mform->setType('gradepass', PARAM_FLOAT); - $mform->addRule('gradepass', null, 'numeric', null, 'client'); + + // Grade to pass. + $mform->addElement('text', 'gradepass', get_string('gradepass', 'grades')); + $mform->addHelpButton('gradepass', 'gradepass', 'grades'); + $mform->setDefault('gradepass', ''); + $mform->setType('gradepass', PARAM_FLOAT); + $mform->addRule('gradepass', null, 'numeric', null, 'client'); + if (!$this->_features->rating) { $mform->disabledIf('gradepass', 'grade[modgrade_type]', 'eq', 'none'); } } diff --git a/grade/tests/behat/grade_to_pass.feature b/grade/tests/behat/grade_to_pass.feature index 04bb39927fc..8ac6e3074c9 100644 --- a/grade/tests/behat/grade_to_pass.feature +++ b/grade/tests/behat/grade_to_pass.feature @@ -15,62 +15,237 @@ Feature: We can set the grade to pass value And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | + And the following "scales" exist: + | name | scale | + | Test Scale 1 | Disappointing, Good, Very good, Excellent | And I log in as "teacher1" And I follow "Course 1" - And I turn editing mode on - And I add a "Assignment" to section "1" and I fill the form with: - | Assignment name | Test Assignment 1 | - | Description | Submit your online text | - | assignsubmission_onlinetext_enabled | 1 | @javascript Scenario: Validate that switching the type of grading used correctly disables grade to pass - When I follow "Test Assignment 1" - And I follow "Edit settings" + When I turn editing mode on + And I add a "Assignment" to section "1" And I expand all fieldsets And I set the field "grade[modgrade_type]" to "Point" Then the "Grade to pass" "field" should be enabled And I set the field "grade[modgrade_type]" to "None" - Then the "Grade to pass" "field" should be disabled + And the "Grade to pass" "field" should be disabled And I press "Save and return to course" @javascript Scenario: Create an activity with a Grade to pass value greater than the maximum grade - When I follow "Test Assignment 1" - And I follow "Edit settings" - And I expand all fieldsets - And I set the field "grade[modgrade_type]" to "Point" - And I set the field "grade[modgrade_point]" to "50" - And I press "Save and display" - And I follow "Edit settings" - And I expand all fieldsets - And I set the field "Grade to pass" to "100" - And I press "Save and display" - Then I should see "The grade to pass is greater than the grade" + When I turn editing mode on + And I add a "Assignment" to section "1" and I fill the form with: + | Assignment name | Test Assignment 1 | + | Description | Submit your online text | + | assignsubmission_onlinetext_enabled | 1 | + | grade[modgrade_type] | Point | + | grade[modgrade_point] | 50 | + | Grade to pass | 100 | + Then I should see "The grade to pass can not be greater than the maximum possible grade 50" And I press "Cancel" @javascript - Scenario: Set a valid grade to pass for an assignment and workshop activity - When I follow "Test Assignment 1" - And I follow "Edit settings" - And I expand all fieldsets - And I set the field "grade[modgrade_type]" to "point" - And I set the field "grade[modgrade_point]" to "50" - And I set the field "Grade to pass" to "25" - And I press "Save and display" - And I follow "View gradebook" + Scenario: Set a valid grade to pass for an assignment activity using points + When I turn editing mode on + And I add a "Assignment" to section "1" and I fill the form with: + | Assignment name | Test Assignment 1 | + | Description | Submit your online text | + | assignsubmission_onlinetext_enabled | 1 | + | grade[modgrade_type] | Point | + | grade[modgrade_point] | 50 | + | Grade to pass | 25 | + And I follow "Grades" And I turn editing mode on And I click on "Edit assign Test Assignment 1" "link" - Then I should see "Edit grade item" Then the field "Grade to pass" matches value "25" And I follow "Course 1" + And I follow "Test Assignment 1" + And I follow "Edit settings" + And I expand all fieldsets + And I set the field "Grade to pass" to "30" + And I press "Save and return to course" + And I follow "Grades" + And I click on "Edit assign Test Assignment 1" "link" + And the field "Grade to pass" matches value "30" + + @javascript + Scenario: Set a valid grade to pass for an assignment activity using scales + When I turn editing mode on + And I add a "Assignment" to section "1" and I fill the form with: + | Assignment name | Test Assignment 1 | + | Description | Submit your online text | + | grade[modgrade_type] | Scale | + | grade[modgrade_scale] | Test Scale 1 | + | Grade to pass | 3 | + And I follow "Grades" + And I turn editing mode on + And I click on "Edit assign Test Assignment 1" "link" + And I follow "Show more..." + Then the field "Grade to pass" matches value "3" + And I set the field "Grade to pass" to "4" + And I press "Save changes" + And I follow "Course 1" + And I follow "Test Assignment 1" + And I follow "Edit settings" + And the field "Grade to pass" matches value "4" + + @javascript + Scenario: Set a invalid grade to pass for an assignment activity using scales + When I turn editing mode on + And I add a "Assignment" to section "1" and I fill the form with: + | Assignment name | Test Assignment 1 | + | Description | Submit your online text | + | grade[modgrade_type] | Scale | + | grade[modgrade_scale] | Test Scale 1 | + | Grade to pass | 10 | + Then I should see "The grade to pass can not be greater than the maximum possible grade 4" + + @javascript + Scenario: Set a valid grade to pass for workshop activity + When I turn editing mode on And I add a "Workshop" to section "1" and I fill the form with: | Workshop name | Test Workshop 1 | | Description | Test workshop | | grade | 80 | - | Grade to pass for submission | 40 | + | Submission grade to pass | 40 | | gradinggrade | 20 | - | Grade to pass for assessment | 10 | + | Assessment grade to pass | 10 | And I follow "Grades" + And I turn editing mode on And I click on "Edit workshop Test Workshop 1 (submission)" "link" + And I follow "Show more..." Then the field "Grade to pass" matches value "40" + And I set the field "Grade to pass" to "45" + And I press "Save changes" + And I click on "Edit workshop Test Workshop 1 (assessment)" "link" + And I follow "Show more..." + And the field "Grade to pass" matches value "10" + And I set the field "Grade to pass" to "15" + And I press "Save changes" + And I follow "Course 1" + And I follow "Test Workshop 1" + And I follow "Edit settings" + And the field "Submission grade to pass" matches value "45" + And the field "Assessment grade to pass" matches value "15" + + @javascript + Scenario: Set an invalid grade to pass for workshop activity + When I turn editing mode on + And I add a "Workshop" to section "1" and I fill the form with: + | Workshop name | Test Workshop 1 | + | Description | Test workshop | + | grade | 80 | + | Submission grade to pass | 90 | + | gradinggrade | 20 | + | Assessment grade to pass | 30 | + Then "The grade to pass can not be greater than the maximum possible grade 80" "text" should exist in the "#fitem_id_submissiongradepass .error" "css_element" + Then "The grade to pass can not be greater than the maximum possible grade 20" "text" should exist in the "#fitem_id_gradinggradepass .error" "css_element" + + @javascript + Scenario: Set a valid grade to pass for quiz activity + When I turn editing mode on + And I add a "Quiz" to section "1" and I fill the form with: + | Name | Test Quiz 1 | + | Grade to pass | 9.5 | + And I follow "Grades" + And I turn editing mode on + And I click on "Edit quiz Test Quiz 1" "link" + And I follow "Show more..." + Then the field "Grade to pass" matches value "9.5" + And I set the field "Grade to pass" to "8" + And I press "Save changes" + And I follow "Course 1" + And I follow "Test Quiz 1" + And I follow "Edit settings" + And the field "Grade to pass" matches value "8.00" + + @javascript + Scenario: Set a valid grade to pass for lesson activity + When I turn editing mode on + And I add a "Lesson" to section "1" and I fill the form with: + | Name | Test Lesson 1 | + | Description | Test | + | Grade to pass | 90 | + And I follow "Grades" + And I turn editing mode on + And I click on "Edit lesson Test Lesson 1" "link" + And I follow "Show more..." + Then the field "Grade to pass" matches value "90" + And I set the field "Grade to pass" to "80" + And I press "Save changes" + And I follow "Course 1" + And I follow "Test Lesson 1" + And I follow "Edit settings" + And the field "Grade to pass" matches value "80" + + @javascript + Scenario: Set a valid grade to pass for database activity + When I turn editing mode on + And I add a "Database" to section "1" and I fill the form with: + | Name | Test Database 1 | + | Description | Test | + | Grade to pass | 90 | + | Aggregate type | Average of ratings | + And I follow "Grades" + And I turn editing mode on + And I click on "Edit data Test Database 1" "link" + And I follow "Show more..." + Then the field "Grade to pass" matches value "90" + And I set the field "Grade to pass" to "80" + And I press "Save changes" + And I follow "Course 1" + And I follow "Test Database 1" + And I follow "Edit settings" + And the field "Grade to pass" matches value "80" + + @javascript + Scenario: Set an invalid grade to pass for forum activity + When I turn editing mode on + And I add a "Forum" to section "1" and I fill the form with: + | Forum name | Test Forum 1 | + | Description | Test | + | Grade to pass | 90 | + | Aggregate type | Average of ratings | + | scale[modgrade_point] | 60 | + Then I should see "The grade to pass can not be greater than the maximum possible grade 60" + + @javascript + Scenario: Set a valid grade to pass for forum activity + When I turn editing mode on + And I add a "Forum" to section "1" and I fill the form with: + | Forum name | Test Forum 1 | + | Description | Test | + | Grade to pass | 90 | + | Aggregate type | Average of ratings | + And I follow "Grades" + And I turn editing mode on + And I click on "Edit forum Test Forum 1" "link" + And I follow "Show more..." + Then the field "Grade to pass" matches value "90" + And I set the field "Grade to pass" to "80" + And I press "Save changes" + And I follow "Course 1" + And I follow "Test Forum 1" + And I follow "Edit settings" + And the field "Grade to pass" matches value "80" + + @javascript + Scenario: Set a valid grade to pass for glossary activity + When I turn editing mode on + And I add a "Glossary" to section "1" and I fill the form with: + | Name | Test Glossary 1 | + | Description | Test | + | Grade to pass | 90 | + | Aggregate type | Average of ratings | + And I follow "Grades" + And I turn editing mode on + And I click on "Edit glossary Test Glossary 1" "link" + And I follow "Show more..." + Then the field "Grade to pass" matches value "90" + And I set the field "Grade to pass" to "80" + And I press "Save changes" + And I follow "Course 1" + And I follow "Test Glossary 1" + And I follow "Edit settings" + And the field "Grade to pass" matches value "80" diff --git a/lang/en/grades.php b/lang/en/grades.php index 0a334dfea9f..a15d5228f7a 100644 --- a/lang/en/grades.php +++ b/lang/en/grades.php @@ -296,7 +296,7 @@ $string['gradeoutcomes'] = 'Outcomes'; $string['gradeoutcomescourses'] = 'Course outcomes'; $string['gradepass'] = 'Grade to pass'; $string['gradepass_help'] = 'This setting determines the minimum grade required to pass. The value is used in activity and course completion, and in the gradebook, where pass grades are highlighted in green and fail grades in red.'; -$string['gradepassgreaterthangrade'] = 'The grade to pass entered is greater than the maximum grade'; +$string['gradepassgreaterthangrade'] = 'The grade to pass can not be greater than the maximum possible grade {$a}'; $string['gradepointdefault'] = 'Grade point default'; $string['gradepointdefault_help'] = 'This setting determines the default value for the grade point value available in an activity.'; $string['gradepointdefault_validateerror'] = 'This setting must be an integer between 1 and the grade point maximum.'; diff --git a/mod/workshop/mod_form.php b/mod/workshop/mod_form.php index ec29acdce4a..8a0597b2ae3 100644 --- a/mod/workshop/mod_form.php +++ b/mod/workshop/mod_form.php @@ -373,10 +373,10 @@ class mod_workshop_mod_form extends moodleform_mod { } if ($data['submissiongradepass'] > $data['grade']) { - $errors['submissiongradepass'] = get_string('gradepassgreaterthangrade', 'grades'); + $errors['submissiongradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['grade']); } if ($data['gradinggradepass'] > $data['gradinggrade']) { - $errors['gradinggradepass'] = get_string('gradepassgreaterthangrade', 'grades'); + $errors['gradinggradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['gradinggrade']); } return $errors;