function qformat_blackboard_6::create_raw_question in Quiz 6.6
Same name and namespace in other branches
- 6.5 includes/moodle/question/format/blackboard_6/format.php \qformat_blackboard_6::create_raw_question()
1 call to qformat_blackboard_6::create_raw_question()
- qformat_blackboard_6::readquestions in includes/
moodle/ question/ format/ blackboard_6/ format.php - Parses an array of lines into an array of questions, where each item is a question object as defined by readquestion(). Questions are defined as anything between blank lines.
File
- includes/
moodle/ question/ format/ blackboard_6/ format.php, line 262
Class
Code
function create_raw_question($quest) {
$question = new StdClass();
$question->qtype = $quest['#']['itemmetadata'][0]['#']['bbmd_questiontype'][0]['#'];
$question->id = $quest['#']['itemmetadata'][0]['#']['bbmd_asi_object_id'][0]['#'];
$presentation->blocks = $quest['#']['presentation'][0]['#']['flow'][0]['#']['flow'];
foreach ($presentation->blocks as $pblock) {
$block = NULL;
$block->type = $pblock['@']['class'];
switch ($block->type) {
case 'QUESTION_BLOCK':
$sub_blocks = $pblock['#']['flow'];
foreach ($sub_blocks as $sblock) {
//echo "Calling process_block from line 263<br>";
$this
->process_block($sblock, $block);
}
break;
case 'RESPONSE_BLOCK':
$choices = NULL;
switch ($question->qtype) {
case 'Matching':
$bb_subquestions = $pblock['#']['flow'];
$sub_questions = array();
foreach ($bb_subquestions as $bb_subquestion) {
$sub_question = NULL;
$sub_question->ident = $bb_subquestion['#']['response_lid'][0]['@']['ident'];
$this
->process_block($bb_subquestion['#']['flow'][0], $sub_question);
$bb_choices = $bb_subquestion['#']['response_lid'][0]['#']['render_choice'][0]['#']['flow_label'][0]['#']['response_label'];
$choices = array();
$this
->process_choices($bb_choices, $choices);
$sub_question->choices = $choices;
if (!isset($block->subquestions)) {
$block->subquestions = array();
}
$block->subquestions[] = $sub_question;
}
break;
case 'Multiple Answer':
$bb_choices = $pblock['#']['response_lid'][0]['#']['render_choice'][0]['#']['flow_label'];
$choices = array();
$this
->process_choices($bb_choices, $choices);
$block->choices = $choices;
break;
case 'Essay':
// Doesn't apply since the user responds with text input
break;
case 'Multiple Choice':
$mc_choices = $pblock['#']['response_lid'][0]['#']['render_choice'][0]['#']['flow_label'];
foreach ($mc_choices as $mc_choice) {
$choices = NULL;
$choices = $this
->process_block($mc_choice, $choices);
$block->choices[] = $choices;
}
break;
case 'Short Response':
// do nothing?
break;
case 'Fill in the Blank':
// do nothing?
break;
case 'Fill in the Blank Plus':
// do nothing?
break;
case 'Numeric':
// do nothing?
break;
default:
$bb_choices = $pblock['#']['response_lid'][0]['#']['render_choice'][0]['#']['flow_label'][0]['#']['response_label'];
$choices = array();
$this
->process_choices($bb_choices, $choices);
$block->choices = $choices;
}
break;
case 'RIGHT_MATCH_BLOCK':
$matching_answerset = $pblock['#']['flow'];
$answerset = array();
foreach ($matching_answerset as $answer) {
// $answerset[] = $this->process_block($answer, $bb_answer);
$bb_answer = null;
$bb_answer->text = $answer['#']['flow'][0]['#']['material'][0]['#']['mat_extension'][0]['#']['mat_formattedtext'][0]['#'];
$answerset[] = $bb_answer;
}
$block->matching_answerset = $answerset;
break;
default:
print "UNHANDLED PRESENTATION BLOCK";
break;
}
$question->{$block->type} = $block;
}
// determine response processing
// there is a section called 'outcomes' that I don't know what to do with
$resprocessing = $quest['#']['resprocessing'];
$respconditions = $resprocessing[0]['#']['respcondition'];
$responses = array();
if ($question->qtype == 'Matching') {
$this
->process_matching_responses($respconditions, $responses);
}
else {
$this
->process_responses($respconditions, $responses);
}
$question->responses = $responses;
$feedbackset = $quest['#']['itemfeedback'];
$feedbacks = array();
$this
->process_feedback($feedbackset, $feedbacks);
$question->feedback = $feedbacks;
return $question;
}