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

lesson_branch is not cleaned when a lesson page is deleted

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.7.4, 2.8.2
    • Fix Version/s: 2.7.8, 2.8.6
    • Component/s: Lesson
    • Labels:
    • Testing Instructions:
      Hide

      Testing require to look at database records. The upgrade step and restoration of old backups needs to be tested on all supported databases

      Before upgrade

      • In a course, as a teacher create a lesson
      • add 2 content pages to the lesson with Content 1 set to "Next" and jump set to "Next page". We will call these 2 pages page 1 and page 2
      • as a student (will not work with a teacher in attempt mode) attempt the lesson and click on "Next" on both pages until you reach the end of lesson page
      • connect again as a teacher click on the lesson, click on the edit tab and delete the content page 1 in the lesson
      • Look in the database, first look into the lesson table to find lesson's id, then look in the lesson_branch table to search for records with lessonid set to the lesson id. you should find 2 records with userid set to student's id that you used in above step to attempt the lesson. One of these 2 records should not have any associated record in the lesson_pages table
      • backup the course

      Upgrade the Moodle website

      • after upgrade verify that the orphaned record in lesson_branch table has been deleted
      • to do that first look into the lesson table to find lesson's id, then look in the lesson_branch table to search for records with lessonid set to the lesson id. You should find 1 record and not 2 with userid set to student's id that you used in above step to attempt the lesson.
      • restore the backup that you have done in step 1 and verify the orphaned record has been deleted
      • to do that first look into the lesson table to find lesson's id, then look in the lesson_branch table to search for records with lessonid set to the lesson id. You should find 1 record and not 2 with userid set to student's id that you used in above step to attempt the lesson.

      Test of page suppression after upgrade

      • In a course, as a teacher create a lesson
      • add 2 content pages to the lesson with Content 1 set to "Next" and jump set to "Next page". We will call these 2 pages page 1 and page 2
      • as a student (will not work with a teacher in attempt mode) attempt the lesson and click on "Next" on both pages until you reach the end of lesson page
      • Look in the database, first look into the lesson table to find lesson's id, then look in the lesson_branch table to search for records with lessonid set to the lesson id. you should find 2 records with userid set to student's id that you used in above step to attempt the lesson.
      • connect again as a teacher click on the lesson, click on the edit tab and delete the content page 1 in the lesson
      • Look again in the database and verify there is now only one record in the lesson_branch table for the lessonid. Verify that the pagid of that record match id of the page 2 record in the lesson_pages table.
      Show
      Testing require to look at database records. The upgrade step and restoration of old backups needs to be tested on all supported databases Before upgrade In a course, as a teacher create a lesson add 2 content pages to the lesson with Content 1 set to "Next" and jump set to "Next page". We will call these 2 pages page 1 and page 2 as a student (will not work with a teacher in attempt mode) attempt the lesson and click on "Next" on both pages until you reach the end of lesson page connect again as a teacher click on the lesson, click on the edit tab and delete the content page 1 in the lesson Look in the database, first look into the lesson table to find lesson's id, then look in the lesson_branch table to search for records with lessonid set to the lesson id. you should find 2 records with userid set to student's id that you used in above step to attempt the lesson. One of these 2 records should not have any associated record in the lesson_pages table backup the course Upgrade the Moodle website after upgrade verify that the orphaned record in lesson_branch table has been deleted to do that first look into the lesson table to find lesson's id, then look in the lesson_branch table to search for records with lessonid set to the lesson id. You should find 1 record and not 2 with userid set to student's id that you used in above step to attempt the lesson. restore the backup that you have done in step 1 and verify the orphaned record has been deleted to do that first look into the lesson table to find lesson's id, then look in the lesson_branch table to search for records with lessonid set to the lesson id. You should find 1 record and not 2 with userid set to student's id that you used in above step to attempt the lesson. Test of page suppression after upgrade In a course, as a teacher create a lesson add 2 content pages to the lesson with Content 1 set to "Next" and jump set to "Next page". We will call these 2 pages page 1 and page 2 as a student (will not work with a teacher in attempt mode) attempt the lesson and click on "Next" on both pages until you reach the end of lesson page Look in the database, first look into the lesson table to find lesson's id, then look in the lesson_branch table to search for records with lessonid set to the lesson id. you should find 2 records with userid set to student's id that you used in above step to attempt the lesson. connect again as a teacher click on the lesson, click on the edit tab and delete the content page 1 in the lesson Look again in the database and verify there is now only one record in the lesson_branch table for the lessonid. Verify that the pagid of that record match id of the page 2 record in the lesson_pages table.
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull Master Branch:

      Description

      In locallib.php in the delete function of the lesson_page class, the lesson_branch table is not purged when we delete a lesson page, so we may have orphaned records in the lesson_branch table.
      Fixing the code is easy.
      My only concern is if we should delete orphaned records or not during upgrade.
      IMHO we should do that because it's always bad to have bad data even if I don't think these ones could be harmful.

        Attachments

          Activity

            People

            Assignee:
            jmvedrine Jean-Michel Vedrine
            Reporter:
            jmvedrine Jean-Michel Vedrine
            Peer reviewer:
            Simey Lameze Simey Lameze
            Integrator:
            Dan Poltawski Dan Poltawski
            Tester:
            Zachary Durber Zachary Durber
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/May/15