| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/PG.pm,v 1.51 2004/05/24 02:01:25 dpvc Exp $ |
4 | # $CVSHeader: webwork2/lib/WeBWorK/PG.pm,v 1.56 2004/07/03 17:29:29 sh002i Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 34 | plainText => "HTML", |
34 | plainText => "HTML", |
| 35 | formattedText => "HTML_tth", |
35 | formattedText => "HTML_tth", |
| 36 | images => "HTML_dpng", |
36 | images => "HTML_dpng", |
| 37 | jsMath => "HTML_jsMath", |
37 | jsMath => "HTML_jsMath", |
| 38 | asciimath => "HTML_asciimath", |
38 | asciimath => "HTML_asciimath", |
| 39 | }; |
|
|
| 40 | |
|
|
| 41 | use constant DISPLAY_MODE_FAILOVER => { |
|
|
| 42 | TeX => [], |
|
|
| 43 | HTML => [], |
|
|
| 44 | HTML_tth => [ "HTML", ], |
|
|
| 45 | HTML_dpng => [ "HTML_tth", "HTML", ], |
|
|
| 46 | HTML_jsMath => [ "HTML_dpng", "HTML_tth", "HTML", ], |
|
|
| 47 | HTML_asciimath => [ "HTML_dpng", "HTML_tth", "HTML", ], |
|
|
| 48 | # legacy modes -- these are not supported, but some problems might try to |
|
|
| 49 | # set the display mode to one of these values manually and some macros may |
|
|
| 50 | # provide rendered versions for these modes but not the one we want. |
|
|
| 51 | Latex2HTML => [ "TeX", "HTML", ], |
|
|
| 52 | HTML_img => [ "HTML_dpng", "HTML_tth", "HTML", ], |
|
|
| 53 | }; |
39 | }; |
| 54 | |
40 | |
| 55 | sub new { |
41 | sub new { |
| 56 | shift; # throw away invocant -- we don't need it |
42 | shift; # throw away invocant -- we don't need it |
| 57 | my ($ce, $user, $key, $set, $problem, $psvn, $formFields, |
43 | my ($ce, $user, $key, $set, $problem, $psvn, $formFields, |
| … | |
… | |
| 97 | $envir{probFileName} = $envir{fileName}; |
83 | $envir{probFileName} = $envir{fileName}; |
| 98 | $envir{problemSeed} = $problem->problem_seed; |
84 | $envir{problemSeed} = $problem->problem_seed; |
| 99 | $envir{displayMode} = translateDisplayModeNames($options->{displayMode}); |
85 | $envir{displayMode} = translateDisplayModeNames($options->{displayMode}); |
| 100 | $envir{languageMode} = $envir{displayMode}; |
86 | $envir{languageMode} = $envir{displayMode}; |
| 101 | $envir{outputMode} = $envir{displayMode}; |
87 | $envir{outputMode} = $envir{displayMode}; |
| 102 | $envir{displayModeFailover} = DISPLAY_MODE_FAILOVER(); |
|
|
| 103 | $envir{displayHintsQ} = $options->{showHints}; |
88 | $envir{displayHintsQ} = $options->{showHints}; |
| 104 | $envir{displaySolutionsQ} = $options->{showSolutions}; |
89 | $envir{displaySolutionsQ} = $options->{showSolutions}; |
| 105 | $envir{texDisposition} = "pdf"; # in webwork2, we use pdflatex |
90 | $envir{texDisposition} = "pdf"; # in webwork2, we use pdflatex |
| 106 | |
91 | |
| 107 | # Problem Information |
92 | # Problem Information |
| … | |
… | |
| 164 | $envir{tempDirectory} = $ce->{courseDirs}->{html_temp}."/"; |
149 | $envir{tempDirectory} = $ce->{courseDirs}->{html_temp}."/"; |
| 165 | $envir{tempURL} = $ce->{courseURLs}->{html_temp}."/"; |
150 | $envir{tempURL} = $ce->{courseURLs}->{html_temp}."/"; |
| 166 | $envir{scriptDirectory} = undef; |
151 | $envir{scriptDirectory} = undef; |
| 167 | $envir{webworkDocsURL} = $ce->{webworkURLs}->{docs}."/"; |
152 | $envir{webworkDocsURL} = $ce->{webworkURLs}->{docs}."/"; |
| 168 | $envir{localHelpURL} = $ce->{webworkURLs}->{local_help}."/"; |
153 | $envir{localHelpURL} = $ce->{webworkURLs}->{local_help}."/"; |
| 169 | $envir{jsMathURL} = $ce->{webworkURLs}->{jsMath}; |
154 | $envir{jsMathURL} = $ce->{webworkURLs}->{jsMath}; |
| 170 | $envir{asciimathURL} = $ce->{webworkURLs}->{asciimath}; |
155 | $envir{asciimathURL} = $ce->{webworkURLs}->{asciimath}; |
| 171 | |
156 | |
| 172 | # Information for sending mail |
157 | # Information for sending mail |
| 173 | |
158 | |
| 174 | $envir{mailSmtpServer} = $ce->{mail}->{smtpServer}; |
159 | $envir{mailSmtpServer} = $ce->{mail}->{smtpServer}; |
| … | |
… | |
| 182 | |
167 | |
| 183 | # ---------------------------------------------------------------------- |
168 | # ---------------------------------------------------------------------- |
| 184 | |
169 | |
| 185 | my $basename = "equation-$envir{psvn}.$envir{probNum}"; |
170 | my $basename = "equation-$envir{psvn}.$envir{probNum}"; |
| 186 | $basename .= ".$envir{problemSeed}" if $envir{problemSeed}; |
171 | $basename .= ".$envir{problemSeed}" if $envir{problemSeed}; |
| 187 | |
172 | |
|
|
173 | # to make grabbing these options easier, we'll pull them out now... |
|
|
174 | my %imagesModeOptions = %{$ce->{pg}->{displayModeOptions}->{images}}; |
|
|
175 | |
| 188 | # Object for generating equation images |
176 | # Object for generating equation images |
| 189 | $envir{imagegen} = WeBWorK::PG::ImageGenerator->new( |
177 | $envir{imagegen} = WeBWorK::PG::ImageGenerator->new( |
| 190 | tempDir => $ce->{webworkDirs}->{tmp}, # global temp dir |
178 | tempDir => $ce->{webworkDirs}->{tmp}, # global temp dir |
| 191 | latex => $envir{externalLaTeXPath}, |
179 | latex => $envir{externalLaTeXPath}, |
| 192 | dvipng => $envir{externalDvipngPath}, |
180 | dvipng => $envir{externalDvipngPath}, |
| 193 | useCache => 1, |
181 | useCache => 1, |
| 194 | cacheDir => $ce->{webworkDirs}->{equationCache}, |
182 | cacheDir => $ce->{webworkDirs}->{equationCache}, |
| 195 | cacheURL => $ce->{webworkURLs}->{equationCache}, |
183 | cacheURL => $ce->{webworkURLs}->{equationCache}, |
| 196 | cacheDB => $ce->{webworkFiles}->{equationCacheDB}, |
184 | cacheDB => $ce->{webworkFiles}->{equationCacheDB}, |
|
|
185 | useMarkers => ($imagesModeOptions{dvipng_align} && $imagesModeOptions{dvipng_align} eq 'mysql'), |
|
|
186 | dvipng_align => $imagesModeOptions{dvipng_align}, |
|
|
187 | dvipng_depth_db => $imagesModeOptions{dvipng_depth_db}, |
| 197 | ); |
188 | ); |
| 198 | |
189 | |
| 199 | # Other things... |
190 | # Other things... |
| 200 | $envir{QUIZ_PREFIX} = $options->{QUIZ_PREFIX}; # used by quizzes |
191 | $envir{QUIZ_PREFIX} = $options->{QUIZ_PREFIX}; # used by quizzes |
| 201 | $envir{PROBLEM_GRADER_TO_USE} = $ce->{pg}->{options}->{grader}; |
192 | $envir{PROBLEM_GRADER_TO_USE} = $ce->{pg}->{options}->{grader}; |