public function display($renderer, $attempt) { global $USER, $CFG, $PAGE; $mform = new lesson_display_answer_form_shortanswer($CFG->wwwroot.'/mod/lesson/continue.php', array('contents'=>$this->get_contents(), 'lessonid'=>$this->lesson->id)); $data = new stdClass; $data->id = $PAGE->cm->id; $data->pageid = $this->properties->id; if (isset($USER->modattempts[$this->lesson->id])) { $data->answer = s($attempt->useranswer); } $mform->set_data($data); return $mform->display(); }
public function display($renderer, $attempt) { global $USER, $CFG, $PAGE; $mform = new lesson_display_answer_form_shortanswer($CFG->wwwroot . '/mod/lesson/continue.php', array('contents' => $this->get_contents(), 'lessonid' => $this->lesson->id)); $data = new stdClass(); $data->id = $PAGE->cm->id; $data->pageid = $this->properties->id; if (isset($USER->modattempts[$this->lesson->id])) { $data->answer = s($attempt->useranswer); } $mform->set_data($data); // Trigger an event question viewed. $eventparams = array('context' => context_module::instance($PAGE->cm->id), 'objectid' => $this->properties->id, 'other' => array('pagetype' => $this->get_typestring())); $event = \mod_lesson\event\question_viewed::create($eventparams); $event->trigger(); return $mform->display(); }