public function to_student($show_level = true, $show_topics = true) { $qd = parent::to_student($show_level, $show_topics); $answers = array_map(function ($a) { return array('text' => $a['text'], 'hex_id' => $a['hex_id']); }, $this->answers); shuffle($answers); $qd['fields'] = $answers; return $qd; }
public function to_student($show_level = true, $show_topics = true) { $qd = parent::to_student($show_level, $show_topics); // nothing to add... return $qd; }
public function to_student($show_level = true, $show_topics = true) { $qd = parent::to_student($show_level, $show_topics); $func = function ($a) { return array('text' => $a['text'], 'hex_id' => $a['hex_id']); }; $left_column = array_map($func, $this->left_column); $right_column = array_map($func, $this->right_column); if ($this->shuffle_left) { shuffle($left_column); } if ($this->shuffle_right) { shuffle($right_column); } $qd['leftColumn'] = $left_column; $qd['rightColumn'] = $right_column; $qd['reorderLeft'] = $this->shuffle_left; $qd['reorderRight'] = $this->shuffle_right; return $qd; }
public function to_student($show_level = true, $show_topics = true) { $qd = parent::to_student($show_level, $show_topics); $qd['min_answers'] = $this->min_answers; $qd['max_answers'] = $this->max_answers; $n = count($this->answers); $nonfixed = []; $shuffled_answers = array_fill(0, $n, null); foreach ($this->answers as $i => $a) { $answer = array('hex_id' => $a['hex_id'], 'text' => $a['text']); if ($a['fixed']) { $shuffled_answers[$i] = $answer; } else { $nonfixed[$i] = $answer; } } shuffle($nonfixed); for ($i = 0; $i < $n; $i++) { if ($shuffled_answers[$i] === null) { $shuffled_answers[$i] = array_shift($nonfixed); } } $qd['answers'] = $shuffled_answers; return $qd; }