Where/how does $COURSE get set up

Where/how does $COURSE get set up

by Howard Miller -
Number of replies: 4
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm calling a new script from a block. Inside the 'standard' block $COURSE is defined but in my new script is (not surprisingly) isn't. This is breaking the call to build_navigation().

Anyway... what's the proper way of getting this created? I'm passing the course id to the script so do I 'just' create it (from the course's db record) or is there something more subtle to be done?
Average of ratings: -
In reply to Howard Miller

Re: Where/how does $COURSE get set up

by Hubert Chathi -
Either require_login, or course_setup if you don't need to check that the user is logged in.
Average of ratings: Useful (1)
In reply to Hubert Chathi

Re: Where/how does $COURSE get set up

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Ahh... that's why require_login takes the courseid as a parameter.

Completely obvious when you know wink

Thanks!!
In reply to Howard Miller

Re: Where/how does $COURSE get set up

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Well, require_login also checks whether the course is visible, and if not checks that the user can see hidden courses. And there are a bunch of other checks done too if you pass a $cm.
In reply to Tim Hunt

Re: Where/how does $COURSE get set up

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The curse of function feature creep dare I say...


require_login_and_optional_do_loads_of_checks_on_the_course();