Moodle
  1. Moodle
  2. MDL-29678

'Error: A required parameter (id) was missing' when using enrolment key to join course

    Details

    • Database:
      MySQL
    • Testing Instructions:
      Hide
      1. Log in as an admin
      2. Create a new user
      3. Create two courses
      4. In the first course enable self enrolment without a key
      5. Log in as the new user
      6. Browse to the course with self enrolment enabled (but DO NOT enrol yourself yet)
      7. In the navigation try to expand the navigation for the course, as well as the expand the navigation for the other course
      8. Use firebug or web dev tool to confirm you get an AJAX request for which the response is an error like "Error: Course or activity not accessible."
      9. Click the enrol me button
      10. Confirm you arrive at a valid page (likely the course front page) and NOT at lib/ajax/getnavbranch.php
      Show
      Log in as an admin Create a new user Create two courses In the first course enable self enrolment without a key Log in as the new user Browse to the course with self enrolment enabled (but DO NOT enrol yourself yet) In the navigation try to expand the navigation for the course, as well as the expand the navigation for the other course Use firebug or web dev tool to confirm you get an AJAX request for which the response is an error like "Error: Course or activity not accessible." Click the enrol me button Confirm you arrive at a valid page (likely the course front page) and NOT at lib/ajax/getnavbranch.php
    • Affected Branches:
      MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull Master Branch:
      wip-MDL-29678-m23
    • Rank:
      19185

      Description

      My site is set up so that users get added via Active Directory, and are given a link to the first subject in their course, which they then enrol in using an enrolment key. I am now finding that when users do so, they get an error page at 'lib/ajax/getnavbranch.php', which says 'Error: A required parameter (id) was missing'. They are still enrolled in the course as expected, but the error page understandably concerns and confuses people.

      In the testing I have done, this only seems to happen for users who were created in active directory; a test account of mine that was created manually within Moodle itself did not have this problem.

        Issue Links

          Activity

          Hide
          Louise Bennett added a comment -

          Further testing suggests it is not just when using an enrolment key; courses without enrolment keys also produce this behaviour.

          Show
          Louise Bennett added a comment - Further testing suggests it is not just when using an enrolment key; courses without enrolment keys also produce this behaviour.
          Hide
          Michael Hughes added a comment -

          I have tried with test users which are both manual and LDAP accounts. When they visit the course to self-enrol they also get the error:
          Error: A required parameter (id) was missing

          reloading the course home page shows they have actually been enrolled.

          Show
          Michael Hughes added a comment - I have tried with test users which are both manual and LDAP accounts. When they visit the course to self-enrol they also get the error: Error: A required parameter (id) was missing reloading the course home page shows they have actually been enrolled.
          Hide
          Eric Hartley added a comment -

          Has any further testing been done on this? I note that the bug is classed as 'minor', but arguably a bug which results in the user enrolling and getting an error message screen is pretty major! Like Michael I'm getting the error with self-enrolment without a key.

          Show
          Eric Hartley added a comment - Has any further testing been done on this? I note that the bug is classed as 'minor', but arguably a bug which results in the user enrolling and getting an error message screen is pretty major! Like Michael I'm getting the error with self-enrolment without a key.
          Hide
          Marshall L. Reeves added a comment -

          I'm also seeing this behavior, but only with some users--most users can register with no problem. Students were manually added to Moodle in our case. When student clicks "Enroll me" button they get the "Error: A required parameter (id) was missing". If they try to register a second time, they do not get the error, but this is probably because they are already enrolled from the first attempt.

          I don't see any difference in the mdl_user record for users who do not get the error and those who do. I have not verified yet if the users who reported the problem have it with every enrollment attempt.

          Show
          Marshall L. Reeves added a comment - I'm also seeing this behavior, but only with some users--most users can register with no problem. Students were manually added to Moodle in our case. When student clicks "Enroll me" button they get the "Error: A required parameter (id) was missing". If they try to register a second time, they do not get the error, but this is probably because they are already enrolled from the first attempt. I don't see any difference in the mdl_user record for users who do not get the error and those who do. I have not verified yet if the users who reported the problem have it with every enrollment attempt.
          Hide
          Marshall L. Reeves added a comment -

          Wanted to add environment info.

          Moodle version 2.1.3 (Build: 20111128)
          PHP 5.3.5 (Jan 5 2011 20:26:24)
          Windows Server 2008, IIS 7.0

          Web client: IE 8.0.7601.17514

          Show
          Marshall L. Reeves added a comment - Wanted to add environment info. Moodle version 2.1.3 (Build: 20111128) PHP 5.3.5 (Jan 5 2011 20:26:24) Windows Server 2008, IIS 7.0 Web client: IE 8.0.7601.17514
          Hide
          Rajesh Taneja added a comment -

          This seems to be a navigation related issue. Adding Sam for his views.

          Show
          Rajesh Taneja added a comment - This seems to be a navigation related issue. Adding Sam for his views.
          Hide
          Sam Hemelryk added a comment -

          Hi everyone.

          Thanks for the report Lousie!

          If possible Lousie, Eric, Marshall, or anyone who has experienced this problem could you please let us know what you have set for the following navigation settings, when logged in as admin they can all be found here under Settings > Site Administration > Navigation.

          1. Show course categories [navshowcategories]
          2. Show all courses [navshowallcourses]
          3. navcourselimit [navcourselimit]

          These three settings determine how the navigation is generated and what is able to be loaded by AJAX.

          I've seen this error before, sporadically, not with AD but just when there is a problem/bug with the navigation AJAX.
          Raj a good place to start would be to test what happens with the navigation, especially in regards to AJAX when enrolling a user through an external system.
          If you don't have an active directory setup you could try first with an external database enrolment instance.

          As mentioned above this is a typical error when AJAX breaks, for some reason if the AJAX request fails the browser upon redirecting for the next action ends up at the AJAX script that we were trying to call.
          The script throwing reporting the error (lib/ajax/getnavbranch.php) is only ever called by AJAX and should never be called by any other means. It defines AJAX_SCRIPT so pretty clear.
          I would start in the following way: check for errors being thrown when loading the navigation by AJAX, particularly in and around the course context and enrolment scripts. You may need to watch your error logs for this. The JS that deals with it should fail silently for all but direct JS errors so you likely will not see any direct reports from JS. The other thing to note is that you must keep in mind what you expect to see as that may provide clues.

          Cheers
          Sam

          Show
          Sam Hemelryk added a comment - Hi everyone. Thanks for the report Lousie! If possible Lousie, Eric, Marshall, or anyone who has experienced this problem could you please let us know what you have set for the following navigation settings, when logged in as admin they can all be found here under Settings > Site Administration > Navigation. Show course categories [navshowcategories] Show all courses [navshowallcourses] navcourselimit [navcourselimit] These three settings determine how the navigation is generated and what is able to be loaded by AJAX. I've seen this error before, sporadically, not with AD but just when there is a problem/bug with the navigation AJAX. Raj a good place to start would be to test what happens with the navigation, especially in regards to AJAX when enrolling a user through an external system. If you don't have an active directory setup you could try first with an external database enrolment instance. As mentioned above this is a typical error when AJAX breaks, for some reason if the AJAX request fails the browser upon redirecting for the next action ends up at the AJAX script that we were trying to call. The script throwing reporting the error (lib/ajax/getnavbranch.php) is only ever called by AJAX and should never be called by any other means. It defines AJAX_SCRIPT so pretty clear. I would start in the following way: check for errors being thrown when loading the navigation by AJAX, particularly in and around the course context and enrolment scripts. You may need to watch your error logs for this. The JS that deals with it should fail silently for all but direct JS errors so you likely will not see any direct reports from JS. The other thing to note is that you must keep in mind what you expect to see as that may provide clues. Cheers Sam
          Hide
          Rajesh Taneja added a comment -

          Thanks for the feedback, Sam.
          I don't have LDAP setup, will try use database and see if I can reproduce this issue.
          It will be helpful, if someone can provide steps to reproduce this issue. According to Michael, it is happening for manual enrollments, but unfortunately I can't reproduce this issue at my end.

          Show
          Rajesh Taneja added a comment - Thanks for the feedback, Sam. I don't have LDAP setup, will try use database and see if I can reproduce this issue. It will be helpful, if someone can provide steps to reproduce this issue. According to Michael, it is happening for manual enrollments, but unfortunately I can't reproduce this issue at my end.
          Hide
          Eric Hartley added a comment -

          Sam, thanks very much for the input - much appreciated!

          In answer to your question, my settings are the defaults:
          Show course categories [navshowcategories] - Yes
          Show all courses [navshowallcourses] - No
          navcourselimit [navcourselimit] - 20

          The bug has only occured intermittently in IE, cannot replicate in Firefox.The bug occurs with both manual enrolment and email based self-enrolment. I don't have LDAP or any other external enrolment set up.

          Just to complete the info, my system settings are as follows:
          Moodle version 2.1.2+ (Build: 20111102)
          PHP 5.3.6
          Linux Server, Apache 2.2.21, MySQL 5.0.92
          Browser problem occurred in: IE8 8.0.6001.1872 (I can replicate it, but the problem only occurs approx 25% of the time). After clicking on back button and screen refresh, the user is enrolled.

          Thanks again for the help.

          Show
          Eric Hartley added a comment - Sam, thanks very much for the input - much appreciated! In answer to your question, my settings are the defaults: Show course categories [navshowcategories] - Yes Show all courses [navshowallcourses] - No navcourselimit [navcourselimit] - 20 The bug has only occured intermittently in IE, cannot replicate in Firefox.The bug occurs with both manual enrolment and email based self-enrolment. I don't have LDAP or any other external enrolment set up. Just to complete the info, my system settings are as follows: Moodle version 2.1.2+ (Build: 20111102) PHP 5.3.6 Linux Server, Apache 2.2.21, MySQL 5.0.92 Browser problem occurred in: IE8 8.0.6001.1872 (I can replicate it, but the problem only occurs approx 25% of the time). After clicking on back button and screen refresh, the user is enrolled. Thanks again for the help.
          Hide
          Marshall L. Reeves added a comment -

          Hi Sam and Rajesh,

          Thanks for your replies.

          My settings are nearly opposite of Eric's:
          Show course categories [navshowcategories] - not checked
          Show all courses [navshowallcourses] - checked
          navcourselimit [navcourselimit] - 20

          Like Sam suggested, I suspect this is caused by a failed AJAX call as well. Seems like the course enrollment executes fine, but then when the page is redirected to show the course homepage, an AJAX call fails to retrieve the course "id" needed by a function either to call the course page or on the course page itself?

          To me a big clue is the random nature of the problem. With the same user account, I can enroll/unenroll in the same course numerous times and find no pattern. Sometime I get the error a few times in a row and sometimes not at all for a few attempts. Same behavior with other user accounts.

          Suspecting browser caching issues, I verified that my browser is set to compare the cached copy "every time I visit the page" and not "automatically". I have also cleared all browser cached files and restarted IE (and even rebooted a few times), all with same random results.

          Maybe that AJAX call sometimes does not execute quickly enough to return the course id before the browser is redirected to the course homepage? I'm not a PHP developer (ColdFusion instead) so I can't follow the logic that happens immediately after the course enrollment successfully completes.

          Show
          Marshall L. Reeves added a comment - Hi Sam and Rajesh, Thanks for your replies. My settings are nearly opposite of Eric's: Show course categories [navshowcategories] - not checked Show all courses [navshowallcourses] - checked navcourselimit [navcourselimit] - 20 Like Sam suggested, I suspect this is caused by a failed AJAX call as well. Seems like the course enrollment executes fine, but then when the page is redirected to show the course homepage, an AJAX call fails to retrieve the course "id" needed by a function either to call the course page or on the course page itself? To me a big clue is the random nature of the problem. With the same user account, I can enroll/unenroll in the same course numerous times and find no pattern. Sometime I get the error a few times in a row and sometimes not at all for a few attempts. Same behavior with other user accounts. Suspecting browser caching issues, I verified that my browser is set to compare the cached copy "every time I visit the page" and not "automatically". I have also cleared all browser cached files and restarted IE (and even rebooted a few times), all with same random results. Maybe that AJAX call sometimes does not execute quickly enough to return the course id before the browser is redirected to the course homepage? I'm not a PHP developer (ColdFusion instead) so I can't follow the logic that happens immediately after the course enrollment successfully completes.
          Hide
          Andrew Souza added a comment -

          We are also having the same problem.

          Windows Server 2008 R2
          IIS 7.5
          Sql Server 2005
          Moodle 2.1 (Build: 20110701)

          NavShowCategories: Checked
          NavShowAllCourses: Checked
          NavCourseLimit: 20

          Show
          Andrew Souza added a comment - We are also having the same problem. Windows Server 2008 R2 IIS 7.5 Sql Server 2005 Moodle 2.1 (Build: 20110701) NavShowCategories: Checked NavShowAllCourses: Checked NavCourseLimit: 20
          Hide
          Eric Hartley added a comment -

          I still can't understand why this bug is listed as 'minor'. Surely a user getting an error screen when they enrol on a course is major? The vast majority of users when faced with an error screen will not use their back button and notice they are enrolled (which is what is happening) - they will just assume the enrolment is not working. Please, please can somebody understands the system get involved with this bug? Thanks!

          Show
          Eric Hartley added a comment - I still can't understand why this bug is listed as 'minor'. Surely a user getting an error screen when they enrol on a course is major? The vast majority of users when faced with an error screen will not use their back button and notice they are enrolled (which is what is happening) - they will just assume the enrolment is not working. Please, please can somebody understands the system get involved with this bug? Thanks!
          Hide
          Sam Hemelryk added a comment -

          Hi guys,

          By chance I think I may have stumbled upon the solution to this issue while reviewing an issue to do with URL redirection within require_login (MDL-22510).

          Presently AJAX requests are leading to require_course_login being called during initialisation, and as part of that call a return URL is being stored in the users session ($SESSION->wantsurl).
          Now although this is being set by require_login because it is an AJAX script call, the call simply fails and the user is not redirected. However the wantsurl remains set in the session.
          When a user arrives self enrols in a course they are taken back to enrol/index.php which redirects to the course front page OR wantsurl if that is set.
          So the bug, a failed require_course_login call during a navigation AJAX request BEFORE enrolling in a course will lead to this error.

          I've just been testing this and can confirm that it is leading to this problem.

          I'll put this up for integration review now, please note if you want to test this the linked issue MDL-22510 MUST be fixed on your test branch. That issue has been integrated but won't be in the weekly release until later this week.

          Cheers
          Sam

          Show
          Sam Hemelryk added a comment - Hi guys, By chance I think I may have stumbled upon the solution to this issue while reviewing an issue to do with URL redirection within require_login ( MDL-22510 ). Presently AJAX requests are leading to require_course_login being called during initialisation, and as part of that call a return URL is being stored in the users session ($SESSION->wantsurl). Now although this is being set by require_login because it is an AJAX script call, the call simply fails and the user is not redirected. However the wantsurl remains set in the session. When a user arrives self enrols in a course they are taken back to enrol/index.php which redirects to the course front page OR wantsurl if that is set. So the bug, a failed require_course_login call during a navigation AJAX request BEFORE enrolling in a course will lead to this error. I've just been testing this and can confirm that it is leading to this problem. I'll put this up for integration review now, please note if you want to test this the linked issue MDL-22510 MUST be fixed on your test branch. That issue has been integrated but won't be in the weekly release until later this week. Cheers Sam
          Hide
          Sam Hemelryk added a comment -

          Up for peer-review now

          Show
          Sam Hemelryk added a comment - Up for peer-review now
          Hide
          Dan Poltawski added a comment -

          Looks good to me.

          The AJAX override to wantsurl is really sensible too, i'm sure this will stop some other bizzare related problems.

          Show
          Dan Poltawski added a comment - Looks good to me. The AJAX override to wantsurl is really sensible too, i'm sure this will stop some other bizzare related problems.
          Hide
          Sam Hemelryk added a comment -

          Thanks Dan, up for integration it goes

          Show
          Sam Hemelryk added a comment - Thanks Dan, up for integration it goes
          Hide
          Eric Hartley added a comment -

          Dan, Sam thanks for your time spent on this - much appreciated.

          Show
          Eric Hartley added a comment - Dan, Sam thanks for your time spent on this - much appreciated.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated (21, 22 and master), thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated (21, 22 and master), thanks!
          Hide
          Rossiani Wijaya added a comment -

          this is working great.

          Test passed.

          Show
          Rossiani Wijaya added a comment - this is working great. Test passed.
          Hide
          Aparup Banerjee added a comment -

          The code here has been spread to upstream moodle repositories and mirrors for anyone to use .

          Closing, have a good weekend!

          Show
          Aparup Banerjee added a comment - The code here has been spread to upstream moodle repositories and mirrors for anyone to use . Closing, have a good weekend!

            People

            • Votes:
              4 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: