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...
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.
What do other moodle users think about this idea?
Best regards,Andreas
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
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
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.
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.
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 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.
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.
which behaviour can we expect for the 1.6 stable and later?
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?
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.
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.
News items - hide
List of courses - first ?
List of categories - hide
see screenshot:
It doesn't fix the fact that hiding a category hides the courses and I have to unhide them....
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.
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
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...
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!
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?
I have explained this situation in Bug #4511...
Cheers Martin - that works for me
$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
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
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
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.
The code you kindly suggest seems to be the same as the one I tried above.
Tim
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
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.
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.
Has there been any movement on this topic?
Thanks,
Jim