Course and course categories invisible

Course and course categories invisible

by Artem Andreev -
Number of replies: 42
I have some courses which must be visible only for participants. For other its must be invisible. I create invisible category but all courses in this category is visible. Before last update it work nice, but after - don't work.

I find code in moodlelib.php

if (!(isteacher($courseid) || !empty($USER->admin)) && (!$course->visible || !course_parent_visible($course))) {
print_header();
notice(get_string('coursehidden'), $CFG->wwwroot .'/');
}

My question is why condition have !course_parent_visible($course)? I think it is unnecessary... If I hide category all courses automatically become invisible. And if I change course visibility I do it deliberately...
Average of ratings: -
In reply to Artem Andreev

Re: Course and course categories invisible

by Andreas Henrich -

Hello everybody,

we used exactly the same technique: Visible courses in an invisible category to hide courses which are relevant only for a small group and others should not even know that these courses exist. It worked nice until the "bug-fix" in 1.5.3+.

I can understand that some people have seen the previous semantics (an invisible category does not affect courses in that category) as a bug. But on the other hand, it is a feature as well. In my opinion an ideal solution would be to have two visibility eyes for the visibility of categories:

  • one with local semantics (no transitive effects on subcategories and courses) and
  • one with transitive semantics.
I think both functionalities are useful and should exist in parallel.

What do other moodle users think about this idea?

Best regards,

Andreas

In reply to Andreas Henrich

Re: Course and course categories invisible

by Steve Hyndman -

I agree Andreas...being able to hide a category, but still have the ability to link to courses in that category is a very useful feature and I'm currently using it on a couple of different sites. We really have both features now since you can hide a category and then hide individual courses within the category--this could be a little tedious if there are a lot of courses to hide, so if there is any change, I would like to see the parallel feature you talk about--maybe a button to hide a category and another button to hide all courses (or all selected courses) within the category.

This is an important feature for blocks as well...on some of my sites I have created activities and resources in the main menu block, but have hidden the block and link to the resources and activities from other places.

Steve

In reply to Steve Hyndman

Re: Course and course categories invisible

by Andreas Henrich -

To be more precise, since the patch

2005-12-13 Tuesday 11:33  patrickslee

	* course/lib.php, lib/datalib.php, lib/moodlelib.php: 
	
	Fixed courses and subcategories in an invisible category being
	visible (Bug #4074)

in version 1.5.3+ it is no longer possible to have visible courses in hidden categories. In my opinion a future version of moodle should support both semantics: hiding with transitive semantics and without.

Best regards,

   Andreas

In reply to Andreas Henrich

Re: Course and course categories invisible

by Robert Brenstein -
I concur that there is no apparent need to explicitly transfer category visibility onto courses. This is in a particular no-no when courses can be listed in multiple categories.

However, the issue of directly accessing courses (that is bypassing category visibility) needs to be addressed somehow as well. I believe this is what triggered this bug and the unfortunate "fixup". I say unfortunate because it has a nasty side effect that making a category visible makes also all its courses visible which causes us to expose courses that were meant to stay invisible.

Personally, I would require explicitly setting course visibility regardless of category visibility. Just add an option to automatically propagate such a setting to all courses in a given category.
In reply to Robert Brenstein

Re: Course and course categories invisible

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Personally, I would require explicitly setting course visibility regardless of category visibility

I guess the fundamental question here is: what is a category? Is it just a name to groups several courses but bears no semantic relationship to them? (in the sense of affecting courses visibility, access controls, etc.)

If the answer is yes, then your proposed solution makes sense. If the answer is no, if the categories not only group courses but also form part of access controls, visibility, etc then modifying a category should modify the underlying courses and subcategories (much the same the NTFS permission system works, for example: think categories == folders and courses == files).

I suspect the future role system might be related to all this and that the answer to the above question might be no.

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: Course and course categories invisible

by Robert Brenstein -
Yes, that is exactly the issue. Andreas summarized it quite well above. And I agree that both should be possible.

What I actually suggested last year was to have a two-prong visibility control. Andreas expresses the same idea in different terms afaik. Technically speaking, each course has an intrinsic visibility flag (set explicitely by admin) as well as effective visibility being a combination of its intrinsic visibility and the visibility of the category it is in. So, we get both transitive and non-transitive visibility.

I am going to code this once I am done modifying Moodle to allow having courses in multiple categories (it is as good as ready). It necessitates changing the current approach to visibility anyhow. If things are kept as they are now, a course will become invisible in all categories if any category with that course is made invisible.
In reply to Iñaki Arenaza

Re: Course and course categories invisible

by Artem Andreev -
I'm sorry for my long absence...

In NTFS files have same permissions as parent if flag "Inherit from parent the permission entries that apply to child objects" is set. And owner/admin can unset this flag and set permission only for this file...

I think category isn't only name for group several courses.
If people hide category - all courses automatically become invisible. But why people can't specially set visible for one course in this category? And why afterwards this course is invisible for participants?

Quotation from bug #4074
After patch:
1) A course created in an hidden category is automatically set to hidden
2) A course can not be set as visible in an invisible category
3) A course moved to a invisible category is set to invisible
4) When a category is set to invisible, all the subcategories and all the courses under are set to invisible
5) When a course is set to visible, all the parent categories are set to visible but not their courses.

I think:
1) good
2) 2 and 5 conflicting
3) good
4) good
5) 2 and 5 conflicting

I suggest to add ability to change courses visibility in invisible categories and these courses could be visible only for participants. Is this case have collisions? I think It's convenient for some people and will not inconvenient for other.
In reply to Artem Andreev

Re: Course and course categories invisible

by Robert Brenstein -
I have already coded handling the visibility of categories and courses independently of each other. I mean I coded it as part of my patch that allows listing courses in multiple categories. I will release it as soon as I have enough time to finish a few loose ends, but a new semester is upon us.
In reply to Andreas Henrich

Re: Course and course categories invisible

by Martín Langhoff -
If you want the bug back, feel free to revert the patch in your installation! smile

In reply to Martín Langhoff

Re: Course and course categories invisible

by Robert Brenstein -
You bet I hunted down and deleted the code that Guillaume added right away after Moodle made me red-faced. I also reported the problem on moodle.org but it was only me against Guillaume sad

http://moodle.org/mod/forum/discuss.php?d=30670#153314

Your post is unfortunely not so helpful. How does one revert a specific patch from standard distribution install? I think this goes beyond what normal Moodle admins can do. mixed
Average of ratings: Useful (1)
In reply to Andreas Henrich

Re: Course and course categories invisible

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I'm going to back out this patch, as it wasn't in fact a bug and has broken big sites using 1.5.x expecting it to be stable.
In reply to Martin Dougiamas

Re: Course and course categories invisible

by Sven Wolf -
Hi Martin,

which behaviour can we expect for the 1.6 stable and later?

In reply to Martin Dougiamas

Re: Course and course categories invisible

by Artem Andreev -
I upgrade to 1.5.4 and all works fine. But when I upgrade to 1.6 I have problems. Participants view courses (this courses places in invisible category) in block "My courses", but can't view content. And they doesn't view this courses in course-category list on front page...
In reply to Artem Andreev

Re: Course and course categories invisible

by Artem Andreev -
I experimented with different settings in Administration >> Configuration >> Site settings

1. News items - hide
List of courses - first
List of categories - hide

Displaying all courses: and from visible categories and from invisible categories... May be must displaying courses from visible categories and only for participants courses from invisible categories?

2. News items - hide
List of courses - hide
List of categories - first

For students displaying courses only from visible categories... For teachers also displaying their courses from invisible categories... May be must displaying courses from visible categories and only for participants (and students and teachers) courses from invisible categories?
In reply to Martin Dougiamas

Re: Course and course categories invisible

by Matt Campbell -
Martin, would you also back this out of 1.6?  I grabbed it from CVS on Friday so I could get ready to upgrade today.  I think it's all in /lib/moodlelib.php, line 1594:
if (!(isteacher($courseid) || !empty($USER->admin)) && (!$course->visible || !course_parent_visible($course))) {

to:
if (!(isteacher($courseid) || !empty($USER->admin)) && (!$course->visible)) {

We've currently got about 250 courses and growing, so I'm using categories and subcategories for access control and course structure.  I imagine that a number of institutions are doing the same thing.  The ability for a student to enter a course should not depend on whether or not its parent category is visible.
In reply to Matt Campbell

Re: Course and course categories invisible

by Daniele Cordella -
Picture of Core developers Picture of Plugin developers
Dear Matt
I appreciate your contribution because you are talking about a broblem I feel close.
This morning I modified, following your suggestion, my local moodle 1.6+ installation. I have a course open to guests and available to students but... if its category is hidden the course is not available to students if its category is visible all is right. I believe your hack is not complete. The error I get when I try to access my "free" course in a hidden category is something like "This course is not available to students". As I told you, if I unhide the category the access works properly.
In reply to Daniele Cordella

Re: Course and course categories invisible

by Genner Cerna -
I upgraded my version to 1.6+ from 1.5+ but the problem is when i go to "Site Setting" there only two option when enabling "Front page format" (New item and List is only available whereis list of courses option goes?). I logged as admin offcourse but when i fresh install locally it does show up but not in my upgraded version.

News items - hide
List of courses - first ?
List of categories - hide

see screenshot:
Attachment Untitled-1.jpg
In reply to Genner Cerna

Re: Course and course categories invisible

by Matt Campbell -
I think this is something they added in 1.6 - you get this 'combo' course-category thing if you have more than a certain number of courses, but I don't know what that number is.  I think it may be 200, that's when my 'list of courses' option went away.
In reply to Daniele Cordella

Re: Course and course categories invisible

by Matt Campbell -
I'm not sure where else to point you on this, because it's working in my production sites.  If you use the courses link on your main page, then drill down through your hidden categories until you get to your courses, what do you see?  If you turn editing on you should just have a list of courses.  I click the icon to make the course visible and then students can access it.

It doesn't fix the fact that hiding a category hides the courses and I have to unhide them....
In reply to Matt Campbell

Re: Course and course categories invisible

by Tony Butler -
I'll second that Matt! Please back it out Martin (preferably before I upgrade next week wink)!!
In reply to Tony Butler

Re: Course and course categories invisible

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Sorry guys, I just fixed this (in time for 1.6.1).  (Patch is here)

I don't follow this forum.   Please remember to file bug reports in the tracker.

Currently we are keeping the new behaviour as default in 1.6.x (hiding a category makes all the courses inaccessible, BUT there is a new config variable you can set in config.php:

     $CFG->allowvisiblecoursesinhiddencategories = true;

which will restore the old behaviour. I'll get it onto the Admin variables page ASAP.


In reply to Martin Dougiamas

Re: Course and course categories invisible

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Is course visibility and availability the same? The distinction in my mind is that I may want to have a course that no longer shows up (and hence is not visible) but still available to the students.  Ideally, I think what I would like to see is the option to show or not to show hidden courses. These are courses that are available but currently not visible. This would be helpful in a situation where you change semesters. By default, you would not have to look at the old stuff; however, within a user profile they could set it to show hidden but available courses. I hope that I am explaining myself clearly. The situation I was running into was a long list of grey'd out courses and in most cases students just want to see what they are currently taking. As an admin, I would like to simply hide the course category Fall Semester and have it hide by default all of the courses but still give teachers and students the ability to go back and see what was there.
In reply to Anthony Borrow

Re: Course and course categories invisible

by Séverin Terrier -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
    Hello,

I'm happy about this patch, and ability to go back to the old (but good) method.

When a 1.5.3+ version sudenly brings this new feature, several users could not access their courses, and we had to show all categories, making a very long list sad

Like Anthony, i think that visibility and availability are 2 different things :
- availability : enables student to access the course (if they're enrolled)
- visibility : allows Moodle users to view courses (and then perhaps try to access and enrolled them)

If we had to vote for the default behaviour, i would preferably be to come back to the old mechanism, that was respecting the choices...
In reply to Anthony Borrow

Re: Course and course categories invisible

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
If you hide the category but make courses visible then this is exactly what happens. Students see nothing before they login, but after they login they will see (and be able to access) all their own courses (via "My Courses").
In reply to Martin Dougiamas

Re: Course and course categories invisible

by Frances Thomson -
This patch doesn't seem to work for me.  I've uploaded a patched version of datalib.php and put the new config setting in config.php but the when accessing the course it still shows up as saying "This course is currently unavailable to students" when a student who is enrolled on the course tries to access to it.

Actually, when I do this it shows the course in the available list of courses when not logged in, but doesn't allow students enrolled on the course to access the course - which is the complete opposite of what I thought this was meant to achieve!
In reply to Frances Thomson

Re: Course and course categories invisible

by Tony Butler -

Frances, it sounds as if something may be very wrong there. As far as I'm aware, hidden categories and their contents should *never* be displayed in the 'course categories' listing to anyone other than admins, let alone to unauthenticated visitors. This is irrespective of whether the courses themselves are hidden or not, or whether or not you have chosen to allow courses in hidden categories to be available to already-enrolled students. 

Or maybe someone can correct me on this?

In reply to Martin Dougiamas

Re: Course and course categories invisible

by Randy Orwin -
I have added the changes to the config.php file, running 1.6.1 and still get "This course is currently unavailable to students" when trying to access the site.  It shows up in the my courses list but the students can't access the course.  Any ideas?
In reply to Martin Dougiamas

Re: Course and course categories invisible

by Artem Andreev -
> I don't follow this forum. Please remember to file bug reports in the tracker.

I have explained this situation in Bug #4511...
In reply to Martin Dougiamas

Re: Course and course categories invisible

by Timothy Takemoto -
Thanks very much for
$CFG->allowvisiblecoursesinhiddencategories = true;

I am going to use my "redirect" course to add various ways into three mother-courses, which will be in a hidden category.
Tim
In reply to Timothy Takemoto

Re: Course and course categories invisible

by Timothy Takemoto -

What would be even better for me would be to be able to allow students to enter these hidden courses but not to show them on the mycourses list - because I am using "redirect" courses from various places in the course heirarchy to take them to mother course containing groups for each class.

This means that they will always go via the redirect, and only the redirect will be show in ”my courses”.

So in
moodle/blocks/course_list/block_course_list.php
Following Matt Campbell's hack above, I changed instances of
$course->visible
to

($course->visible && course_parent_visible($course))
with the intent that both the course and the parent needs to be visible.

But it did not work. For the time being I will leave both courses in the mycourses list - in fact it is the one I am trying to hide that will take them there quicker. But it would be nice to hide it.

And make "redirect" a little quicker. Perhaps there is an optional time delay variable that one can pass...

Tim

In reply to Timothy Takemoto

Re: Course and course categories invisible

by Robert Brenstein -
IMHO, courses (as well as resources and activities) should have a separate flag for being visible and separate for being active (accessible). This would allow us a lot more flexibility.
In reply to Robert Brenstein

Re: Course and course categories invisible

by Timothy Takemoto -

I agree entirely, but Moodle rather more geared towards openness than making things in-accessible, or difficult to find.

For the time being we will have to hack, and send in a bug.

I think I am getting there.

First of all course_parent_visible uses the $CFG->allowvisiblecoursesinhiddencategories, and will always return true if it is set.

Instead the function
category_parent_visible($course->category);
needs to be used.

Secondly course_parent_visible does not seem to be accessible to the block. It needs to be included, or required I guess but datalip.php is not included or required anywhere apparently. Globals??

Tim

In reply to Timothy Takemoto

Re: Course and course categories invisible

by Timothy Takemoto -

This in block_course_list.php
 require_once($CFG->libdir.'/datalib.php');
$linkcss = ($course->visible && category_parent_visible($course->category)) ? "" : " class=\"dimmed\" ";

still gives

Fatal error: Call to undefined function: category_parent_visible() in /home/at2/eigo/public_html/moodle2006_15_last/blocks/course_list/block_course_list.php on line 41

even though there is
function category_parent_visible($parent = 0) {
in datalib.php
requiring the inclusion of a file is not as easy as it looks.

I even tried copying and pasting the function into the block!

If I use
                    include($CFG->libdir.'/datalib.php');
Then on the other hand I get
Fatal error: Cannot redeclare execute_sql() (previously declared in /home/at2/eigo/public_html/moodle2006_15_last/lib/datalib.php:42) in /home/at2/eigo/public_html/moodle2006_15_last/lib/datalib.php on line 42
Which looks like datalib.php has already been included.

In reply to Timothy Takemoto

Re: Course and course categories invisible

by Martín Langhoff -
This is more geared for general developers forum wink you want to use require_once($CFG->libdir.'/datalib.php') there.
In reply to Martín Langhoff

Re: Course and course categories invisible

by Timothy Takemoto -
Thanks. I will move this to the developers forum.
The code you kindly suggest seems to be the same as the one I tried above.
Tim
In reply to Timothy Takemoto

Re: Course and course categories invisible

by Timothy Takemoto -

Sorry, it was just a stupid mistake. I don't think that it deserves the developers attention. If one changes about like 40 of
moodle/blocks/course_list/block_course_list.php
if ($course->id == SITEID) {
To
                    if ($course->id == SITEID || !category_parent_visible($course->category)) {
Then courses in hidden parents will not be shown even if the following is added to config.php
$CFG->allowvisiblecoursesinhiddencategories = true


This way one can put "redirect courses" into various places in the category hierarchy, put the real courses with content in a hidden category, and only the redirect course (doorway course?) will be shown.

This means that the same course content can be called many things, or shared between many "courses" especially with the judicious use of auto-enrolling groups in those hidden "mother" courses.

Problems
1) It asks you if you want to join the redirect course before asking for the group enrolment key of the hidden course which is okay. But if there were no group or course enrolment key in the hidden course, then it would ask if you want to join the course TWICE.
2) Redirects are annoying.
3) Course activities (but not activity content) are visible in all the groups of the hidden course.

I have attached all of the required code to this post. Hack with care.

Tim

In reply to Martin Dougiamas

Re: Course and course categories invisible

by Nicola Bennett -

Hello,

I've got version 1.6.1 installed. I've added this line to my config.php file:

$CFG->allowvisiblecoursesinhiddencategories = true;

I've created a category and made it invisible. I've put a course in this category and made it visible.

On the homepage this category I've created is invisible in the 'Course Categories' list before login - which is correct.

When a student enrolled on this course logins, the course isn't visible in the 'My Courses' block.

With the line above added shouldn't the course be visible to enrolled students?

I'd be very grateful if someone could help with this.

Thank you
Nicola.

In reply to Andreas Henrich

Re: Course and course categories invisible

by Josep M. Fontana -
Actually I have a related request/question. As the number of Moodle courses start to grow in our department, I was looking for ways to use categories to reorganize courses in a way that was more manageable and intuitive for users.

I wanted the main page to show a short list of course categories and then within each one of these categories you would find either another list of subcategories or directly a list of courses. I haven't been able to do that.

When I create a subcategory within one of the available categories you can still see this subcategory in the main Moodle page. The subcategory is indented so it is somewhat of an improvement, but I would like it to be totally hidden under the category and only make it visible when the user clicks on the category. Otherwise, the main page is still very cluttered which is what I would like to avoid.

Does anybody know any way of getting around this problem?

Josep M.