Example #1
0
 public function display($renderer, $attempt)
 {
     global $PAGE, $CFG, $USER;
     $mform = new lesson_display_answer_form_essay($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])) {
         $essayinfo = unserialize($attempt->useranswer);
         $data->answer = $essayinfo->answer;
     }
     $mform->set_data($data);
     return $mform->display();
 }
Example #2
0
 public function display($renderer, $attempt)
 {
     global $PAGE, $CFG, $USER;
     $mform = new lesson_display_answer_form_essay($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])) {
         $essayinfo = self::extract_useranswer($attempt->useranswer);
         $data->answer = $essayinfo->answer;
     }
     $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();
 }