/**
  * Custom validation.
  *
  * The parent validation is ignored on purpose.
  *
  * @throws \coding_exception
  * @return void
  */
 protected function validate_data()
 {
     if ($this->context->contextlevel !== CONTEXT_COURSE) {
         throw new \coding_exception('The context must be a course level context.');
     }
     // Hack to by pass the requirement of the parent class. 'view_all' was the old fashioned-way
     // to describe the page listing all the instances of a module in a course.
     $this->data['other']['content'] = 'view_all';
     parent::validate_data();
 }
 /**
  * Custom validations.
  *
  * @throws \coding_exception in case of any problems.
  */
 protected function validate_data()
 {
     if (!isset($this->other['anonymous'])) {
         throw new \coding_exception("Field other['anonymous'] cannot be empty");
     }
     if (!isset($this->other['cmid'])) {
         throw new \coding_exception("Field other['cmid'] cannot be empty");
     }
     // Call parent validations.
     parent::validate_data();
 }
 /**
  * Custom validation.
  *
  * @throws \coding_exception
  * @return void
  */
 protected function validate_data()
 {
     // Hack to please the parent class. 'view chapter' was the key used in old add_to_log().
     $this->data['other']['content'] = 'view chapter';
     parent::validate_data();
 }