INGInious
INGInious copied to clipboard
frontend : unable to visualize past submissions (javascript error)
Describe the bug students can not access old submissions, due to a Javascript Error.
INGInious installation details
- Version: INGInious @ git+https://github.com/UCL-INGI/INGInious.git@6e14ae8edb65b0ce18059863655659ba9efea129
- Containers version (if applicable) [e.g. the git hash]
To Reproduce Steps to reproduce the behavior:
- Go to A task and submit something
- Click on the left on your old submission
- The submission does not appear
Expected behavior The submission should appear in the codemirror editor.
The Javascript error is raised in codemirror (minified) code :
Uncaught TypeError: e.split is not a function
at Bl (codemirror.js:3:106416)
at va.splitLines (codemirror.js:3:127125)
at va.<anonymous> (codemirror.js:3:119630)
at va.setValue (codemirror.js:3:53793)
at Do.setValue (codemirror.js:3:160479)
at load_input_code (task.js:740:30)
at load_input (task.js:732:52)
at Object.<anonymous> (task.js:685:17)
at u (jquery.min.js:2:27457)
at Object.fireWith [as resolveWith] (jquery.min.js:2:28202)
The line Bl (codemirror.js:3:106416) is return e.split(/\r\n?|\n/)
e should contain the submission code. Instead, e is an Array whose first and only value is the submission code.
e is ['def fn():\r\n...'] instead of 'def fn():\r\n...'.
Looking in the call stack I looked at Object.<anonymous> (task.js:685:17) :
function loadOldSubmissionInput(id, with_feedback)
{
if(loadingSomething)
return;
blurTaskForm();
resetAlerts();
displayTaskInputLoadingAlert();
var url = $('form#task').attr("action");
jQuery.post(url, {"@action": "load_submission_input", "submissionid": id}, null, "json")
.done(function(data)
{
if("status" in data && data['status'] == "ok" && "input" in data)
{
updateMainTags(data);
unblurTaskForm();
load_input(id, data['input']);
if(with_feedback) // load feedback in second place as it may affect the input
loadOldFeedback(data);
}
else
{
displayTaskInputErrorAlert();
unblurTaskForm();
}
}).fail(function()
{
displayTaskInputErrorAlert();
unblurTaskForm();
});
}
Using the chrome debugger, I saw that data['input']['sub01'] (sub01 is the name of the only subproblem of my task) is an Array. I think it should be a string. I added this line
data['input']['sub01'] = data['input']['sub01'][0]; just before load_input(id, data['input']);
Everything works fine !
Sure there is a better fix (may be the issue is in the chunks stored in the database...?), and I would like to know if I am the only one facing this issue
I've got the same issues : my students are unable to reload past submissions :-/.
Same error in JS console.
Using INGInious version v.0.8.7 (upgraded last month).
Instead of changing the loadOldSubmissionInput function, I preferred to go further in the stacktrace and I used the following fix in tasks.js - function load_input_code (approx. line 740) to replace the array by its content (input[key] => input[key][0]) :
function load_input_code(submissionid, key, input)
{
if(key in codeEditors) {
if(key in input)
codeEditors[key].setValue(input[key][0], -1); // BugFix
else
codeEditors[key].setValue("", -1);
}
else {
var field = $("input[name='" + key + "']");
if(key in input)
$(field).val(input[key][0]); //BugFix
else
$(field).val("");
}
}
Seems to be working for now, but I'm not sure about possible side effects. I'd be happy with an official fix :-).