Skip to content

Commit

Permalink
MDL-37329 Navigation: Enrolled courses in category should be added only.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajesh Taneja authored and Damyon Wiese committed Feb 20, 2013
1 parent cfd2add commit 0627e1c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/navigationlib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2757,9 +2757,11 @@ protected function load_category($categoryid, $nodetype = self::TYPE_CATEGORY) {
ORDER BY cc.depth ASC, cc.sortorder ASC, cc.id ASC"; ORDER BY cc.depth ASC, cc.sortorder ASC, cc.id ASC";
$params = array('categoryid1' => $categoryid, 'categoryid2' => $categoryid); $params = array('categoryid1' => $categoryid, 'categoryid2' => $categoryid);
$categories = $DB->get_recordset_sql($sql, $params, 0, $limit); $categories = $DB->get_recordset_sql($sql, $params, 0, $limit);
$categorylist = array();
$subcategories = array(); $subcategories = array();
$basecategory = null; $basecategory = null;
foreach ($categories as $category) { foreach ($categories as $category) {
$categorylist[] = $category->id;
context_helper::preload_from_record($category); context_helper::preload_from_record($category);
if ($category->id == $categoryid) { if ($category->id == $categoryid) {
$this->add_category($category, $this, $nodetype); $this->add_category($category, $this, $nodetype);
Expand All @@ -2780,7 +2782,10 @@ protected function load_category($categoryid, $nodetype = self::TYPE_CATEGORY) {
if ($nodetype === self::TYPE_MY_CATEGORY) { if ($nodetype === self::TYPE_MY_CATEGORY) {
$courses = enrol_get_my_courses(); $courses = enrol_get_my_courses();
foreach ($courses as $course) { foreach ($courses as $course) {
$this->add_course($course, true, self::COURSE_MY); // Add course if it's in category.
if (in_array($course->category, $categorylist)) {
$this->add_course($course, true, self::COURSE_MY);
}
} }
} else { } else {
$courses = $DB->get_recordset('course', array('category' => $categoryid), 'sortorder', '*' , 0, $limit); $courses = $DB->get_recordset('course', array('category' => $categoryid), 'sortorder', '*' , 0, $limit);
Expand Down

0 comments on commit 0627e1c

Please sign in to comment.