course = sloodle_get_record('course', 'id', $id)) error('Could not find course.'); $this->sloodle_course = new SloodleCourse(); if (!$this->sloodle_course->load($this->course)) error(get_string('failedcourseload', 'sloodle')); } /** * Check that the user is logged-in and has permission to alter course settings. */ function check_permission() { // Ensure the user logs in require_login($this->course->id); if (isguestuser()) error(get_string('noguestaccess', 'sloodle')); add_to_log($this->course->id, 'course', 'view sloodle data', '', "{$this->course->id}"); // Ensure the user is allowed to update information on this course $this->course_context = get_context_instance(CONTEXT_COURSE, $this->course->id); require_capability('moodle/course:update', $this->course_context); } /** * Print the course settings page header. */ function sloodle_print_header() { global $CFG; $navigation = "wwwroot}/mod/sloodle/view.php?_type=course&id={$this->course->id}\">".get_string('courseconfig', 'sloodle').""; sloodle_print_header_simple(get_string('courseconfig','sloodle'), " ", $navigation, "", "", true, '', false); } /** * Render the view of the module or feature. * This MUST be overridden to provide functionality. */ function render() { global $CFG; // Fetch string table text $strsloodle = get_string('modulename', 'sloodle'); $strsloodles = get_string('modulenameplural', 'sloodle'); $strsavechanges = get_string('savechanges'); $stryes = get_string('yes'); $strno = get_string('no'); $strenabled = get_string('enabled','sloodle'); $strdisabled = get_string('disabled','sloodle'); $strsubmit = get_string('submit', 'sloodle'); //------------------------------------------------------ // If the form has been submitted, then process the input if (isset($_REQUEST['submit_course_options'])) { // Get the parameters $form_autoreg = required_param('autoreg', PARAM_BOOL); $form_autoenrol = required_param('autoenrol', PARAM_BOOL); // Update the Sloodle course object if ($form_autoreg) $this->sloodle_course->enable_autoreg(); else $this->sloodle_course->disable_autoreg(); if ($form_autoenrol) $this->sloodle_course->enable_autoenrol(); else $this->sloodle_course->disable_autoenrol(); // Update the database if ($this->sloodle_course->write()) { redirect("view.php?_type=course&id={$this->course->id}", get_string('changessaved'), 4); exit(); } else { sloodle_print_box(get_string('error'), 'generalbox boxwidthnarrow boxaligncenter'); } } //------------------------------------------------------ // Display info about Sloodle course configuration echo "
wwwroot}/course/view.php?id={$this->course->id}\"><<< ".get_string('backtocoursepage','sloodle').""; sloodle_print_footer($this->course); } } ?>