123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <?php
- defined('MOODLE_INTERNAL') || die();
- require_once($CFG->dirroot . '/course/format/lib.php');
- class format_competencegraph extends format_base {
-
- private $coursedisplay = COURSE_DISPLAY_SINGLEPAGE;
- private $settings;
- public function __construct($format, $courseid) {
- if ($courseid === 0 || !is_numeric($courseid)) {
- global $COURSE;
- $courseid = $COURSE->id;
- }
- parent::__construct($format, $courseid);
- $section = optional_param('section', 0, PARAM_INT);
- if ($section) {
- $this->coursedisplay = COURSE_DISPLAY_MULTIPAGE;
- }
- }
-
- public function get_settings() {
- if (empty($this->settings) == true) {
- $this->settings = $this->get_format_options();
- }
- return $this->settings;
- }
-
- public function uses_sections() {
- return false;
- }
-
- public function get_view_url($section, $options = array()) {
- $course = $this->get_course();
- $url = new moodle_url('/course/view.php', array('id' => $course->id));
- $sr = null;
- if (array_key_exists('sr', $options)) {
- $sr = $options['sr'];
- }
- if (is_object($section)) {
- $sectionno = $section->section;
- } else {
- $sectionno = $section;
- }
- if ($sectionno !== null) {
- if ($sr !== null) {
- if ($sr) {
- $usercoursedisplay = COURSE_DISPLAY_MULTIPAGE;
- $sectionno = $sr;
- } else {
- $usercoursedisplay = COURSE_DISPLAY_SINGLEPAGE;
- }
- } else {
- $usercoursedisplay = $this->coursedisplay;
- }
- if ($sectionno != 0 && $usercoursedisplay == COURSE_DISPLAY_MULTIPAGE) {
- $url->param('section', $sectionno);
- } else {
- global $CFG;
- if (empty($CFG->linkcoursesections) && !empty($options['navigation'])) {
- return null;
- }
- $url->set_anchor('section-' . $sectionno);
- }
- }
- return $url;
- }
-
- public function supports_ajax() {
- $ajaxsupport = new stdClass();
- $ajaxsupport->capable = true;
- return $ajaxsupport;
- }
-
- public function get_default_blocks() {
- return array(
- BLOCK_POS_LEFT => array(),
- BLOCK_POS_RIGHT => array('search_forums', 'news_items', 'calendar_upcoming', 'recent_activity')
- );
- }
- private function get_context() {
- global $SITE;
- if ($SITE->id == $this->courseid) {
-
- global $PAGE;
- return $PAGE->context;
- } else {
- return context_course::instance($this->courseid);
- }
- }
-
- public function supports_news() {
- return true;
- }
-
- public function allow_stealth_module_visibility($cm, $section) {
-
- return !$section->section || ($section->visible && $section->section <= $this->get_course()->numsections);
- }
- }
|