Skip to content
Snippets Groups Projects
Commit a588c7ce authored by Matt Petro's avatar Matt Petro
Browse files

Separate courses into current and other groups

parent 01e0a136
No related branches found
No related tags found
No related merge requests found
...@@ -101,16 +101,24 @@ class block_course_overview_uwmoodle extends block_base { ...@@ -101,16 +101,24 @@ class block_course_overview_uwmoodle extends block_base {
$terms[self::TERM_OTHER][] = $course; $terms[self::TERM_OTHER][] = $course;
} }
} }
// Sort terms, descending
// TERM_OTHER courses get ordered right after current term // Sort terms with the current term and Misc terms first, followed by others in decreasing order
$term_other = self::TERM_OTHER; // closures in php < 5.4 don't include class information $sortedterms = array();
$sortfcn = function($a,$b) use ($currentterm, $term_other) { if (isset($terms[$currentterm])) {
if ($a == $term_other) { $a = $currentterm - 0.5; } $sortedterms[$currentterm] = $terms[$currentterm];
if ($b == $term_other) { $b = $currentterm - 0.5; } unset($terms[$currentterm]);
if ($a == $b) {return 0;} }
return ($a > $b)? -1 : 1; if (isset($terms[self::TERM_OTHER])) {
}; $sortedterms[self::TERM_OTHER] = $terms[self::TERM_OTHER];
uksort($terms, $sortfcn); unset($terms[self::TERM_OTHER]);
}
ksort($terms);
$terms = array_reverse($terms, true);
// can't use array_merge as the termCodes are numeric, and we want them preserved
foreach ($terms as $termCode=>$term) {
$sortedterms[$termCode] = $term;
}
$terms = $sortedterms;
// Update lastaccess for news summary // Update lastaccess for news summary
foreach ($courses as $c) { foreach ($courses as $c) {
...@@ -141,7 +149,18 @@ class block_course_overview_uwmoodle extends block_base { ...@@ -141,7 +149,18 @@ class block_course_overview_uwmoodle extends block_base {
// display courses // display courses
echo '<div class="courselist">'; echo '<div class="courselist">';
echo '<ul class="treelist">'; echo '<ul class="treelist">';
if (isset($terms[$currentterm]) || isset($terms[self::TERM_OTHER])) {
echo '<h3>Current semester</h3>';
}
$incurrentterms = true;
foreach ($terms as $termcode=>$termcourses) { foreach ($terms as $termcode=>$termcourses) {
if ($incurrentterms && $termcode != $currentterm && $termcode != self::TERM_OTHER) {
//display the separator between current and other terms
echo '<hr />';
echo '<h3>Other semesters</h3>';
$incurrentterms = false;
}
$yuiitems[] = "term-$termcode"; $yuiitems[] = "term-$termcode";
$termname = $this->get_term_name($termcode); $termname = $this->get_term_name($termcode);
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
.block_course_overview_uwmoodle li ul {margin: 0;padding-left:16px;} .block_course_overview_uwmoodle li ul {margin: 0;padding-left:16px;}
.block_course_overview_uwmoodle .coursebox h3 {margin-left:10px;} .block_course_overview_uwmoodle .coursebox h3 {margin-left:10px;}
.block_course_overview_uwmoodle h3 {font-size:1.1em;} .block_course_overview_uwmoodle h3 {font-size:1.1em;}
.block_course_overview_uwmoodle .noncurrentterm .term {color:#AAAAAA;} .block_course_overview_uwmoodle .othersems {}
.block_course_overview_uwmoodle .term {color:#000;} .block_course_overview_uwmoodle .term {color:#000;font-weight:normal;}
.block_course_overview_uwmoodle .shownews {float:right;color:#333;font-weight:normal;margin-right:1em;font-size:91%;} .block_course_overview_uwmoodle .shownews {float:right;color:#333;font-weight:normal;margin-right:1em;font-size:91%;}
.block_course_overview_uwmoodle a:focus, .block_course_overview_uwmoodle a:focus,
.block_course_overview_uwmoodle a:hover, .block_course_overview_uwmoodle a:hover,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment