function definition() { global $CFG, $USER; $form =& $this->_form; $user = CoursePrefsUser::findByUnique($USER->username); $courses = $user->getCoursesAsTeacher(); // Course-specific settings $form->addElement('header', 'course_settings', get_string('materials_courses', 'block_courseprefs')); $form->setHelpButton('course_settings', array('materials_courses', get_string('materials_courses_help', 'block_courseprefs'), 'block_courseprefs', true)); // Remove courses to be generated if they have been created already; i.e. create_flag isn't set $materials = $user->getMaterials(); foreach ($materials as $material) { if (!$material->getCreateFlag()) { unset($courses[$material->getCoursesId()]); } } // Generate checkboxes for courses that haven't had a materials courses created yet foreach ($courses as $course) { $form->addElement('checkbox', MATERIAL_COURSE_FIELD . $course->getId(), NULL, $course->getDepartment() . ' ' . $course->getCourseNumber()); } // BUTTONS BELOW FORM $buttonarray = array(); $buttonarray[] =& $form->createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] =& $form->createElement('cancel'); $form->addGroup($buttonarray, 'buttonar', '', array(' '), false); $form->closeHeaderBefore('buttonar'); }
/** * Content generation method of block; list of page links **/ function get_content() { if ($this->content !== NULL) { return $this->content; } global $CFG, $USER; $this->content = new stdClass(); $this->content->icons = array(); $this->content->footer = ''; $this->content->items = array(); $context = get_context_instance(CONTEXT_SYSTEM); $mentor = has_capability('block/student_gradeviewer:viewgrades', $context) || has_capability('block/student_gradeviewer:sportsviewgrades', $context); $admin = has_capability('block/student_gradeviewer:academicadmin', $context) || has_capability('block/student_gradeviewer:sportsadmin', $context); // If they can't view the grades, then they can't query if ($mentor) { $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/student_gradeviewer/viewgrades.php">' . get_string('view_grades', 'block_student_gradeviewer') . '</a>'; } // This is solely for the admins of the systems, or the Moodle admins if ($admin) { $admin = get_string('admin', 'block_student_gradeviewer'); $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/student_gradeviewer/admin.php">' . $admin . '</a>' . helpbutton('admin', $admin, 'block_student_gradeviewer', true, false, '', true); } if ($mentor || $admin) { $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/student_gradeviewer/analysis.php"> ' . get_string('analysis', 'block_student_gradeviewer') . '</a>'; } // Primary instructors can configure their digest options $cps_user = CoursePrefsUser::findByUnique($USER->username); if (!empty($CFG->cas_email) and $cps_user and $cps_user->getSectionsInfoAsTeacher()) { $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/student_gradeviewer/options.php">' . get_string('options', 'block_student_gradeviewer') . '</a>'; } return $this->content; }
function create_obj($id) { $user = CoursePrefsUser::findByUnique($id); $this->primary_sections = $user->getSectionsInfoAsPrimaryTeacher(true); $this->sections = $user->getSectionsInfoAsTeacher(false, null, true); return $user; }
function validation($data) { global $USER; $errorlog = array(); $form_errorlog = $this->_form->_errors; // Lookup necessary objects related to the user and his/her courses ans sections $user = CoursePrefsUser::findByUnique($USER->username); $sections = $user->getSectionsInfoAsPrimaryTeacher(); // Parse form submission and glean necessary information $this->selected_sections = array(); foreach ($data as $key => $value) { $matches = array(); if (preg_match(UNWANTED_SECTION_PATTERN, $key, $matches)) { $sectionsid = $matches[1]; $coursesid = $matches[2]; $section = $sections[$sectionsid]; // Associated section with its course if (!$this->selected_sections[$coursesid]) { $this->selected_sections[$coursesid] = array(); } $this->selected_sections[$coursesid][$section->id] = $section; } } // Iterate over new unwanted courses and remove new unwanted sections if (!empty($this->selected_courses)) { foreach ($this->selected_courses as $coursesid => $boolean) { if (isset($this->selected_sections[$coursesid])) { unset($this->selected_sections[$coursesid]); } } } }
function definition() { global $USER; $form =& $this->_form; $user = CoursePrefsUser::findByUnique($USER->username); $teamteaches = $user->getRequestedTeamTeaches(); // Pending team teaching invitations header $form->addElement('header', 'pending_teamteach', get_string('header_teamteach_pending', 'block_courseprefs')); $form->setHelpButton('pending_teamteach', array('teamteach_pending', get_string('teamteach_pending_help', 'block_courseprefs'), 'block_courseprefs', true)); // Generate a listing of team teaching invitation the user has made of other teachers which // need to be approved or rejected $display = array(); foreach ($teamteaches as $teamteach) { // Skip the team teaching invitation if it doesn't need to be approved if (!$teamteach->getApprovalFlag()) { continue; } // Lookup information about the requesting user and user's section $teamteach_user = $teamteach->getTtUser(); $display[$teamteach->getId()] = CoursePrefsSection::generateFullnameById($teamteach->getTtSectionsId()) . ' with ' . $teamteach_user->getLastname() . ' ' . $teamteach_user->getFirstname(); } // Skip the remaining form definition if no invitations were found and display a message to the user if (!$display) { $form->addElement('static', null, null, get_string('no_requests', 'block_courseprefs')); return; } // Sort listing of invitations by semesters uasort($display, "cmpSemester"); // Add static elements for each team teach invitiation that hasn't been accepted or rejected yet foreach ($display as $key => $teamteach) { $form->addElement('static', null, null, $teamteach); } }
/** * Content generation method of block; list of page links **/ function get_content() { if ($this->content !== NULL) { return $this->content; } global $CFG, $USER; $this->content = new stdClass(); $user = CoursePrefsUser::findByUnique($USER->username); $this->content->icons = array(); $this->content->footer = ''; $this->content->items = array(); $context = get_context_instance(CONTEXT_SYSTEM); if (has_capability('block/courseprefs:viewdata', $context)) { $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/content_viewer.php">' . get_string('content_viewer', 'block_courseprefs') . '</a>'; } if (!$user || !$user->isTeacher()) { $this->content->items[] = get_string('block_request_link', 'block_courseprefs') . " <a href=\"{$CFG->wwwroot}/blocks/courseprefs/request.php\">here</a> to" . ' request a course'; return $this->content; } // Removing Links that might break current courses $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/creation_enrol.php">' . get_string('creation_link', 'block_courseprefs') . '</a>'; $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/split.php">' . get_string('split_link', 'block_courseprefs') . '</a>'; $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/crosslist.php">' . get_string('crosslist_link', 'block_courseprefs') . '</a>'; $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/teamteach.php">' . get_string('teamteach_link', 'block_courseprefs') . '</a>'; $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/materials.php">' . get_string('materials_link', 'block_courseprefs') . '</a>'; $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/courseprefs/unwanted.php">' . get_string('unwanted_link', 'block_courseprefs') . '</a>'; return $this->content; }
function get_content() { if ($this->content !== NULL) { return $this->content; } global $CFG, $COURSE, $USER; $this->content = new stdClass(); $this->content->icons = array(); $this->content->items = array(); $this->content->footer = ''; list($source, $cap) = $this->permissions($COURSE); if (!$cap) { return $this->content; } //We're in a global section, so we change our links $global = $source == 'system'; $cps_user = CoursePrefsUser::findByUnique($USER->username); // If the cps user is valid, and they are in the teaching role in their course $can_report = ($cps_user and $cps_user->getSectionsForMoodleCourse($COURSE) or is_siteadmin($USER->id)); if (!$global and $can_report) { $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/email.gif"/>'; $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/student_reporting/select.php?id=' . $COURSE->id . '">' . get_string('select', 'block_student_reporting') . '</a>'; } $this->content->icons[] = ''; $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/student_gradeviewer/analysis.php' . ($global ? '' : '?id=' . $COURSE->id) . '">' . get_string('analysis', 'block_student_gradeviewer') . '</a>'; if (!empty($CFG->cas_email) and $cps_user and $cps_user->getSectionsInfoAsTeacher()) { $this->content->items[] = '<a href="' . $CFG->wwwroot . '/blocks/student_gradeviewer/options.php?id=' . $COURSE->id . '">' . get_string('options', 'block_student_gradeviewer') . '</a>'; } return $this->content; }
function validation($data) { global $USER; $errorlog = array(); $user = CoursePrefsUser::findByUnique($USER->username); $crosslists = $user->getCrosslists(); // Parse form submission and glean necessary information $this->selected_crosslists = array(); foreach ($data as $key => $value) { $matches = array(); // Add the ID of the cross list entry to the list of selections if the user owns it if (preg_match(CROSSLIST_DELETE_PATTERN, $key, $matches) && $crosslists[$matches[1]]) { $this->selected_crosslists[] = $matches[1]; } } return $errorlog; }
function validation($data) { global $USER; $errorlog = array(); $user = CoursePrefsUser::findByUnique($USER->username); $teamteaches = $user->getDecisionTeamTeaches(); // Parse form submission and glean necessary information $this->selected_teamteaches = array(); foreach ($data as $key => $value) { $matches = array(); // Add the ID of the team teach entry to the list of selections if the user owns it if (preg_match(PENDING_CHECKBOX_PATTERN, $key, $matches) && $teamteaches[$matches[1]]) { $this->selected_teamteaches[] = $matches[1]; } } return $errorlog; }
function get_content() { if ($this->content !== NULL) { return $this->content; } global $CFG, $COURSE, $USER; $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; // Does the user have the right capability? // Line 4354 of lib/weblib.php suggests that a teacher // is defined by one being able to view details of other users $context = get_context_instance(CONTEXT_COURSE, $COURSE->id); if (!has_capability('moodle/user:viewdetails', $context)) { return $this->content; } $user = CoursePrefsUser::findByUnique($USER->username); // No Atheletes in the course means this block is hidden if (get_athelete_count($COURSE) == 0) { // If in Edit mode: display the no athletes text $edit = optional_param('edit', 0, PARAM_INT); if ($edit) { $this->content->text = '<span>' . get_string('no_atheletes', 'block_athelete_reporting') . '</span>'; } return $this->content; } // Check course's grade to pass $this->courseitem = grade_item::fetch_course_item($COURSE->id); if (is_siteadmin($USER->id)) { $sections = cps_sections($COURSE); } else { if ($user) { $sections = $user->getSectionsForMoodleCourse($COURSE); } else { return $this->content; } } $out = '<div class="block_athelete_reporting_body"> <form method="POST" action="' . $CFG->wwwroot . '/blocks/athelete_reporting/report.php">'; foreach ($sections as $section) { $atheletes = get_atheletes($section); if (!$atheletes) { continue; } $id = 'block_athelete_reporting_section_' . $section->id; $out .= '<div class="block_athelete_reporting_header"> <input type="image" src="' . $CFG->pixpath . '/t/switch_plus.gif" onclick="elementToggleHide(this, true, function(el) { return document.getElementById(\'' . $id . '\');}, \'Show Section\', \'Hide Section\'); return false;"> ' . get_string('format_section', 'block_courseprefs', $section) . ' </div> <div id="' . $id . '" class="block_athelete_reporting_section_body hidden"> ' . array_reduce($atheletes, array($this, 'reduce_athelete')) . ' </div>'; } if (!empty($sections)) { $out .= ' <input type="hidden" name="id" value="' . $COURSE->id . '"> <input type="submit" value="' . get_string('report', 'block_athelete_reporting') . '"> </form>'; } $out .= '<a href="' . $CFG->wwwroot . '/blocks/student_gradeviewer/analysis.php?id=' . $COURSE->id . '">' . get_string('analysis', 'block_student_gradeviewer') . '</a>'; $user = CoursePrefsUser::findByUnique($USER->username); if (!empty($CFG->cas_email) and $user and $user->getSectionsInfoAsTeacher(false, null, true)) { $out .= '<br/><span class="athlete_small_text"> <a href="' . $CFG->wwwroot . '/blocks/student_gradeviewer/options.php?id=' . $COURSE->id . '">' . get_string('options', 'block_student_gradeviewer') . '</a> </span>'; } $out .= '</div>'; $this->content->text = $out; return $this->content; }
/** * PROCESS ENROLLMENT FILE * Expects a file of format: Semester|Student PawsID|Campus|Department|Course #|Section #|Status Code|HRS|Real Date|EFFECTIVE DATE|FERP */ function parse_enrollfile($now, $line) { $fields = array_map('addslashes', array_map('trim', explode('|', $line))); // Process only if we have the correct number of fields if (count($fields) != 11) { $a->file = $this->files['enrollfile']; $a->line = $line; $this->errorlog[] = get_string('malformed', 'block_courseprefs', $a); return; } // Lookup necessary foreign keys for enrollment lookup; throw exception if any are missing list($year, $semester_name) = $this->parse_semester($fields[0]); $semester = CoursePrefsSemester::findByUnique($year, $semester_name, $fields[2]); if (!$semester) { $this->errorlog[] = 'Unable to lookup semester entry for enrollment in ' . $this->files['enrollfile'] . ': ' . $line; return; } $user = CoursePrefsUser::findByUnique($fields[1]); if (!$user) { $this->errorlog[] = 'Unable to lookup user entry for enrollment in ' . $this->files['enrollfile'] . ': ' . $line; return; } $course = CoursePrefsCourse::findByUnique($fields[3], $fields[4]); if (!$course) { $this->errorlog[] = 'Unable to lookup course entry for enrollment in ' . $this->files['enrollfile'] . ': ' . $line; return; } $section = CoursePrefsSection::findByUnique($semester->getId(), $course->getId(), $fields[5]); if (!$section) { $this->errorlog[] = 'Unable to lookup section entry for enrollment in ' . $this->files['enrollfile'] . ': ' . $line; return; } try { $new_fields = array(1, $fields[6], $fields[8], $fields[9], $fields[7]); $this->process_enrollment($user, $section, $new_fields); } catch (Exception $e) { $this->errorlog[] = $e->getMessage() . ' from ' . $this->files['enrollfile'] . ': ' . $line; } $user->setFerpa($fields[10]); try { $user->save(); } catch (Exception $e) { $this->errorlog[] = $e->getMessage() . ' from ' . $this->files['enrollfile'] . ': ' . $line; } }
function validation($data) { global $USER; $errorlog = array(); $form_errorlog = $this->_form->_errors; $user = CoursePrefsUser::findByUnique($USER->username); $courses = $user->getCoursesAsTeacher(); $this->course_create = array(); $this->course_enroll = array(); $enroll_default = CoursePrefsConfig::getNamedValue('course_enroll_days'); $create_default = CoursePrefsConfig::getNamedValue('course_create_days'); // Parse form submission and glean necessary information foreach ($data as $key => $value) { $matches = array(); if (preg_match(CREATE_DAYS_PATTERN, $key, $matches) && $courses[$matches[2]]) { if (!$this->course_create[$matches[1]]) { $this->course_create[$matches[1]] = array(); } $this->course_create[$matches[1]][$matches[2]] = $value; } else { if (preg_match(ENROLL_DAYS_PATTERN, $key, $matches) && $courses[$matches[2]]) { if (!$this->course_enroll[$matches[1]]) { $this->course_enroll[$matches[1]] = array(); } $this->course_enroll[$matches[1]][$matches[2]] = $value; } } } // Iterate over semesters and check course-specific settings are valid foreach ($this->course_create as $semestersid => $courses) { // Check whether the courses' creation value is greater than or equal to its enrollment value foreach ($courses as $coursesid => $value) { /*// Skip course if either of its create or enroll fields weren't submitted properly if ($form_errorlog[$semestersid . CREATE_DAYS_FIELD . $coursesid] || $form_errorlog[$semestersid . ENROLL_DAYS_FIELD . $coursesid]) { continue; }*/ $course_create_days = $this->course_create[$semestersid][$coursesid]; $course_enroll_days = $this->course_enroll[$semestersid][$coursesid]; if ($course_create_days === '0' || $course_enroll_days === '0') { unset($this->course_enroll[$semestersid][$coursesid]); unset($this->course_create[$semestersid][$coursesid]); $errorlog[$semestersid . COURSE_GROUP . $coursesid] = get_string('err_negative_number', 'block_courseprefs'); continue; } if ($course_create_days == '') { $this->course_create[$semestersid][$coursesid] = $create_default; } if ($course_enroll_days == '') { $this->course_enroll[$semestersid][$coursesid] = $enroll_default; } /* if ($course_create_days == '' && $course_enroll_days != '') { $a->name = 'Create'; $errorlog[$semestersid . COURSE_GROUP . $coursesid] = get_string('err_days_invalid', 'block_courseprefs', $a); } else if ($course_enroll_days == '' && $course_create_days!='') { $a->name = 'Enroll'; $errorlog[$semestersid . COURSE_GROUP . $coursesid] = get_string('err_days_invalid', 'block_courseprefs', $a); } */ // Log an error if the course's enrollment value is greater than the creation value if ($course_create_days < $course_enroll_days) { $errorlog[$semestersid . COURSE_GROUP . $coursesid] = get_string('err_create_enroll_compare', 'block_courseprefs'); } } } return $errorlog; }
function validation($data) { global $USER; $errorlog = array(); $form_errorlog = $this->_form->_errors; // Skip processing group if there were errors with any of the related group fields if ($form_errorlog[TEXTBOX_GROUP] || $form_errorlog[SECTIONSID_FIELD]) { return $errorlog; } // Parse form submission and glean necessary information $section_id = $data[SECTIONSID_FIELD]; $department = $data[DEPARTMENT_FIELD]; $course_number = $data[COURSE_NUMBER_FIELD]; $section_number = $data[SECTION_NUMBER_FIELD]; // Build sections ID to courses ID lookup for data validation $user = CoursePrefsUser::findByUnique($USER->username); $sections = $user->getSectionsAsTeacher(); // Log an error if the user isn't the primary teacher of the section selected if (!($sections[$section_id] && $user->isPrimaryTeacher($sections[$section_id]))) { $errorlog[TEXTBOX_GROUP] = get_string('err_not_primary', 'block_courseprefs'); return $errorlog; } // Log an error if the section selected doesn't exist $users_section = $sections[$section_id]; if (!$users_section) { $errorlog[TEXTBOX_GROUP] = get_string('err_unknown_section', 'block_courseprefs'); return $errorlog; } // Retrieve course related to critera and log an error if course doesn't exist $course = CoursePrefsCourse::findByUnique($department, $course_number); if (!$course) { $errorlog[TEXTBOX_GROUP] = get_string('err_unknown_course', 'block_courseprefs'); return $errorlog; } // Retrieve section related to critera and log an error if course doesn't exist $section = CoursePrefsSection::findByUnique($users_section->getSemestersId(), $course->getId(), $section_number); if (!$section) { $errorlog[TEXTBOX_GROUP] = get_string('err_unknown_section', 'block_courseprefs'); return $errorlog; } // Log an error if the user has already selected these sections to be team taught if (CoursePrefsTeamTeach::findByUnique($user->getId(), $users_section->getId(), $section->getId())) { $errorlog[TEXTBOX_GROUP] = get_string('err_same_teamteach', 'block_courseprefs'); return $errorlog; } // Determine the primary teacher of the foreign section $teachers = CoursePrefsTeacher::findBySectionId($section->getId()); $teacher_primary = null; foreach ($teachers as $teacher) { // Skip if teacher is not the primary teacher if (!$teacher->getPrimaryFlag()) { continue; } $teacher_primary = $teacher; break; } // Log an error if there isn't a primary teacher to notify or if the user teaches both courses. // Otherwise, store the ids of the sections selected for team teaching if (!$teacher_primary) { $errorlog[TEXTBOX_GROUP] = get_string('no_instructor', 'block_courseprefs'); } else { if ($teacher_primary->getUsersId() == $user->getId()) { $errorlog[TEXTBOX_GROUP] = get_string('same_teacher', 'block_courseprefs'); } else { $this->section_selections = $section_id; $this->secondary_teamteaches = $section->getId(); } } return $errorlog; }
/** * Deprecated */ static function findByUsername($username) { return CoursePrefsUser::findByUnique($username); }
function define_cps_user() { global $USER; $this->cps_user = CoursePrefsUser::findByUnique($USER->username); }
require_once 'classes/CoursePrefsUser.php'; require_once 'classes/CoursePrefsSplit.php'; require_once 'classes/CoursePrefsSection.php'; require_once 'classes/CoursePrefsLog.php'; require_once 'lib.php'; require_once 'split_form.php'; $selected = required_param('selected'); $number = required_param('number', PARAM_INT); $submit = required_param('submit'); // They want to go back, so take them back if ($submit == "Back") { redirect('split.php'); } list($semestersid, $courseid) = split_selected($selected); require_login(); $user = CoursePrefsUser::findByUnique($USER->username); // Oops, we don't know this fella if (!$user) { redirect_error(ERROR_USER_MISSING); } // Validation comes first $splittable = $user->getSplittableCourses(); // Hmm, selected entry is not splittable...? Hacker? if (!$splittable || !array_key_exists($courseid, $splittable[$semestersid])) { redirect_error(ERROR_COURSE_NONE); } $sections = $user->getSectionsInfoAsPrimaryTeacher(); if ($number < 2 || $number > count($sections)) { // error: number does not match the split citerion // user tried to hack post data redirect('split.php?selected=' . $selected);
function validation($data) { global $USER; $form_errorlog = $this->_form->_errors; $errorlog = array(); // Prematurely end form submission validation if any errors were encountered during submission if (array_key_exists(SECTIONSID_FIELD, $form_errorlog) || array_key_exists(CR_SECTIONSID_FIELD, $form_errorlog)) { return $errorlog; } $user = CoursePrefsUser::findByUnique($USER->username); $sections = $user->getSectionsAsPrimaryTeacher(); // Lookup selected sections from lookup of sections the user teaches $sectionsid = $data[SECTIONSID_FIELD]; $cr_sectionsid = $data[CR_SECTIONSID_FIELD]; $section = $sections[$sectionsid]; $cr_section = $sections[$cr_sectionsid]; // Log an error if the user isn't the primary instructor of the selected section if (!($section && $user->isPrimaryTeacher($section))) { $errorlog[SECTIONSID_FIELD] = get_string('err_crosslist_not_primary', 'block_courseprefs'); } // Log an error if the user isn't the primary instructor of the selected section to be cross listed if (!($cr_section && $user->isPrimaryTeacher($cr_section))) { $errorlog[CR_SECTIONSID_FIELD] = get_string('err_crosslist_not_primary', 'block_courseprefs'); } // Prematurely end form submission validation if any errors were encountered so far if ($errorlog) { return $errorlog; } // Log an error if the selected sections are the same // Log an error if the selected sections are not part of the same semester if ($sectionsid == $cr_sectionsid) { $errorlog[CR_SECTIONSID_FIELD] = get_string('err_crosslist_same_section', 'block_courseprefs'); } else { if ($section->getSemestersId() != $cr_section->getSemestersId()) { $errorlog[CR_SECTIONSID_FIELD] = get_string('err_crosslist_different_semester', 'block_courseprefs'); } } // Prematurely end form submission validation if any errors were encountered so far if ($errorlog) { return $errorlog; } // Validate form submission against existing cross listing entries $crosslists = $user->getCrosslists(); foreach ($crosslists as $id => $crosslist) { // Log an error if the primary section selected is already cross listed as a secondary section if ($sectionsid == $crosslist->getCrSectionsId()) { $errorlog[SECTIONSID_FIELD] = get_string('err_crosslist_section_is_a_secondary', 'block_courseprefs'); } // Log an error if the secondary section selected is already cross listed as a primary section if ($cr_sectionsid == $crosslist->getSectionsId()) { $errorlog[CR_SECTIONSID_FIELD] = get_string('err_crosslist_section_is_a_primary', 'block_courseprefs'); } // Log an error if the user has previously selected the primary and secondary sections // Log an error if the secondary section selected is already cross listed as a secondary section if ($sectionsid == $crosslist->getSectionsId() && $cr_sectionsid == $crosslist->getCrSectionsId()) { $errorlog[CR_SECTIONSID_FIELD] = get_string('err_crosslist_not_unique', 'block_courseprefs'); } else { if ($cr_sectionsid == $crosslist->getCrSectionsId()) { $errorlog[CR_SECTIONSID_FIELD] = get_string('err_crosslist_section_is_a_secondary', 'block_courseprefs'); } } } return $errorlog; }
public function get_options() { global $CFG, $USER, $COURSE; if (!isset($this->user)) { require_once $CFG->dirroot . '/blocks/courseprefs/classes/CoursePrefsUser.php'; $this->user = CoursePrefsUser::findByUnique($USER->username); } if (!isset($this->course)) { $this->course = $COURSE->id == 1 ? null : $COURSE; } if (isset($this->callback)) { $sections = call_user_func($this->callback, $this); } if (empty($sections) and is_siteadmin($USER->id) and $this->course) { $sections = cps_sections($this->course); } if (empty($sections) and $this->user) { $sections = $this->user->getSectionsForMoodleCourse($this->course, false); } $this->sections = $sections; return $sections ? array_map(array($this, 'transform_section'), $sections) : array(); }