/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { $mform->addElement('header', 'globalvarshdr', get_string('globalvarshdr', 'qtype_coordinates')); $mform->removeElement('defaultgrade'); $mform->addElement('hidden', 'defaultgrade'); $mform->setType('defaultgrade', PARAM_RAW); $mform->removeElement('penalty'); $mform->addElement('hidden', 'penalty'); $mform->setType('penalty', PARAM_NUMBER); $mform->setDefault('penalty', 0.1); $mform->addElement('static', 'help_coordinates', get_string('help'), get_string('helponquestionoptions', 'qtype_coordinates')); $mform->addElement('textarea', 'varsrandom', get_string('varsrandom', 'qtype_coordinates'), array('rows' => 4, 'cols' => 70, 'course' => $this->coursefilesid)); $mform->addElement('textarea', 'varsglobal', get_string('varsglobal', 'qtype_coordinates'), array('rows' => 6, 'cols' => 70, 'course' => $this->coursefilesid)); $mform->addElement('select', 'showperanswermark', get_string('showperanswermark', 'qtype_coordinates'), array(get_string('choiceno', 'qtype_coordinates'), get_string('choiceyes', 'qtype_coordinates'))); $mform->setDefault('showperanswermark', 1); $mform->addElement('select', 'peranswersubmit', get_string('peranswersubmit', 'qtype_coordinates'), array(get_string('choiceno', 'qtype_coordinates'), get_string('choiceyes', 'qtype_coordinates'))); $mform->setDefault('peranswersubmit', 1); $mform->addElement('text', 'retrymarkseq', get_string('retrymarkseq', 'qtype_coordinates'), array('size' => 30)); $show_group = array(); $show_group[] =& $mform->createElement('checkbox', 'vars2', '', get_string('vars2', 'qtype_coordinates'), 'onclick="coordinates_form_display(\'vars2\', this.checked)"'); $show_group[] =& $mform->createElement('checkbox', 'preunit', '', get_string('preunit', 'qtype_coordinates'), 'onclick="coordinates_form_display(\'preunit\', this.checked)"'); $show_group[] =& $mform->createElement('checkbox', 'otherrule', '', get_string('otherrule', 'qtype_coordinates'), 'onclick="coordinates_form_display(\'otherrule\', this.checked)"'); //$show_group[] =& $mform->createElement('checkbox','subqtext','',get_string('subqtext','qtype_coordinates'), // 'onclick="coordinates_form_display(\'subqtext\', this.checked)"'); //$show_group[] =& $mform->createElement('checkbox','feedback','',get_string('feedback','qtype_coordinates'), // 'onclick="coordinates_form_display(\'feedback\', this.checked)"'); $show_group[] =& $mform->createElement('checkbox', 'correctnessraw', '', get_string('correctnessraw', 'qtype_coordinates'), 'onclick="coordinates_form_correctness(this.checked)"'); $mform->addGroup($show_group, 'showoptions', get_string('showoptions', 'qtype_coordinates'), array(' '), true); $creategrades = get_grade_options(); $this->add_per_answer_fields($mform, get_string('answerno', 'qtype_coordinates', '{no}'), $creategrades->gradeoptions, 1, 1); }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { //------------------------------------------------------------------------------------------ $creategrades = get_grade_options(); $this->add_per_answer_fields($mform, get_string('answerno', 'qtype_numerical', '{no}'), $creategrades->gradeoptions); //------------------------------------------------------------------------------------------ $repeated = array(); $repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}')); $repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz')); $mform->setType('unit', PARAM_NOTAGS); $repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz')); $mform->setType('multiplier', PARAM_NUMBER); if (isset($this->question->options)) { $countunits = count($this->question->options->units); } else { $countunits = 0; } if ($this->question->formoptions->repeatelements) { $repeatsatstart = $countunits + 2; } else { $repeatsatstart = $countunits; } $this->repeat_elements($repeated, $repeatsatstart, array(), 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_numerical')); if ($mform->elementExists('multiplier[0]')) { /// Does not exist when this form is used in 'move to another category' /// mode with a qusetion that has no units. This was leading to errors. $firstunit =& $mform->getElement('multiplier[0]'); $firstunit->freeze(); $firstunit->setValue('1.0'); $firstunit->setPersistantFreeze(true); } }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { $menu = array(get_string('caseno', 'quiz'), get_string('caseyes', 'quiz')); $mform->addElement('select', 'usecase', get_string('casesensitive', 'quiz'), $menu); $mform->addElement('static', 'answersinstruct', get_string('correctanswers', 'quiz'), get_string('filloutoneanswer', 'quiz')); $mform->closeHeaderBefore('answersinstruct'); $creategrades = get_grade_options(); $gradeoptions = $creategrades->gradeoptions; $repeated = array(); $repeated[] =& $mform->createElement('header', 'answerhdr', get_string('answerno', 'qtype_shortanswer', '{no}')); $repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'), array('size' => 54)); $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions); $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'), array('course' => $this->coursefilesid)); if (isset($this->question->options)) { $countanswers = count($this->question->options->answers); } else { $countanswers = 0; } if ($this->question->formoptions->repeatelements) { $repeatsatstart = QUESTION_NUMANS_START > $countanswers + QUESTION_NUMANS_ADD ? QUESTION_NUMANS_START : $countanswers + QUESTION_NUMANS_ADD; } else { $repeatsatstart = $countanswers; } $repeatedoptions = array(); $mform->setType('answer', PARAM_RAW); $repeatedoptions['fraction']['default'] = 0; $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmoreanswerblanks', 'qtype_shortanswer')); }
/** * Add question-type specific form fields. * * @param object $mform the form being built. */ function definition_inner(&$mform) { global $QTYPES; $menu = array(get_string('answersingleno', 'qtype_multichoice'), get_string('answersingleyes', 'qtype_multichoice')); $mform->addElement('select', 'single', get_string('answerhowmany', 'qtype_multichoice'), $menu); $mform->setDefault('single', 1); $mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0, 1)); $mform->setHelpButton('shuffleanswers', array('multichoiceshuffle', get_string('shuffleanswers', 'qtype_multichoice'), 'quiz')); $mform->setDefault('shuffleanswers', 1); $numberingoptions = $QTYPES[$this->qtype()]->get_numbering_styles(); $menu = array(); foreach ($numberingoptions as $numberingoption) { $menu[$numberingoption] = get_string('answernumbering' . $numberingoption, 'qtype_multichoice'); } $mform->addElement('select', 'answernumbering', get_string('answernumbering', 'qtype_multichoice'), $menu); $mform->setDefault('answernumbering', 'abc'); /* $mform->addElement('static', 'answersinstruct', get_string('choices', 'qtype_multichoice'), get_string('fillouttwochoices', 'qtype_multichoice')); $mform->closeHeaderBefore('answersinstruct'); */ $creategrades = get_grade_options(); $this->add_per_answer_fields($mform, get_string('choiceno', 'qtype_multichoice', '{no}'), $creategrades->gradeoptionsfull, max(5, QUESTION_NUMANS_START)); $mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'qtype_multichoice')); foreach (array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback') as $feedbackname) { $mform->addElement('htmleditor', $feedbackname, get_string($feedbackname, 'qtype_multichoice'), array('course' => $this->coursefilesid)); $mform->setType($feedbackname, PARAM_RAW); } }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { global $QTYPES; $this->qtypeobj =& $QTYPES[$this->qtype()]; $label = get_string("sharedwildcards", "qtype_datasetdependent"); $mform->addElement('hidden', 'initialcategory', 1); $html2 = $this->qtypeobj->print_dataset_definitions_category($this->question); $mform->insertElementBefore($mform->createElement('static', 'listcategory', $label, $html2), 'name'); $addfieldsname = 'updatecategory'; $addstring = get_string("updatecategory", "qtype_calculated"); $mform->registerNoSubmitButton($addfieldsname); $mform->insertElementBefore($mform->createElement('submit', $addfieldsname, $addstring), 'listcategory'); $repeated = array(); $repeated[] =& $mform->createElement('header', 'answerhdr', get_string('answerhdr', 'qtype_calculated', '{no}')); $repeated[] =& $mform->createElement('text', 'answers', get_string('correctanswerformula', 'quiz') . '=', array('size' => 50)); $repeatedoptions['answers']['type'] = PARAM_NOTAGS; $creategrades = get_grade_options(); $gradeoptions = $creategrades->gradeoptions; $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions); $repeatedoptions['fraction']['default'] = 0; $repeated[] =& $mform->createElement('text', 'tolerance', get_string('tolerance', 'qtype_calculated')); $repeatedoptions['tolerance']['type'] = PARAM_NUMBER; $repeatedoptions['tolerance']['default'] = 0.01; $repeated[] =& $mform->createElement('select', 'tolerancetype', get_string('tolerancetype', 'quiz'), $this->qtypeobj->tolerance_types()); $repeated[] =& $mform->createElement('select', 'correctanswerlength', get_string('correctanswershows', 'qtype_calculated'), range(0, 9)); $repeatedoptions['correctanswerlength']['default'] = 2; $answerlengthformats = array('1' => get_string('decimalformat', 'quiz'), '2' => get_string('significantfiguresformat', 'quiz')); $repeated[] =& $mform->createElement('select', 'correctanswerformat', get_string('correctanswershowsformat', 'qtype_calculated'), $answerlengthformats); $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz')); $repeatedoptions['feedback']['type'] = PARAM_RAW; if (isset($this->question->options)) { $count = count($this->question->options->answers); } else { $count = 0; } $repeatsatstart = $count + 1; $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', 1, get_string('addmoreanswerblanks', 'qtype_calculated')); $repeated = array(); $repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}')); $repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz')); $mform->setType('unit', PARAM_NOTAGS); $repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz')); $mform->setType('multiplier', PARAM_NUMBER); if (isset($this->question->options)) { $countunits = count($this->question->options->units); } else { $countunits = 0; } $repeatsatstart = $countunits + 1; $this->repeat_elements($repeated, $repeatsatstart, array(), 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_calculated', '{no}')); $firstunit =& $mform->getElement('multiplier[0]'); $firstunit->freeze(); $firstunit->setValue('1.0'); $firstunit->setPersistantFreeze(true); //hidden elements $mform->addElement('hidden', 'wizard', 'datasetdefinitions'); $mform->setType('wizard', PARAM_ALPHA); }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { $menu = array(get_string('caseno', 'quiz'), get_string('caseyes', 'quiz')); $mform->addElement('select', 'usecase', get_string('casesensitive', 'quiz'), $menu); $mform->addElement('static', 'answersinstruct', get_string('correctanswers', 'quiz'), get_string('filloutoneanswer', 'quiz')); $mform->closeHeaderBefore('answersinstruct'); $creategrades = get_grade_options(); $this->add_per_answer_fields($mform, get_string('answerno', 'qtype_shortanswer', '{no}'), $creategrades->gradeoptions); }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { global $QTYPES; //------------------------------------------------------------------------------------------ $creategrades = get_grade_options(); $this->add_per_answer_fields($mform, get_string('answerno', 'qtype_numerical', '{no}'), $creategrades->gradeoptions); //------------------------------------------------------------------------------------------ $QTYPES['numerical']->add_units_options($mform, $this); $QTYPES['numerical']->add_units_elements($mform, $this); }
public static function round_to_nearest_grade($value) { $options = get_grade_options(); $grades = $options->gradeoptionsfull; $result = 0; foreach ($grades as $grade => $name) { if (abs($grade - $value) < abs($result - $value)) { $result = $grade; } } return $result; }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { //------------------------------------------------------------------------------------------ $creategrades = get_grade_options(); $gradeoptions = $creategrades->gradeoptions; $repeated = array(); $repeatedoptions = array(); $repeated[] =& $mform->createElement('header', 'answerhdr', get_string('answerno', 'qtype_numerical', '{no}')); $repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz')); $mform->setType('answer', PARAM_RAW); $repeated[] =& $mform->createElement('text', 'tolerance', get_string('acceptederror', 'quiz')); $mform->setType('tolerance', PARAM_NUMBER); $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions); $repeatedoptions['fraction']['default'] = 0; $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'), array('course' => $this->coursefilesid)); $mform->setType('feedback', PARAM_RAW); if (isset($this->question->options)) { $countanswers = count($this->question->options->answers); } else { $countanswers = 0; } if ($this->question->formoptions->repeatelements) { $repeatsatstart = QUESTION_NUMANS_START > $countanswers + 1 ? QUESTION_NUMANS_START : $countanswers + 1; } else { $repeatsatstart = $countanswers; } $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', 2, get_string('addmoreanswerblanks', 'qtype_numerical')); //------------------------------------------------------------------------------------------ $repeated = array(); $repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}')); $repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz')); $mform->setType('unit', PARAM_NOTAGS); $repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz')); $mform->setType('multiplier', PARAM_NUMBER); if (isset($this->question->options)) { $countunits = count($this->question->options->units); } else { $countunits = 0; } if ($this->question->formoptions->repeatelements) { $repeatsatstart = $countunits + 2; } else { $repeatsatstart = $countunits; } $this->repeat_elements($repeated, $repeatsatstart, array(), 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_numerical')); $firstunit =& $mform->getElement('multiplier[0]'); $firstunit->freeze(); $firstunit->setValue('1.0'); $firstunit->setPersistantFreeze(true); }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { $mform->removeElement('image'); $mform->addElement('static', 'help_multinumerical', get_string('help'), get_string('helponquestionoptions', 'qtype_multinumerical')); $mform->addElement('text', 'parameters', get_string('parameters', 'qtype_multinumerical'), array('size' => 30)); $mform->addElement('textarea', 'conditions', get_string('conditions', 'qtype_multinumerical'), array('rows' => 5, 'cols' => 60, 'course' => $this->coursefilesid)); $mform->addElement('textarea', 'feedbackperconditions', get_string('feedbackperconditions', 'qtype_multinumerical'), array('rows' => 5, 'cols' => 60, 'course' => $this->coursefilesid)); $colorfboptions = array(0 => get_string('no'), 1 => get_string('yes')); $mform->addElement('select', 'usecolorforfeedback', get_string("usecolorforfeedback", "qtype_multinumerical"), $colorfboptions); $displaycalcoptions = array(0 => get_string('no'), 1 => get_string('yes'), 2 => get_string('onlyforcalculations', 'qtype_multinumerical')); $mform->addElement('select', 'displaycalc', get_string("displaycalc", "qtype_multinumerical"), $displaycalcoptions); $binarygradeoptions = array(0 => get_string('gradefractional', 'qtype_multinumerical'), 1 => get_string('gradebinary', 'qtype_multinumerical')); $mform->addElement('select', 'binarygrade', get_string("binarygrade", "qtype_multinumerical"), $binarygradeoptions); $creategrades = get_grade_options(); }
/** * Add question-type specific form fields. * * @param object $mform the form being built. */ function definition_inner(&$mform) { global $QTYPES; $menu = array(get_string('answersingleno', 'qtype_multichoice'), get_string('answersingleyes', 'qtype_multichoice')); $mform->addElement('select', 'single', get_string('answerhowmany', 'qtype_multichoice'), $menu); $mform->setDefault('single', 1); $mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0, 1)); $mform->setHelpButton('shuffleanswers', array('multichoiceshuffle', get_string('shuffleanswers', 'qtype_multichoice'), 'quiz')); $mform->setDefault('shuffleanswers', 1); $numberingoptions = $QTYPES[$this->qtype()]->get_numbering_styles(); $menu = array(); foreach ($numberingoptions as $numberingoption) { $menu[$numberingoption] = get_string('answernumbering' . $numberingoption, 'qtype_multichoice'); } $mform->addElement('select', 'answernumbering', get_string('answernumbering', 'qtype_multichoice'), $menu); $mform->setDefault('answernumbering', 'abc'); /* $mform->addElement('static', 'answersinstruct', get_string('choices', 'qtype_multichoice'), get_string('fillouttwochoices', 'qtype_multichoice')); $mform->closeHeaderBefore('answersinstruct'); */ $creategrades = get_grade_options(); $gradeoptions = $creategrades->gradeoptionsfull; $repeated = array(); $repeated[] =& $mform->createElement('header', 'choicehdr', get_string('choiceno', 'qtype_multichoice', '{no}')); $repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'), array('size' => 50)); $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions); $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'), array('course' => $this->coursefilesid)); if (isset($this->question->options)) { $countanswers = count($this->question->options->answers); } else { $countanswers = 0; } if ($this->question->formoptions->repeatelements) { $repeatsatstart = max(5, QUESTION_NUMANS_START, $countanswers + QUESTION_NUMANS_ADD); } else { $repeatsatstart = $countanswers; } $repeatedoptions = array(); $repeatedoptions['fraction']['default'] = 0; $mform->setType('answer', PARAM_RAW); $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmorechoiceblanks', 'qtype_multichoice')); $mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'qtype_multichoice')); $mform->addElement('htmleditor', 'correctfeedback', get_string('correctfeedback', 'qtype_multichoice'), array('course' => $this->coursefilesid)); $mform->setType('correctfeedback', PARAM_RAW); $mform->addElement('htmleditor', 'partiallycorrectfeedback', get_string('partiallycorrectfeedback', 'qtype_multichoice'), array('course' => $this->coursefilesid)); $mform->setType('partiallycorrectfeedback', PARAM_RAW); $mform->addElement('htmleditor', 'incorrectfeedback', get_string('incorrectfeedback', 'qtype_multichoice'), array('course' => $this->coursefilesid)); $mform->setType('incorrectfeedback', PARAM_RAW); }
function definition() { global $CFG, $COURSE, $cm, $id; $mform =& $this->_form; // Don't forget the underscore! $repeatarray = array(); $repeatarray[] =& $mform->createElement('header', 'testcases', get_string('testcases', 'assignment_onlinejudge') . '{no}'); require_once $CFG->dirroot . '/lib/questionlib.php'; //for get_grade_options() $choices = get_grade_options()->gradeoptions; // Steal from question lib $repeatarray[] =& $mform->createElement('select', 'subgrade', get_string('subgrade', 'assignment_onlinejudge'), $choices); $repeatarray[] =& $mform->createElement('checkbox', 'usefile', get_string('usefile', 'assignment_onlinejudge')); $repeatarray[] =& $mform->createElement('textarea', 'input', get_string('input', 'assignment_onlinejudge'), 'wrap="virtual" rows="5" cols="50"'); $repeatarray[] =& $mform->createElement('textarea', 'output', get_string('output', 'assignment_onlinejudge'), 'wrap="virtual" rows="5" cols="50"'); $repeatarray[] =& $mform->createElement('filemanager', 'inputfile', get_string('inputfile', 'assignment_onlinejudge'), null, array('subdirs' => 0, 'maxfiles' => 1, 'accepted_types' => array('plaintext'))); $repeatarray[] =& $mform->createElement('filemanager', 'outputfile', get_string('outputfile', 'assignment_onlinejudge'), null, array('subdirs' => 0, 'maxfiles' => 1, 'accepted_types' => array('plaintext'))); $repeatarray[] =& $mform->createElement('text', 'feedback', get_string('feedback', 'assignment_onlinejudge'), array('size' => 50)); $repeatarray[] =& $mform->createElement('hidden', 'caseid', -1); $repeateloptions = array(); $repeateloptions['input']['type'] = PARAM_RAW; $repeateloptions['output']['type'] = PARAM_RAW; $repeateloptions['feedback']['type'] = PARAM_RAW; $repeateloptions['inputfile']['type'] = PARAM_FILE; $repeateloptions['outputfile']['type'] = PARAM_FILE; $repeateloptions['caseid']['type'] = PARAM_INT; $repeateloptions['testcases']['helpbutton'] = array('testcases', 'assignment_onlinejudge'); $repeateloptions['input']['helpbutton'] = array('input', 'assignment_onlinejudge'); $repeateloptions['output']['helpbutton'] = array('output', 'assignment_onlinejudge'); $repeateloptions['inputfile']['helpbutton'] = array('inputfile', 'assignment_onlinejudge'); $repeateloptions['outputfile']['helpbutton'] = array('outputfile', 'assignment_onlinejudge'); $repeateloptions['subgrade']['helpbutton'] = array('subgrade', 'assignment_onlinejudge'); $repeateloptions['feedback']['helpbutton'] = array('feedback', 'assignment_onlinejudge'); $repeateloptions['subgrade']['default'] = 0; $repeateloptions['inputfile']['disabledif'] = array('usefile', 'notchecked'); $repeateloptions['outputfile']['disabledif'] = array('usefile', 'notchecked'); $repeateloptions['input']['disabledif'] = array('usefile', 'checked'); $repeateloptions['output']['disabledif'] = array('usefile', 'checked'); $repeatnumber = max($this->testcasecount + 1, 5); $this->repeat_elements($repeatarray, $repeatnumber, $repeateloptions, 'boundary_repeats', 'add_testcases', 1, get_string('addtestcases', 'assignment_onlinejudge', 1), true); $buttonarray = array(); $buttonarray[] =& $mform->createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] =& $mform->createElement('cancel'); $mform->addElement('hidden', 'id', $id); $mform->setType('id', PARAM_INT); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { global $QTYPES; $this->qtypeobj =& $QTYPES[$this->qtype()]; $label = get_string("sharedwildcards", "qtype_datasetdependent"); $mform->addElement('hidden', 'initialcategory', 1); $html2 = $this->qtypeobj->print_dataset_definitions_category($this->question); $mform->insertElementBefore($mform->createElement('static', 'listcategory', $label, $html2), 'name'); $addfieldsname = 'updatecategory'; $addstring = get_string("updatecategory", "qtype_calculated"); $mform->registerNoSubmitButton($addfieldsname); $mform->insertElementBefore($mform->createElement('submit', $addfieldsname, $addstring), 'listcategory'); $creategrades = get_grade_options(); $this->add_per_answer_fields($mform, get_string('answerhdr', 'qtype_calculated', '{no}'), $creategrades->gradeoptions, 1, 1); $repeated = array(); $repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}')); $repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz')); $mform->setType('unit', PARAM_NOTAGS); $repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz')); $mform->setType('multiplier', PARAM_NUMBER); if (isset($this->question->options)) { $countunits = count($this->question->options->units); } else { $countunits = 0; } if ($this->question->formoptions->repeatelements) { $repeatsatstart = $countunits + 1; } else { $repeatsatstart = $countunits; } $this->repeat_elements($repeated, $repeatsatstart, array(), 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_calculated', '{no}')); if ($mform->elementExists('multiplier[0]')) { $firstunit =& $mform->getElement('multiplier[0]'); $firstunit->freeze(); $firstunit->setValue('1.0'); $firstunit->setPersistantFreeze(true); } //hidden elements $mform->addElement('hidden', 'synchronize', ''); if (isset($this->question->options) && isset($this->question->options->synchronize)) { $mform->setDefault("synchronize", $this->question->options->synchronize); } else { $mform->setDefault("synchronize", 0); } $mform->addElement('hidden', 'wizard', 'datasetdefinitions'); $mform->setType('wizard', PARAM_ALPHA); }
public function _initialize() { parent::_initialize(); //各页面下拉选项列表 $school_year_options = D('SchoolYear')->getOptions($this->school_year); $town_id_options = get_town_options($this->town_id); $school_code_options = get_school_options($this->school_year, $this->town_id, $this->school_code); $this->assign('school_year_options', $school_year_options); $this->assign('town_id_options', $town_id_options); $this->assign('school_code_options', $school_code_options); //判断是否需要为模版年级和班级下拉框赋值 if (in_array(ACTION_NAME, array('template', 'receipt', 'cshedu')) && !IS_AJAX) { $school_grade_options = get_grade_options($this->school_year, $this->town_id, $this->school_code, $this->school_grade, 'school_code'); $class_num_options = get_class_options($this->school_year, $this->town_id, $this->school_code, $this->school_grade, $this->class_num); $this->assign('school_grade_options', $school_grade_options); $this->assign('class_num_options', $class_num_options); } }
/** * Add question-type specific form fields. * * @param object $mform the form being built. */ function definition_inner(&$mform) { $creategrades = get_grade_options(); $gradeoptions = $creategrades->gradeoptionsfull; $repeated = array(); $repeated[] =& $mform->createElement('header', 'choicehdr', get_string('choiceno', 'qtype_multichoice', '{no}')); $repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz')); $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions); $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz')); if (isset($this->question->options)) { $countanswers = count($this->question->options->answers); } else { $countanswers = 0; } $repeatsatstart = QUESTION_NUMANS_START > $countanswers + QUESTION_NUMANS_ADD ? QUESTION_NUMANS_START : $countanswers + QUESTION_NUMANS_ADD; $repeatedoptions = array(); $repeatedoptions['fraction']['default'] = 0; $mform->setType('answer', PARAM_NOTAGS); $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmorechoiceblanks', 'qtype_multichoice')); }
/** * Process the file * This method should not normally be overidden * @return boolean success */ function importprocess() { global $USER; // reset the timer in case file upload was slow @set_time_limit(); // STAGE 1: Parse the file notify(get_string('parsingquestions', 'quiz')); if (!($lines = $this->readdata($this->filename))) { notify(get_string('cannotread', 'quiz')); return false; } if (!($questions = $this->readquestions($lines))) { // Extract all the questions notify(get_string('noquestionsinfile', 'quiz')); return false; } // STAGE 2: Write data to database notify(get_string('importingquestions', 'quiz', $this->count_questions($questions))); // check for errors before we continue if ($this->stoponerror and $this->importerrors > 0) { notify(get_string('importparseerror', 'quiz')); return true; } // get list of valid answer grades $grades = get_grade_options(); $gradeoptionsfull = $grades->gradeoptionsfull; // check answer grades are valid // (now need to do this here because of 'stop on error': MDL-10689) $gradeerrors = 0; $goodquestions = array(); foreach ($questions as $question) { if (!empty($question->fraction) and is_array($question->fraction)) { $fractions = $question->fraction; $answersvalid = true; // in case they are! foreach ($fractions as $key => $fraction) { $newfraction = match_grade_options($gradeoptionsfull, $fraction, $this->matchgrades); if ($newfraction === false) { $answersvalid = false; } else { $fractions[$key] = $newfraction; } } if (!$answersvalid) { notify(get_string('matcherror', 'quiz')); ++$gradeerrors; continue; } else { $question->fraction = $fractions; } } $goodquestions[] = $question; } $questions = $goodquestions; // check for errors before we continue if ($this->stoponerror and $gradeerrors > 0) { return false; } // count number of questions processed $count = 0; foreach ($questions as $question) { // Process and store each question // reset the php timeout @set_time_limit(); // check for category modifiers if ($question->qtype == 'category') { if ($this->catfromfile) { // find/create category object $catpath = $question->category; $newcategory = $this->create_category_path($catpath, '/'); if (!empty($newcategory)) { $this->category = $newcategory; } } continue; } $count++; echo "<hr /><p><b>{$count}</b>. " . $this->format_question_text($question) . "</p>"; $question->category = $this->category->id; $question->stamp = make_unique_id_code(); // Set the unique code (not to be changed) $question->createdby = $USER->id; $question->timecreated = time(); if (!($question->id = insert_record("question", $question))) { error(get_string('cannotinsert', 'quiz')); } $this->questionids[] = $question->id; // Now to save all the answers and type-specific options global $QTYPES; $result = $QTYPES[$question->qtype]->save_question_options($question); if (!empty($result->error)) { notify($result->error); return false; } if (!empty($result->notice)) { notify($result->notice); return true; } // Give the question a unique version stamp determined by question_hash() set_field('question', 'version', question_hash($question), 'id', $question->id); } return true; }
<td>Full Name</td> <td>Grade</td> <td>Camp</td> <td>T-Shirt Size</td> <td></td> </tr> <?php if (!isset($woocommerce->session->player_info)) { ?> <tr> <td><input type="text" class="input-text" name="camper[1][name]" value="" /></td> <td id="grades"> <select name="camper[1][grade]" class="grade"> <option value="">-</option> <?php get_grade_options(); ?> </select> </td> <?php $camps = get_terms(array('camp'), array('hide_empty' => false)); ?> <td id="camps"> <select name="camper[1][camp]" class="grade"> <option value="">-</option> <?php foreach ($camps as $camp) { ?> <option value="<?php echo $camp->slug; ?>
/** * Add question-type specific form fields. * * @param object $mform the form being built. */ function definition_inner(&$mform) { $creategrades = get_grade_options(); $this->add_per_answer_fields($mform, get_string('choiceno', 'qtype_multichoice', '{no}'), $creategrades->gradeoptionsfull); }
/** * Print the form for this assignment type * * @param $mform object Allready existant form */ function setup_elements(&$mform) { global $CFG, $COURSE; $add = optional_param('add', '', PARAM_ALPHA); $update = optional_param('update', 0, PARAM_INT); // Get course module instance $cm = null; $onlinejudge = null; if (!empty($update)) { $cm = get_record('course_modules', 'id', $update); $onlinejudge = get_record('assignment_oj', 'assignment', $cm->instance); } $ynoptions = array(0 => get_string('no'), 1 => get_string('yes')); // Programming languages $choices = $this->get_languages(); $mform->addElement('select', 'lang', get_string('assignmentlangs', 'assignment_onlinejudge'), $choices); $mform->setDefault('lang', $onlinejudge ? $onlinejudge->language : 'c'); // Presentation error grade ratio unset($choices); $choices = get_grade_options()->gradeoptions; // Steal from question lib $mform->addElement('select', 'ratiope', get_string('ratiope', 'assignment_onlinejudge'), $choices); $mform->setHelpButton('ratiope', array('ratiope', get_string('descratiope', 'assignment_onlinejudge'), 'assignment_onlinejudge')); $mform->setDefault('ratiope', $onlinejudge ? $onlinejudge->ratiope : 0); // Max. CPU time unset($choices); $choices = $this->get_max_cpu_times($CFG->assignment_oj_max_cpu); $mform->addElement('select', 'cpulimit', get_string('cpulimit', 'assignment_onlinejudge'), $choices); $mform->setDefault('cpulimit', $onlinejudge ? $onlinejudge->cpulimit : 1); // Max. memory usage unset($choices); $choices = $this->get_max_memory_usages($CFG->assignment_oj_max_mem); $mform->addElement('select', 'memlimit', get_string('memlimit', 'assignment_onlinejudge'), $choices); $mform->setDefault('memlimit', $onlinejudge ? $onlinejudge->memlimit : $CFG->assignment_oj_max_mem); // Allow resubmit $mform->addElement('select', 'resubmit', get_string('allowresubmit', 'assignment'), $ynoptions); $mform->setHelpButton('resubmit', array('resubmit', get_string('allowresubmit', 'assignment'), 'assignment')); $mform->setDefault('resubmit', 1); // Compile only? $mform->addElement('select', 'compileonly', get_string('compileonly', 'assignment_onlinejudge'), $ynoptions); $mform->setHelpButton('compileonly', array('compileonly', get_string('compileonly', 'assignment_onlinejudge'), 'assignment_onlinejudge')); $mform->setDefault('compileonly', $onlinejudge ? $onlinejudge->compileonly : 0); // Email teachers $mform->addElement('select', 'emailteachers', get_string('emailteachers', 'assignment'), $ynoptions); $mform->setHelpButton('emailteachers', array('emailteachers', get_string('emailteachers', 'assignment'), 'assignment')); $mform->setDefault('emailteachers', 0); // Submission max bytes $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes); $choices[1] = get_string('uploadnotallowed'); $choices[0] = get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')'; $mform->addElement('select', 'maxbytes', get_string('maximumfilesize', 'assignment_onlinejudge'), $choices); $mform->setDefault('maxbytes', $CFG->assignment_maxbytes); }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { global $QTYPES; $this->qtypeobj =& $QTYPES[$this->qtype()]; $label = get_string('sharedwildcards', 'qtype_calculated'); $mform->addElement('hidden', 'initialcategory', 1); $mform->addElement('hidden', 'reload', 1); $mform->setType('initialcategory', PARAM_INT); $html2 = $this->qtypeobj->print_dataset_definitions_category($this->question); $mform->insertElementBefore($mform->createElement('static', 'listcategory', $label, $html2), 'name'); if (isset($this->question->id)) { $mform->insertElementBefore($mform->createElement('static', 'initialname', get_string('questionstoredname', 'qtype_calculated'), $this->initialname), 'name'); } $addfieldsname = 'updatecategory'; $addstring = get_string("updatecategory", "qtype_calculated"); $mform->registerNoSubmitButton($addfieldsname); $mform->insertElementBefore($mform->createElement('submit', $addfieldsname, $addstring), 'listcategory'); $mform->registerNoSubmitButton('createoptionbutton'); //editing as regular $mform->setType('single', PARAM_INT); $mform->addElement('hidden', 'shuffleanswers', '1'); $mform->setType('shuffleanswers', PARAM_INT); $mform->addElement('hidden', 'answernumbering', 'abc'); $mform->setType('answernumbering', PARAM_SAFEDIR); $creategrades = get_grade_options(); $this->add_per_answer_fields($mform, get_string('answerhdr', 'qtype_calculated', '{no}'), $creategrades->gradeoptions, 1, 1); $repeated = array(); $QTYPES['numerical']->add_units_options($mform, $this); $QTYPES['numerical']->add_units_elements($mform, $this); //hidden elements $mform->addElement('hidden', 'synchronize', ''); $mform->setType('synchronize', PARAM_INT); $mform->addElement('hidden', 'wizard', 'datasetdefinitions'); $mform->setType('wizard', PARAM_ALPHA); }
} else { echo '</div>'; redirect($SESSION->returnurl); } } } // TODO: remove restriction to quiz $streditingquestion = get_string('editingquestion', 'quiz'); if (isset($SESSION->modform->instance)) { $strediting = '<a href="' . $SESSION->returnurl . '">' . get_string('editingquiz', 'quiz') . '</a> -> ' . $streditingquestion; } else { $strediting = '<a href="edit.php?courseid=' . $course->id . '">' . get_string("editquestions", "quiz") . '</a> -> ' . $streditingquestion; } print_header_simple($streditingquestion, '', $strediting); // prepare the grades selector drop-down used by many question types $creategrades = get_grade_options(); $gradeoptions = $creategrades->gradeoptions; $gradeoptionsfull = $creategrades->gradeoptionsfull; // Initialise defaults if necessary. if (empty($question->id)) { $question->id = ""; } if (empty($question->name)) { $question->name = ""; } if (empty($question->questiontext)) { $question->questiontext = ""; } if (empty($question->image)) { $question->image = ""; }
function definition_inner(&$mform) { global $COURSE, $CFG; $mform->removeElement('image'); make_upload_directory($COURSE->id); // Just in case $coursefiles = get_directory_list("{$CFG->dataroot}/{$COURSE->id}", $CFG->moddata); foreach ($coursefiles as $filename) { if (mimeinfo("icon", $filename) == "image.gif" || mimeinfo("icon", $filename) == "avi.gif" || mimeinfo("icon", $filename) == "flash.gif" || mimeinfo("icon", $filename) == "video.gif") { $images["{$filename}"] = $filename; } } if (empty($images)) { $mform->addElement('static', 'backgroundmedia', get_string('bkgdimage', 'qtype_dragdrop'), get_string('noimagesyet')); } else { $mform->addElement('select', 'backgroundmedia', get_string('bkgdimage', 'qtype_dragdrop'), array_merge(array('' => get_string('none')), $images)); } $mform->addRule('backgroundmedia', get_string('needbackground', 'qtype_dragdrop'), 'required', null, 'client'); $creategrades = get_grade_options(); $gradeoptions = $creategrades->gradeoptions; $mform->addElement('select', 'globalfeedbackgrade', get_string('feedbackmin', 'qtype_dragdrop'), $gradeoptions); $mform->setDefault('globalfeedbackgrade', 0.5); $mform->addRule('globalfeedbackgrade', null, 'required', null, 'client'); $mform->addElement('htmleditor', 'feedbackok', get_string('feedbackok', 'qtype_dragdrop'), array('rows' => 10, 'course' => $this->coursefilesid)); $mform->setType('feedbackok', PARAM_RAW); $mform->setHelpButton('feedbackok', array('feedbackok', get_string('feedbackok', 'qtype_dragdrop'), 'qtype_dragdrop')); $mform->addElement('htmleditor', 'feedbackmissed', get_string('feedbackmissed', 'qtype_dragdrop'), array('rows' => 10, 'course' => $this->coursefilesid)); $mform->setType('feedbackmissed', PARAM_RAW); $mform->setHelpButton('feedbackmissed', array('feedbackmissed', get_string('feedbackmissed', 'qtype_dragdrop'), 'qtype_dragdrop')); $mform->addElement('hidden', 'arrange', 'false'); $mform->setType('arrange', PARAM_ALPHA); // added by harry for layout - beginn $radioarray = array(); $radioarray[] = $mform->createElement('radio', 'arrangemedia', '', get_string('onerow', 'qtype_dragdrop'), 0, ''); $radioarray[] = $mform->createElement('radio', 'arrangemedia', '', get_string('onecolumn', 'qtype_dragdrop'), 1, ''); $radioarray[] = $mform->createElement('radio', 'arrangemedia', '', '2', 2, ''); $radioarray[] = $mform->createElement('radio', 'arrangemedia', '', '3', 3, ''); $radioarray[] = $mform->createElement('radio', 'arrangemedia', '', '4', 4, ''); $radioarray[] = $mform->createElement('radio', 'arrangemedia', '', '5', 5, ''); $radioarray[] = $mform->createElement('radio', 'arrangemedia', '', '6', 6, ''); $radioarray[] = $mform->createElement('radio', 'arrangemedia', '', '7', 7, ''); $radioarray[] = $mform->createElement('radio', 'arrangemedia', '', '8', 8, ''); $radioarray[] = $mform->createElement('radio', 'arrangemedia', '', '9', 9, ''); $radioarray[] = $mform->createElement('radio', 'arrangemedia', '', '10', 10, ''); $mform->addGroup($radioarray, 'radioar', get_string('arrangemedia', 'qtype_dragdrop'), array(' '), false); $mform->setDefault('arrangemedia', 0); $radioarray = array(); $radioarray[] = $mform->createElement('radio', 'placemedia', '', get_string('below', 'qtype_dragdrop'), 0, ''); $radioarray[] = $mform->createElement('radio', 'placemedia', '', get_string('rightbeside', 'qtype_dragdrop'), 1, ''); $mform->addGroup($radioarray, 'radioar2', get_string('placemedia', 'qtype_dragdrop'), array(' '), false); $mform->setDefault('placemedia', 0); // added by harry for layout - end /* $mform->addElement('hidden', 'sesskey', sesskey()); $mform->addElement('hidden', 'id', $this->question->id); $mform->addElement('hidden', 'qtype', $this->question->qtype); $mform->setType('qtype', PARAM_ALPHA); $mform->addElement('hidden', 'courseid', $COURSE->id); $mform->addElement('hidden', 'cmid', $cmid); $mform->setType('cmid', PARAM_INT); $mform->setDefault('cmid', 0); $mform->addElement('hidden', 'returnurl', $qreturnurl); $mform->setType('returnurl', PARAM_LOCALURL); $mform->setDefault('returnurl', 0);*/ $mform->addElement('static', 'answersinstruct', get_string('correctanswers', 'qtype_dragdrop'), get_string('filloutoneanswer', 'qtype_dragdrop')); $mform->closeHeaderBefore('answersinstruct'); $repeated = array(); $repeated[] =& $mform->createElement('header', 'answerhdr', get_string('dragdropno', 'qtype_dragdrop', '{no}')); if (empty($images)) { $repeated[] =& $mform->createElement('static', 'ddmedia', get_string('image', 'qtype_dragdrop'), get_string('noimagesyet')); } else { $repeated[] =& $mform->createElement('select', 'ddmedia', get_string('image', 'qtype_dragdrop'), array_merge(array('' => get_string('none')), $images)); } $repeated[] =& $mform->createElement('htmleditor', 'ddtext', get_string('text', 'qtype_dragdrop'), array('rows' => 6, 'course' => $this->coursefilesid)); $repeated[] =& $mform->createElement('text', 'ddmediatargetx', get_string('imagepositionx', 'qtype_dragdrop'), array('size' => 4)); $repeated[] =& $mform->createElement('text', 'ddmediatargety', get_string('imagepositiony', 'qtype_dragdrop'), array('size' => 4)); $repeated[] =& $mform->createElement('text', 'ddmediadisplaywidth', get_string('imagepositionwidth', 'qtype_dragdrop'), array('size' => 4)); $repeated[] =& $mform->createElement('text', 'ddmediadisplayheight', get_string('imagepositionheight', 'qtype_dragdrop'), array('size' => 4)); $repeated[] =& $mform->createElement('text', 'ddhotspotx', get_string('hotspotx', 'qtype_dragdrop'), array('size' => 4)); $repeated[] =& $mform->createElement('text', 'ddhotspoty', get_string('hotspoty', 'qtype_dragdrop'), array('size' => 4)); $repeated[] =& $mform->createElement('text', 'ddhotspotwidth', get_string('hotspotwidth', 'qtype_dragdrop'), array('size' => 4)); $repeated[] =& $mform->createElement('text', 'ddhotspotheight', get_string('hotspotheight', 'qtype_dragdrop'), array('size' => 4)); $repeated[] =& $mform->createElement('text', 'althotspots', get_string('althotspots', 'qtype_dragdrop'), array('size' => 18)); if (isset($this->question->options)) { $countanswers = count($this->question->options->media); } else { $countanswers = 0; } $repeatsatstart = QUESTION_NUMANS_START > $countanswers + QUESTION_NUMANS_ADD ? QUESTION_NUMANS_START : $countanswers + QUESTION_NUMANS_ADD; $repeatedoptions = array(); $mform->setType('ddtext', PARAM_RAW); $repeatedoptions['fraction']['default'] = 0; $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', QUESTION_NUMANS_ADD, get_string('addmoreanswerblanks', 'qtype_dragdrop')); $mybuttons = array(); //javascript to put into the insert buttons to point to the text field $scriptattrs = 'onclick = "document.forms[\'mform1\'].arrange.value=\'true\'"'; //construct the button to position the hotspots $mform->addElement('submit', 'hotspotsposition', get_string('hotspotspecify', 'qtype_dragdrop'), $scriptattrs); }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { global $QTYPES; $this->qtypeobj =& $QTYPES[$this->qtype()]; $strquestionlabel = $this->qtypeobj->comment_header($this->nonemptyanswer); $label = get_string("sharedwildcards", "qtype_datasetdependent"); $mform->addElement('hidden', 'initialcategory', 1); $mform->addElement('hidden', 'reload', 1); $addfieldsname = 'updatequestion value'; $addstring = get_string("updatecategory", "qtype_calculated"); $mform->registerNoSubmitButton($addfieldsname); //put a submit button to stop supplementary answers on update answers parameters // $mform->insertElementBefore( $mform->createElement('submit', $addfieldsname, $addstring),'listcategory'); $creategrades = get_grade_options(); $this->add_per_answer_fields($mform, get_string('answerhdr', 'qtype_calculated', '{no}'), $creategrades->gradeoptions, 1, 1); $repeated = array(); $repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}')); $repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz')); $mform->setType('unit', PARAM_NOTAGS); $repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz')); $mform->setType('multiplier', PARAM_NUMBER); if (isset($this->question->options)) { $countunits = count($this->question->options->units); } else { $countunits = 0; } if ($this->question->formoptions->repeatelements) { $repeatsatstart = $countunits + 1; } else { $repeatsatstart = $countunits; } $this->repeat_elements($repeated, $repeatsatstart, array(), 'nounits', 'addunits', 2, get_string('addmoreunitblanks', 'qtype_calculated', '{no}')); if ($mform->elementExists('multiplier[0]')) { $firstunit =& $mform->getElement('multiplier[0]'); $firstunit->freeze(); $firstunit->setValue('1.0'); $firstunit->setPersistantFreeze(true); } //hidden elements // $mform->addElement('hidden', 'wizard', 'datasetdefinitions'); // $mform->setType('wizard', PARAM_ALPHA); // $mform->addElement('header', '', ''); $label = "<div class='mdl-align'></div><div class='mdl-align'>" . get_string('wildcardrole', 'qtype_calculatedsimple') . "</div>"; $mform->addElement('html', "<div class='mdl-align'> </div>"); $mform->addElement('html', $label); // explaining the role of datasets so other strings can be shortened $mform->addElement('submit', 'analyzequestion', get_string('findwildcards', 'qtype_calculatedsimple')); $mform->registerNoSubmitButton('analyzequestion'); $mform->closeHeaderBefore('analyzequestion'); if ("" != optional_param('analyzequestion', '', PARAM_RAW)) { $this->wizarddisplay = true; } else { $this->wizwarddisplay = false; } if ($this->maxnumber != -1) { $this->noofitems = $this->maxnumber; } else { $this->noofitems = 0; } if (!empty($this->datasetdefs)) { //So there are some datadefs // we put them on the page $key = 0; $mform->addElement('header', 'additemhdr', get_string('wildcardparam', 'qtype_calculatedsimple')); $idx = 1; if (!empty($this->datasetdefs)) { // unnecessary test $j = $this->noofitems * count($this->datasetdefs) + 1; // foreach ($this->datasetdefs as $defkey => $datasetdef) { $mform->addElement('static', "na[{$j}]", get_string('param', 'qtype_datasetdependent', $datasetdef->name)); $this->qtypeobj->custom_generator_tools_part($mform, $idx, $j); $mform->addElement('hidden', "datasetdef[{$idx}]"); $mform->setType("datasetdef[{$idx}]", PARAM_RAW); $idx++; $mform->addElement('static', "divider[{$j}]", '', '<hr />'); $j++; } } //this should be done before the elements are created and stored as $this->formdata ; //fill out all data sets and also the fields for the next item to add. /*Here we do already the values error analysis so that * we could force all wild cards values display if there is an error in values. * as using a , in a number */ $this->numbererrors = array(); if (!empty($this->datasetdefs)) { $j = $this->noofitems * count($this->datasetdefs); for ($itemnumber = $this->noofitems; $itemnumber >= 1; $itemnumber--) { $data = array(); $numbererrors = array(); $comment = new stdClass(); $comment->stranswers = array(); $comment->outsidelimit = false; $comment->answers = array(); foreach ($this->datasetdefs as $defid => $datasetdef) { if (isset($datasetdef->items[$itemnumber])) { $this->formdata["definition[{$j}]"] = $defid; $this->formdata["itemid[{$j}]"] = $datasetdef->items[$itemnumber]->id; $data[$datasetdef->name] = $datasetdef->items[$itemnumber]->value; $this->formdata["number[{$j}]"] = $number = $datasetdef->items[$itemnumber]->value; if (!is_numeric($number)) { $a = new stdClass(); $a->name = '{' . $datasetdef->name . '}'; $a->value = $datasetdef->items[$itemnumber]->value; if (stristr($number, ',')) { $this->numbererrors["number[{$j}]"] = get_string('nocommaallowed', 'qtype_datasetdependent'); $numbererrors .= $this->numbererrors['number[' . $j . ']'] . "<br />"; } else { $this->numbererrors["number[{$j}]"] = get_string('notvalidnumber', 'qtype_datasetdependent', $a); $numbererrors .= $this->numbererrors['number[' . $j . ']'] . "<br />"; //$comment->outsidelimit = false ; } } else { if (stristr($number, 'x')) { // hexa will pass the test $a = new stdClass(); $a->name = '{' . $datasetdef->name . '}'; $a->value = $datasetdef->items[$itemnumber]->value; $this->numbererrors['number[' . $j . ']'] = get_string('hexanotallowed', 'qtype_datasetdependent', $a); $numbererrors .= $this->numbererrors['number[' . $j . ']'] . "<br />"; } else { if (is_nan($number)) { $a = new stdClass(); $a->name = '{' . $datasetdef->name . '}'; $a->value = $datasetdef->items[$itemnumber]->value; $this->numbererrors["number[{$j}]"] = get_string('notvalidnumber', 'qtype_datasetdependent', $a); $numbererrors .= $this->numbererrors['number[' . $j . ']'] . "<br />"; // $val = 1.0 ; } } } } $j--; } if ($this->noofitems != 0) { if (empty($numbererrors)) { if (!isset($question->id)) { $question->id = 0; } $comment = $this->qtypeobj->comment_on_datasetitems($question->id, $this->nonemptyanswer, $data, $itemnumber); //$this-> if ($comment->outsidelimit) { $this->outsidelimit = $comment->outsidelimit; } $totalcomment = ''; foreach ($this->nonemptyanswer as $key => $answer) { $totalcomment .= $comment->stranswers[$key] . '<br/>'; } $this->formdata['answercomment[' . $itemnumber . ']'] = $totalcomment; } } } $this->formdata['selectdelete'] = '1'; $this->formdata['selectadd'] = '1'; $j = $this->noofitems * count($this->datasetdefs) + 1; $data = array(); // data for comment_on_datasetitems later $idx = 1; foreach ($this->datasetdefs as $defid => $datasetdef) { $this->formdata["datasetdef[{$idx}]"] = $defid; $idx++; } $this->formdata = $this->qtypeobj->custom_generator_set_data($this->datasetdefs, $this->formdata); } $addoptions = array(); $addoptions['1'] = '1'; for ($i = 10; $i <= 100; $i += 10) { $addoptions["{$i}"] = "{$i}"; } $showoptions = array(); $showoptions['1'] = '1'; $showoptions['2'] = '2'; $showoptions['5'] = '5'; for ($i = 10; $i <= 100; $i += 10) { $showoptions["{$i}"] = "{$i}"; } $mform->closeHeaderBefore('additemhdr'); $addgrp = array(); $addgrp[] =& $mform->createElement('submit', 'addbutton', get_string('generatenewitemsset', 'qtype_calculatedsimple')); $addgrp[] =& $mform->createElement('select', "selectadd", '', $addoptions); $addgrp[] =& $mform->createElement('static', "stat", '', get_string('newsetwildcardvalues', 'qtype_calculatedsimple')); $mform->addGroup($addgrp, 'addgrp', '', ' ', false); $mform->registerNoSubmitButton('addbutton'); $mform->closeHeaderBefore('addgrp'); $addgrp1 = array(); $addgrp1[] =& $mform->createElement('submit', 'showbutton', get_string('showitems', 'qtype_calculatedsimple')); $addgrp1[] =& $mform->createElement('select', "selectshow", '', $showoptions); $addgrp1[] =& $mform->createElement('static', "stat", '', get_string('setwildcardvalues', 'qtype_calculatedsimple')); $mform->addGroup($addgrp1, 'addgrp1', '', ' ', false); $mform->registerNoSubmitButton('showbutton'); $mform->closeHeaderBefore('addgrp1'); $mform->addElement('static', "divideradd", '', ''); if ($this->noofitems == 0) { $mform->addElement('static', 'warningnoitems', '', '<span class="error">' . get_string('youmustaddatleastonevalue', 'qtype_calculatedsimple') . '</span>'); $mform->closeHeaderBefore('warningnoitems'); } else { $mform->addElement('header', 'additemhdr1', get_string('wildcardvalues', 'qtype_calculatedsimple')); $mform->closeHeaderBefore('additemhdr1'); // $mform->addElement('header', '', get_string('itemno', 'qtype_datasetdependent', "")); if (!empty($this->numbererrors) || $this->outsidelimit) { $mform->addElement('static', "alert", '', '<span class="error">' . get_string('useadvance', 'qtype_calculatedsimple') . '</span>'); } $mform->addElement('submit', 'updatedatasets', get_string('updatewildcardvalues', 'qtype_calculatedsimple')); $mform->registerNoSubmitButton('updatedatasets'); $mform->setAdvanced("updatedatasets", true); //------------------------------------------------------------------------------------------------------------------------------ $j = $this->noofitems * count($this->datasetdefs); $k = 1; if ("" != optional_param('selectshow')) { $k = optional_param('selectshow'); } for ($i = $this->noofitems; $i >= 1; $i--) { foreach ($this->datasetdefs as $defkey => $datasetdef) { if ($k > 0 || $this->outsidelimit || !empty($this->numbererrors)) { $mform->addElement('text', "number[{$j}]", get_string('wildcard', 'qtype_calculatedsimple', $datasetdef->name)); $mform->setAdvanced("number[{$j}]", true); if (!empty($this->numbererrors['number[' . $j . ']'])) { $mform->addElement('static', "numbercomment[{$j}]", '', '<span class="error">' . $this->numbererrors['number[' . $j . ']'] . '</span>'); $mform->setAdvanced("numbercomment[{$j}]", true); } } else { $mform->addElement('hidden', "number[{$j}]", get_string('wildcard', 'qtype_calculatedsimple', $datasetdef->name)); } $mform->setType("number[{$j}]", PARAM_NUMBER); $mform->addElement('hidden', "itemid[{$j}]"); $mform->setType("itemid[{$j}]", PARAM_INT); $mform->addElement('hidden', "definition[{$j}]"); $mform->setType("definition[{$j}]", PARAM_NOTAGS); $j--; } if (!empty($strquestionlabel) && ($k > 0 || $this->outsidelimit || !empty($this->numbererrors))) { // $repeated[] =& $mform->addElement('static', "answercomment[$i]", $strquestionlabel); $mform->addElement('static', "answercomment[{$i}]", "<b>" . get_string('setno', 'qtype_calculatedsimple', $i) . "</b> " . $strquestionlabel); } if ($k > 0 || $this->outsidelimit || !empty($this->numbererrors)) { $mform->addElement('static', "divider1[{$j}]", '', '<hr />'); } $k--; } } // if ($this->outsidelimit){ // $mform->addElement('static','outsidelimit','',''); // } } else { $mform->addElement('static', 'warningnowildcards', '', '<span class="error">' . get_string('atleastonewildcard', 'qtype_calculatedsimple') . '</span>'); $mform->closeHeaderBefore('warningnowildcards'); } //------------------------------------------------------------------------------------------------------------------------------ //non standard name for button element needed so not using add_action_buttons //hidden elements $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'courseid'); $mform->setType('courseid', PARAM_INT); $mform->setDefault('courseid', 0); $mform->addElement('hidden', 'cmid'); $mform->setType('cmid', PARAM_INT); $mform->setDefault('cmid', 0); if (!empty($this->question->id)) { if ($this->question->formoptions->cansaveasnew) { $mform->addElement('header', 'additemhdr', get_string('converttocalculated', 'qtype_calculatedsimple')); $mform->closeHeaderBefore('additemhdr'); $mform->addElement('checkbox', 'convert', '', get_string('willconverttocalculated', 'qtype_calculatedsimple')); $mform->setDefault('convert', 0); } } // $mform->addElement('hidden', 'wizard', 'edit_calculatedsimple'); // $mform->setType('wizard', PARAM_ALPHA); /* $mform->addElement('hidden', 'returnurl'); $mform->setType('returnurl', PARAM_LOCALURL); $mform->setDefault('returnurl', 0); */ }
private function get_grade_options() { static $options = array(); if (empty($options)) { $tmp = get_grade_options(); $options = $tmp->gradeoptionsfull; } return $options; }
private function ajaxSelect() { $selectType = I('select_type', ''); if ($selectType == '' || !in_array($selectType, array('school', 'grade', 'class'))) { $this->ajaxReturn(array('errno' => 1, 'errtitle' => '参数错误!')); } $options = ''; switch ($selectType) { case 'school': $options = get_school_options($this->school_year, $this->town_id, $this->school_code); break; case 'grade': $options = get_grade_options($this->school_year, $this->town_id, $this->school_code, $this->school_grade); break; case 'class': $options = get_class_options($this->school_year, $this->town_id, $this->school_code, $this->school_grade, $this->class_num); break; } $this->ajaxReturn(array('errno' => 0, 'optionstr' => $options)); }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { // Add the select control which will select the comparison type to use $mform->addElement('select', 'compareby', get_string('compareby', 'qtype_algebra'), array("sage" => get_string('comparesage', 'qtype_algebra'), "eval" => get_string('compareeval', 'qtype_algebra'), "equiv" => get_string('compareequiv', 'qtype_algebra'))); $mform->setDefault('compareby', 'eval'); $mform->setHelpButton('compareby', array('comp_algorithm', get_string('compalgorithm', 'qtype_algebra'), 'qtype_algebra')); // Add the control to select the number of checks to perform // First create an array with all the allowed values. We will then use this array // with the array_combine function to create a single array where the keys are the // same as the array values $chk_array = array('1', '2', '3', '5', '7', '10', '20', '30', '50', '70', '100', '200', '300', '500', '700', '1000'); // Add the select element using the array_combine method discussed above $mform->addElement('select', 'nchecks', get_string('nchecks', 'qtype_algebra'), array_combine($chk_array, $chk_array)); // Set the default number of checks to perform $mform->setDefault('nchecks', '10'); $mform->setHelpButton('nchecks', array('eval_checks', get_string('evalchecks', 'qtype_algebra'), 'qtype_algebra')); // Add the box to set the tolerance to use when performing evaluation checks $mform->addElement('text', 'tolerance', get_string('tolerance', 'qtype_algebra')); $mform->setType('tolerance', PARAM_NUMBER); $mform->setDefault('tolerance', '0.001'); $mform->setHelpButton('tolerance', array('check_tolerance', get_string('checktolerance', 'qtype_algebra'), 'qtype_algebra')); // Add an entry for the answer box prefix $mform->addElement('text', 'answerprefix', get_string('answerprefix', 'qtype_algebra'), array('size' => 55)); $mform->setType('answerprefix', PARAM_RAW); $mform->setHelpButton('answerprefix', array('answer_prefix', get_string('answerboxprefix', 'qtype_algebra'), 'qtype_algebra')); // Add an entry for a disallowed expression $mform->addElement('text', 'disallow', get_string('disallow', 'qtype_algebra'), array('size' => 55)); $mform->setType('disallow', PARAM_RAW); $mform->setHelpButton('disallow', array('disallowed_ans', get_string('disallowanswer', 'qtype_algebra'), 'qtype_algebra')); // Create an array which will store the function checkboxes $func_group = array(); // Create an array to add spacers between the boxes $spacers = array('<br>'); // Add the initial all functions box to the list of check boxes $func_group[] =& $mform->createElement('checkbox', 'all', '', get_string('allfunctions', 'qtype_algebra')); // Create a checkbox element for each function understood by the parser for ($i = 0; $i < count(qtype_algebra_parser::$functions); $i++) { $func = qtype_algebra_parser::$functions[$i]; $func_group[] =& $mform->createElement('checkbox', $func, '', $func); if ($i % 6 == 5) { $spacers[] = '<br>'; } else { $spacers[] = str_repeat(' ', 8 - strlen($func)); } } // Create and add the group of function controls to the form $mform->addGroup($func_group, 'allowedfuncs', get_string('allowedfuncs', 'qtype_algebra'), $spacers, true); $mform->disabledIf('allowedfuncs', 'allowedfuncs[all]', 'checked'); $mform->setDefault('allowedfuncs[all]', 'checked'); $mform->setHelpButton('allowedfuncs', array('allowed_funcs', get_string('allowedfunctions', 'qtype_algebra'), 'qtype_algebra')); // Create the array for the list of variables used in the question $repeated = array(); // Create the array for the list of repeated options used by the variable subforms $repeatedoptions = array(); // Add the form elements to enter the variables $repeated[] =& $mform->createElement('header', 'variablehdr', get_string('variableno', 'qtype_algebra', '{no}')); $repeatedoptions['variablehdr']['helpbutton'] = array('variable', get_string('variable', 'qtype_algebra'), 'qtype_algebra'); $repeated[] =& $mform->createElement('text', 'variable', get_string('variablename', 'qtype_algebra'), array('size' => 20)); $mform->setType('variable', PARAM_RAW); $repeated[] =& $mform->createElement('text', 'varmin', get_string('varmin', 'qtype_algebra'), array('size' => 20)); $mform->setType('varmin', PARAM_RAW); $repeatedoptions['varmin']['default'] = ''; $repeated[] =& $mform->createElement('text', 'varmax', get_string('varmax', 'qtype_algebra'), array('size' => 20)); $mform->setType('varmax', PARAM_RAW); $repeatedoptions['varmax']['default'] = ''; // Get the current number of variables defined, if any if (isset($this->question->options)) { $countvars = count($this->question->options->variables); } else { $countvars = 0; } // Come up with the number of variable entries to add to the form at the start if ($this->question->formoptions->repeatelements) { $repeatsatstart = SYMB_QUESTION_NUMVAR_START > $countvars + SYMB_QUESTION_NUMVAR_ADD ? SYMB_QUESTION_NUMVAR_START : $countvars + SYMB_QUESTION_NUMVAR_ADD; } else { $repeatsatstart = $countvars; } $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'novariables', 'addvariables', SYMB_QUESTION_NUMVAR_ADD, get_string('addmorevariableblanks', 'qtype_algebra')); // Add the instructions for entering answers to the question $mform->addElement('static', 'answersinstruct', get_string('correctanswers', 'quiz'), get_string('filloutoneanswer', 'quiz')); $mform->closeHeaderBefore('answersinstruct'); $creategrades = get_grade_options(); $gradeoptions = $creategrades->gradeoptions; $repeated = array(); $repeated[] =& $mform->createElement('header', 'answerhdr', get_string('answerno', 'qtype_algebra', '{no}')); $repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'), array('size' => 54)); $repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions); $repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'), array('course' => $this->coursefilesid)); if (isset($this->question->options)) { $countanswers = count($this->question->options->answers); } else { $countanswers = 0; } if ($this->question->formoptions->repeatelements) { $repeatsatstart = SYMB_QUESTION_NUMANS_START > $countanswers + SYMB_QUESTION_NUMANS_ADD ? SYMB_QUESTION_NUMANS_START : $countanswers + SYMB_QUESTION_NUMANS_ADD; } else { $repeatsatstart = $countanswers; } $repeatedoptions = array(); $mform->setType('answer', PARAM_RAW); $repeatedoptions['fraction']['default'] = 0; $this->repeat_elements($repeated, $repeatsatstart, $repeatedoptions, 'noanswers', 'addanswers', SYMB_QUESTION_NUMANS_ADD, get_string('addmoreanswerblanks', 'qtype_algebra')); }
/** * Add question-type specific form fields. * * @param MoodleQuickForm $mform the form being built. */ function definition_inner(&$mform) { global $QTYPES; $this->qtypeobj =& $QTYPES[$this->qtype()]; // echo code left for testing period // echo "<p>question ".optional_param('multichoice', '', PARAM_RAW)." optional<pre>";print_r($this->question);echo "</pre></p>"; $label = get_string("sharedwildcards", "qtype_calculated"); $mform->addElement('hidden', 'initialcategory', 1); $mform->addElement('hidden', 'reload', 1); $mform->setType('initialcategory', PARAM_INT); // $html2 = $this->qtypeobj->print_dataset_definitions_category($this->question); $html2 = ""; $mform->insertElementBefore($mform->createElement('static', 'listcategory', $label, $html2), 'name'); if (isset($this->question->id)) { $mform->insertElementBefore($mform->createElement('static', 'initialname', get_string('questionstoredname', 'qtype_calculated'), $this->initialname), 'name'); } $addfieldsname = 'updatecategory'; $addstring = get_string("updatecategory", "qtype_calculated"); $mform->registerNoSubmitButton($addfieldsname); $this->editasmultichoice = 1; $mform->insertElementBefore($mform->createElement('submit', $addfieldsname, $addstring), 'listcategory'); $mform->registerNoSubmitButton('createoptionbutton'); $mform->addElement('hidden', 'multichoice', $this->editasmultichoice); $mform->setType('multichoice', PARAM_INT); // $mform->addElement('header', 'choicehdr',get_string('multichoicecalculatedquestion', 'qtype_calculated')); $menu = array(get_string('answersingleno', 'qtype_multichoice'), get_string('answersingleyes', 'qtype_multichoice')); $mform->addElement('select', 'single', get_string('answerhowmany', 'qtype_multichoice'), $menu); $mform->setDefault('single', 1); $mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0, 1)); $mform->addHelpButton('shuffleanswers', 'shuffleanswers', 'qtype_multichoice'); $mform->setDefault('shuffleanswers', 1); $numberingoptions = $QTYPES['multichoice']->get_numbering_styles(); $menu = array(); foreach ($numberingoptions as $numberingoption) { $menu[$numberingoption] = get_string('answernumbering' . $numberingoption, 'qtype_multichoice'); } $mform->addElement('select', 'answernumbering', get_string('answernumbering', 'qtype_multichoice'), $menu); $mform->setDefault('answernumbering', 'abc'); $creategrades = get_grade_options(); $this->add_per_answer_fields($mform, get_string('choiceno', 'qtype_multichoice', '{no}'), $creategrades->gradeoptionsfull, max(5, QUESTION_NUMANS_START)); $repeated = array(); // if ($this->editasmultichoice == 1){ $nounits = optional_param('nounits', 1, PARAM_INT); $mform->addElement('hidden', 'nounits', $nounits); $mform->setType('nounits', PARAM_INT); $mform->setConstants(array('nounits' => $nounits)); for ($i = 0; $i < $nounits; $i++) { $mform->addElement('hidden', 'unit' . "[{$i}]", optional_param('unit' . "[{$i}]", '', PARAM_NOTAGS)); $mform->setType('unit' . "[{$i}]", PARAM_NOTAGS); $mform->addElement('hidden', 'multiplier' . "[{$i}]", optional_param('multiplier' . "[{$i}]", '', PARAM_NUMBER)); $mform->setType('multiplier' . "[{$i}]", PARAM_NUMBER); } $mform->setType('addunits', 'hidden'); $mform->addElement('header', 'overallfeedbackhdr', get_string('overallfeedback', 'qtype_multichoice')); foreach (array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback') as $feedbackname) { $mform->addElement('editor', $feedbackname, get_string($feedbackname, 'qtype_multichoice'), null, $this->editoroptions); $mform->setType($feedbackname, PARAM_RAW); } //hidden elements $mform->addElement('hidden', 'synchronize', ''); $mform->setType('synchronize', PARAM_INT); if (isset($this->question->options) && isset($this->question->options->synchronize)) { $mform->setDefault("synchronize", $this->question->options->synchronize); } else { $mform->setDefault("synchronize", 0); } $mform->addElement('hidden', 'wizard', 'datasetdefinitions'); $mform->setType('wizard', PARAM_ALPHA); }
/** * Print the form for this assignment type * * @param $mform object Allready existant form */ function setup_elements(&$mform) { global $CFG, $COURSE, $DB; // Some code are copied from parent::setup_elements(). Keep sync please. $ynoptions = array(0 => get_string('no'), 1 => get_string('yes')); $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes); $choices[0] = get_string('courseuploadlimit') . ' (' . display_size($COURSE->maxbytes) . ')'; $mform->addElement('select', 'maxbytes', get_string('maximumfilesize', 'assignment_onlinejudge'), $choices); $mform->setDefault('maxbytes', $CFG->assignment_maxbytes); $mform->addElement('select', 'resubmit', get_string('allowdeleting', 'assignment'), $ynoptions); $mform->addHelpButton('resubmit', 'allowdeleting', 'assignment'); $mform->setDefault('resubmit', 1); $options = array(); for ($i = 1; $i <= 20; $i++) { $options[$i] = $i; } $mform->addElement('select', 'var1', get_string('allowmaxfiles', 'assignment'), $options); $mform->addHelpButton('var1', 'allowmaxfiles', 'assignment'); $mform->setDefault('var1', 1); $mform->addElement('select', 'var2', get_string('allownotes', 'assignment'), $ynoptions); $mform->addHelpButton('var2', 'allownotes', 'assignment'); $mform->setDefault('var2', 0); $mform->addElement('select', 'var3', get_string('hideintro', 'assignment'), $ynoptions); $mform->addHelpButton('var3', 'hideintro', 'assignment'); $mform->setDefault('var3', 0); $mform->addElement('select', 'emailteachers', get_string('emailteachers', 'assignment'), $ynoptions); $mform->addHelpButton('emailteachers', 'emailteachers', 'assignment'); $mform->setDefault('emailteachers', 0); // Get existing onlinejudge settings $update = optional_param('update', 0, PARAM_INT); if (!empty($update)) { $cm = $DB->get_record('course_modules', array('id' => $update), '*', MUST_EXIST); $onlinejudge = $DB->get_record('assignment_oj', array('assignment' => $cm->instance)); } // Programming languages unset($choices); $choices = onlinejudge_get_languages(); $mform->addElement('select', 'language', get_string('assignmentlangs', 'assignment_onlinejudge'), $choices); $mform->setDefault('language', isset($onlinejudge) ? $onlinejudge->language : get_config('local_onlinejudge', 'defaultlanguage')); // Presentation error grade ratio unset($choices); $choices = get_grade_options()->gradeoptions; // Steal from question lib $mform->addElement('select', 'ratiope', get_string('ratiope', 'assignment_onlinejudge'), $choices); $mform->addHelpButton('ratiope', 'ratiope', 'assignment_onlinejudge'); $mform->setDefault('ratiope', isset($onlinejudge) ? $onlinejudge->ratiope : 0); $mform->setAdvanced('ratiope'); // Max. CPU time unset($choices); $choices = $this->get_max_cpu_times(); $mform->addElement('select', 'cpulimit', get_string('cpulimit', 'assignment_onlinejudge'), $choices); $mform->setDefault('cpulimit', isset($onlinejudge) ? $onlinejudge->cpulimit : 1); // Max. memory usage unset($choices); $choices = $this->get_max_memory_usages(); $mform->addElement('select', 'memlimit', get_string('memlimit', 'assignment_onlinejudge'), $choices); $mform->setDefault('memlimit', isset($onlinejudge) ? $onlinejudge->memlimit : 1048576); // Compile only? $mform->addElement('select', 'compileonly', get_string('compileonly', 'assignment_onlinejudge'), $ynoptions); $mform->addHelpButton('compileonly', 'compileonly', 'assignment_onlinejudge'); $mform->setDefault('compileonly', isset($onlinejudge) ? $onlinejudge->compileonly : 0); $mform->setAdvanced('compileonly'); //ideone.com $mform->addElement('text', 'ideoneuser', get_string('ideoneuser', 'assignment_onlinejudge'), array('size' => 20)); $mform->addHelpButton('ideoneuser', 'ideoneuser', 'assignment_onlinejudge'); $mform->setType('ideoneuser', PARAM_ALPHANUMEXT); $mform->setDefault('ideoneuser', isset($onlinejudge) ? $onlinejudge->ideoneuser : ''); $mform->addElement('password', 'ideonepass', get_string('ideonepass', 'assignment_onlinejudge'), array('size' => 20)); $mform->addHelpButton('ideonepass', 'ideonepass', 'assignment_onlinejudge'); $mform->setDefault('ideonepass', isset($onlinejudge) ? $onlinejudge->ideonepass : ''); $course_context = get_context_instance(CONTEXT_COURSE, $COURSE->id); plagiarism_get_form_elements_module($mform, $course_context); }