Filter 'My Courses' dropdown by category name

Filter 'My Courses' dropdown by category name

by Ionuț Vîlsan -
Number of replies: 0

Hello everyone, 

I am new to moodle so please do not kill for noob mistakes.

I added My Courses dropdown button to the custom menu items and everything is working good until now, I can see for each user his courses in the dropdown . What I am trying to do now is to filter the courses that are shown by category name . My final approach would be to have 2 dropdown menus one with ' My courses' and one with 'Tests' 

Here I want to have courses that are not in the 'Test' category


Here I want to have courses that are in the 'Test' category



As you have seen above I do not have any filter now and both courses from different categories are listed in both dropdowns.

This is my code added in core_renderer.php file / render_custom_menu () function 

// my courses 

 if (isloggedin() ) {

 $branchlabel = get_string('mycourses');

 $branchurl = new moodle_url('/course/index.php');

 $branchtitle = $branchlabel;

 $branch = $menu->add($branchlabel, $branchurl, $branchtitle, -1);

 foreach ($mycourses->children as $coursenode) {

 $branch->add($coursenode->get_content(), $coursenode->action, $coursenode->get_title());

 }

 }

 // tests 

 if (isloggedin() ) {

 $branchlabeltest = get_string('teste');

 $branchurltest = new moodle_url('/course/index.php');

 $branchtitletest = $branchlabeltest;

 $branch = $menu->add($branchlabeltest, $branchurltest, $branchtitletest, 0);

 foreach ($mycourses->children as $coursenode) { $branch->add($coursenode->get_content(), $coursenode->action, $coursenode->get_title()); 

 }

 }



Thank you ! 

Average of ratings: -