Skip to content

Commit abef66e

Browse files
committed
A few rendering tweaks.
* Make links with `pg_files` start with a leading slash. * Honor the showCorrectAnswers setting and don't force it to be 2. * Make pg_files thirdPartyAssessts not force CDN use. * Remove the no longer needed `s/#/@/g` from version strings. * Some minor code cleanups.
1 parent d5a1000 commit abef66e

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

lib/WeBWorK/FormatRenderedProblem.pm

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,15 @@ sub formatRenderedProblem {
4545

4646
# Third party CSS
4747
my @third_party_css = map { getAssetURL($formLanguage, $_->[0]) } (
48-
[ 'css/bootstrap.css', ],
49-
[ 'node_modules/jquery-ui-dist/jquery-ui.min.css', ],
48+
['css/bootstrap.css'],
49+
['node_modules/jquery-ui-dist/jquery-ui.min.css'],
5050
['node_modules/@fortawesome/fontawesome-free/css/all.min.css'],
5151
);
5252

5353
# Add CSS files requested by problems via ADD_CSS_FILE() in the PG file
5454
# or via a setting of $ce->{pg}{specialPGEnvironmentVars}{extra_css_files}
5555
# which can be set in course.conf (the value should be an anonomous array).
5656
my @cssFiles;
57-
# if (ref($ce->{pg}{specialPGEnvironmentVars}{extra_css_files}) eq 'ARRAY') {
58-
# push(@cssFiles, { file => $_, external => 0 }) for @{ $ce->{pg}{specialPGEnvironmentVars}{extra_css_files} };
59-
# }
6057
if (ref($rh_result->{flags}{extra_css_files}) eq 'ARRAY') {
6158
push @cssFiles, @{ $rh_result->{flags}{extra_css_files} };
6259
}

lib/WeBWorK/RenderProblem.pm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ sub standaloneRenderer {
212212
showAttemptPreviews => 1, # display LaTeX version of submitted answer
213213
showHints => $showHints, # default is to showHint (set in PG.pm)
214214
showSolutions => $showSolutions,
215-
showCorrectAnswers => $inputs_ref->{showCorrectAnswers} ? 2 : 0,
216-
num_of_correct_ans => $inputs_ref->{numCorrect} || 0,
217-
num_of_incorrect_ans => $inputs_ref->{numIncorrect} || 0,
215+
showCorrectAnswers => $inputs_ref->{showCorrectAnswers} || 0,
216+
num_of_correct_ans => $inputs_ref->{numCorrect} || 0,
217+
num_of_incorrect_ans => $inputs_ref->{numIncorrect} || 0,
218218
displayMode => $inputs_ref->{displayMode},
219219
useMathQuill => !defined $inputs_ref->{entryAssist} || $inputs_ref->{entryAssist} eq 'MathQuill',
220220
answerPrefix => $inputs_ref->{answerPrefix},
@@ -225,8 +225,8 @@ sub standaloneRenderer {
225225
language => $inputs_ref->{language} // 'en',
226226
language_subroutine => WeBWorK::Localize::getLoc($inputs_ref->{language} // 'en'),
227227
templateDirectory => "$ENV{RENDER_ROOT}/",
228-
htmlURL => 'pg_files/',
229-
tempURL => 'pg_files/tmp/',
228+
htmlURL => '/pg_files/',
229+
tempURL => '/pg_files/tmp/',
230230
debuggingOptions => {
231231
show_resource_info => $inputs_ref->{show_resource_info},
232232
view_problem_debugging_info => $inputs_ref->{view_problem_debugging_info}

lib/WeBWorK/Utils.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ sub getThirdPartyAssetURL {
4949
. substr($dependencies->{$_}, 1) . '/'
5050
. ($1 =~ s/(?:\.min)?\.(js|css)$/.min.$1/gr);
5151
} else {
52-
return Mojo::URL->new("${baseURL}$file")->query(version => $dependencies->{$_} =~ s/#/@/gr)->to_string;
52+
return Mojo::URL->new("${baseURL}$file")->query(version => $dependencies->{$_})->to_string;
5353
}
5454
}
5555
}
@@ -102,7 +102,7 @@ sub getAssetURL {
102102
my $wwFile = getThirdPartyAssetURL($file, $thirdPartyWWDependencies, '', 0);
103103
return $wwFile if $wwFile;
104104

105-
my $pgFile = getThirdPartyAssetURL($file, $thirdPartyPGDependencies, 'pg_files/', 1);
105+
my $pgFile = getThirdPartyAssetURL($file, $thirdPartyPGDependencies, '/pg_files/', 0);
106106
return $pgFile if $pgFile;
107107
}
108108

@@ -121,10 +121,10 @@ sub getAssetURL {
121121
return "$staticWWAssets->{$file}" if defined $staticWWAssets->{$file};
122122

123123
# Now check to see if this is a file in the pg htdocs location with a rtl variant.
124-
return "pg_files/$staticPGAssets->{$rtlfile}" if defined $rtlfile && defined $staticPGAssets->{$rtlfile};
124+
return "/pg_files/$staticPGAssets->{$rtlfile}" if defined $rtlfile && defined $staticPGAssets->{$rtlfile};
125125

126126
# Next check to see if this is a file in the pg htdocs location.
127-
return "pg_files/$staticPGAssets->{$file}" if defined $staticPGAssets->{$file};
127+
return "/pg_files/$staticPGAssets->{$file}" if defined $staticPGAssets->{$file};
128128

129129
# If the file was not found in the lists, then just use the given file and assume its path is relative to the
130130
# render app public folder.

0 commit comments

Comments
 (0)