From bb54ee2ddfacc64554630c4e41df44a6a158d058 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Fri, 16 Apr 2021 10:27:59 -0500 Subject: [PATCH 01/10] Update the other formats with the features added to the simple_format in pull request #1301. There are also a few tweaks to the simple format as well. Mainly just adding the answer blank coloration (but only if it is not an answer preview and is a submit or check answers). --- lib/FormatRenderedProblem.pm | 2 +- lib/WebworkClient/json_format.pl | 7 +++++-- lib/WebworkClient/simple2_format.pl | 18 ++++++++---------- lib/WebworkClient/simple_format.pl | 5 +++-- lib/WebworkClient/standard_format.pl | 13 ++++++------- lib/WebworkClient/sticky_format.pl | 7 ++++--- 6 files changed, 27 insertions(+), 25 deletions(-) diff --git a/lib/FormatRenderedProblem.pm b/lib/FormatRenderedProblem.pm index 1958f4ebd9..4dc7cace61 100644 --- a/lib/FormatRenderedProblem.pm +++ b/lib/FormatRenderedProblem.pm @@ -212,7 +212,7 @@ sub formatRenderedProblem { summary => $problemResult->{summary} // '', # can be set by problem grader ); my $answerTemplate = $tbl->answerTemplate; - my $color_input_blanks_script = $tbl->color_answer_blanks; + my $color_input_blanks_script = (!$previewMode && ($checkMode || $submitMode)) ? $tbl->color_answer_blanks : ""; $tbl->imgGen->render(refresh => 1) if $tbl->displayMode eq 'images'; # Score summary diff --git a/lib/WebworkClient/json_format.pl b/lib/WebworkClient/json_format.pl index 9e1916e371..bec38660f2 100644 --- a/lib/WebworkClient/json_format.pl +++ b/lib/WebworkClient/json_format.pl @@ -82,9 +82,9 @@ $json_output->{body_part790} = "

"; -$json_output->{body_part999} = <<'ENDPROBLEMTEMPLATE'; +$json_output->{body_part999_VI} = <<'ENDPROBLEMTEMPLATE'; - +$footer ENDPROBLEMTEMPLATE @@ -104,7 +104,10 @@ $json_output->{hidden_input_field_outputformat} = 'json'; $json_output->{hidden_input_field_language} = '$formLanguage'; $json_output->{hidden_input_field_showSummary} = '$showSummary'; +$json_output->{hidden_input_field_showAnswerNumbers} = '$showAnswerNumbers'; +$json_output->{hidden_input_field_showFooter} = '$showFooter'; $json_output->{hidden_input_field_forcePortNumber} = '$forcePortNumber'; +$json_output->{hidden_input_field_extraHeaderText} = '$extra_header_text'; # These are the real WeBWorK server URLs which the intermediate needs to use # to communicate with WW, while the distant client must use URLs of the diff --git a/lib/WebworkClient/simple2_format.pl b/lib/WebworkClient/simple2_format.pl index b905b0e8ce..49796b7d7d 100644 --- a/lib/WebworkClient/simple2_format.pl +++ b/lib/WebworkClient/simple2_format.pl @@ -33,13 +33,14 @@ $problemHeadText -WeBWorK using host: $SITE_URL, format: simple seed: $problemSeed +WeBWorK using host: $SITE_URL, format: simple2 seed: $problemSeed
$answerTemplate + $color_input_blanks_script
$problemText @@ -54,8 +55,8 @@ - - + + @@ -63,7 +64,10 @@ + + +

@@ -72,13 +76,7 @@

- - - +$footer diff --git a/lib/WebworkClient/simple_format.pl b/lib/WebworkClient/simple_format.pl index bfdac15f89..1d549fa176 100644 --- a/lib/WebworkClient/simple_format.pl +++ b/lib/WebworkClient/simple_format.pl @@ -39,6 +39,7 @@
$answerTemplate + $color_input_blanks_script
$problemText @@ -53,8 +54,8 @@ - - + + diff --git a/lib/WebworkClient/standard_format.pl b/lib/WebworkClient/standard_format.pl index aeacd48f2b..212ce2397d 100644 --- a/lib/WebworkClient/standard_format.pl +++ b/lib/WebworkClient/standard_format.pl @@ -52,8 +52,8 @@ - - + + @@ -61,8 +61,10 @@ + + - +

@@ -79,10 +81,7 @@ $debug_messages

internal errors

$internal_debug_messages - - +$footer diff --git a/lib/WebworkClient/sticky_format.pl b/lib/WebworkClient/sticky_format.pl index 72d5ec71a6..e798e35ad4 100644 --- a/lib/WebworkClient/sticky_format.pl +++ b/lib/WebworkClient/sticky_format.pl @@ -44,6 +44,7 @@

$answerTemplate +$color_input_blanks_script
@@ -75,6 +76,8 @@ + +

@@ -86,9 +89,7 @@

- +$footer From 61fe38c6517184163df49bc04cac4a9127d11226 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Tue, 20 Apr 2021 06:31:42 -0500 Subject: [PATCH 02/10] Add theme selection to the WebworkWebservice clients. This fixes #1335. --- lib/FormatRenderedProblem.pm | 6 +++++- lib/WebworkClient/json_format.pl | 11 +++++++---- lib/WebworkClient/simple2_format.pl | 8 ++++++-- lib/WebworkClient/simple_format.pl | 8 ++++++-- lib/WebworkClient/standard_format.pl | 8 ++++++-- lib/WebworkClient/sticky_format.pl | 7 +++++-- 6 files changed, 35 insertions(+), 13 deletions(-) diff --git a/lib/FormatRenderedProblem.pm b/lib/FormatRenderedProblem.pm index 4dc7cace61..cfa77c7e7f 100644 --- a/lib/FormatRenderedProblem.pm +++ b/lib/FormatRenderedProblem.pm @@ -125,6 +125,10 @@ sub formatRenderedProblem { my $fileName = $self->{input}{envir}{fileName} // ""; my $encoded_source = $self->encoded_source // ""; + # Select the theme and theme directory + my $theme = $self->{inputs_ref}{theme} || $ce->{defaultTheme}; + my $themeDir = "$ce->{webworkURLs}{htdocs}/themes/$theme"; + # Set up the header text my $problemHeadText = ''; @@ -267,7 +271,7 @@ sub formatRenderedProblem { # Show the footer unless it is explicity disabled. my $showFooter = $self->{inputs_ref}{showFooter} // ""; my $footer = $showFooter && $showFooter eq "no" ? '' - : ""; + : ""; # For debugging purposes add $pretty_print_self to the output format in use and uncomment below. #my $pretty_print_self = WebworkClient::pretty_print($self); diff --git a/lib/WebworkClient/json_format.pl b/lib/WebworkClient/json_format.pl index bec38660f2..d915aee726 100644 --- a/lib/WebworkClient/json_format.pl +++ b/lib/WebworkClient/json_format.pl @@ -16,18 +16,20 @@ ENDPROBLEMTEMPLATE -$json_output->{head_part100} = <<'ENDPROBLEMTEMPLATE'; +$json_output->{head_part100_VI} = <<'ENDPROBLEMTEMPLATE'; - + + + ENDPROBLEMTEMPLATE -$json_ouput{head_part200} = <<'ENDPROBLEMTEMPLATE'; +$json_ouput{head_part200_VI} = <<'ENDPROBLEMTEMPLATE'; @@ -41,8 +43,8 @@ - + ENDPROBLEMTEMPLATE $json_output->{head_part300_VI} = '$problemHeadText'; @@ -102,6 +104,7 @@ $json_output->{hidden_input_field_displayMode} = '$displayMode'; $json_output->{hidden_input_field_session_key} = '$session_key'; $json_output->{hidden_input_field_outputformat} = 'json'; +$json_output->{hidden_input_field_theme} = '$theme'; $json_output->{hidden_input_field_language} = '$formLanguage'; $json_output->{hidden_input_field_showSummary} = '$showSummary'; $json_output->{hidden_input_field_showAnswerNumbers} = '$showAnswerNumbers'; diff --git a/lib/WebworkClient/simple2_format.pl b/lib/WebworkClient/simple2_format.pl index 49796b7d7d..69a085db96 100644 --- a/lib/WebworkClient/simple2_format.pl +++ b/lib/WebworkClient/simple2_format.pl @@ -12,9 +12,11 @@ - + + + @@ -29,8 +31,9 @@ - + + $problemHeadText WeBWorK using host: $SITE_URL, format: simple2 seed: $problemSeed @@ -62,6 +65,7 @@ + diff --git a/lib/WebworkClient/simple_format.pl b/lib/WebworkClient/simple_format.pl index 1d549fa176..a47a06cf03 100644 --- a/lib/WebworkClient/simple_format.pl +++ b/lib/WebworkClient/simple_format.pl @@ -11,9 +11,11 @@ - + + + @@ -28,8 +30,9 @@ - + + $problemHeadText WeBWorK using host: $SITE_URL, format: simple seed: $problemSeed @@ -61,6 +64,7 @@ + diff --git a/lib/WebworkClient/standard_format.pl b/lib/WebworkClient/standard_format.pl index 212ce2397d..91fe5f364e 100644 --- a/lib/WebworkClient/standard_format.pl +++ b/lib/WebworkClient/standard_format.pl @@ -9,9 +9,11 @@ - + + + @@ -26,8 +28,9 @@ - + + $problemHeadText @@ -59,6 +62,7 @@ + diff --git a/lib/WebworkClient/sticky_format.pl b/lib/WebworkClient/sticky_format.pl index e798e35ad4..5ac3f1893b 100644 --- a/lib/WebworkClient/sticky_format.pl +++ b/lib/WebworkClient/sticky_format.pl @@ -12,9 +12,10 @@ - + + @@ -32,8 +33,9 @@ - + + $problemHeadText WeBWorK using host: $SITE_URL, format: sticky seed: $problemSeed @@ -74,6 +76,7 @@ + From 7edd635c23bfba09378ccc107cfe41b466518a46 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Thu, 6 May 2021 17:56:22 -0500 Subject: [PATCH 03/10] Make the webwork client formats have the option of not showing any of the submit buttons. They are all shown by default (as it was before). This is implemented for the standard, simple, sticky, and json formats. It does not apply for the others. To hide the buttons add the GET or POST parameters `showPreviewButton=no`, `showCheckAnswersButton=no`, or `showCorrectAnswersButton=no`. The simple2 format is removed as this makes that format pointless. --- lib/FormatRenderedProblem.pm | 14 +++-- lib/WebworkClient/json_format.pl | 15 ++--- lib/WebworkClient/simple2_format.pl | 89 ---------------------------- lib/WebworkClient/simple_format.pl | 9 ++- lib/WebworkClient/standard_format.pl | 9 ++- lib/WebworkClient/sticky_format.pl | 9 ++- 6 files changed, 32 insertions(+), 113 deletions(-) delete mode 100644 lib/WebworkClient/simple2_format.pl diff --git a/lib/FormatRenderedProblem.pm b/lib/FormatRenderedProblem.pm index cfa77c7e7f..a9a611d9c7 100644 --- a/lib/FormatRenderedProblem.pm +++ b/lib/FormatRenderedProblem.pm @@ -240,10 +240,16 @@ sub formatRenderedProblem { $localStorageMessages .= CGI::p('Your overall score for this problem is ' . CGI::span({ id => 'problem-overall-score' }, '')); $localStorageMessages .= CGI::end_div(); - # Submit buttons - my $STRING_Preview = $mt->maketext("Preview My Answers"); - my $STRING_ShowCorrect = $mt->maketext("Show correct answers"); - my $STRING_Submit = $mt->maketext("Check Answers"); + # Submit buttons (all are shown by default) + my $showPreviewButton = $self->{inputs_ref}{showPreviewButton} // ""; + my $previewButton = $showPreviewButton eq "no" ? '' : + ''; + my $showCheckAnswersButton = $self->{inputs_ref}{showCheckAnswersButton} // ""; + my $checkAnswersButton = $showCheckAnswersButton eq "no" ? '' : + ''; + my $showCorrectAnswersButton = $self->{inputs_ref}{showCorrectAnswersButton} // ""; + my $correctAnswersButton = $showCorrectAnswersButton eq "no" ? '' : + ''; # Regular Perl warning messages generated with warn. my $warnings = ''; diff --git a/lib/WebworkClient/json_format.pl b/lib/WebworkClient/json_format.pl index d915aee726..a8102fac89 100644 --- a/lib/WebworkClient/json_format.pl +++ b/lib/WebworkClient/json_format.pl @@ -72,17 +72,7 @@ $json_output->{body_part650_VI} = '$scoreSummary'; -$json_output->{body_part710_VI} = <<'ENDPROBLEMTEMPLATE'; -

- - -ENDPROBLEMTEMPLATE - -$json_output->{body_part780_optional_VI} = <<'ENDPROBLEMTEMPLATE'; - -ENDPROBLEMTEMPLATE - -$json_output->{body_part790} = "

"; +$json_output->{body_part700_VI} = '

$previewButton $checkAnswersButton $correctAnswersButton

'; $json_output->{body_part999_VI} = <<'ENDPROBLEMTEMPLATE';
@@ -108,6 +98,9 @@ $json_output->{hidden_input_field_language} = '$formLanguage'; $json_output->{hidden_input_field_showSummary} = '$showSummary'; $json_output->{hidden_input_field_showAnswerNumbers} = '$showAnswerNumbers'; +$json_output->{hidden_input_field_showPreviewButton} = '$showPreviewButton'; +$json_output->{hidden_input_field_showCheckAnswersButton} = '$showCheckAnswersButton'; +$json_output->{hidden_input_field_showCorrectAnswersButton} = '$showCorrectAnswersButton'; $json_output->{hidden_input_field_showFooter} = '$showFooter'; $json_output->{hidden_input_field_forcePortNumber} = '$forcePortNumber'; $json_output->{hidden_input_field_extraHeaderText} = '$extra_header_text'; diff --git a/lib/WebworkClient/simple2_format.pl b/lib/WebworkClient/simple2_format.pl deleted file mode 100644 index 69a085db96..0000000000 --- a/lib/WebworkClient/simple2_format.pl +++ /dev/null @@ -1,89 +0,0 @@ -$simple_format = <<'ENDPROBLEMTEMPLATE'; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -$problemHeadText - -WeBWorK using host: $SITE_URL, format: simple2 seed: $problemSeed - - -
-
-
- $answerTemplate - $color_input_blanks_script -
-
- $problemText -
-$scoreSummary -$LTIGradeMessage - - - - - - - - - - - - - - - - - - - - - - -

- - - -

-
-
-
-$footer - - - -ENDPROBLEMTEMPLATE - -$simple_format; diff --git a/lib/WebworkClient/simple_format.pl b/lib/WebworkClient/simple_format.pl index a47a06cf03..b451053711 100644 --- a/lib/WebworkClient/simple_format.pl +++ b/lib/WebworkClient/simple_format.pl @@ -68,13 +68,16 @@ + + +

- - - + $previewButton + $checkAnswersButton + $correctAnswersButton

diff --git a/lib/WebworkClient/standard_format.pl b/lib/WebworkClient/standard_format.pl index 91fe5f364e..6ad79b52eb 100644 --- a/lib/WebworkClient/standard_format.pl +++ b/lib/WebworkClient/standard_format.pl @@ -66,13 +66,16 @@ + + +

- - - + $previewButton + $checkAnswersButton + $correctAnswersButton


diff --git a/lib/WebworkClient/sticky_format.pl b/lib/WebworkClient/sticky_format.pl index 5ac3f1893b..b1b0a9aa33 100644 --- a/lib/WebworkClient/sticky_format.pl +++ b/lib/WebworkClient/sticky_format.pl @@ -80,13 +80,16 @@ + + +

- - - +$previewButton +$checkAnswersButton +$correctAnswersButton

From 47325183a6bc1186c5f441168843c4dd5b54df6d Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Thu, 6 May 2021 22:02:37 -0500 Subject: [PATCH 04/10] Remove the standard format and inorporate its contents into the debug format and clean that up a bit. Separate the translator warnings (that don't really exist) and the perl warnings that come from pg that are sent on from renderProblem. --- lib/FormatRenderedProblem.pm | 17 ++-- lib/WebworkClient/debug_format.pl | 113 ++++++++++++++++++++++--- lib/WebworkClient/simple_format.pl | 70 +++++++-------- lib/WebworkClient/standard_format.pl | 97 --------------------- lib/WebworkWebservice/RenderProblem.pm | 5 +- 5 files changed, 148 insertions(+), 154 deletions(-) delete mode 100644 lib/WebworkClient/standard_format.pl diff --git a/lib/FormatRenderedProblem.pm b/lib/FormatRenderedProblem.pm index a9a611d9c7..36acd116aa 100644 --- a/lib/FormatRenderedProblem.pm +++ b/lib/FormatRenderedProblem.pm @@ -253,9 +253,13 @@ sub formatRenderedProblem { # Regular Perl warning messages generated with warn. my $warnings = ''; - if (defined($rh_result->{WARNINGS}) and $rh_result->{WARNINGS}) { - $warnings = qq{

WARNINGS

} . - decode_utf8_base64($rh_result->{WARNINGS}) . "

"; + if ($rh_result->{pg_warnings}) { + $warnings .= qq{
PG WARNINGS
} . + decode_utf8_base64($rh_result->{pg_warnings}) . "
"; + } + if ($rh_result->{translator_warnings}) { + $warnings .= qq{

TRANSLATOR WARNINGS

} . + decode_utf8_base64($rh_result->{translator_warnings}) . "

"; } # PG debug messages generated with DEBUG_message(); @@ -274,14 +278,15 @@ sub formatRenderedProblem { my $debug_messages = $rh_result->{debug_messages}; + # For debugging purposes (only used in the debug format) + my $clientDebug = $self->{inputs_ref}{clientDebug} // ""; + my $client_debug_data = $clientDebug ? "

Webwork client data

" . WebworkClient::pretty_print($self) : ''; + # Show the footer unless it is explicity disabled. my $showFooter = $self->{inputs_ref}{showFooter} // ""; my $footer = $showFooter && $showFooter eq "no" ? '' : ""; - # For debugging purposes add $pretty_print_self to the output format in use and uncomment below. - #my $pretty_print_self = WebworkClient::pretty_print($self); - # Execute and return the interpolated problem template my $format_name = $self->{inputs_ref}{outputformat} // 'simple'; diff --git a/lib/WebworkClient/debug_format.pl b/lib/WebworkClient/debug_format.pl index 45ac8a5816..eea6975bea 100644 --- a/lib/WebworkClient/debug_format.pl +++ b/lib/WebworkClient/debug_format.pl @@ -1,18 +1,105 @@ -$debug_format = -q{ +$debug_format = <<'ENDPROBLEMTEMPLATE'; + + + + + + - - - - - $SITE_URL WeBWorK using host: $SITE_URL, course: $courseID format: debug - - - -

WeBWorK using host: $SITE_URL, course: $courseID format: debug

-$pretty_print_self + + + + + + + + + + + + + + + + + + + + + + + + + + + +$problemHeadText + +WeBWorK using host: $SITE_URL, format: debug, seed: $problemSeed, course: $courseID + + +
+

WeBWorK using host: $SITE_URL, course: $courseID, format: debug

+
+
+
+$answerTemplate +$color_input_blanks_script +
+
+$problemText +
+$scoreSummary +$LTIGradeMessage + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+$previewButton +$checkAnswersButton +$correctAnswersButton +

+
+
+
+ +

Perl warning section

+$warnings +

PG Warning section

+$PG_warning_messages +

Debug message section

+$debug_messages +

internal errors

+$internal_debug_messages +$client_debug_data +
+$footer -}; +ENDPROBLEMTEMPLATE $debug_format; diff --git a/lib/WebworkClient/simple_format.pl b/lib/WebworkClient/simple_format.pl index b451053711..82735ceb82 100644 --- a/lib/WebworkClient/simple_format.pl +++ b/lib/WebworkClient/simple_format.pl @@ -40,46 +40,46 @@
-
- $answerTemplate - $color_input_blanks_script -
+
+$answerTemplate +$color_input_blanks_script +
- $problemText +$problemText
$scoreSummary $LTIGradeMessage - - - - - - - - - - - - - - - - - - - - - - - - -

- $previewButton - $checkAnswersButton - $correctAnswersButton -

- + + + + + + + + + + + + + + + + + + + + + + + + +

+$previewButton +$checkAnswersButton +$correctAnswersButton +

+
$footer diff --git a/lib/WebworkClient/standard_format.pl b/lib/WebworkClient/standard_format.pl deleted file mode 100644 index 6ad79b52eb..0000000000 --- a/lib/WebworkClient/standard_format.pl +++ /dev/null @@ -1,97 +0,0 @@ -$standard_format = <<'ENDPROBLEMTEMPLATE'; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -$problemHeadText - - -WeBWorK using host: $SITE_URL, format: standard seed: $problemSeed course: $courseID - - - -

WeBWorK using host: $SITE_URL, course: $courseID format: standard

- $answerTemplate - $color_input_blanks_script -
-
- $problemText -
-$scoreSummary -$LTIGradeMessage - - - - - - - - - - - - - - - - - - - - - - - - - -

- $previewButton - $checkAnswersButton - $correctAnswersButton -

-
-
- -

Perl warning section

-$warnings -

PG Warning section

-$PG_warning_messages; -

Debug message section

-$debug_messages -

internal errors

-$internal_debug_messages -$footer - - - -ENDPROBLEMTEMPLATE - -$standard_format; diff --git a/lib/WebworkWebservice/RenderProblem.pm b/lib/WebworkWebservice/RenderProblem.pm index 820911e8d6..8c2cd96a08 100644 --- a/lib/WebworkWebservice/RenderProblem.pm +++ b/lib/WebworkWebservice/RenderProblem.pm @@ -404,9 +404,8 @@ sub renderProblem { post_header_text => encode_utf8_base64( $pg->{post_header_text} ), answers => $pg->{answers}, errors => $pg->{errors}, - WARNINGS => encode_utf8_base64( - "WARNINGS\n".$warning_messages."\n
More
\n".$pg->{warnings} - ), + translator_warnings => encode_utf8_base64($pg->{warnings}), + pg_warnings => encode_utf8_base64($warning_messages), PG_ANSWERS_HASH => $pg->{pgcore}->{PG_ANSWERS_HASH}, problem_result => $pg->{result}, problem_state => $pg->{state}, From c94bf3a48b21b9e28ef1c28af6302650dd772b4d Mon Sep 17 00:00:00 2001 From: Nathan Wallach Date: Fri, 7 May 2021 11:18:09 +0300 Subject: [PATCH 05/10] Modify json_format.pl so that the CSS and JS loads are provided as an array of URLs to be used in href, rather than sending the full HTML code to load them. The JS loads which need the "defer" attribute were split from head_part200 into head_part201, and one of those loads /webwork2_files/mathjax/es5/tex-chtml.js should also get id="MathJax-script" in the - - - - - - - - - - - - - -ENDPROBLEMTEMPLATE +# CSS loads - as an array of href values +$json_output->{head_part100_AVI} = [ + "/webwork2_files/js/vendor/bootstrap/css/bootstrap.css", + "/webwork2_files/js/vendor/bootstrap/css/bootstrap-responsive.css", + "/webwork2_files/node_modules/jquery-ui-dist/jquery-ui.min.css", + "/webwork2_files/node_modules/@fortawesome/fontawesome-free/css/all.min.css", + "/webwork2_files/css/knowlstyle.css", + "/webwork2_files/js/apps/ImageView/imageview.css", + '$themeDir/math4.css', + '$themeDir/math4-coloring.css', + '$themeDir/math4-overrides.css', +]; + +# JS loads - as an array of href values - the ones which need defer are in head_part201_AVI +$json_output->{head_part200_AVI} = [ + "/webwork2_files/node_modules/jquery/dist/jquery.min.js", + "/webwork2_files/node_modules/jquery-ui-dist/jquery-ui.min.js", + "/webwork2_files/js/vendor/bootstrap/js/bootstrap.js", + "/webwork2_files/js/apps/InputColor/color.js", + "/webwork2_files/js/apps/Base64/Base64.js", + "/webwork2_files/js/vendor/underscore/underscore.js", + "/webwork2_files/js/legacy/vendor/knowl.js", + "/webwork2_files/js/apps/Problem/problem.js", + "/webwork2_files/js/apps/ImageView/imageview.js", + "/webwork2_files/node_modules/iframe-resizer/js/iframeResizer.contentWindow.min.js", +]; + +# JS loads - as an array of href values - the ones which need defer are in head_part201_AVI +# mathjax/es5/tex-chtml.js also needs id="MathJax-script" in the - + + + @@ -43,8 +44,8 @@
-
-
+
+
$answerTemplate $color_input_blanks_script
@@ -62,10 +63,10 @@ $LTIGradeMessage - + - - + + From 11a5d3ff32e2cba7b0f5e4d09494d795fd27d5ed Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Fri, 7 May 2021 06:42:56 -0500 Subject: [PATCH 07/10] Switch to using a setting of "0" rather than "no" to disable the footer or any of the submit buttons. --- htdocs/js/apps/ProblemSetDetail2/problemsetdetail2.js | 2 +- htdocs/js/apps/SetMaker/setmaker.js | 2 +- lib/FormatRenderedProblem.pm | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/js/apps/ProblemSetDetail2/problemsetdetail2.js b/htdocs/js/apps/ProblemSetDetail2/problemsetdetail2.js index a20c556f7d..d9584761a8 100644 --- a/htdocs/js/apps/ProblemSetDetail2/problemsetdetail2.js +++ b/htdocs/js/apps/ProblemSetDetail2/problemsetdetail2.js @@ -241,7 +241,7 @@ ro.permissionLevel = 10; ro.noprepostambles = 1; ro.processAnswers = 0; - ro.showFooter = "no"; + ro.showFooter = 0; ro.displayMode = $('#problem_displaymode').val(); ro.extra_header_text = ""; if (window.location.port) ro.forcePortNumber = window.location.port; diff --git a/htdocs/js/apps/SetMaker/setmaker.js b/htdocs/js/apps/SetMaker/setmaker.js index cdd48b6916..f2783be218 100644 --- a/htdocs/js/apps/SetMaker/setmaker.js +++ b/htdocs/js/apps/SetMaker/setmaker.js @@ -367,7 +367,7 @@ ro.showSolutions = $('input[name=showSolutions]').is(':checked') ? 1 : 0; ro.noprepostambles = 1; ro.processAnswers = 0; - ro.showFooter = "no"; + ro.showFooter = 0; ro.displayMode = $('select[name=mydisplayMode]').val(); ro.send_pg_flags = 1; ro.extra_header_text = ""; diff --git a/lib/FormatRenderedProblem.pm b/lib/FormatRenderedProblem.pm index f10f334277..4db853a251 100644 --- a/lib/FormatRenderedProblem.pm +++ b/lib/FormatRenderedProblem.pm @@ -242,13 +242,13 @@ sub formatRenderedProblem { # Submit buttons (all are shown by default) my $showPreviewButton = $self->{inputs_ref}{showPreviewButton} // ""; - my $previewButton = $showPreviewButton eq "no" ? '' : + my $previewButton = $showPreviewButton eq "0" ? '' : ''; my $showCheckAnswersButton = $self->{inputs_ref}{showCheckAnswersButton} // ""; - my $checkAnswersButton = $showCheckAnswersButton eq "no" ? '' : + my $checkAnswersButton = $showCheckAnswersButton eq "0" ? '' : ''; my $showCorrectAnswersButton = $self->{inputs_ref}{showCorrectAnswersButton} // ""; - my $correctAnswersButton = $showCorrectAnswersButton eq "no" ? '' : + my $correctAnswersButton = $showCorrectAnswersButton eq "0" ? '' : ''; # Regular Perl warning messages generated with warn. @@ -284,7 +284,7 @@ sub formatRenderedProblem { # Show the footer unless it is explicity disabled. my $showFooter = $self->{inputs_ref}{showFooter} // ""; - my $footer = $showFooter && $showFooter eq "no" ? '' + my $footer = $showFooter eq "0" ? '' : ""; # Execute and return the interpolated problem template From ed950ace6baaa71deaf366863788d57e8a829677 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Fri, 7 May 2021 07:28:01 -0500 Subject: [PATCH 08/10] Give the preview button the same `id` it has in a regular homework problem in webwork. This is so that the javascript in mqedit.js (for MathQuill answers) picks up on it and enter triggers a preview. Also fix some errors in the localstorage.js javascript for the sticky format. --- htdocs/js/apps/LocalStorage/localstorage.js | 35 ++++++++++----------- lib/FormatRenderedProblem.pm | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/htdocs/js/apps/LocalStorage/localstorage.js b/htdocs/js/apps/LocalStorage/localstorage.js index 7b11953eda..d000daf713 100644 --- a/htdocs/js/apps/LocalStorage/localstorage.js +++ b/htdocs/js/apps/LocalStorage/localstorage.js @@ -19,26 +19,25 @@ var WWLocalStorage = function(givenContainer) { storedData = {}; } - var storeData = function () { - //event.preventDefault(); - - if (!storedData['inputs']) { - storedData['inputs'] = {}; - } - - var inputs = $(container).find(":input") - .each(function(index,input) { - if ($(input).attr('type').toUpperCase() == 'RADIO') { - var name = $(input).attr('name'); - storedData['inputs'][name] = $('input[name="'+name+'"]:checked').val(); - } else if (/AnSwEr/.test($(input).attr('name'))) { - - storedData['inputs'][$(input).attr('name')] = $(input).val(); + var storeData = function () { + if (!storedData['inputs']) { + storedData['inputs'] = {}; } - }); - $.jStorage.set(identifier,storedData); - } + var inputs = $(container).find(":input") + .each(function(index) { + var input = $(this); + var type = input.attr('type'); + if (type && type.toUpperCase() == 'RADIO') { + var name = input.attr('name'); + storedData['inputs'][name] = $('input[name="'+name+'"]:checked').val(); + } else if (/AnSwEr/.test(input.attr('name'))) { + storedData['inputs'][input.attr('name')] = $(input).val(); + } + }); + + $.jStorage.set(identifier,storedData); + } $(container).find(":submit").click(storeData); diff --git a/lib/FormatRenderedProblem.pm b/lib/FormatRenderedProblem.pm index 4db853a251..da6b09369a 100644 --- a/lib/FormatRenderedProblem.pm +++ b/lib/FormatRenderedProblem.pm @@ -243,7 +243,7 @@ sub formatRenderedProblem { # Submit buttons (all are shown by default) my $showPreviewButton = $self->{inputs_ref}{showPreviewButton} // ""; my $previewButton = $showPreviewButton eq "0" ? '' : - ''; + ''; my $showCheckAnswersButton = $self->{inputs_ref}{showCheckAnswersButton} // ""; my $checkAnswersButton = $showCheckAnswersButton eq "0" ? '' : ''; From 19631333d932443d8b6bdf91dcac4bfdf31c6b05 Mon Sep 17 00:00:00 2001 From: Nathan Wallach Date: Fri, 7 May 2021 16:15:02 +0300 Subject: [PATCH 09/10] json_format: Use sub-hash for hidden_input_field --- lib/FormatRenderedProblem.pm | 6 +++- lib/WebworkClient/json_format.pl | 53 +++++++++++++++++--------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/lib/FormatRenderedProblem.pm b/lib/FormatRenderedProblem.pm index da6b09369a..1765254e3a 100644 --- a/lib/FormatRenderedProblem.pm +++ b/lib/FormatRenderedProblem.pm @@ -293,8 +293,12 @@ sub formatRenderedProblem { # The json format if ($format_name eq "json") { my $json_output = do("WebworkClient/json_format.pl"); + for my $key (keys %{$json_output->{hidden_input_field}}) { + $json_output->{hidden_input_field}{$key} =~ s/(\$\w+)/$1/gee; + } + for my $key (keys %$json_output) { - if (($key =~ /^hidden_input_field/) || + if ( ($key =~ /^real_webwork/) || ($key =~ /^internal/) || ($key =~ /_A?VI$/) diff --git a/lib/WebworkClient/json_format.pl b/lib/WebworkClient/json_format.pl index d3872a13b2..4b1b9a6310 100644 --- a/lib/WebworkClient/json_format.pl +++ b/lib/WebworkClient/json_format.pl @@ -5,7 +5,7 @@ # Most parts which need variable interpolation end in "_VI". # Parts ending in "_AVI" are references to anonymous arrays whose entries need variable interpolation. # Other parts which need variable interpolation are: -# hidden_input_field_* +# hidden_input_field}{* # real_webwork_* # NOTE: When a variable needs to be interpolated later, the string should be in single quotes not in double quotes. @@ -88,30 +88,33 @@ ENDPROBLEMTEMPLATE -$json_output->{hidden_input_field_answersSubmitted} = '1'; -$json_output->{hidden_input_field_sourceFilePath} = '$sourceFilePath'; -$json_output->{hidden_input_field_problemSource} = '$encoded_source'; -$json_output->{hidden_input_field_problemSeed} = '$problemSeed'; -$json_output->{hidden_input_field_problemUUID} = '$problemUUID'; -$json_output->{hidden_input_field_psvn} = '$psvn'; -$json_output->{hidden_input_field_pathToProblemFile} = '$fileName'; -$json_output->{hidden_input_field_courseName} = '$courseID'; -$json_output->{hidden_input_field_courseID} = '$courseID'; -$json_output->{hidden_input_field_userID} = '$userID'; -$json_output->{hidden_input_field_course_password} = '$course_password'; -$json_output->{hidden_input_field_displayMode} = '$displayMode'; -$json_output->{hidden_input_field_session_key} = '$session_key'; -$json_output->{hidden_input_field_outputformat} = 'json'; -$json_output->{hidden_input_field_theme} = '$theme'; -$json_output->{hidden_input_field_language} = '$formLanguage'; -$json_output->{hidden_input_field_showSummary} = '$showSummary'; -$json_output->{hidden_input_field_showAnswerNumbers} = '$showAnswerNumbers'; -$json_output->{hidden_input_field_showPreviewButton} = '$showPreviewButton'; -$json_output->{hidden_input_field_showCheckAnswersButton} = '$showCheckAnswersButton'; -$json_output->{hidden_input_field_showCorrectAnswersButton} = '$showCorrectAnswersButton'; -$json_output->{hidden_input_field_showFooter} = '$showFooter'; -$json_output->{hidden_input_field_forcePortNumber} = '$forcePortNumber'; -$json_output->{hidden_input_field_extraHeaderText} = '$extra_header_text'; +$json_output->{hidden_input_field} = {}; + + +$json_output->{hidden_input_field}{answersSubmitted} = '1'; +$json_output->{hidden_input_field}{sourceFilePath} = '$sourceFilePath'; +$json_output->{hidden_input_field}{problemSource} = '$encoded_source'; +$json_output->{hidden_input_field}{problemSeed} = '$problemSeed'; +$json_output->{hidden_input_field}{problemUUID} = '$problemUUID'; +$json_output->{hidden_input_field}{psvn} = '$psvn'; +$json_output->{hidden_input_field}{pathToProblemFile} = '$fileName'; +$json_output->{hidden_input_field}{courseName} = '$courseID'; +$json_output->{hidden_input_field}{courseID} = '$courseID'; +$json_output->{hidden_input_field}{userID} = '$userID'; +$json_output->{hidden_input_field}{course_password} = '$course_password'; +$json_output->{hidden_input_field}{displayMode} = '$displayMode'; +$json_output->{hidden_input_field}{session_key} = '$session_key'; +$json_output->{hidden_input_field}{outputformat} = 'json'; +$json_output->{hidden_input_field}{theme} = '$theme'; +$json_output->{hidden_input_field}{language} = '$formLanguage'; +$json_output->{hidden_input_field}{showSummary} = '$showSummary'; +$json_output->{hidden_input_field}{showAnswerNumbers} = '$showAnswerNumbers'; +$json_output->{hidden_input_field}{showPreviewButton} = '$showPreviewButton'; +$json_output->{hidden_input_field}{showCheckAnswersButton} = '$showCheckAnswersButton'; +$json_output->{hidden_input_field}{showCorrectAnswersButton} = '$showCorrectAnswersButton'; +$json_output->{hidden_input_field}{showFooter} = '$showFooter'; +$json_output->{hidden_input_field}{forcePortNumber} = '$forcePortNumber'; +$json_output->{hidden_input_field}{extraHeaderText} = '$extra_header_text'; # These are the real WeBWorK server URLs which the intermediate needs to use # to communicate with WW, while the distant client must use URLs of the From 2e520d48f2c85237872752aba2927757a11d9626 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Tue, 11 May 2021 17:33:34 -0500 Subject: [PATCH 10/10] Pass on the showSolutions and showHints parameters in FormatRenderedProblem and in the formats. --- lib/FormatRenderedProblem.pm | 3 +++ lib/WebworkClient/debug_format.pl | 2 ++ lib/WebworkClient/json_format.pl | 2 ++ lib/WebworkClient/simple_format.pl | 2 ++ lib/WebworkClient/sticky_format.pl | 2 ++ 5 files changed, 11 insertions(+) diff --git a/lib/FormatRenderedProblem.pm b/lib/FormatRenderedProblem.pm index 6c70f2c192..72f75d4953 100644 --- a/lib/FormatRenderedProblem.pm +++ b/lib/FormatRenderedProblem.pm @@ -251,6 +251,9 @@ sub formatRenderedProblem { my $correctAnswersButton = $showCorrectAnswersButton eq "0" ? '' : ''; + my $showSolutions = $self->{inputs_ref}{showSolutions} // ""; + my $showHints = $self->{inputs_ref}{showHints} // ""; + # Regular Perl warning messages generated with warn. my $warnings = ''; if ($rh_result->{pg_warnings}) { diff --git a/lib/WebworkClient/debug_format.pl b/lib/WebworkClient/debug_format.pl index eea6975bea..6a8cc5b08d 100644 --- a/lib/WebworkClient/debug_format.pl +++ b/lib/WebworkClient/debug_format.pl @@ -69,6 +69,8 @@ + + diff --git a/lib/WebworkClient/json_format.pl b/lib/WebworkClient/json_format.pl index 4b1b9a6310..f68a49f9ab 100644 --- a/lib/WebworkClient/json_format.pl +++ b/lib/WebworkClient/json_format.pl @@ -108,6 +108,8 @@ $json_output->{hidden_input_field}{theme} = '$theme'; $json_output->{hidden_input_field}{language} = '$formLanguage'; $json_output->{hidden_input_field}{showSummary} = '$showSummary'; +$json_output->{hidden_input_field}{showHints} = '$showHints'; +$json_output->{hidden_input_field}{showSolution} = '$showSolution'; $json_output->{hidden_input_field}{showAnswerNumbers} = '$showAnswerNumbers'; $json_output->{hidden_input_field}{showPreviewButton} = '$showPreviewButton'; $json_output->{hidden_input_field}{showCheckAnswersButton} = '$showCheckAnswersButton'; diff --git a/lib/WebworkClient/simple_format.pl b/lib/WebworkClient/simple_format.pl index 82735ceb82..f1e25155eb 100644 --- a/lib/WebworkClient/simple_format.pl +++ b/lib/WebworkClient/simple_format.pl @@ -67,6 +67,8 @@ + + diff --git a/lib/WebworkClient/sticky_format.pl b/lib/WebworkClient/sticky_format.pl index e3940e9823..f936b7ff17 100644 --- a/lib/WebworkClient/sticky_format.pl +++ b/lib/WebworkClient/sticky_format.pl @@ -80,6 +80,8 @@ + +