From: pichetp question ";print_r($question);echo "
$answer->fraction
"; $default_values['fraction['.$key.']'] = $answer->fraction; $default_values['tolerance['.$key.']'] = $answer->tolerance; $default_values['tolerancetype['.$key.']'] = $answer->tolerancetype; @@ -587,8 +600,16 @@ class question_edit_calculatedsimple_form extends question_edit_form { $default_values['feedback['.$key.']'] = $answer->feedback; $key++; } - }*/ + } + $default_values['multichoice'] = 0 ; + $default_values['synchronize'] = 0 ; if (isset($question->options)){ + $default_values['unitgradingtype'] = $question->options->unitgradingtype ; + $default_values['unitpenalty'] = $question->options->unitpenalty ; + $default_values['showunits'] = $question->options->showunits ; + $default_values['unitsleft'] = $question->options->unitsleft ; + $default_values['instructions'] = $question->options->instructions ; + $units = array_values($question->options->units); // make sure the default unit is at index 0 usort($units, create_function('$a, $b', @@ -781,7 +802,7 @@ class question_edit_calculatedsimple_form extends question_edit_form { } /*Here we use the already done the error analysis so that * we could force all wild cards values display if there is an error in values. - * as using a , in a number */ + * as using a , in a number *//* $numbers = $data['number']; foreach ($numbers as $key => $number){ if(! is_numeric($number)){ @@ -796,7 +817,7 @@ class question_edit_calculatedsimple_form extends question_edit_form { $errors['number['.$key.']'] = get_string('notvalidnumber', 'qtype_datasetdependent'); } } - + */ if ( $this->noofitems==0 ){ $errors['warning'] = get_string('warning', 'mnet'); } diff --git a/question/type/calculatedsimple/questiontype.php b/question/type/calculatedsimple/questiontype.php index 787dba5fdc..3009c28f14 100644 --- a/question/type/calculatedsimple/questiontype.php +++ b/question/type/calculatedsimple/questiontype.php @@ -24,7 +24,7 @@ class question_calculatedsimple_qtype extends question_calculated_qtype { function save_question_options($question) { //$options = $question->subtypeoptions; // Get old answers: - global $CFG, $DB; + global $CFG, $DB , $QTYPES; if (isset($question->answer) && !isset($question->answers)) { $question->answers = $question->answer; @@ -40,7 +40,7 @@ class question_calculatedsimple_qtype extends question_calculated_qtype { } // Save the units. - $virtualqtype = $this->get_virtual_qtype(); + $virtualqtype = $this->get_virtual_qtype($question); $result = $virtualqtype->save_numerical_units($question); if (isset($result->error)) { return $result; @@ -180,6 +180,11 @@ class question_calculatedsimple_qtype extends question_calculated_qtype { if(!empty($question->makecopy) && !empty($question->convert)) { $DB->set_field('question', 'qtype', 'calculated', array('id'=> $question->id)); } + $result = $QTYPES['numerical']->save_numerical_options($question); + if (isset($result->error)) { + return $result; + } + if (!empty($result->notice)) { return $result; } @@ -261,7 +266,7 @@ class question_calculatedsimple_qtype extends question_calculated_qtype { } function comment_on_datasetitems($questionid, $answers,$data, $number) { - global $DB; + global $DB,$QTYPES; $comment = new stdClass; $comment->stranswers = array(); $comment->outsidelimit = false ; @@ -278,7 +283,7 @@ class question_calculatedsimple_qtype extends question_calculated_qtype { $strmax = get_string('max', 'quiz'); $errors = ''; $delimiter = ': '; - $virtualqtype = $this->get_virtual_qtype(); + $virtualqtype = & $QTYPES['numerical'] ; //$this->get_virtual_qtype($question); foreach ($answers as $key => $answer) { $formula = $this->substitute_variables($answer->answer,$data); $formattedanswer = qtype_calculated_calculate_answer( diff --git a/question/type/numerical/db/install.xml b/question/type/numerical/db/install.xml index 731cfe9a1d..735fc4b466 100644 --- a/question/type/numerical/db/install.xml +++ b/question/type/numerical/db/install.xml @@ -1,10 +1,10 @@ -+ control; ?> + | ++ + | +