Commit 78a6d0ba authored by Pierre Pichet's avatar Pierre Pichet
Browse files

MDL-10110 removing call to multichoice field from code

parent c9acc772
......@@ -339,14 +339,10 @@ class question_dataset_dependent_items_form extends moodleform {
}
$j--;
}
/* if($question->options->multichoice == 1 ){
$comment = $this->qtypeobj->multichoice_comment_on_datasetitems($question->id,$question->questiontext,$answers, $data, $itemnumber);
}else {*/
$comment = $this->qtypeobj->comment_on_datasetitems($this->qtypeobj,$question->id,$question->questiontext,$answers, $data, $itemnumber);
if ($comment->outsidelimit) {
$this->outsidelimit=$comment->outsidelimit ;
}
/* }*/
$totalcomment='';
foreach ($question->options->answers as $key => $answer) {
$totalcomment .= $comment->stranswers[$key].'<br/>';
......@@ -392,16 +388,11 @@ class question_dataset_dependent_items_form extends moodleform {
}
}
//default answercomment will get ignored if answer element is not in the form.
// if($question->options->multichoice == 1 ){
// $comment = $this->qtypeobj->comment_on_datasetitems($this->qtypeobj,$question->id,$question->questiontext,$answers, $data, $itemnumber);
// }else {
$comment = $this->qtypeobj->comment_on_datasetitems($this->qtypeobj,$question->id,$question->questiontext,$answers, $data, ($this->noofitems+1));
if (isset($comment->outsidelimit)&&$comment->outsidelimit) {
$this->outsidelimit=$comment->outsidelimit ;
}
//}
$key1 = 1;
foreach ($question->options->answers as $key => $answer) {
$formdata['answercomment['.($this->noofitems+$key1).']'] = $comment->stranswers[$key];
......
......@@ -45,7 +45,6 @@ class question_edit_calculated_form extends question_edit_form {
// $repeated = parent::get_per_answer_fields($mform, $label, $gradeoptions, $repeatedoptions, $answersoption);
$repeated = array();
$repeated[] =& $mform->createElement('header', 'answerhdr', $label);
// if ($this->editasmultichoice == 1){
$repeated[] =& $mform->createElement('text', 'answer', get_string('answer', 'quiz'), array('size' => 50));
$repeated[] =& $mform->createElement('select', 'fraction', get_string('grade'), $gradeoptions);
$repeated[] =& $mform->createElement('htmleditor', 'feedback', get_string('feedback', 'quiz'),
......@@ -91,21 +90,10 @@ class question_edit_calculated_form extends question_edit_form {
$addfieldsname='updatecategory';
$addstring=get_string("updatecategory", "qtype_calculated");
$mform->registerNoSubmitButton($addfieldsname);
$this->editasmultichoice = 0 ;
/* if ( '' != optional_param('changetomultichoice', '', PARAM_RAW)){
$this->editasmultichoice = 1 ;
}
if ( '' != optional_param('changetocalculated', '', PARAM_RAW)){
$this->editasmultichoice = 0 ;
}*/
$mform->insertElementBefore( $mform->createElement('submit', $addfieldsname, $addstring),'listcategory');
$mform->registerNoSubmitButton('createoptionbutton');
$mform->addElement('hidden', 'multichoice',$this->editasmultichoice);
$mform->setType('multichoice', PARAM_INT);
//editing as regular
$mform->setType('single', PARAM_INT);
......
......@@ -34,7 +34,6 @@ class question_calculated_qtype extends default_questiontype {
// echo $OUTPUT->notification('Error: Missing question options for calculated question'.$question->id.'!');
// return false;
$question->options->synchronize = 0;
// $question->options->multichoice = 0;
$question->options->single = 0; //$question->single;
$question->options->answernumbering = 'abc';
$question->options->shuffleanswers = 0 ;
......@@ -137,7 +136,6 @@ class question_calculated_qtype extends default_questiontype {
}
// as used only by calculated
$options->synchronize = $question->synchronize;
// $options->multichoice = 0 ;//$question->multichoice;
$options->single = 0; //$question->single;
$options->answernumbering = $question->answernumbering;
$options->shuffleanswers = $question->shuffleanswers;
......@@ -1410,35 +1408,10 @@ class question_calculated_qtype extends default_questiontype {
function get_correct_responses(&$question, &$state) {
// virtual type for printing
$virtualqtype = $this->get_virtual_qtype();
$unit = $this-> get_default_numerical_unit($question,$virtualqtype);
$unit = $this->get_default_numerical_unit($question,$virtualqtype);
// We modify the question to look like a numerical question
// $numericalquestion = fullclone($question);
$this->convert_answers($question, $state);
/* if ($question->options->multichoice != 1 ) {
if($unit = $virtualqtype->get_default_numerical_unit($question)){
$unit = $unit->unit;
} else {
$unit = '';
}
foreach ($question->options->answers as $answer) {
if (((int) $answer->fraction) === 1) {
$answernumerical = qtype_calculated_calculate_answer(
$answer->answer, $state->options->dataset, $answer->tolerance,
$answer->tolerancetype, $answer->correctanswerlength,
$answer->correctanswerformat, ''); // remove unit
$correct = array('' => $answernumerical->answer);
$correct['answer']= $correct[''];
if (isset($correct['']) && $correct[''] != '*' && $unit ) {
$correct[''] .= ' '.$unit;
$correct['unit']= $unit;
}
return $correct;
}
}
}else{*/
return $virtualqtype->get_correct_responses($question, $state) ;
/*}
return null;*/
}
function substitute_variables($str, $dataset) {
......@@ -2121,7 +2094,6 @@ class question_calculated_qtype extends default_questiontype {
//Now, build the question_calculated_options record structure
$calculated_options->questionid = $new_question_id;
$calculated_options->synchronize = backup_todb($cal_info['#']['SYNCHRONIZE']['0']['#']);
// $calculated_options->multichoice = backup_todb($cal_info['#']['MULTICHOICe']['0']['#']);
$calculated_options->single = backup_todb($cal_info['#']['SINGLE']['0']['#']);
$calculated_options->shuffleanswers = isset($cal_info['#']['SHUFFLEANSWERS']['0']['#'])?backup_todb($mul_info['#']['SHUFFLEANSWERS']['0']['#']):'';
$calculated_options->correctfeedback = backup_todb($cal_info['#']['CORRECTFEEDBACK']['0']['#']);
......
<?php
<?PHP // $Id$
$plugin->version = 2009092000;
$plugin->version = 2010020800;
$plugin->requires = 2007101000;
?>
......@@ -25,74 +25,7 @@ class question_calculatedmulti_qtype extends question_calculated_qtype {
function requires_qtypes() {
return array('multichoice');
}
/*
function get_question_options(&$question) {
// First get the datasets and default options
global $CFG, $DB, $OUTPUT, $QTYPES;
if (!$question->options = $DB->get_record('question_calculated_options', array('question' => $question->id))) {
// echo $OUTPUT->notification('Error: Missing question options for calculated question'.$question->id.'!');
// return false;
$question->options->synchronize = 0;
// $question->options->multichoice = 1;
}
// echo "<p> questionoptions <pre>";print_r($question);echo "</pre></p>";
// $QTYPES['numerical']->get_numerical_options($question);
/* $question->options->unitgradingtype = 0;
$question->options->unitpenalty = 0;
$question->options->showunits = 0 ;
$question->options->unitsleft = 0 ;
$question->options->instructions = '' ;
// echo "<p> questionoptions <pre>";print_r($question);echo "</pre></p>";
if (!$question->options->answers = $DB->get_records_sql(
"SELECT a.*, c.tolerance, c.tolerancetype, c.correctanswerlength, c.correctanswerformat " .
"FROM {question_answers} a, " .
" {question_calculated} c " .
"WHERE a.question = ? " .
"AND a.id = c.answer ".
"ORDER BY a.id ASC", array($question->id))) {
echo $OUTPUT->notification('Error: Missing question answer for calculated question ' . $question->id . '!');
return false;
}
if(false === parent::get_question_options($question)) {
return false;
}
if (!$options = $DB->get_records('question_calculated', array('question' => $question->id))) {
notify("No options were found for calculated question
#{$question->id}! Proceeding with defaults.");
// $options = new Array();
$options= new stdClass;
$options->tolerance = 0.01;
$options->tolerancetype = 1; // relative
$options->correctanswerlength = 2;
$options->correctanswerformat = 1; // decimals
}
// For historic reasons we also need these fields in the answer objects.
// This should eventually be removed and related code changed to use
// the values in $question->options instead.
foreach ($question->options->answers as $key => $answer) {
$answer = &$question->options->answers[$key]; // for PHP 4.x
$answer->calcid = $options->id;
$answer->tolerance = $options->tolerance;
$answer->tolerancetype = $options->tolerancetype;
$answer->correctanswerlength = $options->correctanswerlength;
$answer->correctanswerformat = $options->correctanswerformat;
}
//$virtualqtype = $this->get_virtual_qtype( $question);
// $QTYPES['numerical']->get_numerical_units($question);
if( isset($question->export_process)&&$question->export_process){
$question->options->datasets = $this->get_datasets_for_export($question);
}
return true;
}
*/
function save_question_options($question) {
//$options = $question->subtypeoptions;
......@@ -110,7 +43,6 @@ class question_calculatedmulti_qtype extends question_calculated_qtype {
$options->question = $question->id;
}
$options->synchronize = $question->synchronize;
// $options->multichoice = $question->multichoice;
$options->single = $question->single;
$options->answernumbering = $question->answernumbering;
$options->shuffleanswers = $question->shuffleanswers;
......@@ -283,7 +215,7 @@ class question_calculatedmulti_qtype extends question_calculated_qtype {
}
function create_runtime_question($question, $form) {
$question = parent::create_runtime_question($question, $form);
$question = default_questiontype::create_runtime_question($question, $form);
$question->options->answers = array();
foreach ($form->answers as $key => $answer) {
$a->answer = trim($form->answer[$key]);
......
......@@ -286,7 +286,6 @@ class question_edit_calculatedsimple_form extends question_edit_form {
$this->qtypeobj =& $QTYPES[$this->qtype()];
$strquestionlabel = $this->qtypeobj->comment_header($this->nonemptyanswer);
$label = get_string("sharedwildcards", "qtype_datasetdependent");
$mform->addElement('hidden', 'multichoice', 0);
$mform->addElement('hidden', 'synchronize', 0);
$mform->addElement('hidden', 'initialcategory', 1);
$mform->setType('initialcategory', PARAM_INT);
......@@ -600,7 +599,6 @@ class question_edit_calculatedsimple_form extends question_edit_form {
$key++;
}
}
$default_values['multichoice'] = 0 ;
$default_values['synchronize'] = 0 ;
if (isset($question->options)){
$default_values['unitgradingtype'] = $question->options->unitgradingtype ;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment