}
if (isset($workshop->submissionfiletypes)) {
- $workshop->submissionfiletypes = workshop::clean_file_extensions($workshop->submissionfiletypes);
+ $filetypesutil = new \core_form\filetypes_util();
+ $submissionfiletypes = $filetypesutil->normalize_file_types($workshop->submissionfiletypes);
+ $workshop->submissionfiletypes = implode(' ', $submissionfiletypes);
}
if (isset($workshop->overallfeedbackfiletypes)) {
- $workshop->overallfeedbackfiletypes = workshop::clean_file_extensions($workshop->overallfeedbackfiletypes);
+ $filetypesutil = new \core_form\filetypes_util();
+ $overallfeedbackfiletypes = $filetypesutil->normalize_file_types($workshop->overallfeedbackfiletypes);
+ $workshop->overallfeedbackfiletypes = implode(' ', $overallfeedbackfiletypes);
}
// insert the new record so we get the id
// create calendar events
workshop_calendar_update($workshop, $workshop->coursemodule);
+ if (!empty($workshop->completionexpected)) {
+ \core_completion\api::update_completion_date_event($cmid, 'workshop', $workshop->id, $workshop->completionexpected);
+ }
return $workshop->id;
}
}
if (isset($workshop->submissionfiletypes)) {
- $workshop->submissionfiletypes = workshop::clean_file_extensions($workshop->submissionfiletypes);
+ $filetypesutil = new \core_form\filetypes_util();
+ $submissionfiletypes = $filetypesutil->normalize_file_types($workshop->submissionfiletypes);
+ $workshop->submissionfiletypes = implode(' ', $submissionfiletypes);
}
if (isset($workshop->overallfeedbackfiletypes)) {
- $workshop->overallfeedbackfiletypes = workshop::clean_file_extensions($workshop->overallfeedbackfiletypes);
+ $filetypesutil = new \core_form\filetypes_util();
+ $overallfeedbackfiletypes = $filetypesutil->normalize_file_types($workshop->overallfeedbackfiletypes);
+ $workshop->overallfeedbackfiletypes = implode(' ', $overallfeedbackfiletypes);
}
// todo - if the grading strategy is being changed, we may want to replace all aggregated peer grades with nulls
// update calendar events
workshop_calendar_update($workshop, $workshop->coursemodule);
+ $completionexpected = (!empty($workshop->completionexpected)) ? $workshop->completionexpected : null;
+ \core_completion\api::update_completion_date_event($workshop->coursemodule, 'workshop', $workshop->id, $completionexpected);
return true;
}
* only workshop events belonging to the course specified are checked.
*
* @param integer $courseid The Course ID.
+ * @param int|stdClass $instance workshop module instance or ID.
+ * @param int|stdClass $cm Course module object or ID.
* @return bool Returns true if the calendar events were successfully updated.
*/
-function workshop_refresh_events($courseid = 0) {
+function workshop_refresh_events($courseid = 0, $instance = null, $cm = null) {
global $DB;
+ // If we have instance information then we can just update the one event instead of updating all events.
+ if (isset($instance)) {
+ if (!is_object($instance)) {
+ $instance = $DB->get_record('workshop', array('id' => $instance), '*', MUST_EXIST);
+ }
+ if (isset($cm)) {
+ if (!is_object($cm)) {
+ $cm = (object)array('id' => $cm);
+ }
+ } else {
+ $cm = get_coursemodule_from_instance('workshop', $instance->id);
+ }
+ workshop_calendar_update($instance, $cm->id);
+ return true;
+ }
+
if ($courseid) {
// Make sure that the course id is numeric.
if (!is_numeric($courseid)) {
} else {
- $sql = "SELECT s.id, u.lastname, u.firstname
+ $userfields = get_all_user_name_fields(true, 'u');
+ $sql = "SELECT s.id, $userfields
FROM {workshop_submissions} s
JOIN {user} u ON (s.authorid = u.id)
WHERE s.example = 0 AND s.workshopid = ?";