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 "

".get_string('courseconfig','sloodle')."

\n"; echo "

(".get_string('course').": \"wwwroot}/course/view.php?id={$this->course->id}\">".$this->sloodle_course->get_full_name()."\")

"; sloodle_print_box(get_string('courseconfig:info','sloodle'), 'generalbox boxaligncenter boxwidthnormal'); echo "
\n"; // Get the initial form values $val_autoreg = (int)(($this->sloodle_course->get_autoreg()) ? 1 : 0); $val_autoenrol = (int)(($this->sloodle_course->get_autoenrol()) ? 1 : 0); // Make the selection options for enabling/disabling items $selection_menu = array(0 => $strdisabled, 1 => $strenabled); // Start the box sloodle_print_box_start('generalbox boxaligncenter boxwidthnormal'); echo '

'.get_string('coursesettings','sloodle').'

'; // Start the form (including a course ID hidden parameter) echo "
\n"; echo "course->id}\">\n"; echo "\n"; // AUTO REGISTRATION // echo "

\n"; sloodle_helpbutton('auto_registration', get_string('help:autoreg','sloodle'), 'sloodle', true, false, '', false); echo get_string('autoreg', 'sloodle').': '; choose_from_menu($selection_menu, 'autoreg', $val_autoreg, '', '', 0, false); // Add the site status if (!sloodle_autoreg_enabled_site()) echo '
 ('.get_string('autoreg:disabled','sloodle').')'; echo "

\n"; // AUTO ENROLMENT // echo "

\n"; sloodle_helpbutton('auto_enrolment', get_string('help:autoenrol','sloodle'), 'sloodle', true, false, '', false); echo get_string('autoenrol', 'sloodle').': '; choose_from_menu($selection_menu, 'autoenrol', $val_autoenrol, '', '', 0, false); // Add the site status if (!sloodle_autoenrol_enabled_site()) echo '
 ('.get_string('autoenrol:disabled','sloodle').')'; echo '

'; // Close the form, along with a submit button echo "\n
\n"; // Finish the box echo '
'; sloodle_print_box_end(); //------------------------------------------------------ // Loginzone information sloodle_print_box_start('generalbox boxaligncenter boxwidthnarrow'); echo '

'.get_string('loginzonedata','sloodle').'

'; $lastupdated = '('.get_string('unknown','sloodle').')'; if ($this->sloodle_course->get_loginzone_time_updated() > 0) $lastupdated = date('Y-m-d H:i:s', $this->sloodle_course->get_loginzone_time_updated()); echo get_string('position','sloodle').': '.$this->sloodle_course->get_loginzone_position().'
'; echo get_string('size','sloodle').': '.$this->sloodle_course->get_loginzone_size().'
'; echo get_string('region','sloodle').': '.$this->sloodle_course->get_loginzone_region().'
'; echo get_string('lastupdated','sloodle').': '.$lastupdated.'
'; echo '
'; // Have we been instructed to clear all pending allocations? if (isset($_REQUEST['clear_loginzone_allocations'])) { // Delete all allocations relating to this course sloodle_delete_records('sloodle_loginzone_allocation', 'course', $this->course->id); } // Create a form echo "
\n"; echo "course->id}\">\n"; echo "\n"; // Determine how many allocations there are for this course $allocs = sloodle_count_records('sloodle_loginzone_allocation', 'course', $this->course->id); echo get_string('pendingallocations','sloodle').': '.$allocs.'  '; echo ''; echo "
\n"; echo '
'; sloodle_print_box_end(); //------------------------------------------------------ $course = $this->course; } /** * Print the footer for this course. */ function sloodle_print_footer() { global $CFG; echo "

wwwroot}/course/view.php?id={$this->course->id}\"><<< ".get_string('backtocoursepage','sloodle').""; sloodle_print_footer($this->course); } } ?>