-
Bug
-
Resolution: Fixed
-
Minor
-
3.9.4, 3.10.1, 3.11, 4.0
-
MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
-
MOODLE_310_STABLE, MOODLE_39_STABLE
-
MDL-70947-master -
Previously (MDL-62712) we implemented protection, so that if a file is in the middle of being up-loaded, you get a warning if you try to leave (e.g. submit the form) before the upload is complete.
However, due to other changes, there are at least two problems with this:
A) Not all uploads are protected. For example,
- Start writing a new forum discussion and add something to all required form fields.
- Drag-and-drop a large image into atto (it probably helps to use your browser developer tools to throttel your connection.)
- Before the upload is complete, click the Submit button.
Actual result: the forum just stubmit.
Expected result: you are warned.
B) This protection interacts badly with the double-submit protection (MDL-38555).
- Go to a form with a file-manager (e.g. Question bank > Import)
- Fill in required fields.
- Drag a large file into the file manager.
- Click Submit.
- In the pop-up warning "Your responses have not been saved to the server ...", click cancel
Expected result: once the upload completes, you can submit.
Acutal result: you are suck on a form with a disabled button, and nothing you can do.
Following a discussion between Huong and Tim, we think a solution might be.
- We should introduce custom events upload-started and upload-complete. (Does Moodle have a naming convention for this? tool_dataprivacy uses names like tool_dataprivacy-data_request:approve, so perhaps core_form-upload:start, core_form-upload:complete.)
- We should listen to those events in lib/form/amd/src/submit.js. This brings the two bits of code that were previsouly interacting badly close together, where the interaction is easier to understant). This event listener should implement the current onbeforeunload logic, but should also disable buttons during the upload (like Huong's first proposed solution.)
- We should improve the way buttons are disabled. We should only disable buttons that are currently enabled, and when we do, we should add an attribute like data-disabled-by-upload-protection="1". Then, when upload is complete, we should re-enable all the buttons with that data attribute, and remove the attributes.
- To help with event triggering, it might be useful to add helper methods triggerUploadStart() and triggerUploadComplete() in lib/form/amd/src/submit.js (I am not sure).
- Then ensure that all places where file uploads are hadled trigger the necessary events. That is, replace the two current reportUploadDirtyState functions with the new events, and add the events to atto_image and atto_filedragdrop.
- caused a regression
-
MDL-74287 Early (web) installation steps lead to table does not exist errors
- Closed
-
MDL-77368 Remove left over console debugging code in file upload module
- Closed
- has been marked as being related by
-
MDL-62712 Filepicker: Lost the uploading file when user press Submit before upload process has done
- Closed
- is a regression caused by
-
MDL-66679 Submit button remains disabled after file download
- Closed
-
MDL-38555 Forms do not prevent same data submission multiple times.
- Closed
- Testing discovered
-
MDL-71644 File upload still gets stuck if try to leave page mid-upload
- Closed