diff --git a/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm b/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
index 10f832f6f6..5773bd8c00 100644
--- a/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
+++ b/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
@@ -2318,13 +2318,34 @@ sub output_JS{
my $site_url = $ce->{webworkURLs}->{htdocs};
+ # Add CSS files requested by problems via ADD_CSS_FILE() in the PG file
+ # or via a setting of $ce->{pg}{specialPGEnvironmentVars}{extra_css_files}
+ # which can be set in course.conf (the value should be an anonomous array).
+ my %cssFiles;
+ if (ref($ce->{pg}{specialPGEnvironmentVars}{extra_css_files}) eq "ARRAY") {
+ $cssFiles{$_} = 1 for @{$ce->{pg}{specialPGEnvironmentVars}{extra_css_files}};
+ }
+ for my $pg (@{$self->{ra_pg_results}}) {
+ next unless ref($pg);
+ if (ref($pg->{flags}{extra_css_files}) eq "ARRAY") {
+ $cssFiles{$_} = 1 for @{$pg->{flags}{extra_css_files}};
+ }
+ }
+ for (keys(%cssFiles)) {
+ if (-f "$WeBWorK::Constants::WEBWORK_DIRECTORY/htdocs/$_") {
+ print "\n";
+ } else {
+ print "\n";
+ }
+ }
+
# The Base64.js file, which handles base64 encoding and decoding
print CGI::start_script({type=>"text/javascript", src=>"$site_url/js/apps/Base64/Base64.js"}), CGI::end_script();
# This is for MathView.
if ($self->{will}->{useMathView}) {
if ((grep(/MathJax/,@{$ce->{pg}->{displayModes}}))) {
- print "";
+ print qq{};
print CGI::start_script({type=>"text/javascript"});
print "mathView_basepath = \"$site_url/images/mathview/\";";
print CGI::end_script();
@@ -2350,8 +2371,8 @@ sub output_JS{
# MathQuill interface
if ($self->{will}->{useMathQuill}) {
- print "";
- print "";
+ print qq{"};
+ print qq{"};
print CGI::start_script({type=>"text/javascript",
src=>"$site_url/js/apps/MathQuill/mathquill.min.js"}), CGI::end_script();
print CGI::start_script({type=>"text/javascript",
@@ -2371,29 +2392,27 @@ sub output_JS{
print CGI::start_script({type=>"text/javascript", src=>"$site_url/js/apps/GatewayQuiz/gateway.js"}), CGI::end_script();
# This is for the image dialog
- print "\n";
+ print qq{"};
print CGI::start_script({type=>"text/javascript", src=>"$site_url/js/apps/ImageView/imageview.js"}), CGI::end_script();
# Add JS files requested by problems via ADD_JS_FILE() in the PG file.
my %jsFiles;
for my $pg (@{$self->{ra_pg_results}}) {
next unless ref($pg);
- if (defined($pg->{flags}{extra_js_files})) {
+ if (ref($pg->{flags}{extra_js_files}) eq "ARRAY") {
# Avoid duplicates
- for (@{$pg->{flags}{extra_js_files}}) {
- $jsFiles{$_->{file}} = $_->{local};
- }
+ $jsFiles{$_->{file}} = $_->{local} for @{$pg->{flags}{extra_js_files}};
}
}
for (keys(%jsFiles)) {
- if ($jsFiles{$_} && -f "$WeBWorK::Constants::WEBWORK_DIRECTORY/htdocs/js/$_") {
+ if ($jsFiles{$_} && -f "$WeBWorK::Constants::WEBWORK_DIRECTORY/htdocs/$_") {
print CGI::start_script({type => "text/javascript",
- src => "$site_url/js/$_"}), CGI::end_script();
+ src => "$site_url/$_"}), CGI::end_script();
} elsif (!$jsFiles{$_}) {
print CGI::start_script({type => "text/javascript",
- src => "$_"}), CGI::end_script();
+ src => $_}), CGI::end_script();
} else {
- print "\n";
+ print "\n";
}
}
diff --git a/lib/WeBWorK/ContentGenerator/Problem.pm b/lib/WeBWorK/ContentGenerator/Problem.pm
index c3f58fe9cf..ace7895074 100644
--- a/lib/WeBWorK/ContentGenerator/Problem.pm
+++ b/lib/WeBWorK/ContentGenerator/Problem.pm
@@ -2390,21 +2390,19 @@ sub output_JS{
print CGI::start_script({type=>"text/javascript", src=>"$site_url/js/apps/ImageView/imageview.js"}), CGI::end_script();
# Add JS files requested by problems via ADD_JS_FILE() in the PG file.
- if (defined($self->{pg}{flags}{extra_js_files})) {
+ if (ref($self->{pg}{flags}{extra_js_files}) eq "ARRAY") {
my %jsFiles;
# Avoid duplicates
- for (@{$self->{pg}{flags}{extra_js_files}}) {
- $jsFiles{$_->{file}} = $_->{local};
- }
+ $jsFiles{$_->{file}} = $_->{local} for @{$self->{pg}{flags}{extra_js_files}};
for (keys(%jsFiles)) {
- if ($jsFiles{$_} && -f "$WeBWorK::Constants::WEBWORK_DIRECTORY/htdocs/js/$_") {
+ if ($jsFiles{$_} && -f "$WeBWorK::Constants::WEBWORK_DIRECTORY/htdocs/$_") {
print CGI::start_script({type => "text/javascript",
- src => "$site_url/js/$_"}), CGI::end_script();
+ src => "$site_url/$_"}), CGI::end_script();
} elsif (!$jsFiles{$_}) {
print CGI::start_script({type => "text/javascript",
- src => "$_"}), CGI::end_script();
+ src => $_}), CGI::end_script();
} else {
- print "\n";
+ print "\n";
}
}
}
@@ -2437,32 +2435,21 @@ sub output_CSS {
print "\n";
# Add CSS files requested by problems via ADD_CSS_FILE() in the PG file
- # or via a setting of $ce->{pg}->{specialPGEnvironmentVars}->{extra_css_files}
- # which can be set in course.conf (the value should be an anon array).
- my $pg = $self->{pg};
- if ( defined( $pg->{flags}{extra_css_files} ) ||
- ( defined( $ce->{pg}->{specialPGEnvironmentVars}->{extra_css_files} ) &&
- scalar( @{$ce->{pg}->{specialPGEnvironmentVars}->{extra_css_files}} ) > 0 )
- ) {
- my $baseDir = $ce->{webwork_htdocs_url};
- my $webwork_dir = $WeBWorK::Constants::WEBWORK_DIRECTORY;
- my $cssFile;
- my %cssFiles;
- # Avoid duplicates
- my @courseCssRequests = ();
- if ( defined($ce->{pg}->{specialPGEnvironmentVars}->{extra_css_files} ) ) {
- @courseCssRequests = ( @{$ce->{pg}->{specialPGEnvironmentVars}->{extra_css_files}
-} );
- }
- foreach $cssFile ( @courseCssRequests, @{$pg->{flags}{extra_css_files}} ) {
- $cssFiles{$cssFile} = 1;
- }
- foreach $cssFile ( keys( %cssFiles ) ) {
- if ( -f "$webwork_dir/htdocs/css/$cssFile" ) { # FIXME - test for existence
- print "\n";
- } else {
- print "\n";
- }
+ # or via a setting of $ce->{pg}{specialPGEnvironmentVars}{extra_css_files}
+ # which can be set in course.conf (the value should be an anonomous array).
+ my %cssFiles;
+ # Avoid duplicates
+ if (ref($ce->{pg}{specialPGEnvironmentVars}{extra_css_files}) eq "ARRAY") {
+ $cssFiles{$_} = 1 for @{$ce->{pg}{specialPGEnvironmentVars}{extra_css_files}};
+ }
+ if (ref($self->{pg}{flags}{extra_css_files}) eq "ARRAY") {
+ $cssFiles{$_} = 1 for @{$self->{pg}{flags}{extra_css_files}};
+ }
+ for (keys(%cssFiles)) {
+ if (-f "$WeBWorK::Constants::WEBWORK_DIRECTORY/htdocs/$_") {
+ print "\n";
+ } else {
+ print "\n";
}
}