From: pichetp Date: Wed, 13 Jun 2007 03:32:45 +0000 (+0000) Subject: solving lost of dataitems MDL-10087 merging from 1.8 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a3701fdc051eec21b2b048efc95be7aaaa8585f6;p=moodle.git solving lost of dataitems MDL-10087 merging from 1.8 --- diff --git a/question/type/datasetdependent/abstractqtype.php b/question/type/datasetdependent/abstractqtype.php index b2522ca649..8e2bdd9db2 100644 --- a/question/type/datasetdependent/abstractqtype.php +++ b/question/type/datasetdependent/abstractqtype.php @@ -207,7 +207,7 @@ class question_dataset_dependent_questiontype extends default_questiontype { * @param object $form * @param int $questionfromid default = '0' */ - function preparedatasets($form , $questionfromid='0'){ + function preparedatasets(&$form , $questionfromid='0'){ // the dataset names present in the edit_question_form and edit_calculated_form are retrieved $possibledatasets = $this->find_dataset_names($form->questiontext); $mandatorydatasets = array(); @@ -287,20 +287,20 @@ class question_dataset_dependent_questiontype extends default_questiontype { if (empty($form->id)) { // for a new question $form->id is empty $question = parent::save_question($question, $form, $course); //prepare the datasets using default $questionfromid - $form->datasets = $this->preparedatasets($form); + $this->preparedatasets($form); $form->id = $question->id; $this->save_dataset_definitions($form); } else if (!empty($form->makecopy)){ $questionfromid = $form->id ; $question = parent::save_question($question, $form, $course); //prepare the datasets - $form->datasets = $this->preparedatasets($form,$questionfromid); + $this->preparedatasets($form,$questionfromid); $form->id = $question->id; $this->save_as_new_dataset_definitions($form,$questionfromid ); } else {// editing a question $question = parent::save_question($question, $form, $course); //prepare the datasets - $form->datasets = $this->preparedatasets($form,$question->id); + $this->preparedatasets($form,$question->id); $form->id = $question->id; $this->save_dataset_definitions($form); } @@ -368,8 +368,8 @@ class question_dataset_dependent_questiontype extends default_questiontype { foreach ($defids as $defid) { $datasetdef = &$datasetdefinitions[$defid]; if (isset($datasetdef->id)) { - // This dataset is not used any more, delete it if (!isset($tmpdatasets[$defid])) { + // This dataset is not used any more, delete it delete_records('question_datasets', 'question', $form->id, 'datasetdefinition', $datasetdef->id);