/** * Update grade item for this submission. */ function update_grade($submission) { problemstatement_update_grades($this->problemstatement, $submission->userid); }
/** * Update grades by firing grade_updated event * * @param object $problemstatement null means all problemstatements * @param int $userid specific user only, 0 mean all */ function problemstatement_update_grades($problemstatement = null, $userid = 0, $nullifnone = true) { global $CFG; if (!function_exists('grade_update')) { //workaround for buggy PHP versions require_once $CFG->libdir . '/gradelib.php'; } if ($problemstatement != null) { if ($grades = problemstatement_get_user_grades($problemstatement, $userid)) { foreach ($grades as $k => $v) { if ($v->rawgrade == -1) { $grades[$k]->rawgrade = null; } } problemstatement_grade_item_update($problemstatement, $grades); } else { problemstatement_grade_item_update($problemstatement); } } else { $sql = "SELECT a.*, cm.idnumber as cmidnumber, a.course as courseid\n FROM {$CFG->prefix}problemstatement a, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m\n WHERE m.name='problemstatement' AND m.id=cm.module AND cm.instance=a.id"; if ($rs = get_recordset_sql($sql)) { while ($problemstatement = rs_fetch_next_record($rs)) { if ($problemstatement->grade != 0) { problemstatement_update_grades($problemstatement); } else { problemstatement_grade_item_update($problemstatement); } } rs_close($rs); } } }