Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend : unable to visualize past submissions (javascript error) #1021

Open
lsignac opened this issue Sep 2, 2024 · 2 comments
Open

frontend : unable to visualize past submissions (javascript error) #1021

lsignac opened this issue Sep 2, 2024 · 2 comments
Labels
Bug Triage needed Project maintainers still have to review this issue

Comments

@lsignac
Copy link

lsignac commented Sep 2, 2024

Describe the bug
students can not access old submissions, due to a Javascript Error.

INGInious installation details

To Reproduce
Steps to reproduce the behavior:

  1. Go to A task and submit something
  2. Click on the left on your old submission
  3. 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

@lsignac lsignac added Bug Triage needed Project maintainers still have to review this issue labels Sep 2, 2024
@lsignac lsignac changed the title Add the context of the bug at the beginning of the title, if possible, e.g. [frontend/installer] frontend : unable to visualize past submissions (javascript error) Sep 2, 2024
@vvandenschrieck
Copy link

vvandenschrieck commented Oct 11, 2024

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).

@vvandenschrieck
Copy link

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 :-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Triage needed Project maintainers still have to review this issue
Projects
None yet
Development

No branches or pull requests

2 participants