Hi Jaimie. I'm trying to follow all your instructions but I have problems finding the blocks you mentioned. I've already installed flex page, but cannot find the site where I can download the other 2 blocks (profile redirect and courses available). The only stuff I've found are manuals. Can you help me aout with this? Please?...
Hi guys, I'm having the same issue, we are using Moodle 2.4.6, and we have students that enroll on a course, but then they are able to see all the other courses that they are NOT enrolled in. How do i hide those courses from them?
PS: am 100% new to moodle
Thanks
M
BTW: i think i have tried everything, spent 2 hours playing around with the settings, hiding courses, changing permissions, all to no avail.. please HELP
This tweek is for Moodle 2.6 and may work with 2.x
In my moodle units are displayed as 'Combo list'. So if you have a different setting you might have to adapt the code.
Script file to edit course/renderer.php
To hide units that users have no access to
This bit is easy and straightforward. You simply have to add a line of code
in function coursecat_courses(...)
in foreach ($courses as $course) {
if($course->can_access()) // add this line
$content .= $this->coursecat_coursebox($chelper, $course, $classes); // just before this line
To hide categories with no accessable units
This part is a bit tricky. The function coursecat_category_content() returns HTML code that is placed under each category. What I look for here is if there is any units in that block. Each unit is wrapped in a div tag with a class 'coursebox'. So we search for this and if found concludes that this category has units and hence display it. The code is added in 3 parts of the function.
in function coursecat_category(...)
$hidecat = false; // add this in the beginning
.
.
.
// load category content
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, $depth); // under this line
if(strpos($categorycontent,'coursebox')===false) // add this two lines
$dol_hidecat = true; // and this line too
.
.
.
if($dol_hidecat) // just before the return an the end of the function, add this two lines
$content = '';
return $content;
Hi Alfie,
I'd been looking for a way to hide courses from unenrolled users for a long time, and your solution seems to have worked. Thanks for that!
But there is still one problem. After I added the code, although users are now only able to see the courses they are enrolled into, a warning appears on the front page:
Notice: Undefined variable: dol_hidecat in /home/platne/cubeenglish/public_html/moodle/course/renderer.php on line 1640 Notice: Undefined variable: dol_hidecat in /home/platne/cubeenglish/public_html/moodle/course/renderer.php on line 1640
This seems like a simple enough problem to overcome, but as I'm just starting out with php it exceeds my capacities.
Would appreciate any help!
Luko
Sorry Luko for getting back to you after a long while.
The solution is to declare the variable
$dol_hidecat = false;
Just before the if statement.