cm = get_coursemodule_from_id('sloodle', $id)) error('Course module ID was incorrect.'); // Fetch the course data if (!$this->course = sloodle_get_record('course', 'id', $this->cm->course)) error('Failed to retrieve course.'); $this->sloodle_course = new SloodleCourse(); if (!$this->sloodle_course->load($this->course)) error(get_string('failedcourseload', 'sloodle')); // Fetch the SLOODLE instance itself if (!$this->sloodle = sloodle_get_record('sloodle', 'id', $this->cm->instance)) error('Failed to find SLOODLE module instance'); } /** * Check that the user has permission to view this module, and check if they can edit it too. */ function check_permission() { // Make sure the user is logged-in require_course_login($this->course, true, $this->cm); sloodle_add_to_log($this->cm, 'view', array('id'=>$this->cm->id), "{$this->sloodle->id}"); // Check for permissions $this->module_context = context_module::instance($this->cm->id); $this->course_context = context_course::instance($this->course->id, IGNORE_MISSING); if (has_capability('moodle/course:manageactivities', $this->module_context)) $this->canedit = true; // If the module is hidden, then can the user still view it? if (empty($this->cm->visible) && !has_capability('moodle/course:viewhiddenactivities', $this->module_context)) notice(get_string('activityiscurrentlyhidden')); } /** * Process any form data which has been submitted. */ function process_form() { } /** * Print module header info. */ function sloodle_print_header() { global $CFG; // Offer the user an 'update' button if they are allowed to edit the module $editbuttons = ''; if ($this->canedit) { $editbuttons = update_module_button($this->cm->id, $this->course->id, get_string('modulename', 'sloodle')); } // Display the header $navigation = "course->id}\">".get_string('modulenameplural','sloodle')." ->"; sloodle_print_header_simple(format_string($this->sloodle->name), " ", "{$navigation} ".format_string($this->sloodle->name), "", "", true, $editbuttons, false); // Display the module name $img = ' '; sloodle_print_heading($img.$this->sloodle->name, 'center'); // Display the module type and description $fulltypename = get_string("moduletype:{$this->sloodle->type}", 'sloodle'); echo '

'.get_string('moduletype', 'sloodle').': '.$fulltypename; echo sloodle_helpbutton("moduletype_{$this->sloodle->type}", $fulltypename, 'sloodle', true, false, '', true).'

'; // We'll apply a general introduction to all Controllers, since they seem to confuse lots of people! $intro = $this->sloodle->intro; if ($this->sloodle->type == SLOODLE_TYPE_CTRL) $intro = '

'.get_string('controllerinfo','sloodle').'

' . $this->sloodle->intro; // Display the intro in a box, if we have an intro if (!empty($intro)) sloodle_print_box($intro, 'generalbox', 'intro'); } /** * Render the view of the module or feature. * This MUST be overridden to provide functionality. */ function render() { } /** * Print the footer for this course. */ function sloodle_print_footer() { sloodle_print_footer($this->course); } } ?>