src/Repository.php
public function readQuestions($quizId) {
        $quizSlots = $this->readStoreRecords('quiz_slots', ['quizid' => $quizId]);
        $questions = [];
        foreach ($quizSlots as $index => $quizSlot) {
            try {
                $question = $this->readStoreRecord('question', ['id' => $quizSlot->questionid]);
                $question->answers = $this->readStoreRecords('question_answers', ['question' => $question->id]);
                $question->url = $this->cfg->wwwroot . '/mod/question/question.php?id='.$question->id;

                if ($question->qtype == 'numerical') {
                    $question->numerical = (object)[
                        'answers' => $this->readStoreRecords('question_numerical', ['question' => $question->id]),
                        'options' => $this->readStoreRecord('question_numerical_options', ['question' => $question->id]),
                        'units' => $this->readStoreRecords('question_numerical_units', ['question' => $question->id])
                    ];
                } else if ($question->qtype == 'match') {
                    $question->match = (object)[
                        'options' => $this->readStoreRecord('qtype_match_options', ['questionid' => $question->id]),
                        'subquestions' => $this->readStoreRecords('qtype_match_subquestions', ['questionid' => $question->id])
                    ];
                } else if (strpos($question->qtype, 'calculated') === 0) {
                    $question->calculated = (object)[
                        'answers' => $this->readStoreRecords('question_calculated', ['question' => $question->id]),
                        'options' => $this->readStoreRecord('question_calculated_options', ['question' => $question->id])
                    ];
                } else if ($question->qtype == 'shortanswer') {
                    $question->shortanswer = (object)[
                        'options' => $this->readStoreRecord('qtype_shortanswer_options', ['questionid' => $question->id])
                    ];
                }

                $questions[$question->id] = $question;
            }
            catch (\Exception $e) {
                // Question not found; maybe it was deleted since the event.
                // Don't add the question to the list, but also don't block the attempt event.
            }
        }

        return $questions;
    }
public function readQuestions($quizId) {
        $quizSlots = $this->readStoreRecords('quiz_slots', ['quizid' => $quizId]);
        $questions = [];
        foreach ($quizSlots as $index => $quizSlot) {
            try {
                $question = $this->readStoreRecord('question', ['id' => $quizSlot->questionid]);
                $question->answers = $this->readStoreRecords('question_answers', ['question' => $question->id]);
                $question->url = $this->cfg->wwwroot . '/mod/question/question.php?id='.$question->id;

                if ($question->qtype == 'numerical') {
                    $question->numerical = (object)[
                        'answers' => $this->readStoreRecords('question_numerical', ['question' => $question->id]),
                        'options' => $this->readStoreRecord('question_numerical_options', ['question' => $question->id]),
                        'units' => $this->readStoreRecords('question_numerical_units', ['question' => $question->id])
                    ];
                } else if ($question->qtype == 'match') {
                    $question->match = (object)[
                        'options' => $this->readStoreRecord('qtype_match_options', ['questionid' => $question->id]),
                        'subquestions' => $this->readStoreRecords('qtype_match_subquestions', ['questionid' => $question->id])
                    ];
                } else if (strpos($question->qtype, 'calculated') === 0) {
                    $question->calculated = (object)[
                        'answers' => $this->readStoreRecords('question_calculated', ['question' => $question->id]),
                        'options' => $this->readStoreRecord('question_calculated_options', ['question' => $question->id])
                    ];
                } else if ($question->qtype == 'shortanswer') {
                    $question->shortanswer = (object)[
                        'options' => $this->readStoreRecord('qtype_shortanswer_options', ['questionid' => $question->id])
                    ];
                }

                $questions[$question->id] = $question;
            }
            catch (\Exception $e) {
                // Question not found; maybe it was deleted since the event.
                // Don't add the question to the list, but also don't block the attempt event.
            }
        }

        return $questions;
    }
Reads questions from the store with the given quiz id.
@param String $id
@return PhpArr