/** * Called to define this moodle form * * @return void */ public function definition() { global $CFG, $COURSE, $DB, $PAGE; $sphereLib; $mform = $this->_form; $sphereLib = new setask_sphere(); #here we get a list of problems from sphere engine $problems = $sphereLib->getProblemsToForm(); //sphereGetProblems(); #$sphereLib->getProblemsToForm();//s #var_dump($problems); $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('select', 'problem', 'Problem: ', $problems); $mform->addElement('text', 'name', get_string('setaskmentname', 'setask'), array('size' => '64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->standard_intro_elements(get_string('description', 'setask')); $mform->addElement('filemanager', 'introattachments', get_string('introattachments', 'setask'), null, array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes)); $mform->addHelpButton('introattachments', 'introattachments', 'setask'); $ctx = null; if ($this->current && $this->current->coursemodule) { $cm = get_coursemodule_from_instance('setask', $this->current->id, 0, false, MUST_EXIST); $ctx = context_module::instance($cm->id); } $setaskment = new setask($ctx, null, null); if ($this->current && $this->current->course) { if (!$ctx) { $ctx = context_course::instance($this->current->course); } $course = $DB->get_record('course', array('id' => $this->current->course), '*', MUST_EXIST); $setaskment->set_course($course); } $config = get_config('setask'); $mform->addElement('header', 'availability', get_string('availability', 'setask')); $mform->setExpanded('availability', true); $name = get_string('allowsubmissionsfromdate', 'setask'); $options = array('optional' => true); $mform->addElement('date_time_selector', 'allowsubmissionsfromdate', $name, $options); $mform->addHelpButton('allowsubmissionsfromdate', 'allowsubmissionsfromdate', 'setask'); $name = get_string('duedate', 'setask'); $mform->addElement('date_time_selector', 'duedate', $name, array('optional' => true)); $mform->addHelpButton('duedate', 'duedate', 'setask'); $name = get_string('cutoffdate', 'setask'); $mform->addElement('date_time_selector', 'cutoffdate', $name, array('optional' => true)); $mform->addHelpButton('cutoffdate', 'cutoffdate', 'setask'); $name = get_string('alwaysshowdescription', 'setask'); $mform->addElement('checkbox', 'alwaysshowdescription', $name); $mform->addHelpButton('alwaysshowdescription', 'alwaysshowdescription', 'setask'); $mform->disabledIf('alwaysshowdescription', 'allowsubmissionsfromdate[enabled]', 'notchecked'); $setaskment->add_all_plugin_settings($mform); $mform->addElement('header', 'submissionsettings', get_string('submissionsettings', 'setask')); $name = get_string('submissiondrafts', 'setask'); $mform->addElement('selectyesno', 'submissiondrafts', $name); $mform->addHelpButton('submissiondrafts', 'submissiondrafts', 'setask'); $name = get_string('requiresubmissionstatement', 'setask'); $mform->addElement('selectyesno', 'requiresubmissionstatement', $name); $mform->addHelpButton('requiresubmissionstatement', 'requiresubmissionstatement', 'setask'); $mform->setType('requiresubmissionstatement', PARAM_BOOL); $options = array(ASSIGN_ATTEMPT_REOPEN_METHOD_NONE => get_string('attemptreopenmethod_none', 'mod_setask'), ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL => get_string('attemptreopenmethod_manual', 'mod_setask'), ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS => get_string('attemptreopenmethod_untilpass', 'mod_setask')); $mform->addElement('select', 'attemptreopenmethod', get_string('attemptreopenmethod', 'mod_setask'), $options); $mform->addHelpButton('attemptreopenmethod', 'attemptreopenmethod', 'mod_setask'); $options = array(ASSIGN_UNLIMITED_ATTEMPTS => get_string('unlimitedattempts', 'mod_setask')); $options += array_combine(range(1, 30), range(1, 30)); $mform->addElement('select', 'maxattempts', get_string('maxattempts', 'mod_setask'), $options); $mform->addHelpButton('maxattempts', 'maxattempts', 'setask'); $mform->disabledIf('maxattempts', 'attemptreopenmethod', 'eq', ASSIGN_ATTEMPT_REOPEN_METHOD_NONE); $mform->addElement('header', 'groupsubmissionsettings', get_string('groupsubmissionsettings', 'setask')); $name = get_string('teamsubmission', 'setask'); $mform->addElement('selectyesno', 'teamsubmission', $name); $mform->addHelpButton('teamsubmission', 'teamsubmission', 'setask'); if ($setaskment->has_submissions_or_grades()) { $mform->freeze('teamsubmission'); } $name = get_string('preventsubmissionnotingroup', 'setask'); $mform->addElement('selectyesno', 'preventsubmissionnotingroup', $name); $mform->addHelpButton('preventsubmissionnotingroup', 'preventsubmissionnotingroup', 'setask'); $mform->setType('preventsubmissionnotingroup', PARAM_BOOL); $mform->disabledIf('preventsubmissionnotingroup', 'teamsubmission', 'eq', 0); $name = get_string('requireallteammemberssubmit', 'setask'); $mform->addElement('selectyesno', 'requireallteammemberssubmit', $name); $mform->addHelpButton('requireallteammemberssubmit', 'requireallteammemberssubmit', 'setask'); $mform->disabledIf('requireallteammemberssubmit', 'teamsubmission', 'eq', 0); $mform->disabledIf('requireallteammemberssubmit', 'submissiondrafts', 'eq', 0); $groupings = groups_get_all_groupings($setaskment->get_course()->id); $options = array(); $options[0] = get_string('none'); foreach ($groupings as $grouping) { $options[$grouping->id] = $grouping->name; } $name = get_string('teamsubmissiongroupingid', 'setask'); $mform->addElement('select', 'teamsubmissiongroupingid', $name, $options); $mform->addHelpButton('teamsubmissiongroupingid', 'teamsubmissiongroupingid', 'setask'); $mform->disabledIf('teamsubmissiongroupingid', 'teamsubmission', 'eq', 0); if ($setaskment->has_submissions_or_grades()) { $mform->freeze('teamsubmissiongroupingid'); } $mform->addElement('header', 'notifications', get_string('notifications', 'setask')); $name = get_string('sendnotifications', 'setask'); $mform->addElement('selectyesno', 'sendnotifications', $name); $mform->addHelpButton('sendnotifications', 'sendnotifications', 'setask'); $name = get_string('sendlatenotifications', 'setask'); $mform->addElement('selectyesno', 'sendlatenotifications', $name); $mform->addHelpButton('sendlatenotifications', 'sendlatenotifications', 'setask'); $mform->disabledIf('sendlatenotifications', 'sendnotifications', 'eq', 1); $name = get_string('sendstudentnotificationsdefault', 'setask'); $mform->addElement('selectyesno', 'sendstudentnotifications', $name); $mform->addHelpButton('sendstudentnotifications', 'sendstudentnotificationsdefault', 'setask'); // Plagiarism enabling form. if (!empty($CFG->enableplagiarism)) { require_once $CFG->libdir . '/plagiarismlib.php'; plagiarism_get_form_elements_module($mform, $ctx->get_course_context(), 'mod_setask'); } $this->standard_grading_coursemodule_elements(); $name = get_string('blindmarking', 'setask'); $mform->addElement('selectyesno', 'blindmarking', $name); $mform->addHelpButton('blindmarking', 'blindmarking', 'setask'); if ($setaskment->has_submissions_or_grades()) { $mform->freeze('blindmarking'); } $name = get_string('markingworkflow', 'setask'); $mform->addElement('selectyesno', 'markingworkflow', $name); $mform->addHelpButton('markingworkflow', 'markingworkflow', 'setask'); $name = get_string('markingallocation', 'setask'); $mform->addElement('selectyesno', 'markingallocation', $name); $mform->addHelpButton('markingallocation', 'markingallocation', 'setask'); $mform->disabledIf('markingallocation', 'markingworkflow', 'eq', 0); $this->standard_coursemodule_elements(); $this->apply_admin_defaults(); $this->add_action_buttons(); // Add warning popup/noscript tag, if grades are changed by user. $hasgrade = false; if (!empty($this->_instance)) { $hasgrade = $DB->record_exists_select('setask_grades', 'setaskment = ? AND grade <> -1', array($this->_instance)); } if ($mform->elementExists('grade') && $hasgrade) { $module = array('name' => 'mod_setask', 'fullpath' => '/mod/setask/module.js', 'requires' => array('node', 'event'), 'strings' => array(array('changegradewarning', 'mod_setask'))); $PAGE->requires->js_init_call('M.mod_setask.init_grade_change', null, false, $module); // Add noscript tag in case. $noscriptwarning = $mform->createElement('static', 'warning', null, html_writer::tag('noscript', get_string('changegradewarning', 'mod_setask'))); $mform->insertElementBefore($noscriptwarning, 'grade'); } }