public function save_dates(cm_info $cm, array $dates) { parent::save_dates($cm, $dates); // Fetch module instance from $mods array. $quiz = $this->mods[$cm->instance]; $quiz->instance = $cm->instance; $quiz->coursemodule = $cm->id; // Updating date values. foreach ($dates as $datetype => $datevalue) { $quiz->{$datetype} = $datevalue; } // Calling the update event method to change the calender evenrs accordingly. quiz_update_events($quiz); }
public function validation($data, $files) { global $CFG; $errors = parent::validation($data, $files); $modinfo = $this->_customdata['modinfo']; $course = $this->_customdata['course']; $coursecontext = context_course::instance($course->id); $moddatesettings = array(); $forceddatesettings = array(); foreach ($data as $key => $value) { if ($key == "coursestartdate") { continue; } $cmsettings = explode('_', $key); // The array should have 4 keys. if (count($cmsettings) != 4) { continue; } // Ignore 0th position, it will be 'date' // 1st position should be the mod type // 2nd will be the id of module // 3rd will be property of module // ensure that the name is proper. if (isset($cmsettings['1']) && isset($cmsettings['2']) && isset($cmsettings['3'])) { // Check if its mod date settings. if ($cmsettings['1'] == 'mod') { // Check if config date settings are forced // and this is one of the forced date setting. if (($CFG->enableavailability || $CFG->enablecompletion) && in_array($cmsettings['3'], array('completionexpected', 'availablefrom', 'availableuntil'))) { $forceddatesettings[$cmsettings['2']][$cmsettings['3']] = $value; } else { // It is module date setting. $moddatesettings[$cmsettings['2']][$cmsettings['3']] = $value; } } } } $cms = $modinfo->get_cms(); // Validating forced date settings. foreach ($forceddatesettings as $modid => $datesettings) { // Course module object. $cm = $cms[$modid]; $moderrors = array(); if (isset($datesettings['availablefrom']) && isset($datesettings['availableuntil']) && $datesettings['availablefrom'] != 0 && $datesettings['availableuntil'] != 0 && $datesettings['availablefrom'] > $datesettings['availableuntil']) { $errors['date_mod_' . $modid . '_availableuntil'] = get_string('badavailabledates', 'condition'); } } // Validating mod date settings. foreach ($moddatesettings as $modid => $datesettings) { // Course module object. $cm = $cms[$modid]; $moderrors = array(); if ($mod = report_editdates_mod_date_extractor::make($cm->modname, $course)) { $moderrors = $mod->validate_dates($cm, $datesettings); if (!empty($moderrors)) { foreach ($moderrors as $errorfield => $errorstr) { $errors['date_mod_' . $modid . '_' . $errorfield] = $errorstr; } } } } return $errors; }
public function __construct($course) { parent::__construct($course, 'data'); parent::load_data(); }
public function __construct($course) { parent::__construct($course, 'oucollaborate'); parent::load_data(); }
/** * Does this cm have any date settings? * @param stdClass $cm the course_module settings. * @param stdClass $course the course settings. * @return bool whether there are any dates to edit for this activity. */ function report_editdates_cm_has_dates($cm, $course) { global $CFG; $coursehasavailability = !empty($CFG->enableavailability); $coursehascompletion = !empty($CFG->enablecompletion) && !empty($course->enablecompletion); if ($coursehasavailability || $coursehascompletion) { return true; } return (bool) report_editdates_mod_date_extractor::make($cm->modname, $course); }
public function __construct($course) { parent::__construct($course, 'ouelluminate'); parent::load_data(); }
$sectionsettings = array('availablefrom', 'availableuntil'); $section = new stdClass(); $section->id = $sectionid; foreach ($sectionsettings as $setting) { if (isset($datesettings[$setting])) { $section->{$setting} = $datesettings[$setting]; } else { $section->{$setting} = 0; } } $DB->update_record('course_sections', $section, true); } // Update mod date settings. foreach ($moddatesettings as $modid => $datesettings) { $cm = $cms[$modid]; $mod = report_editdates_mod_date_extractor::make($cm->modname, $course); if ($mod) { $mod->save_dates($cm, $datesettings); } } // Update block date settings. $courseblocks = $DB->get_records("block_instances", array('parentcontextid' => $coursecontext->id)); foreach ($blockdatesettings as $blockid => $datesettings) { $block = $courseblocks[$blockid]; $blockobj = block_instance($block->blockname, $block, $PAGE); if ($blockobj->user_can_edit()) { $blockdatextrator = report_editdates_block_date_extractor::make($block->blockname, $course); if ($blockdatextrator) { $blockdatextrator->save_dates($blockobj, $datesettings); } }
public function __construct($course) { parent::__construct($course, 'externalquiz'); parent::load_data(); }
public function __construct($course) { parent::__construct($course, 'questionnaire'); parent::load_data(); }