Merge branch 'MDL-27907' of git://github.com/timhunt/moodle

This commit is contained in:
Sam Hemelryk 2011-06-20 14:10:41 +08:00
commit 8e307054d3
2 changed files with 8 additions and 48 deletions

View file

@ -73,28 +73,15 @@ class qtype_calculated_edit_form extends qtype_numerical_edit_form {
public function get_per_answer_fields($mform, $label, $gradeoptions,
&$repeatedoptions, &$answersoption) {
$repeated = array();
$repeated[] = $mform->createElement('header', 'answerhdr', $label);
$repeated[] = $mform->createElement('text', 'answer',
get_string('answer', 'question'), array('size' => 50));
$repeated[] = $mform->createElement('select', 'fraction',
get_string('grade'), $gradeoptions);
$repeated[] = $mform->createElement('editor', 'feedback',
get_string('feedback', 'question'), null, $this->editoroptions);
$repeatedoptions['answer']['type'] = PARAM_RAW;
$repeatedoptions['fraction']['default'] = 0;
$answersoption = 'answers';
$repeated = parent::get_per_answer_fields($mform, $label, $gradeoptions,
$repeatedoptions, $answersoption);
$mform->setType('answer', PARAM_NOTAGS);
$repeated[1]->setLabel(get_string('correctanswerformula', 'qtype_calculated') . '=');
$repeatedoptions['tolerance']['default'] = 0.01;
$addrepeated = array();
$addrepeated[] = $mform->createElement('text', 'tolerance',
get_string('tolerance', 'qtype_calculated'));
$addrepeated[] = $mform->createElement('select', 'tolerancetype',
get_string('tolerancetype', 'qtype_numerical'),
$this->qtypeobj->tolerance_types());
$repeatedoptions['tolerance']['type'] = PARAM_NUMBER;
$repeatedoptions['tolerance']['default'] = 0.01;
get_string('tolerancetype', 'qtype_numerical'), $this->qtypeobj->tolerance_types());
$addrepeated[] = $mform->createElement('select', 'correctanswerlength',
get_string('correctanswershows', 'qtype_calculated'), range(0, 9));
@ -106,8 +93,9 @@ class qtype_calculated_edit_form extends qtype_numerical_edit_form {
);
$addrepeated[] = $mform->createElement('select', 'correctanswerformat',
get_string('correctanswershowsformat', 'qtype_calculated'), $answerlengthformats);
array_splice($repeated, 3, 0, $addrepeated);
$repeated[1]->setLabel(get_string('correctanswerformula', 'qtype_calculated') . ' = ');
array_splice($repeated, 4, 0, $addrepeated);
return $repeated;
}

View file

@ -286,34 +286,6 @@ class qtype_calculatedsimple_edit_form extends qtype_calculated_edit_form {
parent::__construct($submiturl, $question, $category, $contexts, $formeditable);
}
public function get_per_answer_fields($mform, $label, $gradeoptions,
&$repeatedoptions, &$answersoption) {
$repeated = parent::get_per_answer_fields($mform, $label, $gradeoptions,
$repeatedoptions, $answersoption);
$mform->setType('answer', PARAM_NOTAGS);
$addrepeated = array();
$addrepeated[] = $mform->createElement('text', 'tolerance',
get_string('tolerance', 'qtype_calculated'));
$repeatedoptions['tolerance']['type'] = PARAM_NUMBER;
$repeatedoptions['tolerance']['default'] = 0.01;
$addrepeated[] = $mform->createElement('select', 'tolerancetype',
get_string('tolerancetype', 'qtype_numerical'), $this->qtypeobj->tolerance_types());
$addrepeated[] = $mform->createElement('select', 'correctanswerlength',
get_string('correctanswershows', 'qtype_calculated'), range(0, 9));
$repeatedoptions['correctanswerlength']['default'] = 2;
$answerlengthformats = array(
'1' => get_string('decimalformat', 'qtype_numerical'),
'2' => get_string('significantfiguresformat', 'qtype_calculated')
);
$addrepeated[] = $mform->createElement('select', 'correctanswerformat',
get_string('correctanswershowsformat', 'qtype_calculated'), $answerlengthformats);
array_splice($repeated, 3, 0, $addrepeated);
$repeated[1]->setLabel(get_string('correctanswerformula', 'qtype_calculated').'=');
return $repeated;
}
/**
* Add question-type specific form fields.
*