Hiding courses based on login info

Hiding courses based on login info

by Marilyn Fleming -
Number of replies: 4

I'm a Moodle newbie. For the application I have in mind, I will need to make some code changes. However, I don't want to do it in a way that cuts me off from all of those great new features that are coming along.

Top priority is to set up private courses. Not just unavailable to certain users, but totally invisible to them. Say Moodle contains courses for Dept A, Dept B, and public. Until a user is authenticated, he sees only public courses. As part of his sign-up he can say he belongs to Dept A. Then, once authenticated, he can see public and Dept A courses, but cannot see Dept B courses.

Another need is something like a unique student ID number that the student can't change, so grades for all Dept A courses can be extracted from the database (externally, not from Moodle) and exported somewhere else, where they can be merged based on student ID.

My question is this -- what's the best way to approach making this kind of change so I don't cut myself off from future updates?

Average of ratings: -
In reply to Marilyn Fleming

Re: Hiding courses based on login info

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
Well, posting your plans here like that is a great start.  approve  Posting large core patches out of the blue have less of a chance of getting accepted - simply because integrating them with all the other stuff coming in at the same time is often difficult.

Changes like this need to add generic functionality for every site while remaining backward-compatible, and efficient.  So let's think about this.

In Moodle lingo you want to make the category visibility dependent on a user setting.

Random first questions I have are: can we trust the student to make this setting?  If you are trusting the student to make the setting then what's the harm of just showing all the categories as now?  What happens if they change their setting?  How can we support more than one setting (for students in multiple categories/departments) ?  What happens if the category names get shifted around?  Things start getting complex ...

One quick suggestion I have is to use the department field that already exists in the user table (though there is no longer a GUI to access it) ... and if the value of this is the same as a category name, then only show this category and it's children.  Perhaps the GUI for it could be on the user profile page, and they set it by selecting from a list of the current category names.

An even quicker suggestion is to simply set up a separate Moodle for each department.  smile
In reply to Martin Dougiamas

Re: Hiding courses based on login info

by Marilyn Fleming -

Multiple Moodles sounds like it would be easy to do. Only catch is I'm working on a virtual host, and would prefer not to carry multiple copies of the source code. At least at first, it's likely to be many "departments", small number of courses in each. The departments are actually different companies, and not only is the course content confidential, the actual name of the course may be confidential.

Suppose I wanted to just have multiple config.php's, with one copy of other source. Guess that means I would have to change the require statement in every .php file. Right?

In reply to Marilyn Fleming

Re: Hiding courses based on login info

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
Until something more official gets implemented, you just need to hack your config.php with something like this. (No need to change any other file)

If you take manual control over the enrollments then another tricky thing you can do with existing code is this:  have all the courses visible, but inside an invisible category.  The category will not be shown anywhere to students or guests, but once users log in then all their OWN courses are shown on the front page as "My courses".
In reply to Marilyn Fleming

Re: Hiding courses based on login info

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
The ID number field is already in the user table, and has a GUI for students to enter it on their profile, so that one is easy.

There are some future plans to make a better system for arbitrary optional/required user data.