diff --git a/question/question.php b/question/question.php index 2fada32f1dc..bf31bebb084 100644 --- a/question/question.php +++ b/question/question.php @@ -25,6 +25,8 @@ $movecontext = optional_param('movecontext', 0, PARAM_BOOL);//switch to make qu //uneditable - form is displayed to edit category only $returnurl = optional_param('returnurl', 0, PARAM_LOCALURL); +$inpopup = optional_param('inpopup', 0, PARAM_BOOL); + if ($movecontext && !$id){ print_error('questiondoesnotexist', 'question', $returnurl); } @@ -174,26 +176,27 @@ if ($mform->is_cancelled()){ } $question = $QTYPES[$question->qtype]->save_question($question, $fromform, $COURSE, $wizardnow); - if ($QTYPES[$qtype]->finished_edit_wizard($fromform) || $movecontext){ - - if (optional_param('inpopup', 0, PARAM_BOOL)) { + if (($QTYPES[$question->qtype]->finished_edit_wizard($fromform)) || $movecontext){ + if ($inpopup) { notify(get_string('changessaved'), ''); close_window(3); } else { redirect($returnurl); } } else { - $nexturlparams = array('returnurl'=>$returnurl) - + $fromform->nextpageparam;//useful for passing data to the next page which is not saved in the database - if ($question->id) { - $nexturlparams['id'] = $question->id; - } else { // only for creating new questions - $nexturlparams['category'] = $question->category; - $nexturlparams['qtype'] =$question->qtype; + $nexturlparams = array('returnurl'=>$returnurl); + if (isset($fromform->nextpageparam) && is_array($fromform->nextpageparam)){ + $nexturlparams += $fromform->nextpageparam;//useful for passing data to the next page which is not saved in the database } + $nexturlparams['id'] = $question->id; $nexturlparams['wizardnow'] = $fromform->wizard; $nexturl = new moodle_url('question.php', $nexturlparams); - redirect($nexturl); + if ($cmid){ + $nexturl->param('cmid', $cmid); + } else { + $nexturl->param('courseid', $COURSE->id); + } + redirect($nexturl->out()); } } else { diff --git a/question/type/calculated/edit_calculated_form.php b/question/type/calculated/edit_calculated_form.php index 30c2c3a1cc3..880603a82a9 100644 --- a/question/type/calculated/edit_calculated_form.php +++ b/question/type/calculated/edit_calculated_form.php @@ -96,11 +96,12 @@ class question_edit_calculated_form extends question_edit_form { } $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); - + if ($mform->elementExists('multiplier[0]')){ + $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); @@ -149,15 +150,19 @@ class question_edit_calculated_form extends question_edit_form { $qu = new stdClass; $el = new stdClass; /* no need to call elementExists() here */ - $el=$this->_form->getElement('category'); + if ($this->_form->elementExists('category')){ + $el=$this->_form->getElement('category'); + } else { + $el=$this->_form->getElement('categorymoveto'); + } if($value =$el->getSelected()) { $qu->category =$value[0]; }else { $qu->category=$question->category;// on load $question->category is set by question.php } $html2 = $this->qtypeobj->print_dataset_definitions_category($qu); - $this->_form->_elements[$this->_form->_elementIndex['listcategory']]->_text = $html2 ; - $question = (object)((array)$question + $default_values); + $this->_form->_elements[$this->_form->_elementIndex['listcategory']]->_text = $html2 ; + $question = (object)((array)$question + $default_values); parent::set_data($question); } diff --git a/question/type/datasetdependent/datasetdefinitions_form.php b/question/type/datasetdependent/datasetdefinitions_form.php index d6ae8c72a38..923e0c46422 100644 --- a/question/type/datasetdependent/datasetdefinitions_form.php +++ b/question/type/datasetdependent/datasetdefinitions_form.php @@ -51,7 +51,7 @@ class question_dataset_dependent_definitions_form extends moodleform { $datadefscat = $this->qtypeobj->get_dataset_definitions_category($this->question); $datasetmenus = array(); $label = "