/** * Sets up the table. * * @param string $uniqueid Unique id of table. * @param \core_competency\template $template The template. */ public function __construct($uniqueid, \core_competency\template $template) { parent::__construct($uniqueid); // This object should not be used without the right permissions. if (!$template->can_read()) { throw new \required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } // Set protected properties. $this->template = $template; $this->context = $this->template->get_context(); // Define columns in the table. $this->define_table_columns(); // Define configs. $this->define_table_configs(); }
/** * Template event viewed. * * Requires moodle/competency:templateview capability at the system context. * * @param mixed $templateorid The id or the template. * @return boolean */ public static function template_viewed($templateorid) { static::require_enabled(); $template = $templateorid; if (!is_object($template)) { $template = new template($template); } // First we do a permissions check. if (!$template->can_read()) { throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } // Trigger a template viewed event. \core\event\competency_template_viewed::create_from_template($template)->trigger(); return true; }