public function get_quiz() {
        global $DB;

        if (empty($this->quiz)) {
            if (empty($this->record->quizid)) {
                throw new \coding_exception('quizid is not set.');
            }
            $this->quiz = $DB->get_record('quiz', array('id' => $this->record->quizid));
        }

        return $this->quiz;
    }