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

Course completion restrictions broken for sections after API import

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE

      Description

      Say we have two activities (in this example assignments) in a course in two different sections:

      • Section 1
        • Assignment 1
      • Section 2
        • Assignment 2

      Activities and sections can depend on activities. This means "Section 2" can depend on the completion of "Assigment 1" which means "Section 2" will (e.g.) only be avalable if "Assignment 1" is marked as completed.

      This works out of the box in Moodle. However sometimes these "Restrict access" references between activities and sections are ruined after an API import with the method core_course_external::import_course (located in the path "/course/externallib.php").

      It's very strange because it only happens sometimes and only if you do a manual import and an API import afterwards. I don't know if it happens in other scenarios as well.

      How to test:

      Create three empty courses:

      • Course 1
      • Course 2
      • Course 3

      Add two activities to "Course 1" (e.g. assignments) in two different sections:

      • Section 1
        • Assignment 1
      • Section 2
        • Assignment 2

      1) Edit "Section 2" by clicking the cogwheel icon, expand the "Restrict access" tab and choose "Add restriction" => "Activity completion"
      2) Choose "Assignment 1" and "Must be marked as completed" as the condition for the access restriction
      3) Click the "Save changes" button to go back to the course

      Below "Section 2" the following text should now appear:
      "Not available unless: The activity Assignment 1 is marked complete"

      1) Go to "Course 2"
      2) Do a manual import from "Course 1" (with all data)
      3) Look at the imported data. Everything should be ok (no missing activity)

      Now call the webservice using REST and import all data from "Course 2" to "Course 3":
      This will (sometimes) result in broken restrictions (activity condition) in "Course 3". If that's the case you should see this text in "Course 3" below "Section 2":
      "Not available unless: The activity Missing activity is marked complete"

      The activity (Assignment 1) is there but the reference between the activity and the section isn't. Seems to be a bug.

      Everything seems to work fine if you do two manual imports after each other so I'm quite sure this bug only occurs in the API import method core_course_external::import_course (located in the path "/course/externallib.php").

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              johnnypraxis Johnny Drud
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Juan Leyva, Jake Dallimore, Jun Pataleta
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: