You are here

function qformat_examview::parse_matching_groups in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/question/format/examview/format.php \qformat_examview::parse_matching_groups()
1 call to qformat_examview::parse_matching_groups()
qformat_examview::readquestions in includes/moodle/question/format/examview/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/examview/format.php, line 61

Class

qformat_examview

Code

function parse_matching_groups($matching_groups) {
  if (empty($matching_groups)) {
    return;
  }
  foreach ($matching_groups as $match_group) {
    $newgroup = NULL;
    $groupname = trim($match_group['@']['name']);
    $questiontext = $this
      ->unxmlise($match_group['#']['text'][0]['#']);
    $newgroup->questiontext = trim($questiontext);
    $newgroup->subchoices = array();
    $newgroup->subquestions = array();
    $newgroup->subanswers = array();
    $choices = $match_group['#']['choices']['0']['#'];
    foreach ($choices as $key => $value) {
      if (strpos(trim($key), 'choice-') !== FALSE) {
        $key = strtoupper(trim(str_replace('choice-', '', $key)));
        $newgroup->subchoices[$key] = trim($value['0']['#']);
      }
    }
    $this->matching_questions[$groupname] = $newgroup;
  }
}