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

Course: Drag and drop uploads can be added to wrong section

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 3.10.7
    • Course
    • MOODLE_310_STABLE
    • MDL-72881-master
    • Hide

      Note: There are 2 types of drag-and-drop of a file onto a course page: media files that pop up a dialog, and other files that don't. To test both routes, you will need an image file (.png) and a text file (.txt).

      1. Create a new course with Topics format
      2. Go to the course and turn editing on.
      3. Set the title of topic 2 to 'Important files!'.
      4. Open a second tab on the same course.
      5. In the second tab, delete topic 1.
      6. In the first tab, drag and drop a text file (something.txt) from your computer into the 'Important files!' topic. Wait for upload to finish.
        • EXPECTED: The 'Important files!' topic should now contain a text file.
      7. Drag and drop an image file (something.png) into the same topic. From the popup dialog that appears, choose the option to add a file resource.
        • EXPECTED: The image file should appear in the topic as a clickable link.
      8. Drag and drop the image file (something.png) into the same topic again. From the popup dialog that appears, choose the other option to add to course page.
        • EXPECTED: The image should appear in the topic (within a label).
      9. Reload the page
        • EXPECTED: All three added items should still be in the 'Important files!' topic, even though this topic has now moved up the page a bit.
      Show
      Note: There are 2 types of drag-and-drop of a file onto a course page: media files that pop up a dialog, and other files that don't. To test both routes, you will need an image file (.png) and a text file (.txt). Create a new course with Topics format Go to the course and turn editing on. Set the title of topic 2 to 'Important files!'. Open a second tab on the same course. In the second tab, delete topic 1. In the first tab, drag and drop a text file (something.txt) from your computer into the 'Important files!' topic. Wait for upload to finish. EXPECTED: The 'Important files!' topic should now contain a text file. Drag and drop an image file (something.png) into the same topic. From the popup dialog that appears, choose the option to add a file resource. EXPECTED: The image file should appear in the topic as a clickable link. Drag and drop the image file (something.png) into the same topic again. From the popup dialog that appears, choose the other option to add to course page. EXPECTED: The image should appear in the topic (within a label). Reload the page EXPECTED: All three added items should still be in the 'Important files!' topic, even though this topic has now moved up the page a bit.

      If you use drag-and-drop upload to a course that multiple people are editing, this can have unexpected results because it uses section number (not id) to identify the place you are uploading to.

      To reproduce:

      1. Create a new course with Topics format
      2. Go to the course and turn editing on.
      3. Add a label in topic 2 with text 'This topic has an important file'.
      4. Add a label in topic 3 with text 'This topic does not have a file'.
      5. Open a second tab on the same course.
      6. In the second tab, delete topic 1.
      7. In the first tab, drag and drop a text file (something.txt) from your computer into topic 2.
        • Observe that the file has appeared correctly in topic 2 before the label that says there is a file in that topic.
      8. Reload the page
        • Now the file is showing in the topic that supposedly doesn't have a file.

      This is a made-up example; the problem is worse when sections are configured to appear on different pages. In that case, when you reload the page your file that you just added disappears entirely.

      We also had cases where the course got somehow broken as a result of this - a cmid that isn't in any section at all, for instance - which could be this problem, or could be because the logic about drag and drop upload doesn't use database transactions which it should do. So I'll add a transaction as well when I change it.

      There are of course lots of ways that something similar could break the page when two people are editing a course at once (for example, somebody could delete the same topic you are actually editing) but this one is easily avoidable - all that is needed is to use the section id instead of the section number, and the topic being uploaded to will stay consistent.

            quen Sam Marshall
            quen Sam Marshall
            Ferran Recio Ferran Recio
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h

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