Skip to content

Commit

Permalink
MDL-10110 removing call to multichoice field from code
Browse files Browse the repository at this point in the history
  • Loading branch information
ppichet committed Feb 8, 2010
1 parent c9acc77 commit 78a6d0b
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 124 deletions.
9 changes: 0 additions & 9 deletions question/type/calculated/datasetitems_form.php
Expand Up @@ -339,14 +339,10 @@ function set_data($question){
}
$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/>';
Expand Down Expand Up @@ -392,16 +388,11 @@ function set_data($question){
}

}
//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];
Expand Down
12 changes: 0 additions & 12 deletions question/type/calculated/edit_calculated_form.php
Expand Up @@ -45,7 +45,6 @@ function get_per_answer_fields(&$mform, $label, $gradeoptions, &$repeatedoptions
// $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'),
Expand Down Expand Up @@ -91,21 +90,10 @@ function definition_inner(&$mform) {
$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);

Expand Down
30 changes: 1 addition & 29 deletions question/type/calculated/questiontype.php
Expand Up @@ -34,7 +34,6 @@ function get_question_options(&$question) {
// 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 ;
Expand Down Expand Up @@ -137,7 +136,6 @@ function save_question_options($question) {
}
// 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;
Expand Down Expand Up @@ -1410,35 +1408,10 @@ function print_question_grading_details(&$question, &$state, &$cmoptions, &$opti
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) {
Expand Down Expand Up @@ -2121,7 +2094,6 @@ function restore($old_question_id,$new_question_id,$info,$restore) {
//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']['#']);
Expand Down
6 changes: 3 additions & 3 deletions question/type/calculated/version.php
@@ -1,5 +1,5 @@
<?php
<?PHP // $Id$

$plugin->version = 2009092000;
$plugin->version = 2010020800;
$plugin->requires = 2007101000;

?>
70 changes: 1 addition & 69 deletions question/type/calculatedmulti/questiontype.php
Expand Up @@ -25,74 +25,7 @@ function has_wildcards_in_responses($question, $subqid) {
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;
Expand All @@ -110,7 +43,6 @@ function save_question_options($question) {
$options->question = $question->id;
}
$options->synchronize = $question->synchronize;
// $options->multichoice = $question->multichoice;
$options->single = $question->single;
$options->answernumbering = $question->answernumbering;
$options->shuffleanswers = $question->shuffleanswers;
Expand Down Expand Up @@ -283,7 +215,7 @@ function save_session_and_responses(&$question, &$state) {
}

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]);
Expand Down
2 changes: 0 additions & 2 deletions question/type/calculatedsimple/edit_calculatedsimple_form.php
Expand Up @@ -286,7 +286,6 @@ function definition_inner(&$mform) {
$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);
Expand Down Expand Up @@ -600,7 +599,6 @@ function set_data($question) {
$key++;
}
}
$default_values['multichoice'] = 0 ;
$default_values['synchronize'] = 0 ;
if (isset($question->options)){
$default_values['unitgradingtype'] = $question->options->unitgradingtype ;
Expand Down

0 comments on commit 78a6d0b

Please sign in to comment.