public function get_entries(ImsQtiReader $item, ImsQtiReader $interaction) { $result = array(); $sets = $interaction->list_simpleMatchSet(); if (count($sets) == 0) { //associateInteraction $questions = $this->get_choices($interaction); $answers = array_merge($questions); } else { if (count($sets) == 1) { //should not be the case $questions = $this->get_choices($sets[0]); $answers = array_merge($questions); } else { //matchInteraction $questions = $this->get_choices($sets[0]); $answers = $this->get_choices($sets[1]); } } $done = array(); $responses = $this->get_correct_responses($item, $interaction); foreach ($responses as $response) { $pair = explode(' ', $response); $question = isset($questions[$pair[0]]) ? $questions[$pair[0]] : null; $answer = isset($answers[$pair[1]]) ? $answers[$pair[1]] : null; if (!empty($question)) { $result[] = $this->create_entry($question, $answer); $done[$pair[1]] = $pair[1]; } } foreach ($answers as $key => $answer) { if (!isset($done[$key])) { $result[] = $this->create_entry(null, $answer); } } return $result; }