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

When a page is deleted, files from other page answers could be deleted

XMLWordPrintable

    • MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE
    • MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE
    • wip-MDL-57649-master
    • Hide

      Before upgrade.

      1. Create a lesson.
      2. Add a question.
      3. Add images everywhere that you can (Page contents, Answer, response).
      4. Go to the database and check for the files that you uploaded.

        select *
        FROM "mdl_files"
        where component like '%lesson%'
        

      5. Make note of the entries relating to your lesson.
      6. Delete the question page.
      7. Check that the page_answers and page_responses are still in the files table.
      8. Upgrade to the current version.
      9. Check that the page_answers and page_responses have now been deleted.

      After upgrade

      1. Run through steps 1 - 6
      2. Check the database again and see that this time all of the files (page_answers, page_responses, and page_contents) have been deleted.
      Show
      Before upgrade. Create a lesson. Add a question. Add images everywhere that you can (Page contents, Answer, response). Go to the database and check for the files that you uploaded. select * FROM "mdl_files" where component like '%lesson%' Make note of the entries relating to your lesson. Delete the question page. Check that the page_answers and page_responses are still in the files table. Upgrade to the current version. Check that the page_answers and page_responses have now been deleted. After upgrade Run through steps 1 - 6 Check the database again and see that this time all of the files (page_answers, page_responses, and page_contents) have been deleted.
    • 3.4 Sprint 2

      I noticed this when reviewing the code for the lesson module (I'm reviewing it because I'm working in Web Services for the mobile app).

      https://github.com/moodle/moodle/blob/master/mod/lesson/locallib.php#L2400

      The itemid for the file areas page_answers and page_responses is not the pageid, is the page's answer id.

      The way to solve this would be iterate over all the pages answers and then delete those are files using the answer id as itemid.

      foreach ($lessonanswers as $answer){
              $fs->delete_area_files($context->id, 'mod_lesson', 'page_answers', $answer->id);
              $fs->delete_area_files($context->id, 'mod_lesson', 'page_responses', $answer->id);
      }
      

        1. after_step1.png
          after_step1.png
          133 kB
        2. after_step2.png
          after_step2.png
          110 kB
        3. after_step3.png
          after_step3.png
          71 kB
        4. after_step4.png
          after_step4.png
          110 kB
        5. after_step5.png
          after_step5.png
          93 kB
        6. step1.png
          step1.png
          129 kB
        7. step2.png
          step2.png
          123 kB
        8. step3.png
          step3.png
          77 kB

            abgreeve Adrian Greeve
            jleyva Juan Leyva
            Andrew Lyons Andrew Lyons
            Dan Poltawski Dan Poltawski
            Marina Glancy Marina Glancy
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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