diff --git a/question/type/calculated/questiontype.php b/question/type/calculated/questiontype.php index e2e7eb8efb9..a390e25d953 100644 --- a/question/type/calculated/questiontype.php +++ b/question/type/calculated/questiontype.php @@ -331,6 +331,8 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype $minmaxgrp[] =& $mform->createElement('text', "calcmin[$idx]", get_string('calcmin', 'qtype_datasetdependent'), 'size="3"'); $minmaxgrp[] =& $mform->createElement('text', "calcmax[$idx]", get_string('calcmax', 'qtype_datasetdependent'), 'size="3"'); $mform->addGroup($minmaxgrp, 'minmaxgrp', get_string('minmax', 'qtype_datasetdependent'), ' - ', false); + $mform->setType('calcmin', PARAM_NUMBER); + $mform->setType('calcmax', PARAM_NUMBER); $precisionoptions = range(0, 10); $mform->addElement('select', "calclength[$idx]", get_string('calclength', 'qtype_datasetdependent'), $precisionoptions); @@ -339,10 +341,6 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype $mform->addElement('select', "calcdistribution[$idx]", get_string('calcdistribution', 'qtype_datasetdependent'), $distriboptions); - $mform->addElement('hidden', "definition[$j]"); - $mform->addElement('hidden', "itemid[$j]"); - - } function custom_generator_set_data($datasetdefs, $formdata){ @@ -394,7 +392,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype if (empty($form->definition) || empty($form->calcmin) || empty($form->calcmax) || empty($form->calclength) || empty($form->calcdistribution)) { - // I gues not: + // I guess not } else { // Looks like we just could have some new information here @@ -452,6 +450,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype } // Handle adding and removing of dataset items $i = 1; + ksort($fromform->definition); foreach ($fromform->definition as $key => $defid) { //if the delete button has not been pressed then skip the datasetitems //in the 'add item' part of the form. diff --git a/question/type/datasetdependent/datasetdefinitions_form.php b/question/type/datasetdependent/datasetdefinitions_form.php index 2c45304cdf5..b383d1c35f2 100644 --- a/question/type/datasetdependent/datasetdefinitions_form.php +++ b/question/type/datasetdependent/datasetdefinitions_form.php @@ -66,7 +66,7 @@ class question_dataset_dependent_definitions_form extends moodleform { $key++; } } - $this->add_action_buttons(true, get_string('nextpage', 'qtype_calculated')); + $this->add_action_buttons(false, get_string('nextpage', 'qtype_calculated')); //hidden elements diff --git a/question/type/datasetdependent/datasetitems_form.php b/question/type/datasetdependent/datasetitems_form.php index b25bad75466..5da7c2b7a07 100644 --- a/question/type/datasetdependent/datasetitems_form.php +++ b/question/type/datasetdependent/datasetitems_form.php @@ -62,74 +62,69 @@ class question_dataset_dependent_items_form extends moodleform { function definition() { $mform =& $this->_form; $strquestionlabel = $this->qtypeobj->comment_header($this->question); - -//------------------------------------------------------------------------------------------------------------------------------ if ($this->maxnumber != -1){ $this->noofitems = $this->maxnumber; } else { $this->noofitems = 0; } - $j = 1; - for ($i=1; $i <= $this->noofitems; $i++){ - $mform->addElement('header', 'itemhdr', get_string('itemno', 'qtype_datasetdependent', $i)); - foreach ($this->datasetdefs as $defkey => $datasetdef){ - $mform->addElement('text', "number[$j]", get_string('param', 'qtype_datasetdependent', $datasetdef->name)); - $mform->setType("number[$j]", PARAM_NUMBER); - - $mform->addElement('hidden', "itemid[$j]"); - - $mform->addElement('hidden', "definition[$j]"); - - $j++; - } - if ('' != $strquestionlabel){ - $repeated[] =& $mform->addElement('static', "answercomment[$i]", $strquestionlabel); - } - if ($i == $this->noofitems) {//last item - $mform->addElement('submit', 'deletebutton', get_string('deletelastitem', 'qtype_datasetdependent')); - - } - } - $mform->setType("itemid", PARAM_INT); - $mform->setType("definition", PARAM_NOTAGS); - - $mform->addElement('submit', 'addbutton', get_string('additem', 'qtype_datasetdependent')); - $mform->closeHeaderBefore('addbutton'); - - //------------------------------------------------------------------------------------------------------------------------------ $mform->addElement('header', 'additemhdr', get_string('itemtoadd', 'qtype_datasetdependent')); $idx = 1; + $j = (($this->noofitems) * count($this->datasetdefs))+1; foreach ($this->datasetdefs as $defkey => $datasetdef){ $mform->addElement('text', "number[$j]", get_string('param', 'qtype_datasetdependent', $datasetdef->name)); $this->qtypeobj->custom_generator_tools_part(&$mform, $idx, $j); $idx++; - $j++; + $mform->addElement('hidden', "definition[$j]"); + $mform->addElement('hidden', "itemid[$j]"); $mform->addElement('static', "divider[$j]", '', '