[system] / branches / rel-2-4-patches / webwork-modperl / lib / WeBWorK / PG.pm Repository:
ViewVC logotype

Diff of /branches/rel-2-4-patches/webwork-modperl/lib/WeBWorK/PG.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 4376 Revision 4677
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: webwork2/lib/WeBWorK/PG.pm,v 1.65 2006/05/23 20:47:27 gage Exp $ 4# $CVSHeader: webwork2/lib/WeBWorK/PG.pm,v 1.68 2006/08/24 21:16:36 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.
23 23
24=cut 24=cut
25 25
26use strict; 26use strict;
27use warnings; 27use warnings;
28use Safe::Hole;
28use WeBWorK::PG::ImageGenerator; 29use WeBWorK::PG::ImageGenerator;
29use WeBWorK::Utils qw(runtime_use formatDateTime makeTempDirectory); 30use WeBWorK::Utils qw(runtime_use formatDateTime makeTempDirectory);
31use WeBWorK::Utils::RestrictedClosureClass;
30 32
31use constant DISPLAY_MODES => { 33use constant DISPLAY_MODES => {
32 # display name # mode name 34 # display name # mode name
33 tex => "TeX", 35 tex => "TeX",
34 plainText => "HTML", 36 plainText => "HTML",
35 formattedText => "HTML_tth", 37 formattedText => "HTML_tth",
36 images => "HTML_dpng", 38 images => "HTML_dpng",
37 jsMath => "HTML_jsMath", 39 jsMath => "HTML_jsMath",
38 asciimath => "HTML_asciimath", 40 asciimath => "HTML_asciimath",
41 LaTeXMathML => "HTML_LaTeXMathML",
39}; 42};
40 43
41sub new { 44sub new {
42 shift; # throw away invocant -- we don't need it 45 shift; # throw away invocant -- we don't need it
43 my ($ce, $user, $key, $set, $problem, $psvn, $formFields, 46 my ($ce, $user, $key, $set, $problem, $psvn, $formFields,
59 $set, 62 $set,
60 $problem, 63 $problem,
61 $psvn, 64 $psvn,
62 $formFields, 65 $formFields,
63 $options, 66 $options,
67 $extras,
64 ) = @_; 68 ) = @_;
65 69
66 my %envir; 70 my %envir;
67 71
68 # ---------------------------------------------------------------------- 72 # ----------------------------------------------------------------------
137 # ADDED: dvipngTempDir 141 # ADDED: dvipngTempDir
138 # ADDED: jsMathURL 142 # ADDED: jsMathURL
139 # ADDED: asciimathURL 143 # ADDED: asciimathURL
140 # ADDED: macrosPath 144 # ADDED: macrosPath
141 # REMOVED: macrosDirectory, courseScriptsDirectory 145 # REMOVED: macrosDirectory, courseScriptsDirectory
146 # ADDED: LaTeXMathML
142 147
143 $envir{cgiDirectory} = undef; 148 $envir{cgiDirectory} = undef;
144 $envir{cgiURL} = undef; 149 $envir{cgiURL} = undef;
145 $envir{classDirectory} = undef; 150 $envir{classDirectory} = undef;
146 $envir{macrosPath} = $ce->{pg}->{directories}{macrosPath}; 151 $envir{macrosPath} = $ce->{pg}->{directories}{macrosPath};
154 $envir{scriptDirectory} = undef; 159 $envir{scriptDirectory} = undef;
155 $envir{webworkDocsURL} = $ce->{webworkURLs}->{docs}."/"; 160 $envir{webworkDocsURL} = $ce->{webworkURLs}->{docs}."/";
156 $envir{localHelpURL} = $ce->{webworkURLs}->{local_help}."/"; 161 $envir{localHelpURL} = $ce->{webworkURLs}->{local_help}."/";
157 $envir{jsMathURL} = $ce->{webworkURLs}->{jsMath}; 162 $envir{jsMathURL} = $ce->{webworkURLs}->{jsMath};
158 $envir{asciimathURL} = $ce->{webworkURLs}->{asciimath}; 163 $envir{asciimathURL} = $ce->{webworkURLs}->{asciimath};
164 $envir{LaTeXMathMLURL} = $ce->{webworkURLs}->{LaTeXMathML};
159 $envir{server_root_url} = $ce->{apache_root_url}; 165 $envir{server_root_url} = $ce->{apache_root_url};
160 166
161 # Information for sending mail 167 # Information for sending mail
162 168
163 $envir{mailSmtpServer} = $ce->{mail}->{smtpServer}; 169 $envir{mailSmtpServer} = $ce->{mail}->{smtpServer};
169 my $ansEvalDefaults = $ce->{pg}->{ansEvalDefaults}; 175 my $ansEvalDefaults = $ce->{pg}->{ansEvalDefaults};
170 $envir{$_} = $ansEvalDefaults->{$_} foreach (keys %$ansEvalDefaults); 176 $envir{$_} = $ansEvalDefaults->{$_} foreach (keys %$ansEvalDefaults);
171 177
172 # ---------------------------------------------------------------------- 178 # ----------------------------------------------------------------------
173 179
174 my $basename = "equation-$envir{psvn}.$envir{probNum}"; 180 # ADDED: ImageGenerator for images mode
175 $basename .= ".$envir{problemSeed}" if $envir{problemSeed}; 181 if (defined $extras->{image_generator}) {
182 #$envir{imagegen} = $extras->{image_generator};
183 # only allow access to the add() method
184 $envir{imagegen} = new WeBWorK::Utils::RestrictedClosureClass($extras->{image_generator}, "add");
185 }
176 186
177 # to make grabbing these options easier, we'll pull them out now... 187 if (defined $extras->{mailer}) {
178 my %imagesModeOptions = %{$ce->{pg}->{displayModeOptions}->{images}}; 188 my $rmailer = new WeBWorK::Utils::RestrictedClosureClass($extras->{mailer},
189 qw/Open SendEnc Close Cancel skipped_recipients error error_msg/);
190 my $safe_hole = new Safe::Hole {};
191 $envir{mailer} = $safe_hole->wrap($rmailer);
192 }
179 193
180 # Object for generating equation images
181 $envir{imagegen} = WeBWorK::PG::ImageGenerator->new(
182 tempDir => $ce->{webworkDirs}->{tmp}, # global temp dir
183 latex => $envir{externalLaTeXPath},
184 dvipng => $envir{externalDvipngPath},
185 useCache => 1,
186 cacheDir => $ce->{webworkDirs}->{equationCache},
187 cacheURL => $ce->{webworkURLs}->{equationCache},
188 cacheDB => $ce->{webworkFiles}->{equationCacheDB},
189 useMarkers => ($imagesModeOptions{dvipng_align} && $imagesModeOptions{dvipng_align} eq 'mysql'),
190 dvipng_align => $imagesModeOptions{dvipng_align},
191 dvipng_depth_db => $imagesModeOptions{dvipng_depth_db},
192 );
193
194 # ADDED: jsMath options 194 # ADDED: jsMath options
195 $envir{jsMath} = {%{$ce->{pg}{displayModeOptions}{jsMath}}}; 195 $envir{jsMath} = {%{$ce->{pg}{displayModeOptions}{jsMath}}};
196 196
197 # Other things... 197 # Other things...
198 $envir{QUIZ_PREFIX} = $options->{QUIZ_PREFIX}; # used by quizzes 198 $envir{QUIZ_PREFIX} = $options->{QUIZ_PREFIX}; # used by quizzes

Legend:
Removed from v.4376  
changed lines
  Added in v.4677

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9