From cf532b4fce00323726eb47ec9d8238a0fc0c6eac Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Tue, 1 Oct 2024 15:55:16 -0500 Subject: [PATCH] Fix multiple loading of javscript for the single problem grader. This is the cause of issue #2588. If a gateway quiz has mulitple problems on the same page, then the single problem grader template is loaded once for each problem. Each time the template is loaded, it adds the single problem grader javacript to the page. So as many instances of the javascript are active on the page as there are problems on the page. As such, the save button event handlers are added once for each problem on the page as well. So when the save button is clicked, the score and comment for that problem are submitted once for each problem on the page. All of those requests firing at the same time can cause authentication to fail because the session key can be deleted and put back in again by different processes, and the timing of things can mess things up. Note that this does reveal some deeper database issues though. --- templates/HTML/SingleProblemGrader/grader.html.ep | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/HTML/SingleProblemGrader/grader.html.ep b/templates/HTML/SingleProblemGrader/grader.html.ep index e8f51ab399..295d1a708d 100644 --- a/templates/HTML/SingleProblemGrader/grader.html.ep +++ b/templates/HTML/SingleProblemGrader/grader.html.ep @@ -1,8 +1,11 @@ % use WeBWorK::Utils 'wwRound'; % -% content_for js => begin - <%= javascript getAssetURL($ce, 'js/ProblemGrader/singleproblemgrader.js'), defer => undef =%> -% end +% if (!stash->{jsInserted}) { + % stash->{jsInserted} = 1; + % content_for js => begin + <%= javascript getAssetURL($ce, 'js/ProblemGrader/singleproblemgrader.js'), defer => undef =%> + % end +% } %