/** * Given an object containing all the necessary data, * (defined by the form in mod_form.php) this function * will update an existing instance with new data. * * @param stdClass $workshop An object from the form in mod_form.php * @return bool success */ function workshop_update_instance(stdclass $workshop) { global $CFG, $DB; require_once(dirname(__FILE__) . '/locallib.php'); $workshop->timemodified = time(); $workshop->id = $workshop->instance; $workshop->useexamples = (int)!empty($workshop->useexamples); $workshop->usepeerassessment = (int)!empty($workshop->usepeerassessment); $workshop->useselfassessment = (int)!empty($workshop->useselfassessment); $workshop->latesubmissions = (int)!empty($workshop->latesubmissions); $workshop->phaseswitchassessment = (int)!empty($workshop->phaseswitchassessment); $workshop->evaluation = 'best'; // todo - if the grading strategy is being changed, we must replace all aggregated peer grades with nulls // todo - if maximum grades are being changed, we should probably recalculate or invalidate them $DB->update_record('workshop', $workshop); $context = get_context_instance(CONTEXT_MODULE, $workshop->coursemodule); // process the custom wysiwyg editors if ($draftitemid = $workshop->instructauthorseditor['itemid']) { $workshop->instructauthors = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructauthors', 0, workshop::instruction_editors_options($context), $workshop->instructauthorseditor['text']); $workshop->instructauthorsformat = $workshop->instructauthorseditor['format']; } if ($draftitemid = $workshop->instructreviewerseditor['itemid']) { $workshop->instructreviewers = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructreviewers', 0, workshop::instruction_editors_options($context), $workshop->instructreviewerseditor['text']); $workshop->instructreviewersformat = $workshop->instructreviewerseditor['format']; } // re-save the record with the replaced URLs in editor fields $DB->update_record('workshop', $workshop); // update gradebook items workshop_grade_item_update($workshop); workshop_grade_item_category_update($workshop); // update calendar events workshop_calendar_update($workshop, $workshop->coursemodule); return true; }
/** * Given an object containing all the necessary data, * (defined by the form in mod_form.php) this function * will update an existing instance with new data. * * @param stdClass $workshop An object from the form in mod_form.php * @return bool success */ function workshop_update_instance(stdclass $workshop) { global $CFG, $DB; require_once(dirname(__FILE__) . '/locallib.php'); $workshop->timemodified = time(); $workshop->id = $workshop->instance; $workshop->useexamples = (int)!empty($workshop->useexamples); $workshop->usepeerassessment = 1; $workshop->useselfassessment = (int)!empty($workshop->useselfassessment); $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); } if (isset($workshop->submissionfiletypes)) { $workshop->submissionfiletypes = workshop::clean_file_extensions($workshop->submissionfiletypes); } if (isset($workshop->overallfeedbackfiletypes)) { $workshop->overallfeedbackfiletypes = workshop::clean_file_extensions($workshop->overallfeedbackfiletypes); } // todo - if the grading strategy is being changed, we may want to replace all aggregated peer grades with nulls $DB->update_record('workshop', $workshop); $context = context_module::instance($workshop->coursemodule); // process the custom wysiwyg editors if ($draftitemid = $workshop->instructauthorseditor['itemid']) { $workshop->instructauthors = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructauthors', 0, workshop::instruction_editors_options($context), $workshop->instructauthorseditor['text']); $workshop->instructauthorsformat = $workshop->instructauthorseditor['format']; } if ($draftitemid = $workshop->instructreviewerseditor['itemid']) { $workshop->instructreviewers = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructreviewers', 0, workshop::instruction_editors_options($context), $workshop->instructreviewerseditor['text']); $workshop->instructreviewersformat = $workshop->instructreviewerseditor['format']; } if ($draftitemid = $workshop->conclusioneditor['itemid']) { $workshop->conclusion = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'conclusion', 0, workshop::instruction_editors_options($context), $workshop->conclusioneditor['text']); $workshop->conclusionformat = $workshop->conclusioneditor['format']; } // re-save the record with the replaced URLs in editor fields $DB->update_record('workshop', $workshop); // update gradebook items workshop_grade_item_update($workshop); workshop_grade_item_category_update($workshop); // update calendar events workshop_calendar_update($workshop, $workshop->coursemodule); return true; }