General help

 
 
Picture of Martin Burrow
My Moodle: My Moodle how to show only courses enrolled on
 

Using 1.9.2

Hi, as far as I understand it the course list in My Moodle shows all the courses a user able to 'view'. So when the students go to My Moodle they see a list of all the courses they have ever visited, as well as any they are actually enrolled on. I would like to narrow this down so that just courses they are enrolled in are displayed in the list.

Looking at the code my moodle /index.php uses  "get_my_courses"  which in turn mainly uses "get_user_courses_bycap"   which goes by moodle/course:view .   

 Is there a capability that will narrow down the results to just enrolled courses???  

 have seen moodle/course:participate but that looks like just for M2.0

or is there any other function that will pull out courses that a user ID has a particular role in??

Thanks

 
Average of ratings: -
Picture of Jamie Tinley
Re: My Moodle: My Moodle how to show only courses enrolled on
 

Hi Martin. Did you find a solution?  I've been searching for hours too.  I created a new role with view courses allowed.  I assigned some parents to this role systemwide. It works for me because it allows them to see all courses but not enroll in them. However, their mymoodle page shows courses they have never even visited let alone enrolled in.  They DO show up as participants but not in the locally assigned course role. Many searches suggested two alternate solutions which were dead ends: that the course category 'assign' roles was used: no. and that the systemwide role authenticated users was conflicting with my new role. not that I can see.  Various trackers suggest how to hide certain assignments but that's not what I want.  I created a new course and it shows up but others don't show up and I can see no differences. resetting these courses did not work because it's the site front page role not the course role.  Index.php in My folder seems a good place to edit but I'm not a php programmer.  Any ideas would be helpful - I hope you found a solution.

 
Average of ratings: -
Picture of Ciro Baron Neto
Re: My Moodle: My Moodle how to show only courses enrolled on
 

Hi Guys,

I had the same problem here and a good solution is comment the line 2578 of the /couse/lib.php file.

} else {
if ($DB->count_records("course_categories") > 1) {
echo $OUTPUT->box_start("categorybox");
print_whole_category_list();
echo $OUTPUT->box_end();
} else {
//print_courses(0);     <- COMMENT THIS LINE
}
}

 

Cheers!

 
Average of ratings: -
Picture of Pere O.
Re: My Moodle: My Moodle how to show only courses enrolled on
 

I don't see why Moodle, while having so many settings pages, still doesn't have a configurable option for this.

Anyways, that solution worked for me with 2.3, but no with 2.4.

I ended up modifying print_courses() function inside course/lib.php: 

/**
 * Category is 0 (for all courses) or an object
 */
function print_courses($category) {
    // CHANGE1: Disable course listing for non administrators. We used https://moodle.org/mod/forum/discuss.php?d=164375#p846068 before.
    if (!has_capability('moodle/site:config', context_system::instance())) {
        return;
    }
    // END CHANGE1;
 
Average of ratings: -
Picture of Pere O.
Re: My Moodle: My Moodle how to show only courses enrolled on
 

Hi, this is only to disencourage the use of this and similar patches. They are the source of a lot of problems, see for example: https://moodle.org/mod/forum/discuss.php?d=220279

 
Average of ratings: -