$questionarray = array_unique(explode(",",$questionlist));
$questionlist = implode(",", $questionarray);
unset($questionarray);
- $accepted_qtypes = array(SHORTANSWER, TRUEFALSE, MULTICHOICE, MATCH, NUMERICAL, CALCULATED);
foreach ($attempts as $attempt) {
switch ($attemptselection) {
continue;
}
$qtype = ($quizquestions[$i]->qtype=='random') ? $states[$i]->options->question->qtype : $quizquestions[$i]->qtype;
- if (!in_array ($qtype, $accepted_qtypes)){
+ $q = get_question_responses($quizquestions[$i], $states[$i]);
+ if (empty($q)){
continue;
}
- $q = get_question_responses($quizquestions[$i], $states[$i]);
$qid = $q->id;
if (!isset($questions[$qid])) {
$questions[$qid]['id'] = $qid;
*/
// ULPGC ecastro
function get_all_responses(&$question, &$state) {
- unset($answers);
- if (is_array($question->options->answers)) {
+ if (isset($question->options->answers) && is_array($question->options->answers)) {
+ $answers = array();
foreach ($question->options->answers as $aid=>$answer) {
- unset ($r);
+ $r = new stdClass;
$r->answer = $answer->answer;
$r->credit = $answer->fraction;
$answers[$aid] = $r;
}
+ $result = new stdClass;
+ $result->id = $question->id;
+ $result->responses = $answers;
+ return $result;
} else {
- $answers[]="error"; // just for debugging, eliminate
+ return null;
}
- $result->id = $question->id;
- $result->responses = $answers;
- return $result;
}
/**