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

question_category.stamp should be unique, but this is not enforced

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 3.2
    • 2.9.6, 3.0.4, 3.1
    • Backup, Questions
    • MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE
    • MOODLE_32_STABLE
    • MDL-54864-master
    • Hide

      We need to test the upgrade process, so you'll need to revert the patch and its DB changes

      1. Revert this patch. This will allow duplicate stamps to be created when moving question categories around after a restore.
      2. Using your favourite DB tool, remove the unique index (contextid, stamp) from question_categories.

      Setting up the courses and duplication of contextid, stamp

      1. Create a new course under the 'Miscellaneous' category and navigate to course home
      2. Create a new question category at course-level (Course admin > Question bank > Categories)
        • Under the 'Add category' form (bottom of page) set parent category to 'Top', under the bold section 'Course: YOUR COURSE NAME'
        • Enter a name and save
      3. Confirm that you see the new question category listed under the section titles 'Question cateogories for course: YOUR COURSE NAME'
      4. From the course admin menu select 'Question bank > Questions'
      5. Select the category you just created from the list and click 'Create new question'
      6. Click 'True/false'
      7. Enter a name and description and click save changes
      8. Click 'Question bank > Categories' from the course admin block
      9. Confirm that* you see a'(1)' next to the category you just created, indicating that one question has been created within it.
      10. Go to course home and add a quiz
      11. Name it and click 'save and display'
      12. Click 'Edit quiz' button to add questions
      13. Click 'Add' and select 'a question from question bank'
      14. Select the question category you created earlier and add the question by checking the box and clicking 'Add selected .. to quiz'
      15. Confirm that you see the question listed
      16. From the admin menu, select 'Course admin > Backup'
      17. Backup the course, using all default settings (You can use 'Jump to final step')
      18. When the backup finishes, click 'Continue'
      19. Click the restore link to restore the course
      20. Continue to restore as a new course, with category = 'Miscellaneous'. Change the name slightly so you can differentiate.
      21. When the restore completes, click continue.
      22. Now, using your preferred DB tool inspect the question_categories table.
      23. For the category you created earlier, confirm that:
        • There are 2 entries
        • Both entries share the same stamp value
        • The 2 entries have different contextid values
      24. Copy this stamp and remember it!
      25. Leave your DB tool open
      26. Now, in the original course you created, click 'Question bank > Categories'
      27. Edit the category you created earlier and change its parent to 'Top' under the 'Category: Miscellaneous' header. Save.
      28. Confirm that you see the category listed under the 'Question categories for category: Miscellaneous' section
      29. Do the same for the restored course. You may wish to rename the category as you move it.
      30. Now, back in your DB tool, refresh and confirm that:
        • There are still 2 records for the question category you created
        • Both records have the same stamp value
        • Both records have the same contextid
      31. Again, leave the DB tool open

      Testing the upgrade script

      1. Apply the patch
      2. Click 'dashboard' and run through the upgrade process
      3. Confirm that the upgrade completes and that no errors/warnings are present.
      4. Now, in your DB tool, Confirm that
        • There are still 2 records for the question category you created earlier
        • The record with the higher ID (from the restore) has a new stamp (compare it to the stamp you copied from the original earlier)
        • Both records have the same contextid

      Testing the question category form changes:

      1. Navigate back to the course home of the original course
      2. Restore the course into a new course, make sure to change the name
      3. Using your DB tool, Confirm that
        • You now see 3 entries for the question category you created earlier
        • The stamp of the newest record matches the stamp of the original, albeit in a different context.
      4. Within the restored course move the question category from the course-level to the miscellaneous level, as before
      5. Again, with your DB tool, confirm that
        • You now see 3 entries for the question category you created earlier
        • Of those 3, the stamp for the newest entry doesn't match the stamp of the original
        • The 2 entries share the same context id.
      Show
      We need to test the upgrade process, so you'll need to revert the patch and its DB changes Revert this patch. This will allow duplicate stamps to be created when moving question categories around after a restore. Using your favourite DB tool, remove the unique index (contextid, stamp) from question_categories. Setting up the courses and duplication of contextid, stamp Create a new course under the 'Miscellaneous' category and navigate to course home Create a new question category at course-level (Course admin > Question bank > Categories) Under the 'Add category' form (bottom of page) set parent category to 'Top', under the bold section 'Course: YOUR COURSE NAME' Enter a name and save Confirm that you see the new question category listed under the section titles 'Question cateogories for course: YOUR COURSE NAME' From the course admin menu select 'Question bank > Questions' Select the category you just created from the list and click 'Create new question' Click 'True/false' Enter a name and description and click save changes Click 'Question bank > Categories' from the course admin block Confirm that* you see a'(1)' next to the category you just created, indicating that one question has been created within it. Go to course home and add a quiz Name it and click 'save and display' Click 'Edit quiz' button to add questions Click 'Add' and select 'a question from question bank' Select the question category you created earlier and add the question by checking the box and clicking 'Add selected .. to quiz' Confirm that you see the question listed From the admin menu, select 'Course admin > Backup' Backup the course, using all default settings (You can use 'Jump to final step') When the backup finishes, click 'Continue' Click the restore link to restore the course Continue to restore as a new course, with category = 'Miscellaneous'. Change the name slightly so you can differentiate. When the restore completes, click continue. Now, using your preferred DB tool inspect the question_categories table. For the category you created earlier, confirm that: There are 2 entries Both entries share the same stamp value The 2 entries have different contextid values Copy this stamp and remember it! Leave your DB tool open Now, in the original course you created, click 'Question bank > Categories' Edit the category you created earlier and change its parent to 'Top' under the 'Category: Miscellaneous' header. Save. Confirm that you see the category listed under the 'Question categories for category: Miscellaneous' section Do the same for the restored course. You may wish to rename the category as you move it. Now, back in your DB tool, refresh and confirm that: There are still 2 records for the question category you created Both records have the same stamp value Both records have the same contextid Again, leave the DB tool open Testing the upgrade script Apply the patch Click 'dashboard' and run through the upgrade process Confirm that the upgrade completes and that no errors/warnings are present. Now, in your DB tool, Confirm that There are still 2 records for the question category you created earlier The record with the higher ID (from the restore) has a new stamp (compare it to the stamp you copied from the original earlier) Both records have the same contextid Testing the question category form changes: Navigate back to the course home of the original course Restore the course into a new course, make sure to change the name Using your DB tool, Confirm that You now see 3 entries for the question category you created earlier The stamp of the newest record matches the stamp of the original, albeit in a different context. Within the restored course move the question category from the course-level to the miscellaneous level, as before Again, with your DB tool, confirm that You now see 3 entries for the question category you created earlier Of those 3, the stamp for the newest entry doesn't match the stamp of the original The 2 entries share the same context id.
    • 3.2 Sprint 4

      This has been separated out from MDL-26442. Briefly, the problem is that question_category.stamp should be unique, but there is not a unique index to enforce that, and there are bugs (we believe in backup and restore) that lead to non-unique values there.

      This causes problems with later backups and restores. For more details see https://tracker.moodle.org/browse/MDL-26442?focusedCommentId=219984&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-219984 and the reply.

            jaked Jake Dallimore
            timhunt Tim Hunt
            Tim Hunt Tim Hunt
            Dan Poltawski Dan Poltawski
            Adrian Greeve Adrian Greeve
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

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