diff --git a/block_course_overview_uwmoodle.php b/block_course_overview_uwmoodle.php index 6b307e27b030dd4e53d580d9182103832610d4ce..008248c72ad36b60fd456a34f8f4619b2e128a15 100644 --- a/block_course_overview_uwmoodle.php +++ b/block_course_overview_uwmoodle.php @@ -101,16 +101,24 @@ class block_course_overview_uwmoodle extends block_base { $terms[self::TERM_OTHER][] = $course; } } - // Sort terms, descending - // TERM_OTHER courses get ordered right after current term - $term_other = self::TERM_OTHER; // closures in php < 5.4 don't include class information - $sortfcn = function($a,$b) use ($currentterm, $term_other) { - if ($a == $term_other) { $a = $currentterm - 0.5; } - if ($b == $term_other) { $b = $currentterm - 0.5; } - if ($a == $b) {return 0;} - return ($a > $b)? -1 : 1; - }; - uksort($terms, $sortfcn); + + // Sort terms with the current term and Misc terms first, followed by others in decreasing order + $sortedterms = array(); + if (isset($terms[$currentterm])) { + $sortedterms[$currentterm] = $terms[$currentterm]; + unset($terms[$currentterm]); + } + if (isset($terms[self::TERM_OTHER])) { + $sortedterms[self::TERM_OTHER] = $terms[self::TERM_OTHER]; + 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 foreach ($courses as $c) { @@ -141,7 +149,18 @@ class block_course_overview_uwmoodle extends block_base { // display courses echo '<div class="courselist">'; 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) { + + 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"; $termname = $this->get_term_name($termcode); diff --git a/styles.css b/styles.css index 437fbd4504b2f8a160cd5a45847a819f17fe01ac..d746cd46cc0e5cf2882e99d229cbb9f57455492a 100644 --- a/styles.css +++ b/styles.css @@ -13,8 +13,8 @@ .block_course_overview_uwmoodle li ul {margin: 0;padding-left:16px;} .block_course_overview_uwmoodle .coursebox h3 {margin-left:10px;} .block_course_overview_uwmoodle h3 {font-size:1.1em;} -.block_course_overview_uwmoodle .noncurrentterm .term {color:#AAAAAA;} -.block_course_overview_uwmoodle .term {color:#000;} +.block_course_overview_uwmoodle .othersems {} +.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 a:focus, .block_course_overview_uwmoodle a:hover,