mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge branch 'MDL-74516' of https://github.com/stronk7/moodle
This commit is contained in:
commit
27b5573e51
@ -492,8 +492,16 @@ abstract class moodleform_mod extends moodleform {
|
||||
$validategradepass = true;
|
||||
}
|
||||
|
||||
// Confirm gradepass is a valid non-zero value.
|
||||
if ($validategradepass && (!isset($data[$gradepassfieldname]) || grade_floatval($data[$gradepassfieldname]) == 0)) {
|
||||
// We need to make all the validations related with $gradepassfieldname
|
||||
// with them being correct floats, keeping the originals unmodified for
|
||||
// later validations / showing the form back...
|
||||
// TODO: Note that once MDL-73994 is fixed we'll have to re-visit this and
|
||||
// adapt the code below to the new values arriving here, without forgetting
|
||||
// the special case of empties and nulls.
|
||||
$gradepass = isset($data[$gradepassfieldname]) ? unformat_float($data[$gradepassfieldname]) : null;
|
||||
|
||||
// Confirm gradepass is a valid non-empty (null or zero) value.
|
||||
if ($validategradepass && (is_null($gradepass) || $gradepass == 0)) {
|
||||
$errors['completionpassgrade'] = get_string(
|
||||
'activitygradetopassnotset',
|
||||
'completion'
|
||||
@ -959,10 +967,9 @@ abstract class moodleform_mod extends moodleform {
|
||||
}
|
||||
|
||||
// Grade to pass.
|
||||
$mform->addElement('text', $gradepassfieldname, get_string('gradepass', 'grades'));
|
||||
$mform->addElement('float', $gradepassfieldname, get_string('gradepass', 'grades'));
|
||||
$mform->addHelpButton($gradepassfieldname, 'gradepass', 'grades');
|
||||
$mform->setDefault($gradepassfieldname, '');
|
||||
$mform->setType($gradepassfieldname, PARAM_RAW);
|
||||
$mform->hideIf($gradepassfieldname, $assessedfieldname, 'eq', '0');
|
||||
$mform->hideIf($gradepassfieldname, "{$scalefieldname}[modgrade_type]", 'eq', 'none');
|
||||
}
|
||||
@ -1136,10 +1143,9 @@ abstract class moodleform_mod extends moodleform {
|
||||
}
|
||||
|
||||
// Grade to pass.
|
||||
$mform->addElement('text', $gradepassfieldname, get_string($gradepassfieldname, 'grades'));
|
||||
$mform->addElement('float', $gradepassfieldname, get_string($gradepassfieldname, 'grades'));
|
||||
$mform->addHelpButton($gradepassfieldname, $gradepassfieldname, 'grades');
|
||||
$mform->setDefault($gradepassfieldname, '');
|
||||
$mform->setType($gradepassfieldname, PARAM_RAW);
|
||||
$mform->hideIf($gradepassfieldname, "{$gradefieldname}[modgrade_type]", 'eq', 'none');
|
||||
}
|
||||
}
|
||||
|
@ -1586,14 +1586,14 @@ function grade_course_reset($courseid) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a number to 5 decimal point float, an empty string or a null db compatible format
|
||||
* Convert a number to 5 decimal point float, null db compatible format
|
||||
* (we need this to decide if db value changed)
|
||||
*
|
||||
* @param float|null $number The number to convert
|
||||
* @return float|null float or null
|
||||
*/
|
||||
function grade_floatval(?float $number) {
|
||||
if (is_null($number) or $number === '') {
|
||||
if (is_null($number)) {
|
||||
return null;
|
||||
}
|
||||
// we must round to 5 digits to get the same precision as in 10,5 db fields
|
||||
|
@ -54,3 +54,36 @@ Feature: Set a quiz to be marked complete when the student passes
|
||||
And I navigate to "Reports" in current page administration
|
||||
And I click on "Activity completion" "link"
|
||||
And "Completed" "icon" should exist in the "Student 1" "table_row"
|
||||
|
||||
Scenario Outline: Verify that gradepass, together with completionpassgrade are validated correctly
|
||||
Given the following "language customisations" exist:
|
||||
| component | stringid | value |
|
||||
| core_langconfig | decsep | <decsep> |
|
||||
And the following "activity" exist:
|
||||
| activity | name | course | idnumber | gradepass | completion | completionpassgrade |
|
||||
| quiz | Oh, grades, passgrades and floats| C1 | ohgrades | <gradepass>| 2 | <completionpassgrade> |
|
||||
When I am on the "ohgrades" "quiz activity editing" page logged in as "teacher1"
|
||||
And I expand all fieldsets
|
||||
And I set the field "Grade to pass" to "<gradepass>"
|
||||
And I set the field "completionusegrade" to "1"
|
||||
And I set the field "completionpassgrade" to "<completionpassgrade>"
|
||||
And I press "Save and display"
|
||||
Then I should see "<seen>"
|
||||
And I should not see "<notseen>"
|
||||
|
||||
Examples:
|
||||
| gradepass | completionpassgrade | decsep | seen | notseen | outcome |
|
||||
| | 0 | . | method: Highest | Save and display | ok |
|
||||
| | 1 | . | does not have a valid | method: Highest | completion-err |
|
||||
| 0 | 0 | . | method: Highest | Save and display | ok |
|
||||
| 0 | 1 | . | does not have a valid | method: Highest | completion-err |
|
||||
| aaa | 0 | . | must enter a number | method: Highest | number-err |
|
||||
| aaa | 1 | . | must enter a number | method: Highest | number-err |
|
||||
| 200 | 0 | . | can not be greater | method: Highest | grade-big-err |
|
||||
| 200 | 1 | . | can not be greater | method: Highest | grade-big-err |
|
||||
| 5.55 | 0 | . | 5.55 out of 100 | Save and display | ok |
|
||||
| 5.55 | 1 | . | 5.55 out of 100 | Save and display | ok |
|
||||
| 5#55 | 0 | . | must enter a number | method: Highest | number-err |
|
||||
| 5#55 | 1 | . | must enter a number | method: Highest | number-err |
|
||||
| 5#55 | 0 | # | 5#55 out of 100 | Save and display | ok |
|
||||
| 5#55 | 1 | # | 5#55 out of 100 | Save and display | ok |
|
||||
|
@ -97,10 +97,9 @@ 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->addElement('float', 'submissiongradepass', get_string('gradetopasssubmission', 'workshop'));
|
||||
$mform->addHelpButton('submissiongradepass', 'gradepass', 'grades');
|
||||
$mform->setDefault('submissiongradepass', '');
|
||||
$mform->setType('submissiongradepass', PARAM_RAW);
|
||||
|
||||
$label = get_string('gradinggrade', 'workshop');
|
||||
$mform->addGroup(array(
|
||||
@ -110,10 +109,9 @@ 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->addElement('float', 'gradinggradepass', get_string('gradetopassgrading', 'workshop'));
|
||||
$mform->addHelpButton('gradinggradepass', 'gradepass', 'grades');
|
||||
$mform->setDefault('gradinggradepass', '');
|
||||
$mform->setType('gradinggradepass', PARAM_RAW);
|
||||
|
||||
$options = array();
|
||||
for ($i = 5; $i >= 0; $i--) {
|
||||
@ -469,7 +467,14 @@ class mod_workshop_mod_form extends moodleform_mod {
|
||||
isset($data['completiongradeitemnumber'])) {
|
||||
$itemnames = component_gradeitems::get_itemname_mapping_for_component('mod_workshop');
|
||||
$gradepassfield = $itemnames[(int) $data['completiongradeitemnumber']] . 'gradepass';
|
||||
if (!isset($data[$gradepassfield]) || grade_floatval($data[$gradepassfield]) == 0) {
|
||||
// We need to make all the validations related with $gradepassfield
|
||||
// with them being correct floats, keeping the originals unmodified for
|
||||
// later validations / showing the form back...
|
||||
// TODO: Note that once MDL-73994 is fixed we'll have to re-visit this and
|
||||
// adapt the code below to the new values arriving here, without forgetting
|
||||
// the special case of empties and nulls.
|
||||
$gradepass = isset($data[$gradepassfield]) ? unformat_float($data[$gradepassfield]) : null;
|
||||
if (is_null($gradepass) || $gradepass == 0) {
|
||||
$errors['completionpassgrade'] = get_string(
|
||||
'activitygradetopassnotset',
|
||||
'completion'
|
||||
|
Loading…
x
Reference in New Issue
Block a user