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

Lesson module error on save - Cannot find grade item for 'lesson'

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Create a site on 3.7. This particular version

        git checkout e56b93b7e4cc55865a161a73d28add98fdf473df

      2. Create a course, with activity completion enabled
      3. Enrol a few students
      4. Create a lesson module, setting:
        • Grade type = none
        • Activity completion: 'Show activity as complete when conditions are met' and tick the following:
          • 'require grade'
          • 'require view'
      5. Click 'Save and display'
      6. Now, create a content page for the lesson and save that.
      7. Checkout 3.8 branch and run the site upgrade.
      8. Once upgrade is complete, log in to the site as a student
      9. View the lesson activity and notice no error
      10. As an admin, go to the lesson settings and confirm the 'Requires grade' flag is not set.
      11. Repeat above with upgrades to 3.9, 3.10 and master branches in #7
      Show
      Create a site on 3.7. This particular version git checkout e56b93b7e4cc55865a161a73d28add98fdf473df Create a course, with activity completion enabled Enrol a few students Create a lesson module, setting: Grade type = none Activity completion: 'Show activity as complete when conditions are met' and tick the following: 'require grade' 'require view' Click 'Save and display' Now, create a content page for the lesson and save that. Checkout 3.8 branch and run the site upgrade. Once upgrade is complete, log in to the site as a student View the lesson activity and notice no error As an admin, go to the lesson settings and confirm the 'Requires grade' flag is not set. Repeat above with upgrades to 3.9, 3.10 and master branches in #7
    • Affected Branches:
      MOODLE_29_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE, MOODLE_39_STABLE
    • Pull from Repository:
    • Pull 3.9 Branch:
    • Pull 3.10 Branch:
      MDL-50955-310
    • Pull 3.11 Branch:
      MDL-50955-311
    • Pull Master Branch:
      MDL-50955-master
    • Story Points:
      3
    • Sprint:
      4.0 holding pattern 7, 4.0 holding pattern 8

      Description

      Sites running 3.7 or earlier may have bad completion configuration, which persists into 3.8, 3.9 or master when upgrading. This leads to an error when viewing the module as a student.

      Replication instructions

      1. Create a site on 3.7
      2. Create a course, with activity completion enabled
      3. Enrol a few students
      4. Create a lesson module, setting:

      • Grade type = none
      • Activity completion: 'Show activity as complete when conditions are met' and tick the following:
        • 'require grade'
        • 'require view'

      5. Click 'Save and display'
      6. Now, create a content page for the lesson and save that.
      7. Checkout master and run the site upgrade.
      8. Once upgrade is complete, log in to the site as a student
      9. View the lesson activity and notice the error

      This occurs because 'require grade' is not compatible with 'grade type' = 'none'. This is not possible in new installs, but legacy sites upgrading may still have bad data. We should fix this if possible/sensible.

      Workaround:

      Re-save the activity in a 3.8 or newer site.

      Original description (for posterity only - affects 3.7 and earlier versions of Moodle only)

      Pre-requisites :

      Course activity completion is enabled at site level

      Steps to replicate:

      1) Create course and enable course activity completion.
      2) Turn editing on
      3) Add lesson module with following settings:

      Name: anything
      Description: anything
      Grade type: none
      Activity completion - completion tracking : when conditions are met
      Activity completion - require view : tick
      Activity completion - require grade: tick
      Activity completion -Expect completed on : tick and leave as today

      4) Click 'save and display'

      Result:

      Debug info: Cannot find grade item for 'lesson'
      cm '16' matching number '0'
      Error code: err_system

      Stack trace:

      line 1329 of /lib/completionlib.php: moodle_exception thrown
      line 650 of /lib/completionlib.php: call to completion_info>internal_systemerror()-
      line 583 of /lib/completionlib.php: call to completion_info>internal_get_state()-
      line 707 of /lib/completionlib.php: call to completion_info>update_state()-
      line 53 of /mod/lesson/view.php: call to completion_info>set_module_viewed()-

      NOTE: I've found that this affects other modules too, so probably an issue with the completionlib as opposed to the module itself.

        Attachments

          Activity

            People

            Assignee:
            peterdias Peter Dias
            Reporter:
            brudinie guy thomas
            Peer reviewer:
            Mihail Geshoski
            Integrator:
            Adrian Greeve
            Tester:
            Anna Carissa Sadia
            Participants:
            Component watchers:
            David Jones, Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan, Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            6 Vote for this issue
            Watchers:
            15 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              18/Jan/21

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 1 hour, 35 minutes
                1d 1h 35m