function qformat_blackboard_6::process_mc in Quiz 6.6
Same name and namespace in other branches
- 6.5 includes/moodle/question/format/blackboard_6/format.php \qformat_blackboard_6::process_mc()
1 call to qformat_blackboard_6::process_mc()
- 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 670
Class
Code
function process_mc($quest, &$questions) {
$question = $this
->process_common($quest);
$question->qtype = MULTICHOICE;
$question->single = 1;
$feedback = array();
foreach ($quest->feedback as $fback) {
$feedback[$fback->ident] = addslashes($fback->text);
}
foreach ($quest->responses as $response) {
if (isset($response->title)) {
if ($response->title == 'correct') {
// only one answer possible for this qtype so first index is correct answer
$correct = $response->ident[0]['varequal'][0]['#'];
}
}
else {
// fallback method for when the title is not set
if ($response->feedback == 'correct') {
// only one answer possible for this qtype so first index is correct answer
$correct = $response->ident[0]['varequal'][0]['#'];
// added [0]['varequal'][0]['#'] to $response->ident - CT 8/9/06
}
}
}
$i = 0;
foreach ($quest->RESPONSE_BLOCK->choices as $response) {
$question->answer[$i] = addslashes($response->text);
if ($correct == $response->ident) {
$question->fraction[$i] = 1;
// this is a bit of a hack to catch the feedback... first we see if a 'correct' feedback exists
// then specific feedback for this question (maybe this should be switched?, but from my example
// question pools I have not seen response specific feedback, only correct or incorrect feedback
if (!empty($feedback['correct'])) {
$question->feedback[$i] = $feedback['correct'];
}
elseif (!empty($feedback[$i])) {
$question->feedback[$i] = $feedback[$i];
}
else {
// failsafe feedback (should be '' instead?)
$question->feedback[$i] = "correct";
}
}
else {
$question->fraction[$i] = 0;
if (!empty($feedback['incorrect'])) {
$question->feedback[$i] = $feedback['incorrect'];
}
elseif (!empty($feedback[$i])) {
$question->feedback[$i] = $feedback[$i];
}
else {
// failsafe feedback (should be '' instead?)
$question->feedback[$i] = 'incorrect';
}
}
$i++;
}
if (!empty($question)) {
$questions[] = $question;
}
}