Index: questiontype.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/multianswer/questiontype.php,v retrieving revision 1.40 diff -u -r1.40 questiontype.php --- questiontype.php 24 Sep 2007 14:18:47 -0000 1.40 +++ questiontype.php 6 Oct 2007 04:40:26 -0000 @@ -127,6 +127,28 @@ return parent::save_question($question, $form, $course); } + function move_question_to_category($question, $tocategoryid){ + global $QTYPES; + if (!set_field('question', 'category', $tocategoryid, 'id', $question->id)) { + return false; // error('Could not update category field'); + } + echo " question
"; print_r($question);echo ""; +//exit; + // Get relevant data indexed by positionkey from the multianswers table + if (!$sequence = get_field('question_multianswer', 'sequence', 'question', $question->id)) { + notify('Error: Cloze question '.$question->id.' is missing question options!'); + return false; + } + + $wrappedquestions = get_records_list('question', 'id', $sequence, 'id ASC'); + foreach ($wrappedquestions as $subquestion){ + if(! $QTYPES[$subquestion->qtype]->move_question_to_category($subquestion, $tocategoryid)){ + return false; + } + } + return true; + } + function create_session_and_responses(&$question, &$state, $cmoptions, $attempt) { $state->responses = array(); foreach ($question->options->questions as $key => $wrapped) {