-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
1.8
-
None
-
MOODLE_18_STABLE
When you type the ENTER key on a <input> field of the item values in datasetitems_form.php, the default submit button used is the first one on the form.
When there is at least one item, this the DELETE ITEM submit button .
So if you type the ENTER key, an item will be DELETED.(and the values update if the item remains!!!)
If there is no items, the first submit button is ADD ITEM
So if you type the ENTER key, an item will be ADDED (and the dataset definitions will be updated!!)
A first easy modification is to put an additional submit button that will be ignored by the actual code so the default process will be applied.
Actually the default is to update the items values and some of the fields of the definitions.
something like
if ($i == $this->noofitems)
and MODIFY DATASET ITEM VALUES values before the ADD ITEM submit button when there no one item value displayed.
In this case when you type ENTER this
so the lines after if ($i == $this->noofitems) {//last item
can be like
if ($i == $this->noofitems)
{//last item $mform->addElement('submit', 'modifyitemvalues', get_string('UPDATE DATASET ITEM AND DEFINITION VALUES ', 'qtype_datasetdependent')); $mform->addElement('submit', 'deletebutton', get_string('deletelastitem', 'qtype_datasetdependent')); } }
$mform->setType("itemid", PARAM_INT);
$mform->setType("definition", PARAM_NOTAGS);
if ( $this->noofitems == 0 )
{ $mform->addElement('submit', 'modifydatadefsvalues', get_string('UPDATE DATASET DEFINITION VALUES', 'qtype_datasetdependent')); $mform->addElement('submit', 'addbutton', get_string('additem', 'qtype_datasetdependent')); $mform->closeHeaderBefore('modifydatadefsvalues'); }else
{ $mform->addElement('submit', 'addbutton', get_string('additem', 'qtype_datasetdependent')); $mform->closeHeaderBefore('addbutton'); }
The solution has been applied in the following url user: moodle pw:moodle
choosing one calculated question (i.e id = 21)