Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-77645

Course Editor JS error when student tries to access course while enrolment method is disabled

XMLWordPrintable

    • MOODLE_401_STABLE
    • MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-77645-401
    • Hide
      1. Log in as admin
      2. Create a course
      3. Create a test user
      4. Enrol user a student in course
      5. Press Edit enrolment for the student
        • Status: Suspended
      6. Log out
      7. Log in as test user
      8. Open browser developer console
      9. Navigate to <WWWROOT>/course/index.php
      10. Press Test course
      11. Confirm there is no "EXCEPTION RAISED WHILE INIT COURSE EDITOR" error in console
      Show
      Log in as admin Create a course Create a test user Enrol user a student in course Press Edit enrolment for the student Status: Suspended Log out Log in as test user Open browser developer console Navigate to <WWWROOT>/course/index.php Press Test course Confirm there is no "EXCEPTION RAISED WHILE INIT COURSE EDITOR" error in console

      I figured out that there's a bug in (at least) Moodle 4.1.2 which occurs when I do the following:

      1. Create a course
      2. Enrol a student to a course
      3. Disable the enrolment method
      4. Try to open the course page as student
      5. The page is rendered correctly, but in the console of the browser, the following exception occurs: 

      I also wrote a small Behat script that helps to reproduce / cover this scenario:

      @javascript @enrolment_test
      Feature: title
          In order to value
          As a role
          I want feature    Scenario: Test
              Given the following "users" exist:
                  | username | firstname | lastname |
                  | student  | Student   | 1        |
              And the following "courses" exist:
                  | fullname | shortname |
                  | Course 1 | C1        |
              And I log in as "admin"
              And I am on "Course 1" course homepage
              And I navigate to course participants
              And I enrol "Student 1" user as "Student"
              And I am on the "Course 1" "Enrolment methods" page
              And I click on "Disable" "icon" in the "Manual enrolments" "table_row"
              Then I log out
              And I log in as "student"
              And I am on "Course 1" course homepage
              Then I should see "You cannot enrol yourself in this course."

      When you run this scenario, Behat finally fails with the following error (because of the exception):

      Javascript code and/or AJAX requests are not ready after 10 seconds. There is a Javascript error or the code is extremely slow (core/reactive:registerInstance1:core_courseformat/placeholder:loadcourseindex:core/reactive:registerComponent3:core/reactive:registerComponent5). If you are using a slow machine, consider setting $CFG->behat_increasetimeout. (Exception) 

            pholden Paul Holden
            mstimvol Tim Volckmann
            Laurent David Laurent David
            Andrew Lyons Andrew Lyons
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 51 minutes
                1h 51m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.