. /** * Competence Graph * * Competence graph format allows the visualization of courses with competencies in a graph. * In the course structure, teacher associates activities to competencies. Each course module * can have restrictions between them, so a module is opened only when the student accomplish * its requirements. In student visualization, the structure of the course is presented as a * graph. In such graph, each node is a resource available to the student that can be handled. * Subgraphs in the main graph represent competences. As students can have different paths in * the course, the plugin registers all the steps that a student produces. * * @package course/format * @subpackage competencegraph * @version 0.1 * @author Laboratório de Informática na Educação * @link http://www.usp.br/line/competencegraph * @license http://www.gnu.org/copyleft/gpl.html GNU Public License */ defined('MOODLE_INTERNAL') || die(); require_once($CFG->dirroot . '/course/format/lib.php'); // For format_base. class format_competencegraph extends format_base { // Used to determine the type of view URL to generate - parameter or anchor. 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; } } /** * Returns the format's settings and gets them if they do not exist. * @return type The settings as an array. */ public function get_settings() { if (empty($this->settings) == true) { $this->settings = $this->get_format_options(); } return $this->settings; } /** * Indicates this format uses sections. * * @return bool Returns false */ public function uses_sections() { return false; } /** * The URL to use for the specified course (with section) * * @param int|stdClass $section Section object from database or just field course_sections.section * if omitted the course view page is returned * @param array $options options for view URL. At the moment core uses: * 'navigation' (bool) if true and section has no separate page, the function returns null * 'sr' (int) used by multipage formats to specify to which section to return * @return null|moodle_url */ 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'])) { // MDL-57412. return null; } $url->set_anchor('section-' . $sectionno); } } return $url; } /** * Returns the information about the ajax support in the given source format * * The returned object's property (boolean)capable indicates that * the course format supports Moodle course ajax features. * The property (array)testedbrowsers can be used as a parameter for {@link ajaxenabled()}. * * @return stdClass */ public function supports_ajax() { $ajaxsupport = new stdClass(); $ajaxsupport->capable = true; return $ajaxsupport; } /** * Returns the list of blocks to be automatically added for the newly created course * * @return array of default blocks, must contain two keys BLOCK_POS_LEFT and BLOCK_POS_RIGHT * each of values is an array of block names (for left and right side columns) */ 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) { // Use the context of the page which should be the course category. global $PAGE; return $PAGE->context; } else { return context_course::instance($this->courseid); } } /** * Indicates whether the course format supports the creation of a news forum. * * @return bool */ public function supports_news() { return true; } /** * Returns whether this course format allows the activity to * have "triple visibility state" - visible always, hidden on course page but available, hidden. * * @param stdClass|cm_info $cm course module (may be null if we are displaying a form for adding a module) * @param stdClass|section_info $section section where this module is located or will be added to * @return bool */ public function allow_stealth_module_visibility($cm, $section) { // Allow the third visibility state inside visible sections or in section 0, not allow in orphaned sections. return !$section->section || ($section->visible && $section->section <= $this->get_course()->numsections); } }