$outcome_rec = new object(); $outcome_rec->standard = 1; $outcome_rec->courseid = 0; require_login(); require_capability('moodle/grade:manage', $systemcontext); } } // default return url $gpr = new grade_plugin_return(); $returnurl = $gpr->get_return_url('index.php?id=' . $courseid); $mform = new edit_outcome_form(null, array('gpr' => $gpr)); $mform->set_data($outcome_rec); if ($mform->is_cancelled()) { redirect($returnurl); } else { if ($data = $mform->get_data(false)) { $outcome = new grade_outcome(array('id' => $id)); $data->usermodified = $USER->id; grade_outcome::set_properties($outcome, $data); if (empty($outcome->id)) { if (!has_capability('moodle/grade:manage', $systemcontext)) { $data->standard = 0; } $outcome->courseid = !empty($data->standard) ? null : $courseid; if (empty($outcome->courseid)) { $outcome->courseid = null; } $outcome->insert(); } else { if (isset($data->standard)) { $outcome->courseid = !empty($data->standard) ? null : $courseid;
$gpr = new grade_plugin_return(); $returnurl = $gpr->get_return_url('index.php?id=' . $courseid); $editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true, 'context' => $systemcontext); if (!empty($outcome_rec->id)) { $editoroptions['subdirs'] = file_area_contains_subdirs($systemcontext, 'grade', 'outcome', $outcome_rec->id); $outcome_rec = file_prepare_standard_editor($outcome_rec, 'description', $editoroptions, $systemcontext, 'grade', 'outcome', $outcome_rec->id); } else { $editoroptions['subdirs'] = false; $outcome_rec = file_prepare_standard_editor($outcome_rec, 'description', $editoroptions, $systemcontext, 'grade', 'outcome', null); } $mform = new edit_outcome_form(null, compact('gpr', 'editoroptions')); $mform->set_data($outcome_rec); if ($mform->is_cancelled()) { redirect($returnurl); } else { if ($data = $mform->get_data()) { $outcome = new grade_outcome(array('id' => $id)); $data->usermodified = $USER->id; if (empty($outcome->id)) { $data->description = $data->description_editor['text']; grade_outcome::set_properties($outcome, $data); if (!has_capability('moodle/grade:manage', $systemcontext)) { $data->standard = 0; } $outcome->courseid = !empty($data->standard) ? null : $courseid; if (empty($outcome->courseid)) { $outcome->courseid = null; } $outcome->insert(); $data = file_postupdate_standard_editor($data, 'description', $editoroptions, $systemcontext, 'grade', 'outcome', $outcome->id); $DB->set_field($outcome->table, 'description', $data->description, array('id' => $outcome->id));