/** * Called to define this moodle form * * @return void */ public function definition() { global $CFG, $COURSE, $DB, $PAGE; $mform = $this->_form; $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('select', 'state', 'State/Province: '); $mform->addElement('text', 'name', get_string('seplmentname', 'sepl'), array('size' => '64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $se_problems = new SphereEngine\Api("dadeea82cdd4b840cbde18858d9f17d6fb11a957", "v3", "problems"); $problemsClient = $se_problems->getProblemsClient(); #$client = (new SphereEngine\Api("dadeea82cdd4b840cbde18858d9f17d6fb11a957", "v3", "problems"))->getProblemsClient(); #$result = $problemsClient->problems->all(); #$mform->addElement('select', 'problem', 'Problem: ',$result);//, $state); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://problems.sphere-engine.com/api/v3/problems?access_token=dadeea82cdd4b840cbde18858d9f17d6fb11a957"); curl_setopt($ch, CURLOPT_POST, 1); #curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output2 = curl_exec($ch); curl_close($ch); $client = (new SphereEngine\Api("dadeea82cdd4b840cbde18858d9f17d6fb11a957", "v3", "endpoint"))->getProblemsClient(); var_dump($user); #var_dump( #$client->problems->all(['items']); var_dump($server_output2); $result2 = json_decode($server_output2, true); var_dump($result2); $mform->addElement('select', 'problem', 'Problem: ', $result2); //, $state); $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $this->standard_intro_elements(get_string('description', 'sepl')); $mform->addElement('filemanager', 'introattachments', get_string('introattachments', 'sepl'), null, array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes)); $mform->addHelpButton('introattachments', 'introattachments', 'sepl'); $ctx = null; if ($this->current && $this->current->coursemodule) { $cm = get_coursemodule_from_instance('sepl', $this->current->id, 0, false, MUST_EXIST); $ctx = context_module::instance($cm->id); } $seplment = new sepl($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); $seplment->set_course($course); } $config = get_config('sepl'); $mform->addElement('header', 'availability', get_string('availability', 'sepl')); $mform->setExpanded('availability', true); $name = get_string('allowsubmissionsfromdate', 'sepl'); $options = array('optional' => true); $mform->addElement('date_time_selector', 'allowsubmissionsfromdate', $name, $options); $mform->addHelpButton('allowsubmissionsfromdate', 'allowsubmissionsfromdate', 'sepl'); $name = get_string('duedate', 'sepl'); $mform->addElement('date_time_selector', 'duedate', $name, array('optional' => true)); $mform->addHelpButton('duedate', 'duedate', 'sepl'); $name = get_string('cutoffdate', 'sepl'); $mform->addElement('date_time_selector', 'cutoffdate', $name, array('optional' => true)); $mform->addHelpButton('cutoffdate', 'cutoffdate', 'sepl'); $name = get_string('alwaysshowdescription', 'sepl'); $mform->addElement('checkbox', 'alwaysshowdescription', $name); $mform->addHelpButton('alwaysshowdescription', 'alwaysshowdescription', 'sepl'); $mform->disabledIf('alwaysshowdescription', 'allowsubmissionsfromdate[enabled]', 'notchecked'); $seplment->add_all_plugin_settings($mform); $mform->addElement('header', 'submissionsettings', get_string('submissionsettings', 'sepl')); $name = get_string('submissiondrafts', 'sepl'); $mform->addElement('selectyesno', 'submissiondrafts', $name); $mform->addHelpButton('submissiondrafts', 'submissiondrafts', 'sepl'); $name = get_string('requiresubmissionstatement', 'sepl'); $mform->addElement('selectyesno', 'requiresubmissionstatement', $name); $mform->addHelpButton('requiresubmissionstatement', 'requiresubmissionstatement', 'sepl'); $mform->setType('requiresubmissionstatement', PARAM_BOOL); $options = array(ASSIGN_ATTEMPT_REOPEN_METHOD_NONE => get_string('attemptreopenmethod_none', 'mod_sepl'), ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL => get_string('attemptreopenmethod_manual', 'mod_sepl'), ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS => get_string('attemptreopenmethod_untilpass', 'mod_sepl')); $mform->addElement('select', 'attemptreopenmethod', get_string('attemptreopenmethod', 'mod_sepl'), $options); $mform->addHelpButton('attemptreopenmethod', 'attemptreopenmethod', 'mod_sepl'); $options = array(ASSIGN_UNLIMITED_ATTEMPTS => get_string('unlimitedattempts', 'mod_sepl')); $options += array_combine(range(1, 30), range(1, 30)); $mform->addElement('select', 'maxattempts', get_string('maxattempts', 'mod_sepl'), $options); $mform->addHelpButton('maxattempts', 'maxattempts', 'sepl'); $mform->disabledIf('maxattempts', 'attemptreopenmethod', 'eq', ASSIGN_ATTEMPT_REOPEN_METHOD_NONE); $mform->addElement('header', 'groupsubmissionsettings', get_string('groupsubmissionsettings', 'sepl')); $name = get_string('teamsubmission', 'sepl'); $mform->addElement('selectyesno', 'teamsubmission', $name); $mform->addHelpButton('teamsubmission', 'teamsubmission', 'sepl'); if ($seplment->has_submissions_or_grades()) { $mform->freeze('teamsubmission'); } $name = get_string('preventsubmissionnotingroup', 'sepl'); $mform->addElement('selectyesno', 'preventsubmissionnotingroup', $name); $mform->addHelpButton('preventsubmissionnotingroup', 'preventsubmissionnotingroup', 'sepl'); $mform->setType('preventsubmissionnotingroup', PARAM_BOOL); $mform->disabledIf('preventsubmissionnotingroup', 'teamsubmission', 'eq', 0); $name = get_string('requireallteammemberssubmit', 'sepl'); $mform->addElement('selectyesno', 'requireallteammemberssubmit', $name); $mform->addHelpButton('requireallteammemberssubmit', 'requireallteammemberssubmit', 'sepl'); $mform->disabledIf('requireallteammemberssubmit', 'teamsubmission', 'eq', 0); $mform->disabledIf('requireallteammemberssubmit', 'submissiondrafts', 'eq', 0); $groupings = groups_get_all_groupings($seplment->get_course()->id); $options = array(); $options[0] = get_string('none'); foreach ($groupings as $grouping) { $options[$grouping->id] = $grouping->name; } $name = get_string('teamsubmissiongroupingid', 'sepl'); $mform->addElement('select', 'teamsubmissiongroupingid', $name, $options); $mform->addHelpButton('teamsubmissiongroupingid', 'teamsubmissiongroupingid', 'sepl'); $mform->disabledIf('teamsubmissiongroupingid', 'teamsubmission', 'eq', 0); if ($seplment->has_submissions_or_grades()) { $mform->freeze('teamsubmissiongroupingid'); } $mform->addElement('header', 'notifications', get_string('notifications', 'sepl')); $name = get_string('sendnotifications', 'sepl'); $mform->addElement('selectyesno', 'sendnotifications', $name); $mform->addHelpButton('sendnotifications', 'sendnotifications', 'sepl'); $name = get_string('sendlatenotifications', 'sepl'); $mform->addElement('selectyesno', 'sendlatenotifications', $name); $mform->addHelpButton('sendlatenotifications', 'sendlatenotifications', 'sepl'); $mform->disabledIf('sendlatenotifications', 'sendnotifications', 'eq', 1); $name = get_string('sendstudentnotificationsdefault', 'sepl'); $mform->addElement('selectyesno', 'sendstudentnotifications', $name); $mform->addHelpButton('sendstudentnotifications', 'sendstudentnotificationsdefault', 'sepl'); // Plagiarism enabling form. if (!empty($CFG->enableplagiarism)) { require_once $CFG->libdir . '/plagiarismlib.php'; plagiarism_get_form_elements_module($mform, $ctx->get_course_context(), 'mod_sepl'); } $this->standard_grading_coursemodule_elements(); $name = get_string('blindmarking', 'sepl'); $mform->addElement('selectyesno', 'blindmarking', $name); $mform->addHelpButton('blindmarking', 'blindmarking', 'sepl'); if ($seplment->has_submissions_or_grades()) { $mform->freeze('blindmarking'); } $name = get_string('markingworkflow', 'sepl'); $mform->addElement('selectyesno', 'markingworkflow', $name); $mform->addHelpButton('markingworkflow', 'markingworkflow', 'sepl'); $name = get_string('markingallocation', 'sepl'); $mform->addElement('selectyesno', 'markingallocation', $name); $mform->addHelpButton('markingallocation', 'markingallocation', 'sepl'); $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('sepl_grades', 'seplment = ? AND grade <> -1', array($this->_instance)); } if ($mform->elementExists('grade') && $hasgrade) { $module = array('name' => 'mod_sepl', 'fullpath' => '/mod/sepl/module.js', 'requires' => array('node', 'event'), 'strings' => array(array('changegradewarning', 'mod_sepl'))); $PAGE->requires->js_init_call('M.mod_sepl.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_sepl'))); $mform->insertElementBefore($noscriptwarning, 'grade'); } }