What is the process that determines whether a Course is available to a student or not?

What is the process that determines whether a Course is available to a student or not?

by Deleted user -
Number of replies: 7
I'm looking to make some mods, and am wondering if the gurus can point me to the proper files and tables...

How does the process flow to determine whether a student should have access to a course or not? I understand that there would be some check of roles in the course, but there also has to be a check on whether the student is actually enrolled or not? I'm more interested in this second check... which file contains this check to see if they are enrolled (and then assuming roles are okay) actually ALLOWS the student access to the course as opposed to leaving it greyed out?

Thanks
Average of ratings: -
In reply to Deleted user

Re: What is the process that determines whether a Course is available to a student or not?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Enrolment is handled by roles. You are enroled in a course if you are assigned a role (e.g. Student or Teacher) in the course, or in a larger context that includes it.

The checking is done in the require_login function, which almost every Moodle script call somewhere near the top. Going and reading the code is probably the easiest and most reliable way to see what it does.
In reply to Tim Hunt

Re: What is the process that determines whether a Course is available to a student or not?

by ben reynolds -
Hey Tim,
Why isn't the Moodle sample code thing easier to find?
Isn't this what Jeff seeks?
http://xref.moodle.org/nav.html?config-dist.php.source.html

I'm a non-programmer, so maybe I'm wrong, but I've used this to point my IT people to "near this line" is where you need to make the change stuff.
In reply to ben reynolds

Re: What is the process that determines whether a Course is available to a student or not?

by Deleted user -
Thanks Tim...

Where is the require_login function located (file and directory)?

And just to confirm, it is this require_login function that checks to see if the role of say student is assigned for a particular course, prior to the courses being displayed on say the main moodle page?
In reply to Deleted user

Re: What is the process that determines whether a Course is available to a student or not?

by Deleted user -
Thanks Ben...

That phpXref for Moodle makes it incredibly easy to find a function (like require_login)!!
In reply to ben reynolds

Re: What is the process that determines whether a Course is available to a student or not?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The code seems to be very easy to find. You were even able to give a URL where anyone can view it!

Except for the fact that the xref site uses frames, so you have to work harder to get a specific URL (Hint: use This frame -> Show only this frame in your broswer).

http://xref.moodle.org/nav.html?lib/moodlelib.php.source.html#l1800

So, what exactly are you complaining about.

Of course, since I am a developer, I never use this site, because I have the Moodle code in my IDE, which puts even more powerful searching and browsing tools at my fingertips.
In reply to Tim Hunt

Re: What is the process that determines whether a Course is available to a student or not?

by ben reynolds -
Right, I should have been clearer.

I'm complaining that I found that code by accident on a Google search. Moodle.org doesn't seem to say, "Hey, here is a link to the code!"
In reply to ben reynolds

Re: What is the process that determines whether a Course is available to a student or not?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That is true, although there are plenty of links if you go into the developer docs in MoodleDocs. Moodle.org is about to get a face lift. Hopefully there will then be such a link.