Index: format/xml/format.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/format/xml/format.php,v retrieving revision 1.59 diff -u -r1.59 format.php --- format/xml/format.php 30 Sep 2009 13:38:36 -0000 1.59 +++ format/xml/format.php 12 Oct 2009 18:18:41 -0000 @@ -270,35 +270,6 @@ } /** - * import short answer type question - * @param array question question array from xml tree - * @return object question object - */ - function import_shortanswer( $question ) { - // get common parts - $qo = $this->import_headers( $question ); - - // header parts particular to shortanswer - $qo->qtype = SHORTANSWER; - - // get usecase - $qo->usecase = $this->getpath($question, array('#','usecase',0,'#'), $qo->usecase ); - - // run through the answers - $answers = $question['#']['answer']; - $a_count = 0; - foreach ($answers as $answer) { - $ans = $this->import_answer( $answer ); - $qo->answer[$a_count] = $ans->answer; - $qo->fraction[$a_count] = $ans->fraction; - $qo->feedback[$a_count] = $ans->feedback; - ++$a_count; - } - - return $qo; - } - - /** * import description type question * @param array question question array from xml tree * @return object question object @@ -541,9 +512,6 @@ elseif ($question_type=='truefalse') { $qo = $this->import_truefalse( $question ); } - elseif ($question_type=='shortanswer') { - $qo = $this->import_shortanswer( $question ); - } elseif ($question_type=='numerical') { $qo = $this->import_numerical( $question ); } @@ -877,18 +845,6 @@ $expout .= " \n"; } break; - case SHORTANSWER: - $expout .= " {$question->options->usecase}\n "; - foreach($question->options->answers as $answer) { - $percent = 100 * $answer->fraction; - $expout .= " \n"; - $expout .= $this->writetext( $answer->answer,3,false ); - $expout .= " \n"; - $expout .= $this->writetext( $answer->feedback,4,false ); - $expout .= " \n"; - $expout .= " \n"; - } - break; case NUMERICAL: foreach ($question->options->answers as $answer) { $tolerance = $answer->tolerance; Index: type/shortanswer/db/install.xml =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/shortanswer/db/install.xml,v retrieving revision 1.5 diff -u -r1.5 install.xml --- type/shortanswer/db/install.xml 1 May 2009 14:07:50 -0000 1.5 +++ type/shortanswer/db/install.xml 12 Oct 2009 17:44:14 -0000 @@ -1,5 +1,5 @@ - @@ -7,9 +7,8 @@ - - - + + @@ -17,4 +16,4 @@
-
+ \ No newline at end of file Index: type/shortanswer/db/upgrade.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/shortanswer/db/upgrade.php,v retrieving revision 1.5 diff -u -r1.5 upgrade.php --- type/shortanswer/db/upgrade.php 16 Aug 2008 12:16:07 -0000 1.5 +++ type/shortanswer/db/upgrade.php 12 Oct 2009 17:48:13 -0000 @@ -34,6 +34,18 @@ /// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php /// $result = result of database_manager methods /// } + if ($oldversion < 2006032201) { + /// Define table question_shortanswer to manage fields + $table = new xmldb_table('question_shortanswer'); + + /// Dropping obsoleted field answers + $field = new xmldb_field('answers'); + if ($dbman->field_exists($table, $field)) { + $dbman->drop_field($table, $field); + } + + upgrade_plugin_savepoint($result, 2006032201, 'qtype', 'shortanswer'); + } return $result; } Index: type/shortanswer/questiontype.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/shortanswer/questiontype.php,v retrieving revision 1.45 diff -u -r1.45 questiontype.php --- type/shortanswer/questiontype.php 7 Oct 2009 20:59:45 -0000 1.45 +++ type/shortanswer/questiontype.php 12 Oct 2009 18:22:57 -0000 @@ -42,7 +42,6 @@ $oldanswers = array(); } - $answers = array(); $maxfraction = -1; // Insert all the new answers @@ -67,13 +66,11 @@ $answer->feedback = $question->feedback[$key]; $answer->id = $DB->insert_record("question_answers", $answer); } - $answers[] = $answer->id; if ($question->fraction[$key] > $maxfraction) { $maxfraction = $question->fraction[$key]; } } - $question->answers = implode(',', $answers); $parentresult = parent::save_question_options($question); if($parentresult !== null) { // Parent function returns null if all is OK return $parentresult; @@ -220,52 +217,6 @@ return 0; } -/// RESTORE FUNCTIONS ///////////////// - - /* - * Restores the data in the question - * - * This is used in question/restorelib.php - */ - function restore($old_question_id,$new_question_id,$info,$restore) { - global $DB; - - $status = parent::restore($old_question_id, $new_question_id, $info, $restore); - - if ($status) { - $extraquestionfields = $this->extra_question_fields(); - $questionextensiontable = array_shift($extraquestionfields); - - //We have to recode the answers field (a list of answers id) - $questionextradata = $DB->get_record($questionextensiontable, array($this->questionid_column_name() => $new_question_id)); - if (isset($questionextradata->answers)) { - $answers_field = ""; - $in_first = true; - $tok = strtok($questionextradata->answers, ","); - while ($tok) { - // Get the answer from backup_ids - $answer = backup_getid($restore->backup_unique_code,"question_answers",$tok); - if ($answer) { - if ($in_first) { - $answers_field .= $answer->new_id; - $in_first = false; - } else { - $answers_field .= ",".$answer->new_id; - } - } - // Check for next - $tok = strtok(","); - } - // We have the answers field recoded to its new ids - $questionextradata->answers = $answers_field; - // Update the question - $status = $status && $DB->update_record($questionextensiontable, $questionextradata); - } - } - - return $status; - } - /** * Prints the score obtained and maximum score available plus any penalty * information Index: type/shortanswer/version.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/shortanswer/version.php,v retrieving revision 1.2 diff -u -r1.2 version.php --- type/shortanswer/version.php 10 Oct 2007 16:09:49 -0000 1.2 +++ type/shortanswer/version.php 12 Oct 2009 17:45:24 -0000 @@ -1,6 +1,6 @@ version = 2006032200; +$plugin->version = 2006032201; $plugin->requires = 2007101000; ?>