本文整理汇总了PHP中get_grade_options函数的典型用法代码示例。如果您正苦于以下问题:PHP get_grade_options函数的具体用法?PHP get_grade_options怎么用?PHP get_grade_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_grade_options函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition_inner
/**
* 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);
}
示例2: definition_inner
/**
* 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);
}
}
示例3: definition_inner
/**
* 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'));
}
示例4: definition_inner
/**
* 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);
}
}
示例5: definition_inner
/**
* 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);
}
示例6: definition_inner
/**
* 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);
}
示例7: definition_inner
/**
* 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);
}
示例8: round_to_nearest_grade
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;
}
示例9: definition_inner
/**
* 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();
}
示例10: definition_inner
/**
* 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);
}
示例11: definition
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');
}
示例12: definition_inner
/**
* 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);
}
示例13: _initialize
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);
}
}
示例14: definition_inner
/**
* 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'));
}
示例15: importprocess
/**
* 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)) {
//.........这里部分代码省略.........