/** * Define the elements to be displayed at the form * * Called by the parent::definition() * * @return void */ protected function definition_inner(&$mform) { $norepeats = $this->_customdata['norepeats']; // number of dimensions to display $descriptionopts = $this->_customdata['descriptionopts']; // wysiwyg fields options $current = $this->_customdata['current']; // current data to be set $mform->addElement('hidden', 'norepeats', $norepeats); $mform->setType('norepeats', PARAM_INT); // value not to be overridden by submitted value $mform->setConstants(array('norepeats' => $norepeats)); for ($i = 0; $i < $norepeats; $i++) { $mform->addElement('header', 'dimension' . $i, get_string('dimensionnumber', 'workshopform_accumulative', $i + 1)); $mform->addElement('hidden', 'dimensionid__idx_' . $i); $mform->setType('dimensionid__idx_' . $i, PARAM_INT); $mform->addElement('editor', 'description__idx_' . $i . '_editor', get_string('dimensiondescription', 'workshopform_accumulative'), '', $descriptionopts); // todo replace modgrade with an advanced element (usability issue discussed with Olli) $mform->addElement('modgrade', 'grade__idx_' . $i, get_string('dimensionmaxgrade', 'workshopform_accumulative'), null, true); $mform->setDefault('grade__idx_' . $i, 10); $mform->addElement('select', 'weight__idx_' . $i, get_string('dimensionweight', 'workshopform_accumulative'), workshop::available_dimension_weights_list()); $mform->setDefault('weight__idx_' . $i, 1); } $mform->registerNoSubmitButton('noadddims'); $mform->addElement('submit', 'noadddims', get_string('addmoredimensions', 'workshopform_accumulative', workshop_accumulative_strategy::ADDDIMS)); $mform->closeHeaderBefore('noadddims'); $this->set_data($current); }
function definition() { $mform = $this->_form; $current = $this->_customdata['current']; $workshop = $this->_customdata['workshop']; $editoropts = $this->_customdata['editoropts']; $options = $this->_customdata['options']; $mform->addElement('header', 'assessmentsettings', get_string('assessmentsettings', 'workshop')); if (!empty($options['editableweight'])) { $mform->addElement('select', 'weight', get_string('assessmentweight', 'workshop'), workshop::available_assessment_weights_list()); $mform->setDefault('weight', 1); } $mform->addElement('static', 'gradinggrade', get_string('gradinggradecalculated', 'workshop')); if (!empty($options['overridablegradinggrade'])) { $grades = array('' => get_string('notoverridden', 'workshop')); for ($i = (int) $workshop->gradinggrade; $i >= 0; $i--) { $grades[$i] = $i; } $mform->addElement('select', 'gradinggradeover', get_string('gradinggradeover', 'workshop'), $grades); $mform->addElement('editor', 'feedbackreviewer_editor', get_string('feedbackreviewer', 'workshop'), null, $editoropts); $mform->setType('feedbackreviewer_editor', PARAM_RAW); } $mform->addElement('hidden', 'asid'); $mform->setType('asid', PARAM_INT); $mform->addElement('submit', 'save', get_string('saveandclose', 'workshop')); $this->set_data($current); }
/** * Add the fields that are common for all grading strategies. * * If the strategy does not support all these fields, then you can override * this method and remove the ones you don't want with * $mform->removeElement(). * Strategy subclassess should define their own fields in definition_inner() * * @return void */ public function definition() { global $CFG; $mform = $this->_form; $this->mode = $this->_customdata['mode']; // influences the save buttons $this->strategy = $this->_customdata['strategy']; // instance of the strategy api class $this->workshop = $this->_customdata['workshop']; // instance of the workshop api class $this->options = $this->_customdata['options']; // array with addiotional options // add the strategy-specific fields $this->definition_inner($mform); // add the data common for all subplugins $mform->addElement('hidden', 'strategy', $this->workshop->strategy); $mform->setType('strategy', PARAM_PLUGIN); if (!empty($this->options['editableweight']) and !$mform->isFrozen()) { $mform->addElement('header', 'assessmentsettings', get_string('assessmentweight', 'workshop')); $mform->addElement('select', 'weight', get_string('assessmentweight', 'workshop'), workshop::available_assessment_weights_list()); $mform->setDefault('weight', 1); } $buttonarray = array(); if ($this->mode == 'preview') { $buttonarray[] = $mform->createElement('cancel', 'backtoeditform', get_string('backtoeditform', 'workshop')); } if ($this->mode == 'assessment') { $buttonarray[] = $mform->createElement('submit', 'saveandcontinue', get_string('saveandcontinue', 'workshop')); $buttonarray[] = $mform->createElement('submit', 'saveandclose', get_string('saveandclose', 'workshop')); $buttonarray[] = $mform->createElement('cancel'); } $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); }
function validation($data, $files) { global $CFG, $USER, $DB; $errors = parent::validation($data, $files); if (empty($data['id']) and empty($data['example'])) { // make sure there is no submission saved meanwhile from another browser window $sql = "SELECT COUNT(s.id)\n FROM {workshop_submissions} s\n JOIN {workshop} w ON (s.workshopid = w.id)\n JOIN {course_modules} cm ON (w.id = cm.instance)\n JOIN {modules} m ON (m.name = 'workshop' AND m.id = cm.module)\n WHERE cm.id = ? AND s.authorid = ? AND s.example = 0"; if ($DB->count_records_sql($sql, array($data['cmid'], $USER->id))) { $errors['title'] = get_string('err_multiplesubmissions', 'mod_workshop'); } } if (isset($data['attachment_filemanager']) and isset($this->_customdata['workshop']->submissionfiletypes)) { $whitelist = workshop::normalize_file_extensions($this->_customdata['workshop']->submissionfiletypes); if ($whitelist) { $draftfiles = file_get_drafarea_files($data['attachment_filemanager']); if ($draftfiles) { $wrongfiles = array(); foreach ($draftfiles->list as $file) { if (!workshop::is_allowed_file_type($file->filename, $whitelist)) { $wrongfiles[] = $file->filename; } } if ($wrongfiles) { $a = array('whitelist' => workshop::clean_file_extensions($whitelist), 'wrongfiles' => implode(', ', $wrongfiles)); $errors['attachment_filemanager'] = get_string('err_wrongfileextension', 'mod_workshop', $a); } } } } return $errors; }
/** * Define the elements to be displayed at the form * * Called by the parent::definition() * * @return void */ protected function definition_inner(&$mform) { $plugindefaults = get_config('workshopform_numerrors'); $nodimensions = $this->_customdata['nodimensions']; // number of currently filled dimensions $norepeats = $this->_customdata['norepeats']; // number of dimensions to display $descriptionopts = $this->_customdata['descriptionopts']; // wysiwyg fields options $current = $this->_customdata['current']; // current data to be set $mform->addElement('hidden', 'norepeats', $norepeats); $mform->setType('norepeats', PARAM_INT); // value not to be overridden by submitted value $mform->setConstants(array('norepeats' => $norepeats)); for ($i = 0; $i < $norepeats; $i++) { $mform->addElement('header', 'dimension' . $i, get_string('dimensionnumber', 'workshopform_numerrors', $i + 1)); $mform->addElement('hidden', 'dimensionid__idx_' . $i); // the id in workshop_forms $mform->setType('dimensionid__idx_' . $i, PARAM_INT); $mform->addElement('editor', 'description__idx_' . $i . '_editor', get_string('dimensiondescription', 'workshopform_numerrors'), '', $descriptionopts); $mform->addElement('text', 'grade0__idx_' . $i, get_string('grade0', 'workshopform_numerrors'), array('size' => '15')); $mform->setDefault('grade0__idx_' . $i, $plugindefaults->grade0); $mform->setType('grade0__idx_' . $i, PARAM_TEXT); $mform->addElement('text', 'grade1__idx_' . $i, get_string('grade1', 'workshopform_numerrors'), array('size' => '15')); $mform->setDefault('grade1__idx_' . $i, $plugindefaults->grade1); $mform->setType('grade1__idx_' . $i, PARAM_TEXT); $mform->addElement('select', 'weight__idx_' . $i, get_string('dimensionweight', 'workshopform_numerrors'), workshop::available_dimension_weights_list()); $mform->setDefault('weight__idx_' . $i, 1); } $mform->addElement('header', 'mappingheader', get_string('grademapping', 'workshopform_numerrors')); $mform->addElement('static', 'mappinginfo', get_string('maperror', 'workshopform_numerrors'), get_string('mapgrade', 'workshopform_numerrors')); // get the total weight of all items == maximum weighted number of errors $totalweight = 0; for ($i = 0; $i < $norepeats; $i++) { if (!empty($current->{'weight__idx_' . $i})) { $totalweight += $current->{'weight__idx_' . $i}; } } $totalweight = max($totalweight, $nodimensions); $percents = array(); $percents[''] = ''; for ($i = 100; $i >= 0; $i--) { $percents[$i] = get_string('percents', 'workshopform_numerrors', $i); } $mform->addElement('static', 'mappingzero', 0, get_string('percents', 'workshopform_numerrors', 100)); for ($i = 1; $i <= $totalweight; $i++) { $selects = array(); $selects[] = $mform->createElement('select', 'map__idx_' . $i, $i, $percents); $selects[] = $mform->createElement('static', 'mapdefault__idx_' . $i, '', get_string('percents', 'workshopform_numerrors', floor(100 - $i * 100 / $totalweight))); $mform->addGroup($selects, 'grademapping' . $i, $i, array(' '), false); $mform->setDefault('map__idx_' . $i, ''); } $mform->registerNoSubmitButton('noadddims'); $mform->addElement('submit', 'noadddims', get_string('addmoredimensions', 'workshopform_numerrors', workshop_numerrors_strategy::ADDDIMS)); $mform->closeHeaderBefore('noadddims'); $this->set_data($current); }
/** * Add the fields that are common for all grading strategies. * * If the strategy does not support all these fields, then you can override * this method and remove the ones you don't want with * $mform->removeElement(). * Strategy subclassess should define their own fields in definition_inner() * * @return void */ public function definition() { global $CFG; $mform = $this->_form; $this->mode = $this->_customdata['mode']; // influences the save buttons $this->strategy = $this->_customdata['strategy']; // instance of the strategy api class $this->workshop = $this->_customdata['workshop']; // instance of the workshop api class $this->options = $this->_customdata['options']; // array with addiotional options // Disable shortforms $mform->setDisableShortforms(); // add the strategy-specific fields $this->definition_inner($mform); // add the data common for all subplugins $mform->addElement('hidden', 'strategy', $this->workshop->strategy); $mform->setType('strategy', PARAM_PLUGIN); if ($this->workshop->overallfeedbackmode and $this->is_editable()) { $mform->addElement('header', 'overallfeedbacksection', get_string('overallfeedback', 'mod_workshop')); $mform->addElement('editor', 'feedbackauthor_editor', get_string('feedbackauthor', 'mod_workshop'), null, $this->workshop->overall_feedback_content_options()); if ($this->workshop->overallfeedbackmode == 2) { $mform->addRule('feedbackauthor_editor', null, 'required', null, 'client'); } if ($this->workshop->overallfeedbackfiles) { $mform->addElement('filemanager', 'feedbackauthorattachment_filemanager', get_string('feedbackauthorattachment', 'mod_workshop'), null, $this->workshop->overall_feedback_attachment_options()); } } if (!empty($this->options['editableweight']) and $this->is_editable()) { $mform->addElement('header', 'assessmentsettings', get_string('assessmentweight', 'workshop')); $mform->addElement('select', 'weight', get_string('assessmentweight', 'workshop'), workshop::available_assessment_weights_list()); $mform->setDefault('weight', 1); } $buttonarray = array(); if ($this->mode == 'preview') { $buttonarray[] = $mform->createElement('cancel', 'backtoeditform', get_string('backtoeditform', 'workshop')); } if ($this->mode == 'assessment') { if (!empty($this->options['pending'])) { $buttonarray[] = $mform->createElement('submit', 'saveandshownext', get_string('saveandshownext', 'workshop')); } $buttonarray[] = $mform->createElement('submit', 'saveandclose', get_string('saveandclose', 'workshop')); $buttonarray[] = $mform->createElement('submit', 'saveandcontinue', get_string('saveandcontinue', 'workshop')); $buttonarray[] = $mform->createElement('cancel'); } $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); }
/** * Triggered when the '\mod_workshop\event\course_module_viewed' event is triggered. * * This does the same job as {@link workshopallocation_scheduled_cron()} but for the * single workshop. The idea is that we do not need to wait for cron to execute. * Displaying the workshop main view.php can trigger the scheduled allocation, too. * * @param \mod_workshop\event\course_module_viewed $event * @return bool */ public static function workshop_viewed($event) { global $DB, $CFG; require_once $CFG->dirroot . '/mod/workshop/locallib.php'; $workshop = $event->get_record_snapshot('workshop', $event->objectid); $course = $event->get_record_snapshot('course', $event->courseid); $cm = $event->get_record_snapshot('course_modules', $event->contextinstanceid); $workshop = new \workshop($workshop, $cm, $course); $now = time(); // Non-expensive check to see if the scheduled allocation can even happen. if ($workshop->phase == \workshop::PHASE_SUBMISSION and $workshop->submissionend > 0 and $workshop->submissionend < $now) { // Make sure the scheduled allocation has been configured for this workshop, that it has not // been executed yet and that the passed workshop record is still valid. $sql = "SELECT a.id\n FROM {workshopallocation_scheduled} a\n JOIN {workshop} w ON a.workshopid = w.id\n WHERE w.id = :workshopid\n AND a.enabled = 1\n AND w.phase = :phase\n AND w.submissionend > 0\n AND w.submissionend < :now\n AND (a.timeallocated IS NULL OR a.timeallocated < w.submissionend)"; $params = array('workshopid' => $workshop->id, 'phase' => \workshop::PHASE_SUBMISSION, 'now' => $now); if ($DB->record_exists_sql($sql, $params)) { // Allocate submissions for assessments. $allocator = $workshop->allocator_instance('scheduled'); $result = $allocator->execute(); // Todo inform the teachers about the results. } } return true; }
/** * Returns example submissions to be assessed by the owner of the planner * * This is here to cache the DB query because the same list is needed later in view.php * * @see workshop::get_examples_for_reviewer() for the format of returned value * @return array */ public function get_examples() { if (is_null($this->examples)) { $this->examples = $this->workshop->get_examples_for_reviewer($this->userid); } return $this->examples; }
$edit = optional_param('edit', false, PARAM_BOOL); // open for editing? $delete = optional_param('delete', false, PARAM_BOOL); // example removal requested $confirm = optional_param('confirm', false, PARAM_BOOL); // example removal request confirmed $assess = optional_param('assess', false, PARAM_BOOL); // assessment required $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, false, $cm); if (isguestuser()) { print_error('guestsarenotallowed'); } $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); $PAGE->set_url($workshop->exsubmission_url($id), array('edit' => $edit)); $PAGE->set_title($workshop->name); $PAGE->set_heading($course->fullname); if ($edit) { $PAGE->navbar->add(get_string('exampleediting', 'workshop')); } else { $PAGE->navbar->add(get_string('example', 'workshop')); } $output = $PAGE->get_renderer('mod_workshop'); if ($id) { // example is specified $example = $workshop->get_example_by_id($id); } else { // no example specified - create new one require_capability('mod/workshop:manageexamples', $workshop->context);
/** * Definition of the setting form elements */ public function definition() { global $OUTPUT; $mform = $this->_form; $workshop = $this->_customdata['workshop']; $current = $this->_customdata['current']; if (!empty($workshop->submissionend)) { $strtimeexpected = workshop::timestamp_formats($workshop->submissionend); } if (!empty($current->timeallocated)) { $strtimeexecuted = workshop::timestamp_formats($current->timeallocated); } $mform->addElement('header', 'scheduledallocationsettings', get_string('scheduledallocationsettings', 'workshopallocation_scheduled')); $mform->addHelpButton('scheduledallocationsettings', 'scheduledallocationsettings', 'workshopallocation_scheduled'); $mform->addElement('checkbox', 'enablescheduled', get_string('enablescheduled', 'workshopallocation_scheduled'), get_string('enablescheduledinfo', 'workshopallocation_scheduled'), 1); $mform->addElement('header', 'scheduledallocationinfo', get_string('currentstatus', 'workshopallocation_scheduled')); if ($current === false) { $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'workshopallocation_scheduled'), get_string('resultdisabled', 'workshopallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid')))); } else { if (!empty($current->timeallocated)) { $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'workshopallocation_scheduled'), get_string('currentstatusexecution1', 'workshopallocation_scheduled', $strtimeexecuted) . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/valid')))); if ($current->resultstatus == workshop_allocation_result::STATUS_EXECUTED) { $strstatus = get_string('resultexecuted', 'workshopallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/valid'))); } else { if ($current->resultstatus == workshop_allocation_result::STATUS_FAILED) { $strstatus = get_string('resultfailed', 'workshopallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid'))); } else { $strstatus = get_string('resultvoid', 'workshopallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid'))); } } if (!empty($current->resultmessage)) { $strstatus .= html_writer::empty_tag('br') . $current->resultmessage; // yes, this is ugly. better solution suggestions are welcome. } $mform->addElement('static', 'inforesult', get_string('currentstatusresult', 'workshopallocation_scheduled'), $strstatus); if ($current->timeallocated < $workshop->submissionend) { $mform->addElement('static', 'infoexpected', get_string('currentstatusnext', 'workshopallocation_scheduled'), get_string('currentstatusexecution2', 'workshopallocation_scheduled', $strtimeexpected) . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/caution')))); $mform->addHelpButton('infoexpected', 'currentstatusnext', 'workshopallocation_scheduled'); } else { $mform->addElement('checkbox', 'reenablescheduled', get_string('currentstatusreset', 'workshopallocation_scheduled'), get_string('currentstatusresetinfo', 'workshopallocation_scheduled')); $mform->addHelpButton('reenablescheduled', 'currentstatusreset', 'workshopallocation_scheduled'); } } else { if (empty($current->enabled)) { $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'workshopallocation_scheduled'), get_string('resultdisabled', 'workshopallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid')))); } else { if ($workshop->phase != workshop::PHASE_SUBMISSION) { $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'workshopallocation_scheduled'), get_string('resultfailed', 'workshopallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid'))) . html_writer::empty_tag('br') . get_string('resultfailedphase', 'workshopallocation_scheduled')); } else { if (empty($workshop->submissionend)) { $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'workshopallocation_scheduled'), get_string('resultfailed', 'workshopallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/invalid'))) . html_writer::empty_tag('br') . get_string('resultfaileddeadline', 'workshopallocation_scheduled')); } else { if ($workshop->submissionend < time()) { // next cron will execute it $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'workshopallocation_scheduled'), get_string('currentstatusexecution4', 'workshopallocation_scheduled') . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/caution')))); } else { $mform->addElement('static', 'infostatus', get_string('currentstatusexecution', 'workshopallocation_scheduled'), get_string('currentstatusexecution3', 'workshopallocation_scheduled', $strtimeexpected) . ' ' . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/caution')))); } } } } } } parent::definition(); $mform->addHelpButton('randomallocationsettings', 'randomallocationsettings', 'workshopallocation_scheduled'); }
/** * Regular jobs to execute via cron * * @return boolean true on success, false otherwise */ function workshop_cron() { global $CFG, $DB; $now = time(); mtrace(' processing workshop subplugins ...'); cron_execute_plugin_type('workshopallocation', 'workshop allocation methods'); // now when the scheduled allocator had a chance to do its job, check if there // are some workshops to switch into the assessment phase $workshops = $DB->get_records_select("workshop", "phase = 20 AND phaseswitchassessment = 1 AND submissionend > 0 AND submissionend < ?", array($now)); if (!empty($workshops)) { mtrace('Processing automatic assessment phase switch in '.count($workshops).' workshop(s) ... ', ''); require_once($CFG->dirroot.'/mod/workshop/locallib.php'); foreach ($workshops as $workshop) { $cm = get_coursemodule_from_instance('workshop', $workshop->id, $workshop->course, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); $workshop->switch_phase(workshop::PHASE_ASSESSMENT); $workshop->log('update switch phase', $workshop->view_url(), $workshop->phase); // disable the automatic switching now so that it is not executed again by accident // if the teacher changes the phase back to the submission one $DB->set_field('workshop', 'phaseswitchassessment', 0, array('id' => $workshop->id)); // todo inform the teachers } mtrace('done'); } return true; }
/** * Validates the form input * * @param array $data submitted data * @param array $files submitted files * @return array eventual errors indexed by the field name */ public function validation($data, $files) { $errors = parent::validation($data, $files); // Validate lists of allowed extensions. foreach (array('submissionfiletypes', 'overallfeedbackfiletypes') as $fieldname) { if (isset($data[$fieldname])) { $invalidextensions = workshop::invalid_file_extensions($data[$fieldname], array_keys(core_filetypes::get_types())); if ($invalidextensions) { $errors[$fieldname] = get_string('err_unknownfileextension', 'mod_workshop', workshop::clean_file_extensions($invalidextensions)); } } } // check the phases borders are valid if ($data['submissionstart'] > 0 and $data['submissionend'] > 0 and $data['submissionstart'] >= $data['submissionend']) { $errors['submissionend'] = get_string('submissionendbeforestart', 'mod_workshop'); } if ($data['assessmentstart'] > 0 and $data['assessmentend'] > 0 and $data['assessmentstart'] >= $data['assessmentend']) { $errors['assessmentend'] = get_string('assessmentendbeforestart', 'mod_workshop'); } // check the phases do not overlap if (max($data['submissionstart'], $data['submissionend']) > 0 and max($data['assessmentstart'], $data['assessmentend']) > 0) { $phasesubmissionend = max($data['submissionstart'], $data['submissionend']); $phaseassessmentstart = min($data['assessmentstart'], $data['assessmentend']); if ($phaseassessmentstart == 0) { $phaseassessmentstart = max($data['assessmentstart'], $data['assessmentend']); } if ($phasesubmissionend > 0 and $phaseassessmentstart > 0 and $phaseassessmentstart < $phasesubmissionend) { foreach (array('submissionend', 'submissionstart', 'assessmentstart', 'assessmentend') as $f) { if ($data[$f] > 0) { $errors[$f] = get_string('phasesoverlap', 'mod_workshop'); break; } } } } // Check that the submission grade pass is a valid number. if (!empty($data['submissiongradepass'])) { $submissiongradefloat = unformat_float($data['submissiongradepass'], true); if ($submissiongradefloat === false) { $errors['submissiongradepass'] = get_string('err_numeric', 'form'); } else { if ($submissiongradefloat > $data['grade']) { $errors['submissiongradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['grade']); } } } // Check that the grade pass is a valid number. if (!empty($data['gradinggradepass'])) { $gradepassfloat = unformat_float($data['gradinggradepass'], true); if ($gradepassfloat === false) { $errors['gradinggradepass'] = get_string('err_numeric', 'form'); } else { if ($gradepassfloat > $data['gradinggrade']) { $errors['gradinggradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['gradinggrade']); } } } return $errors; }
public function test_lcm() { $this->resetAfterTest(true); // fixture setup + exercise SUT + verify in one step $this->assertEquals(workshop::lcm(1, 4), 4); $this->assertEquals(workshop::lcm(2, 4), 4); $this->assertEquals(workshop::lcm(4, 2), 4); $this->assertEquals(workshop::lcm(2, 3), 6); $this->assertEquals(workshop::lcm(6, 4), 12); }
public function aggregate_grading_grades_process(array $assessments, $timegraded = null) { parent::aggregate_grading_grades_process($assessments, $timegraded); }
require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; require_once dirname(__FILE__) . '/locallib.php'; $cmid = required_param('cmid', PARAM_INT); // course module id $sid = required_param('sid', PARAM_INT); // example submission id $aid = required_param('aid', PARAM_INT); // the user's assessment id $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, false, $cm); if (isguestuser()) { print_error('guestsarenotallowed'); } $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); $strategy = $workshop->grading_strategy_instance(); $PAGE->set_url($workshop->excompare_url($sid, $aid)); $example = $workshop->get_example_by_id($sid); $assessment = $workshop->get_assessment_by_id($aid); if ($assessment->submissionid != $example->id) { print_error('invalidarguments'); } $mformassessment = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, false); if ($refasid = $DB->get_field('workshop_assessments', 'id', array('submissionid' => $example->id, 'weight' => 1))) { $reference = $workshop->get_assessment_by_id($refasid); $mformreference = $strategy->get_assessment_form($PAGE->url, 'assessment', $reference, false); } $canmanage = has_capability('mod/workshop:manageexamples', $workshop->context); $isreviewer = $USER->id == $assessment->reviewerid; if ($canmanage) {
/** * Print a detailed representation of what a user has done with * a given particular instance of this module, for user activity reports. * * @return string HTML */ function workshop_user_complete($course, $user, $mod, $workshop) { global $CFG, $DB, $OUTPUT; require_once dirname(__FILE__) . '/locallib.php'; require_once $CFG->libdir . '/gradelib.php'; $workshop = new workshop($workshop, $mod, $course); $grades = grade_get_grades($course->id, 'mod', 'workshop', $workshop->id, $user->id); if (!empty($grades->items[0]->grades)) { $submissiongrade = reset($grades->items[0]->grades); $info = get_string('submissiongrade', 'workshop') . ': ' . $submissiongrade->str_long_grade; echo html_writer::tag('li', $info, array('class' => 'submissiongrade')); } if (!empty($grades->items[1]->grades)) { $assessmentgrade = reset($grades->items[1]->grades); $info = get_string('gradinggrade', 'workshop') . ': ' . $assessmentgrade->str_long_grade; echo html_writer::tag('li', $info, array('class' => 'gradinggrade')); } if (has_capability('mod/workshop:viewallsubmissions', $workshop->context)) { if ($submission = $workshop->get_submission_by_author($user->id)) { $title = format_string($submission->title); $url = $workshop->submission_url($submission->id); $link = html_writer::link($url, $title); $info = get_string('submission', 'workshop') . ': ' . $link; echo html_writer::tag('li', $info, array('class' => 'submission')); } } if (has_capability('mod/workshop:viewallassessments', $workshop->context)) { if ($assessments = $workshop->get_assessments_by_reviewer($user->id)) { foreach ($assessments as $assessment) { $a = new stdclass(); $a->submissionurl = $workshop->submission_url($assessment->submissionid)->out(); $a->assessmenturl = $workshop->assess_url($assessment->id)->out(); $a->submissiontitle = s($assessment->submissiontitle); echo html_writer::tag('li', get_string('assessmentofsubmission', 'workshop', $a)); } } } }
/** * Performs the reset of all workshop instances in the course. * * @param stdClass $data The actual course reset settings. * @return array List of results, each being array[(string)component, (string)item, (string)error] */ function workshop_reset_userdata(stdClass $data) { global $CFG, $DB; if (empty($data->reset_workshop_submissions) and empty($data->reset_workshop_assessments) and empty($data->reset_workshop_phase) ) { // Nothing to do here. return array(); } $workshoprecords = $DB->get_records('workshop', array('course' => $data->courseid)); if (empty($workshoprecords)) { // What a boring course - no workshops here! return array(); } require_once($CFG->dirroot . '/mod/workshop/locallib.php'); $course = $DB->get_record('course', array('id' => $data->courseid), '*', MUST_EXIST); $status = array(); foreach ($workshoprecords as $workshoprecord) { $cm = get_coursemodule_from_instance('workshop', $workshoprecord->id, $course->id, false, MUST_EXIST); $workshop = new workshop($workshoprecord, $cm, $course); $status = array_merge($status, $workshop->reset_userdata($data)); } return $status; }
for ($i = 5; $i >= 0; $i--) { $options[$i] = $i; } $settings->add(new admin_setting_configselect('workshop/gradedecimals', get_string('gradedecimals', 'workshop'), get_string('configgradedecimals', 'workshop'), 0, $options)); if (isset($CFG->maxbytes)) { $options = get_max_upload_sizes($CFG->maxbytes); $settings->add(new admin_setting_configselect('workshop/maxbytes', get_string('maxbytes', 'workshop'), get_string('configmaxbytes', 'workshop'), 0, $options)); } $settings->add(new admin_setting_configselect('workshop/strategy', get_string('strategy', 'workshop'), get_string('configstrategy', 'workshop'), 'accumulative', workshop::available_strategies_list())); $options = workshop::available_example_modes_list(); $settings->add(new admin_setting_configselect('workshop/examplesmode', get_string('examplesmode', 'workshop'), get_string('configexamplesmode', 'workshop'), workshop::EXAMPLES_VOLUNTARY, $options)); // include the settings of allocation subplugins $allocators = get_plugin_list('workshopallocation'); foreach ($allocators as $allocator => $path) { if (file_exists($settingsfile = $path . '/settings.php')) { $settings->add(new admin_setting_heading('workshopallocationsetting'.$allocator, get_string('allocation', 'workshop') . ' - ' . get_string('pluginname', 'workshopallocation_' . $allocator), '')); include($settingsfile); } } // include the settings of grading strategy subplugins $strategies = get_plugin_list('workshopform');
/** * Renders the workshop grading report * * @param workshop_grading_report $gradingreport * @return string html code */ protected function render_workshop_grading_report(workshop_grading_report $gradingreport) { $data = $gradingreport->get_data(); $options = $gradingreport->get_options(); $grades = $data->grades; $userinfo = $data->userinfo; if (empty($grades)) { return ''; } $table = new html_table(); $table->attributes['class'] = 'grading-report'; $sortbyfirstname = $this->helper_sortable_heading(get_string('firstname'), 'firstname', $options->sortby, $options->sorthow); $sortbylastname = $this->helper_sortable_heading(get_string('lastname'), 'lastname', $options->sortby, $options->sorthow); if (self::fullname_format() == 'lf') { $sortbyname = $sortbylastname . ' / ' . $sortbyfirstname; } else { $sortbyname = $sortbyfirstname . ' / ' . $sortbylastname; } $table->head = array(); $table->head[] = $sortbyname; $table->head[] = $this->helper_sortable_heading(get_string('submission', 'workshop'), 'submissiontitle', $options->sortby, $options->sorthow); $table->head[] = $this->helper_sortable_heading(get_string('receivedgrades', 'workshop')); if ($options->showsubmissiongrade) { $table->head[] = $this->helper_sortable_heading(get_string('submissiongradeof', 'workshop', $data->maxgrade), 'submissiongrade', $options->sortby, $options->sorthow); } $table->head[] = $this->helper_sortable_heading(get_string('givengrades', 'workshop')); if ($options->showgradinggrade) { $table->head[] = $this->helper_sortable_heading(get_string('gradinggradeof', 'workshop', $data->maxgradinggrade), 'gradinggrade', $options->sortby, $options->sorthow); } $table->rowclasses = array(); $table->colclasses = array(); $table->data = array(); foreach ($grades as $participant) { $numofreceived = count($participant->reviewedby); $numofgiven = count($participant->reviewerof); $published = $participant->submissionpublished; // compute the number of <tr> table rows needed to display this participant if ($numofreceived > 0 and $numofgiven > 0) { $numoftrs = workshop::lcm($numofreceived, $numofgiven); $spanreceived = $numoftrs / $numofreceived; $spangiven = $numoftrs / $numofgiven; } elseif ($numofreceived == 0 and $numofgiven > 0) { $numoftrs = $numofgiven; $spanreceived = $numoftrs; $spangiven = $numoftrs / $numofgiven; } elseif ($numofreceived > 0 and $numofgiven == 0) { $numoftrs = $numofreceived; $spanreceived = $numoftrs / $numofreceived; $spangiven = $numoftrs; } else { $numoftrs = 1; $spanreceived = 1; $spangiven = 1; } for ($tr = 0; $tr < $numoftrs; $tr++) { $row = new html_table_row(); if ($published) { $row->attributes['class'] = 'published'; } // column #1 - participant - spans over all rows if ($tr == 0) { $cell = new html_table_cell(); $cell->text = $this->helper_grading_report_participant($participant, $userinfo); $cell->rowspan = $numoftrs; $cell->attributes['class'] = 'participant'; $row->cells[] = $cell; } // column #2 - submission - spans over all rows if ($tr == 0) { $cell = new html_table_cell(); $cell->text = $this->helper_grading_report_submission($participant); $cell->rowspan = $numoftrs; $cell->attributes['class'] = 'submission'; $row->cells[] = $cell; } // column #3 - received grades if ($tr % $spanreceived == 0) { $idx = intval($tr / $spanreceived); $assessment = self::array_nth($participant->reviewedby, $idx); $cell = new html_table_cell(); $cell->text = $this->helper_grading_report_assessment($assessment, $options->showreviewernames, $userinfo, get_string('gradereceivedfrom', 'workshop')); $cell->rowspan = $spanreceived; $cell->attributes['class'] = 'receivedgrade'; if (is_null($assessment) or is_null($assessment->grade)) { $cell->attributes['class'] .= ' null'; } else { $cell->attributes['class'] .= ' notnull'; } $row->cells[] = $cell; } // column #4 - total grade for submission if ($options->showsubmissiongrade and $tr == 0) { $cell = new html_table_cell(); $cell->text = $this->helper_grading_report_grade($participant->submissiongrade, $participant->submissiongradeover); $cell->rowspan = $numoftrs; $cell->attributes['class'] = 'submissiongrade'; $row->cells[] = $cell; } // column #5 - given grades if ($tr % $spangiven == 0) { $idx = intval($tr / $spangiven); $assessment = self::array_nth($participant->reviewerof, $idx); $cell = new html_table_cell(); $cell->text = $this->helper_grading_report_assessment($assessment, $options->showauthornames, $userinfo, get_string('gradegivento', 'workshop')); $cell->rowspan = $spangiven; $cell->attributes['class'] = 'givengrade'; if (is_null($assessment) or is_null($assessment->grade)) { $cell->attributes['class'] .= ' null'; } else { $cell->attributes['class'] .= ' notnull'; } $row->cells[] = $cell; } // column #6 - total grade for assessment if ($options->showgradinggrade and $tr == 0) { $cell = new html_table_cell(); $cell->text = $this->helper_grading_report_grade($participant->gradinggrade); $cell->rowspan = $numoftrs; $cell->attributes['class'] = 'gradinggrade'; $row->cells[] = $cell; } $table->data[] = $row; } } return html_writer::table($table); }
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); require_once(dirname(__FILE__).'/locallib.php'); $cmid = required_param('cmid', PARAM_INT); $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, false, $cm); require_capability('mod/workshop:editdimensions', $PAGE->context); $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); // todo: check if there already is some assessment done and do not allowed the change of the form // once somebody already used it to assess $PAGE->set_url($workshop->editform_url()); $PAGE->set_title($workshop->name); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(get_string('editingassessmentform', 'workshop')); // load the grading strategy logic $strategy = $workshop->grading_strategy_instance(); // load the form to edit the grading strategy dimensions $mform = $strategy->get_edit_strategy_form($PAGE->url);
$buttontext = get_string('assess', 'workshop'); } else { $class = ' graded'; $submission->status = 'graded'; $buttontext = get_string('reassess', 'workshop'); } echo $output->box_start('generalbox assessment-summary' . $class); echo $output->render($workshop->prepare_submission_summary($submission, $shownames)); echo $output->box_end(); } print_collapsible_region_end(); } break; case workshop::PHASE_CLOSED: if (trim($workshop->conclusion)) { $conclusion = file_rewrite_pluginfile_urls($workshop->conclusion, 'pluginfile.php', $workshop->context->id, 'mod_workshop', 'conclusion', 0, workshop::instruction_editors_options($workshop->context)); print_collapsible_region_start('', 'workshop-viewlet-conclusion', get_string('conclusion', 'workshop')); echo $output->box(format_text($conclusion, $workshop->conclusionformat, array('overflowdiv' => true)), array('generalbox', 'conclusion')); print_collapsible_region_end(); } $finalgrades = $workshop->get_gradebook_grades($USER->id); if (!empty($finalgrades)) { print_collapsible_region_start('', 'workshop-viewlet-yourgrades', get_string('yourgrades', 'workshop')); echo $output->box_start('generalbox grades-yourgrades'); echo $output->render($finalgrades); echo $output->box_end(); print_collapsible_region_end(); } if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) { $perpage = get_user_preferences('workshop_perpage', 10); $groupid = groups_get_activity_group($workshop->cm, true);
<?php require_once("upload_form.php"); require_once("../../locallib.php"); global $PAGE, $DB; $cm = required_param('cm', PARAM_INT); $cm = get_coursemodule_from_id('workshop',$cm); require_login($cm->course); $context = $PAGE->context; require_capability('mod/workshop:allocate', $context); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); $form = $workshop->teammode ? new workshop_allocation_teammode_manual_upload_form() : new workshop_allocation_manual_upload_form(); if($form->exportValue('clear')) { $vals = $DB->get_records('workshop_submissions',array('workshopid' => $workshop->id), '', 'id'); $DB->delete_records_list('workshop_assessments','submissionid',array_keys($vals)); } else { $csv = array_map('str_getcsv',explode("\n",$form->get_file_content('file'))); $usernames = array(); foreach($csv as $a) {
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); require_once(dirname(__FILE__).'/locallib.php'); $asid = required_param('asid', PARAM_INT); // assessment id $assessment = $DB->get_record('workshop_assessments', array('id' => $asid), '*', MUST_EXIST); $submission = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid, 'example' => 0), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $submission->workshopid), '*', MUST_EXIST); $course = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST); require_login($course, false, $cm); if (isguestuser()) { print_error('guestsarenotallowed'); } $workshop = new workshop($workshop, $cm, $course); $PAGE->set_url($workshop->assess_url($assessment->id)); $PAGE->set_title($workshop->name); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(get_string('assessingsubmission', 'workshop')); $canviewallassessments = has_capability('mod/workshop:viewallassessments', $workshop->context); $canviewallsubmissions = has_capability('mod/workshop:viewallsubmissions', $workshop->context); $cansetassessmentweight = has_capability('mod/workshop:allocate', $workshop->context); $canoverridegrades = has_capability('mod/workshop:overridegrades', $workshop->context); $isreviewer = ($USER->id == $assessment->reviewerid); $isauthor = ($USER->id == $submission->authorid); if ($isreviewer or $isauthor or ($canviewallassessments and $canviewallsubmissions)) { // such a user can continue
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); require_once(dirname(__FILE__).'/locallib.php'); $asid = required_param('asid', PARAM_INT); // assessment id $assessment = $DB->get_record('workshop_assessments', array('id' => $asid), '*', MUST_EXIST); $example = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid, 'example' => 1), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $example->workshopid), '*', MUST_EXIST); $course = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST); require_login($course, false, $cm); if (isguestuser()) { print_error('guestsarenotallowed'); } $workshop = new workshop($workshop, $cm, $course); $PAGE->set_url($workshop->exassess_url($assessment->id)); $PAGE->set_title($workshop->name); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(get_string('assessingexample', 'workshop')); $currenttab = 'assessment'; $canmanage = has_capability('mod/workshop:manageexamples', $workshop->context); $isreviewer = ($USER->id == $assessment->reviewerid); if ($isreviewer or $canmanage) { // such a user can continue } else { print_error('nopermissions', 'error', $workshop->view_url(), 'assess example submission'); }
$pagingbar = new paging_bar($data->totalcount, $page, $perpage, $PAGE->url, 'page'); // grading report display options $reportopts = new stdclass(); $reportopts->showauthornames = $showauthornames; $reportopts->showreviewernames = $showreviewernames; $reportopts->sortby = $sortby; $reportopts->sorthow = $sorthow; $reportopts->showsubmissiongrade = false; $reportopts->showgradinggrade = false; echo $output->render($pagingbar); echo $output->render(new workshop_grading_report($data, $reportopts)); echo $output->render($pagingbar); } } if (trim($workshop->instructreviewers)) { $instructions = file_rewrite_pluginfile_urls($workshop->instructreviewers, 'pluginfile.php', $PAGE->context->id, 'mod_workshop', 'instructreviewers', 0, workshop::instruction_editors_options($PAGE->context)); print_collapsible_region_start('', 'workshop-viewlet-instructreviewers', get_string('instructreviewers', 'workshop')); echo $output->box(format_text($instructions, $workshop->instructreviewersformat, array('overflowdiv' => true)), array('generalbox', 'instructions')); print_collapsible_region_end(); } // does the user have to assess examples before assessing other's work? $examplesmust = ($workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_ASSESSMENT); // is the assessment of example submissions considered finished? $examplesdone = has_capability('mod/workshop:manageexamples', $workshop->context); // can the examples be assessed? $examplesavailable = true; if (!$examplesdone and $examplesmust and $ownsubmissionexists === false) { print_collapsible_region_start('', 'workshop-viewlet-examplesfail', get_string('exampleassessments', 'workshop')); echo $output->box(get_string('exampleneedsubmission', 'workshop')); print_collapsible_region_end(); $examplesavailable = false;
* @subpackage workshop * @copyright 2009 David Mudrak <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); require_once(dirname(__FILE__).'/locallib.php'); require_once(dirname(__FILE__).'/allocation/lib.php'); $cmid = required_param('cmid', PARAM_INT); // course module $method = optional_param('method', 'manual', PARAM_ALPHAEXT); // method to use $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); $PAGE->set_url($workshop->allocation_url($method)); require_login($course, false, $cm); $context = $PAGE->context; require_capability('mod/workshop:allocate', $context); $PAGE->set_title($workshop->name); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(get_string('allocation', 'workshop')); $allocator = $workshop->allocator_instance($method); $initresult = $allocator->init(); //
<?php require_once("upload_form.php"); require_once("../../locallib.php"); global $PAGE, $DB, $SESSION; $cm = required_param('cm', PARAM_INT); $cm = get_coursemodule_from_id('workshop',$cm); require_login($cm->course); $context = $PAGE->context; require_capability('mod/workshop:allocate', $context); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); $workshop = new workshop($workshop, $cm, $course); $form = new workshop_allocation_manual_groups_upload_form(); $csv = array_map('str_getcsv',preg_split("/[\r\n]+/",$form->get_file_content('file'))); if($form->exportValue('clear')) { $vals = $DB->get_records('workshop_submissions',array('workshopid' => $workshop->id), '', 'id,title'); list($select, $params) = $DB->get_in_or_equal(array_keys($vals)); $delete = $DB->get_records_select('workshop_assessments',"submissionid $select AND grade is NULL",$params,'','id'); $dontdelete = $DB->get_records_select('workshop_assessments',"submissionid $select AND grade is not NULL",$params,'','id,submissionid,reviewerid'); $DB->delete_records_list('workshop_assessments','id',array_keys($delete)); $reviewers = array(); foreach ($dontdelete as $key => $value) {
$cmid = required_param('cmid', PARAM_INT); // course module id $id = optional_param('id', 0, PARAM_INT); // submission id $edit = optional_param('edit', false, PARAM_BOOL); // open for editing? $assess = optional_param('assess', false, PARAM_BOOL); // instant assessment required $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, false, $cm); if (isguestuser()) { print_error('guestsarenotallowed'); } $workshoprecord = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); $workshop = new workshop($workshoprecord, $cm, $course); $PAGE->set_url($workshop->submission_url(), array('cmid' => $cmid, 'id' => $id)); if ($edit) { $PAGE->url->param('edit', $edit); } if ($id) { // submission is specified $submission = $workshop->get_submission_by_id($id); $params = array('objectid' => $submission->id, 'context' => $workshop->context, 'courseid' => $workshop->course->id, 'relateduserid' => $submission->authorid, 'other' => array('workshopid' => $workshop->id)); $event = \mod_workshop\event\submission_viewed::create($params); $event->trigger(); } else { // no submission specified if (!($submission = $workshop->get_submission_by_author($USER->id))) { $submission = new stdclass(); $submission->id = null;
/** * Prepares the form before data are set * * Additional wysiwyg editor are prepared here, the introeditor is prepared automatically by core. * Grade items are set here because the core modedit supports single grade item only. * * @param array $data to be set * @return void */ public function data_preprocessing(&$data) { if ($this->current->instance) { // editing an existing workshop - let us prepare the added editor elements (intro done automatically) $draftitemid = file_get_submitted_draft_itemid('instructauthors'); $data['instructauthorseditor']['text'] = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_workshop', 'instructauthors', 0, workshop::instruction_editors_options($this->context), $data['instructauthors']); $data['instructauthorseditor']['format'] = $data['instructauthorsformat']; $data['instructauthorseditor']['itemid'] = $draftitemid; $draftitemid = file_get_submitted_draft_itemid('instructreviewers'); $data['instructreviewerseditor']['text'] = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_workshop', 'instructreviewers', 0, workshop::instruction_editors_options($this->context), $data['instructreviewers']); $data['instructreviewerseditor']['format'] = $data['instructreviewersformat']; $data['instructreviewerseditor']['itemid'] = $draftitemid; $draftitemid = file_get_submitted_draft_itemid('conclusion'); $data['conclusioneditor']['text'] = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_workshop', 'conclusion', 0, workshop::instruction_editors_options($this->context), $data['conclusion']); $data['conclusioneditor']['format'] = $data['conclusionformat']; $data['conclusioneditor']['itemid'] = $draftitemid; } else { // adding a new workshop instance $draftitemid = file_get_submitted_draft_itemid('instructauthors'); file_prepare_draft_area($draftitemid, null, 'mod_workshop', 'instructauthors', 0); // no context yet, itemid not used $data['instructauthorseditor'] = array('text' => '', 'format' => editors_get_preferred_format(), 'itemid' => $draftitemid); $draftitemid = file_get_submitted_draft_itemid('instructreviewers'); file_prepare_draft_area($draftitemid, null, 'mod_workshop', 'instructreviewers', 0); // no context yet, itemid not used $data['instructreviewerseditor'] = array('text' => '', 'format' => editors_get_preferred_format(), 'itemid' => $draftitemid); $draftitemid = file_get_submitted_draft_itemid('conclusion'); file_prepare_draft_area($draftitemid, null, 'mod_workshop', 'conclusion', 0); // no context yet, itemid not used $data['conclusioneditor'] = array('text' => '', 'format' => editors_get_preferred_format(), 'itemid' => $draftitemid); } }