Merge branch 'MDL-51806_30' of https://github.com/snake/moodle into MOODLE_30_STABLE

This commit is contained in:
David Monllao
2016-05-30 10:52:21 +08:00
2 changed files with 39 additions and 8 deletions
+16
View File
@@ -81,6 +81,14 @@ function workshop_add_instance(stdclass $workshop) {
$workshop->phaseswitchassessment = (int)!empty($workshop->phaseswitchassessment);
$workshop->evaluation = 'best';
if (isset($workshop->gradinggradepass)) {
$workshop->gradinggradepass = unformat_float($workshop->gradinggradepass);
}
if (isset($workshop->submissiongradepass)) {
$workshop->submissiongradepass = unformat_float($workshop->submissiongradepass);
}
// insert the new record so we get the id
$workshop->id = $DB->insert_record('workshop', $workshop);
@@ -141,6 +149,14 @@ function workshop_update_instance(stdclass $workshop) {
$workshop->latesubmissions = (int)!empty($workshop->latesubmissions);
$workshop->phaseswitchassessment = (int)!empty($workshop->phaseswitchassessment);
if (isset($workshop->gradinggradepass)) {
$workshop->gradinggradepass = unformat_float($workshop->gradinggradepass);
}
if (isset($workshop->submissiongradepass)) {
$workshop->submissiongradepass = unformat_float($workshop->submissiongradepass);
}
// todo - if the grading strategy is being changed, we may want to replace all aggregated peer grades with nulls
$DB->update_record('workshop', $workshop);
+23 -8
View File
@@ -100,8 +100,7 @@ class mod_workshop_mod_form extends moodleform_mod {
$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');
$mform->setType('submissiongradepass', PARAM_RAW);
$label = get_string('gradinggrade', 'workshop');
$mform->addGroup(array(
@@ -114,8 +113,7 @@ class mod_workshop_mod_form extends moodleform_mod {
$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');
$mform->setType('gradinggradepass', PARAM_RAW);
$options = array();
for ($i=5; $i>=0; $i--) {
@@ -372,11 +370,28 @@ class mod_workshop_mod_form extends moodleform_mod {
}
}
if ($data['submissiongradepass'] > $data['grade']) {
$errors['submissiongradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['grade']);
// Check that the submission grade pass is a valid number.
if (isset($data['submissiongradepass'])) {
$submissiongradefloat = unformat_float($data['submissiongradepass'], true);
if ($submissiongradefloat === false || $submissiongradefloat === null) {
$errors['submissiongradepass'] = get_string('err_numeric', 'form');
} else {
if ($submissiongradefloat > $data['grade']) {
$errors['submissiongradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['grade']);
}
}
}
if ($data['gradinggradepass'] > $data['gradinggrade']) {
$errors['gradinggradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['gradinggrade']);
// Check that the grade pass is a valid number.
if (isset($data['gradinggradepass'])) {
$gradepassfloat = unformat_float($data['gradinggradepass'], true);
if ($gradepassfloat === false || $gradepassfloat === null) {
$errors['gradinggradepass'] = get_string('err_numeric', 'form');
} else {
if ($gradepassfloat > $data['gradinggrade']) {
$errors['gradinggradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['gradinggrade']);
}
}
}
return $errors;