Add error flash for strange bug that can occur in firefox where dragged files may not end up 'sticking' in the file upload input, prompting user to reupload their files instead of failing silently'
MODIFY
app/views/assessments/_handin_form.html.erb
app/views/assessments/_handin_form.html.erb
var submittedFile = false;
function flashError(message) {
- const elem = $("<div />").prop("id", "flash_error").addClass("error").text(message);
- $("#flashes").append(
- elem
- );
-
- setTimeout(() => {
- elem.hide(500);
- }, 3000);
+ const elem = $(".file-error").text(message).show();
}
function dropHandler(e) {
document.querySelector("#handin_show_assessment input[type='file']").addEventListener(
"change",
function (e) {
- console.log("files changed");
showFiles();
},
false
}
if (fileSelector.files.length === 1) {
- $(".handin-row").hide();
+ $(".handin-row").hide(0, function () {
+ $(".file-error").hide();
+ });
$(".handedin-row").show();
enableSubmit();
}
</script>
<% end %>
<div class="row handin-row">
+ <div class="error file-error" id="flash_error" style="background: white;display: none;">
+ There was an error processing your file, please try adding it again.
+ </div>
<div class="valign-wrapper drag-drop-handin" onclick="clickDrag();" ondrop="dropHandler(event);" ondragover="dragOverHandler(event);" ondragenter="dragEnter(event);" ondragexit="dragExit(event);">
<p class="center-align" style="color:grey;" ondrop="dropHandler(event);" ondragover="dragOverHandler(event);" ondragenter="dragEnter(event);" ondragexit="dragExit(event);"><b>Drag a file here to hand in. Click to select a file.</b> <br /> <span style="font-size: 10px;">Files do not submit automatically.</span></p>
</div>

Add error flash for strange bug that can occur in firefox where dragged files may not end up 'sticking' in the file upload input, prompting user to reupload their files instead of failing silently'