Bug #7125

Students cannot enter private access course in "special course" mode

Added by Yannick Warnier over 6 years ago. Updated over 6 years ago.

Bug resolved
Daniel Barreto
Global / Others / Misc
Target version:
Start date:
Due date:
% Done:


Estimated time:
Spent time:
SCRUM pts - complexity:


  • create a course
  • put it in private access
  • through the edition in the admin section, set it as "special course"
  • create a new student
  • login as the new student
  • the special course appears in the list of courses
  • click the course
  • you get a "Not allowed" message
  • get back to the courses list
  • click the course
  • now you are allowed...

The behaviour of "special courses" is that they register you completely to the course the first time you click on it. As such, you should be registered in the table course_rel_user immediately.
The issue here is probably that the "api_is_allowed()" is called before the special-course process of registering the user is made, and this is wrong.

Please make sure the "special course" check is made before the api_is_allowed() call. Do not do that inside the api_is_allowed() function, as it would slow down a lot of other pages. We just need it on the course homepage.

Associated revisions

Revision 20dba872 (diff)
Added by Daniel Barreto over 6 years ago

Set is_allowed_in_course = true in session if successfully subscribe in special course -refs #7125



Updated by Yannick Warnier over 6 years ago

  • Assignee changed from Julio Montoya to Daniel Barreto

Updated by Daniel Barreto over 6 years ago

  • Status changed from Assigned to Needs testing
  • Assignee changed from Daniel Barreto to Yannick Warnier
  • % Done changed from 10 to 70

course_home use api_protect_course_script():

$is_allowed_in_course = api_is_allowed_in_course();
case COURSE_VISIBILITY_REGISTERED: //Private - access authorized to course members only - 1
    if (api_get_user_id() && !api_is_anonymous() && $is_allowed_in_course) {
        $is_visible = true;
if (!$is_visible) {
    return false;
    return true;

Then user's session should have 'is_allowed_in_course' true
For that if user is successfully subscribed then call Session::write() to set it true

Done in PR#292


Updated by Yannick Warnier over 6 years ago

  • Status changed from Needs testing to Bug resolved
  • Assignee changed from Yannick Warnier to Daniel Barreto
  • % Done changed from 70 to 100

Tested and approved. Thanks!

Also available in: Atom PDF