mirror of
https://github.com/moodle/moodle.git
synced 2025-06-04 07:06:45 +02:00
MDL-32249 completion: Make grade criteria more consistent
Also, round course grades and remove hardcoded string. Note: This patch also removes the ability to update the course grade from the completion interface
This commit is contained in:
parent
6be7840ce6
commit
08f19f4848
@ -141,16 +141,6 @@ if ($form->is_cancelled()){
|
||||
$aggregation->setMethod($data->role_aggregation);
|
||||
$aggregation->save();
|
||||
|
||||
// Update course total passing grade
|
||||
if (!empty($data->criteria_grade)) {
|
||||
if ($grade_item = grade_category::fetch_course_category($course->id)->grade_item) {
|
||||
$grade_item->gradepass = $data->criteria_grade_value;
|
||||
if (method_exists($grade_item, 'update')) {
|
||||
$grade_item->update('course/completion.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_to_log($course->id, 'course', 'completion updated', 'completion.php?id='.$course->id);
|
||||
|
||||
$url = new moodle_url('/course/view.php', array('id' => $course->id));
|
||||
|
@ -179,10 +179,13 @@ class course_completion_form extends moodleform {
|
||||
$criteria->config_form_display($mform);
|
||||
|
||||
// Completion on course grade
|
||||
$mform->addElement('header', 'grade', get_string('grade'));
|
||||
$mform->addElement('header', 'grade', get_string('coursegrade', 'completion'));
|
||||
|
||||
// Grade enable and passing grade
|
||||
$course_grade = $DB->get_field('grade_items', 'gradepass', array('courseid' => $course->id, 'itemtype' => 'course'));
|
||||
if (!$course_grade) {
|
||||
$course_grade = '0.00000';
|
||||
}
|
||||
$criteria = new completion_criteria_grade($params);
|
||||
$criteria->config_form_display($mform, $course_grade);
|
||||
|
||||
|
@ -110,6 +110,7 @@ $string['courseprerequisites']='Course prerequisites';
|
||||
$string['coursesavailable']='Courses available';
|
||||
$string['coursesavailableexplaination']='<i>Course completion criteria must be set for a course to appear in this list</i>';
|
||||
$string['criteria']='Criteria';
|
||||
$string['criteriagradenote'] = 'Please note that updating the required grade here will not update the current course pass grade.';
|
||||
$string['criteriagroup']='Criteria group';
|
||||
$string['criteriarequiredall']='All criteria below are required';
|
||||
$string['criteriarequiredany']='Any criteria below are required';
|
||||
@ -124,6 +125,8 @@ $string['datepassed']='Date passed';
|
||||
$string['daysafterenrolment']='Days after enrolment';
|
||||
$string['durationafterenrolment']='Duration after enrolment';
|
||||
$string['fraction']='Fraction';
|
||||
$string['gradexrequired']='{$a} required';
|
||||
$string['graderequired']='Grade required';
|
||||
$string['inprogress']='In progress';
|
||||
$string['manualcompletionby']='Manual completion by';
|
||||
$string['manualselfcompletion']='Manual self completion';
|
||||
@ -136,7 +139,6 @@ $string['nocriteriaset']='No completion criteria set for this course';
|
||||
$string['notenroled']='You are not enrolled in this course';
|
||||
$string['notyetstarted']='Not yet started';
|
||||
$string['overallcriteriaaggregation']='Overall criteria type aggregation';
|
||||
$string['passinggrade']='Passing grade';
|
||||
$string['pending']='Pending';
|
||||
$string['periodpostenrolment']='Period post enrolment';
|
||||
$string['prerequisites']='Prerequisites';
|
||||
|
@ -62,8 +62,9 @@ class completion_criteria_grade extends completion_criteria {
|
||||
*/
|
||||
public function config_form_display(&$mform, $data = null) {
|
||||
$mform->addElement('checkbox', 'criteria_grade', get_string('enable'));
|
||||
$mform->addElement('text', 'criteria_grade_value', get_string('passinggrade', 'completion'));
|
||||
$mform->addElement('text', 'criteria_grade_value', get_string('graderequired', 'completion'));
|
||||
$mform->setDefault('criteria_grade_value', $data);
|
||||
$mform->addElement('static', 'criteria_grade_value_note', '', get_string('criteriagradenote', 'completion'));
|
||||
|
||||
if ($this->id) {
|
||||
$mform->setDefault('criteria_grade', 1);
|
||||
@ -128,7 +129,7 @@ class completion_criteria_grade extends completion_criteria {
|
||||
* @return string
|
||||
*/
|
||||
public function get_title() {
|
||||
return get_string('grade');
|
||||
return get_string('coursegrade', 'completion');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,7 +138,8 @@ class completion_criteria_grade extends completion_criteria {
|
||||
* @return string
|
||||
*/
|
||||
public function get_title_detailed() {
|
||||
return (float) $this->gradepass . '% required';
|
||||
$graderequired = round($this->gradepass, 2).'%';
|
||||
return get_string('gradexrequired', 'completion', $graderequired);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,15 +158,16 @@ class completion_criteria_grade extends completion_criteria {
|
||||
* @return string
|
||||
*/
|
||||
public function get_status($completion) {
|
||||
// Cast as floats to get rid of excess decimal places
|
||||
$grade = (float) $this->get_grade($completion);
|
||||
$gradepass = (float) $this->gradepass;
|
||||
$grade = $this->get_grade($completion);
|
||||
$graderequired = $this->get_title_detailed();
|
||||
|
||||
if ($grade) {
|
||||
return $grade.'% ('.$gradepass.'% to pass)';
|
||||
$grade = round($grade, 2).'%';
|
||||
} else {
|
||||
return $gradepass.'% to pass';
|
||||
$grade = get_string('nograde');
|
||||
}
|
||||
|
||||
return $grade.' ('.$graderequired.')';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -231,11 +234,11 @@ class completion_criteria_grade extends completion_criteria {
|
||||
public function get_details($completion) {
|
||||
$details = array();
|
||||
$details['type'] = get_string('coursegrade', 'completion');
|
||||
$details['criteria'] = get_string('passinggrade', 'completion');
|
||||
$details['requirement'] = ((float)$this->gradepass).'%';
|
||||
$details['criteria'] = get_string('graderequired', 'completion');
|
||||
$details['requirement'] = round($this->gradepass, 2).'%';
|
||||
$details['status'] = '';
|
||||
|
||||
$grade = (float)$this->get_grade($completion);
|
||||
$grade = round($this->get_grade($completion), 2);
|
||||
if ($grade) {
|
||||
$details['status'] = $grade.'%';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user