mirror of
https://github.com/moodle/moodle.git
synced 2025-02-22 02:49:53 +01:00
Removed functions that build objects for question export. Now done
using existing functions in questiontype classes.
This commit is contained in:
parent
6cd7ac5fec
commit
683f250a40
@ -2272,115 +2272,6 @@ function get_questions_category( $category ) {
|
||||
return $qresults;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get question data for export
|
||||
*
|
||||
* @todo This really needs to be handled by the question types rather
|
||||
* than by the switch statement below.
|
||||
* @author presumably Howard Miller
|
||||
* function to read single question, parameter is object view of
|
||||
* quiz_categories record, results is a combined object
|
||||
* defined as follows...
|
||||
* ->id quiz_questions id
|
||||
* ->category category
|
||||
* ->name q name
|
||||
* ->questiontext
|
||||
* ->image
|
||||
* ->qtype see defines at the top of this file
|
||||
* ->stamp not too sure
|
||||
* ->version not sure
|
||||
* ----SHORTANSWER
|
||||
* ->usecase
|
||||
* ->answers array of answers
|
||||
* ----TRUEFALSE
|
||||
* ->trueanswer truefalse answer
|
||||
* ->falseanswer truefalse answer
|
||||
* ----MULTICHOICE
|
||||
* ->layout
|
||||
* ->single many or just one correct answer
|
||||
* ->answers array of answer objects
|
||||
* ----NUMERIC
|
||||
* ->min minimum answer span
|
||||
* ->max maximum answer span
|
||||
* ->answer single answer
|
||||
* ----MATCH
|
||||
* ->subquestions array of sub questions
|
||||
* ---->questiontext
|
||||
* ---->answertext
|
||||
function get_question_data( $question ) {
|
||||
// what to do next depends of question type (qtype)
|
||||
switch ($question->qtype) {
|
||||
case SHORTANSWER:
|
||||
$shortanswer = get_record("quiz_shortanswer","question",$question->id);
|
||||
$question->usecase = $shortanswer->usecase;
|
||||
$question->answers = get_exp_answers( $question->id );
|
||||
break;
|
||||
case TRUEFALSE:
|
||||
if (!$truefalse = get_record("quiz_truefalse","question",$question->id)) {
|
||||
error( "quiz_truefalse record $question->id not found" );
|
||||
}
|
||||
$question->trueanswer = get_exp_answer( $truefalse->trueanswer );
|
||||
$question->falseanswer = get_exp_answer( $truefalse->falseanswer );
|
||||
break;
|
||||
case MULTICHOICE:
|
||||
if (!$multichoice = get_record("quiz_multichoice","question",$question->id)) {
|
||||
error( "quiz_multichoice $question->id not found" );
|
||||
}
|
||||
$question->layout = $multichoice->layout;
|
||||
$question->single = $multichoice->single;
|
||||
$question->answers = get_exp_answers( $multichoice->question );
|
||||
break;
|
||||
case NUMERICAL:
|
||||
if (!$numeric = get_record("quiz_numerical","question",$question->id)) {
|
||||
error( "quiz_numerical $question->id not found" );
|
||||
}
|
||||
$question->min = $numeric->min;
|
||||
$question->max = $numeric->max;
|
||||
$question->answer = get_exp_answer( $numeric->answer );
|
||||
break;
|
||||
case MATCH:
|
||||
if (!$subquestions = get_records("quiz_match_sub","question",$question->id)) {
|
||||
error( "quiz_match_sub $question->id not found" );
|
||||
}
|
||||
$question->subquestions = $subquestions;
|
||||
break;
|
||||
case DESCRIPTION:
|
||||
// nothing to do
|
||||
break;
|
||||
case MULTIANSWER:
|
||||
// nothing to do
|
||||
break;
|
||||
case RANDOM:
|
||||
// nothing to do
|
||||
break;
|
||||
default:
|
||||
notify("No handler for question type $question->qtype in get_question");
|
||||
}
|
||||
return $question;
|
||||
}
|
||||
|
||||
/**
|
||||
* function to return single record from quiz_answers table
|
||||
*/
|
||||
function get_exp_answer( $id ) {
|
||||
if (!$answer = get_record("quiz_answers","id",$id )) {
|
||||
error( "quiz_answers record $id not found" );
|
||||
}
|
||||
return $answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to return array of answers for export
|
||||
*/
|
||||
function get_exp_answers( $question_num ) {
|
||||
if (!$answers = get_records("quiz_answers","question",$question_num)) {
|
||||
error( "quiz_answers question $question_num not found" );
|
||||
}
|
||||
return $answers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a comma separated list of ids of the category and all subcategories
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user