Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 11 files changed
  • 0 commit comments
  • 1 contributor
Showing with 101 additions and 110 deletions.
  1. +14 −3 classes/lib.php
  2. +1 −2 events/ues.php
  3. +1 −2 formslib.php
  4. +1 −1 lang/en/block_cps.php
  5. +6 −6 split.php
  6. +23 −20 split_form.php
  7. +4 −0 styles.css
  8. +4 −4 team_request.php
  9. +37 −60 team_request_form.php
  10. +7 −7 team_section.php
  11. +3 −5 team_section_form.php
View
17 classes/lib.php
@@ -226,16 +226,23 @@ class cps_split extends ues_user_section_accessor implements unique, undoable, v
var $groupingid;
public static function is_valid($courses) {
- $valids = self::filter_valid($courses);
+ $valids = self::filter_valid_courses($courses);
return !empty($valids);
}
- public static function filter_valid($courses) {
+ public static function filter_valid_courses($courses) {
return array_filter($courses, function ($course) {
return count($course->sections) > 1;
});
}
+ public static function filter_valid($semesters) {
+ return array_filter($semesters, function($semester) {
+ $semester->courses = cps_split::filter_valid_courses($semester->courses);
+ return count($semester->courses) > 0;
+ });
+ }
+
public static function in_course($course) {
global $USER;
@@ -247,6 +254,9 @@ public static function in_course($course) {
$sections = cps_unwant::active_sections_for($teacher, true);
foreach ($sections as $section) {
+ if ($section->courseid != $course->id) {
+ continue;
+ }
$course->sections[$section->id] = $section;
}
}
@@ -569,8 +579,9 @@ public function label($from_userid = null) {
}
$sem = $this->semester();
+ $session = $sem->get_session_key();
- $label = "$sem->year $sem->name $course->department $course->cou_number";
+ $label = "$sem->year $sem->name$session $course->department $course->cou_number";
return $label . ' with ' . fullname($user);
}
View
3 events/ues.php
@@ -200,8 +200,7 @@ public static function ues_course_create($course) {
}
$semester = $section->semester();
- $session = !empty($semester->session_key) ?
- ' (' . $semester->session_key . ')' : '';
+ $session = $semester->get_session_key();
$ues_course = $section->course();
View
3 formslib.php
@@ -120,8 +120,7 @@ public function display_course($course, $sem) {
}
public function display_semester($sem) {
- $session = !empty($sem->session_key) ?
- ' (' . $sem->session_key. ')' : '';
+ $session = $sem->get_session_key();
return "$sem->year $sem->name$session";
}
View
2 lang/en/block_cps.php
@@ -137,7 +137,7 @@
// Team Requests
$string['team_request'] = 'Team Teach Requests';
-$string['team_query_for'] = 'Query a course: {$a->year} {$a->name}';
+$string['team_query_for'] = 'Query course: {$a->year} {$a->name} {$a->session_key}';
$string['team_teachers'] = 'Select one or more Instructors';
View
12 split.php
@@ -22,11 +22,11 @@
print_error('no_section', 'block_cps');
}
-$courses = ues_course::merge_sections($sections);
+$semesters = ues_semester::merge_sections($sections);
-$valid_courses = cps_split::filter_valid($courses);
+$valid_semesters = cps_split::filter_valid($semesters);
-if (empty($valid_courses)) {
+if (empty($valid_semesters)) {
print_error('no_courses', 'block_cps');
}
@@ -48,7 +48,7 @@
$PAGE->requires->js('/blocks/cps/js/selection.js');
$PAGE->requires->js('/blocks/cps/js/split.js');
-$form = split_form::create($valid_courses);
+$form = split_form::create($valid_semesters);
if ($form->is_cancelled()) {
redirect(new moodle_url('/my'));
@@ -61,7 +61,7 @@
$form = new split_form_finish();
try {
- $form->process($data, $valid_courses);
+ $form->process($data, $valid_semesters);
$form->display();
} catch (Exception $e) {
@@ -72,7 +72,7 @@
die();
}
- $form = split_form::next_from($form->next, $data, $valid_courses);
+ $form = split_form::next_from($form->next, $data, $valid_semesters);
}
echo $OUTPUT->header();
View
43 split_form.php
@@ -28,30 +28,29 @@ class split_form_select extends split_form {
var $current = self::SELECT;
var $next = self::SHELLS;
- public static function build($courses) {
- return array('courses' => $courses);
+ public static function build($semesters) {
+ return array('semesters' => $semesters);
}
function definition() {
$m =& $this->_form;
$m->addElement('header', 'select', self::_s('select'));
- $semesters = ues_semester::get_all();
-
- $courses = $this->_customdata['courses'];
+ $semesters = $this->_customdata['semesters'];
- foreach ($courses as $course) {
+ foreach ($semesters as $semester) {
- $semester = $semesters[reset($course->sections)->semesterid];
+ foreach ($semester->courses as $course) {
+ $display = ' ' . $this->display_course($course, $semester);
- $display = ' ' . $this->display_course($course, $semester);
+ if (cps_split::exists($course)) {
+ $display .= ' (' . self::_s('split_option_taken') . ')';
+ }
- if (cps_split::exists($course)) {
- $display .= ' (' . self::_s('split_option_taken') . ')';
+ $key = $semester->id . '_' . $course->id;
+ $m->addElement('radio', 'selected', '', $display, $key);
}
-
- $m->addElement('radio', 'selected', '', $display, $course->id);
}
$m->addRule('selected', self::_s('err_select_one'), 'required', null, 'client');
@@ -60,19 +59,20 @@ function definition() {
}
function validation($data) {
- $courses = $this->_customdata['courses'];
+ $semesters = $this->_customdata['semesters'];
if (empty($data['selected'])) {
return array('selected' => self::_s('err_select_one'));
}
- if (empty($courses[$data['selected']])) {
+ list($semid, $couid) = explode('_', $data['selected']);
+ if (empty($semesters[$semid]->courses[$couid])) {
return array('selected' => self::_s('err_select'));
}
$errors = array();
- $course = $courses[$data['selected']];
+ $course = $semesters[$semid]->courses[$couid];
$section_count = count($course->sections);
@@ -97,10 +97,12 @@ class split_form_shells extends split_form {
var $next = self::DECIDE;
var $prev = self::SELECT;
- public static function build($courses) {
- $selected = required_param('selected', PARAM_INT);
+ public static function build($semesters) {
+ $selected = required_param('selected', PARAM_RAW);
+
+ list($semid, $couid) = explode('_', $selected);
- return array('course' => $courses[$selected]);
+ return array('course' => $semesters[$semid]->courses[$couid]);
}
function definition() {
@@ -406,8 +408,9 @@ function validation($data) {
class split_form_finish implements finalized_form {
- function process($data, $valid_courses) {
- $course = $valid_courses[$data->selected];
+ function process($data, $semesters) {
+ list($semid, $couid) = explode('_', $data->selected);
+ $course = $semesters[$semid]->courses[$couid];
$current_splits = cps_split::in_course($course);
View
4 styles.css
@@ -3,6 +3,10 @@
text-align: center;
}
+.split_available_sections select[multiple] {
+ min-height: 200px;
+}
+
.split_available_sections {
float: left;
padding: 0 0 0 15px;
View
8 team_request.php
@@ -24,7 +24,7 @@
print_error('no_section', 'block_cps');
}
-$courses = ues_course::merge_sections($sections);
+$semesters = ues_semester::merge_sections($sections);
$_s = ues::gen_str('block_cps');
@@ -40,7 +40,7 @@
$PAGE->set_url('/blocks/cps/team_request.php');
$PAGE->set_pagetype('cps-teamteach');
-$form = team_request_form::create($courses);
+$form = team_request_form::create($semesters);
if ($form->is_cancelled()) {
redirect(new moodle_url('/my'));
@@ -53,7 +53,7 @@
} else if ($form->next == team_request_form::FINISHED) {
$form = new team_request_form_finish();
- $form->process($data, $courses);
+ $form->process($data, $semesters);
$form->display();
@@ -64,7 +64,7 @@
)));
}
- $form = team_request_form::next_from($form->next, $data, $courses);
+ $form = team_request_form::next_from($form->next, $data, $semesters);
}
echo $OUTPUT->header();
View
97 team_request_form.php
@@ -24,38 +24,30 @@ class team_request_form_select extends team_request_form {
var $current = self::SELECT;
var $next = self::SHELLS;
- public static function build($courses) {
- return array('courses' => $courses);
+ public static function build($semesters) {
+ return array('semesters' => $semesters);
}
function definition() {
$m =& $this->_form;
- $courses = $this->_customdata['courses'];
-
- $semesters = array();
+ $semesters = $this->_customdata['semesters'];
$m->addElement('header', 'select_course', self::_s('select'));
- foreach ($courses as $course) {
- foreach ($course->sections as $section) {
- $id = $section->semesterid;
- if (isset($semesters[$id])) {
- continue;
- }
+ foreach ($semesters as $semester) {
+ foreach ($semester->courses as $course) {
- $semesters[$id] = $section->semester();
- }
+ $display = $this->display_course($course, $semester);
- $semester = $semesters[$id];
+ if (cps_team_request::exists($course, $semester)) {
+ $display .= ' (' . self::_s('team_request_option') . ')';
+ }
- $display = "$semester->year $semester->name $course->department $course->cou_number";
+ $key = $semester->id . '_' . $course->id;
- if (cps_team_request::exists($course, $semester)) {
- $display .= ' (' . self::_s('team_request_option') . ')';
+ $m->addElement('radio', 'selected', '', $display, $key);
}
-
- $m->addElement('radio', 'selected', '', $display, $course->id);
}
$m->addRule('selected', self::_s('err_select_one'), 'required', null, 'client');
@@ -68,9 +60,11 @@ function validation($data) {
return array('selected' => self::_s('err_select_one'));
}
- $course = $this->_customdata['courses'][$data['selected']];
+ list($semid, $couid) = explode('_', $data['selected']);
+ $semesters = $this->_customdata['semesters'];
- $semester = reset($course->sections)->semester();
+ $semester = $semesters[$semid];
+ $course = $semester->courses[$couid];
if (cps_team_request::exists($course, $semester)) {
$this->next = self::UPDATE;
@@ -107,9 +101,7 @@ function definition() {
$semester = $this->_customdata['semester'];
- $to_display = function ($course) use ($semester) {
- return "$semester->year $semester->name $course->department $course->cou_number";
- };
+ $to_display = $this->to_display($semester);
$m->addElement('header', 'selected_course', $to_display($course));
@@ -193,8 +185,6 @@ function definition() {
$m->addElement('hidden', 'selected', '');
$m->addElement('hidden', 'shells', $groupingid);
- $m->addElement('hidden', 'semesterid', $semester->id);
-
foreach ($queries as $number => $query) {
$users = implode(',', $selected_users[$number]);
@@ -249,9 +239,7 @@ function definition() {
$semester = $this->_customdata['semester'];
- $to_display = function ($course) use ($semester) {
- return "$semester->year $semester->name $course->department $course->cou_number";
- };
+ $to_display = $this->to_display($semester);
$to_bold = function ($text) { return "<strong>$text</strong>"; };
@@ -314,7 +302,6 @@ function definition() {
}
$m->addElement('hidden', 'selected', '');
- $m->addElement('hidden', 'semesterid', $semester->id);
$m->addElement('hidden', 'update_option', '');
@@ -367,9 +354,7 @@ function definition() {
$semester = $this->_customdata['semester'];
- $to_display = function ($course) use ($semester) {
- return "$semester->year $semester->name $course->department $course->cou_number";
- };
+ $to_display = $this->to_display($semester);
$team_teaches = cps_team_request::in_course($course, $semester);
@@ -417,7 +402,6 @@ function definition() {
$m->addElement('hidden', 'selected', '');
$m->addElement('hidden', 'update_option', '');
- $m->addElement('hidden', 'semesterid', $semester->id);
$this->generate_states_and_buttons();
}
@@ -428,12 +412,15 @@ class team_request_form_shells extends team_request_form {
var $prev = self::SELECT;
var $next = self::QUERY;
- public static function build($courses) {
- $selected = required_param('selected', PARAM_INT);
+ public static function build($semesters) {
+ $selected = required_param('selected', PARAM_RAW);
- $semester = reset($courses[$selected]->sections)->semester();
+ list($semid, $couid) = explode('_', $selected);
- return array('selected_course' => $courses[$selected], 'semester' => $semester);
+ $semester = $semesters[$semid];
+ $course = $semester->courses[$couid];
+
+ return array('selected_course' => $course, 'semester' => $semester);
}
function definition() {
@@ -443,7 +430,7 @@ function definition() {
$sem = $this->_customdata['semester'];
- $display = "$sem->year $sem->name $course->department $course->cou_number";
+ $display = $this->display_course($course, $sem);
$m->addElement('header', 'selected_course', $display);
@@ -454,8 +441,6 @@ function definition() {
$m->addElement('select', 'shells', self::_s('team_how_many'), $options);
$m->addElement('hidden', 'selected', '');
- $m->addElement('hidden', 'semesterid', $sem->id);
-
$this->generate_states_and_buttons();
}
@@ -501,7 +486,7 @@ function definition() {
$this->prev = self::UPDATE;
}
- $display = "$semester->year $semester->name $course->department $course->cou_number";
+ $display = $this->display_course($course, $semester);
$m->addElement('header', 'selected_course', $display);
@@ -542,7 +527,6 @@ function definition() {
$m->addElement('hidden', 'shells', '');
$m->addElement('hidden', 'reshell', 0);
- $m->addElement('hidden', 'semesterid', $semester->id);
$this->generate_states_and_buttons();
}
@@ -652,9 +636,7 @@ function definition() {
$this->prev;
}
- $to_display = function ($course) use ($semester) {
- return "$semester->year $semester->name $course->department $course->cou_number";
- };
+ $to_display = $this->to_display($semester);
$m->addElement('header', 'selected_course', $to_display($selected_course));
@@ -706,8 +688,6 @@ function definition() {
$m->addElement('hidden', 'selected', '');
$m->addElement('hidden', 'shells', '');
$m->addElement('hidden', 'reshell', 0);
- $m->addElement('hidden', 'semesterid', $semester->id);
-
$this->generate_states_and_buttons();
}
@@ -765,9 +745,7 @@ function definition() {
$semester = $this->_customdata['semester'];
- $to_display = function ($course) use ($semester) {
- return "$semester->year $semester->name $course->department $course->cou_number";
- };
+ $to_display = $this->to_display($semester);
$m->addElement('header', 'review', self::_s('review_selection'));
@@ -809,18 +787,17 @@ function definition() {
$m->addElement('hidden', 'update_option', $update_option);
}
- $m->addElement('hidden', 'semesterid', $semester->id);
-
$this->generate_states_and_buttons();
}
}
class team_request_form_finish implements finalized_form {
- function process($data, $courses) {
+ function process($data, $semesters) {
- $course = $courses[$data->selected];
+ list($semid, $couid) = explode('_', $data->selected);
- $semester = ues_semester::get(array('id' => $data->semesterid));
+ $semester = $semesters[$semid];
+ $course = $semester->courses[$couid];
$teamteaches = cps_team_request::in_course($course, $semester);
@@ -829,7 +806,7 @@ function process($data, $courses) {
if ($exists and $data->update_option == team_request_form_update::MANAGE_REQUESTS) {
$this->handle_approvals($data, $teamteaches);
} else {
- $this->save_or_update($data, $teamteaches);
+ $this->save_or_update($data, $teamteaches, $couid, $semid);
}
}
@@ -862,7 +839,7 @@ function undo($teamteaches) {
}
}
- function save_or_update($data, $current_teamteaches) {
+ function save_or_update($data, $current_teamteaches, $couid, $semid) {
global $USER;
foreach (range(1, $data->shells) as $number) {
@@ -876,8 +853,8 @@ function save_or_update($data, $current_teamteaches) {
foreach ($selected as $userid) {
$params = array (
'userid' => $USER->id,
- 'courseid' => $data->selected,
- 'semesterid' => $data->semesterid,
+ 'courseid' => $couid,
+ 'semesterid' => $semid,
'requested_course' => $requested->id,
'requested' => $userid
);
View
14 team_section.php
@@ -22,17 +22,17 @@
print_error('no_section', 'block_cps');
}
-$courses = ues_course::merge_sections($sections);
+$semesters = ues_semester::merge_sections($sections);
-$courseid = required_param('id', PARAM_INT);
+$key = required_param('id', PARAM_RAW);
+list($semid, $couid) = explode('_', $key);
-if (!isset($courses[$courseid])) {
+if (!isset($semesters[$semid]) or !isset($semesters[$semid]->courses[$couid])) {
print_error('not_course', 'block_cps');
}
-$course = $courses[$courseid];
-
-$semester = reset($course->sections)->semester();
+$semester = $semesters[$semid];
+$course = $semester->courses[$couid];
$current_requests = cps_team_request::in_course($course, $semester, true);
@@ -57,7 +57,7 @@
$PAGE->set_heading($blockname . ': '. $heading);
$PAGE->navbar->add($blockname);
$PAGE->navbar->add($heading);
-$PAGE->set_url('/blocks/cps/team_section.php', array('id' => $courseid));
+$PAGE->set_url('/blocks/cps/team_section.php', array('id' => $key));
$PAGE->set_pagetype('cps-teamteach');
$PAGE->requires->js('/lib/jquery.js');
View
8 team_section_form.php
@@ -84,7 +84,7 @@ function definition() {
$m->addElement('static', 'continue_build', '', self::_s('team_continue_build'));
- $m->addElement('hidden', 'id', $course->id);
+ $m->addElement('hidden', 'id', $semester->id . '_' . $course->id);
$this->is_a_master = $is_a_master;
$this->not_a_master = $not_a_master;
@@ -312,7 +312,7 @@ function definition() {
list($course, $semester, $requests) = $this->extract_data();
- $display = "$semester->year $semester->name";
+ $display = "$semester->year $semester->name" . $semester->get_session_key();
$all_courses = array($course->id => $course);
@@ -495,7 +495,7 @@ function definition() {
list($course, $semester, $requests) = $this->extract_data();
- $display = "$semester->year $semester->name";
+ $display = "$semester->year $semester->name" . $semester->get_session_key();
$to_coursename = function ($course) {
return "$course->department $course->cou_number";
@@ -566,8 +566,6 @@ class team_section_form_finish implements finalized_form, updating_form {
var $id;
function process($data, $initial_data) {
- $this->id = $data->id;
-
$requests = $initial_data['requests'];
$course = $initial_data['course'];

No commit comments for this range

Something went wrong with that request. Please try again.