[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 2192 Revision 3355
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.49 2004/05/23 01:15:28 jj Exp $ 4# $CVSHeader: webwork2/lib/WeBWorK/PG.pm,v 1.60 2005/05/14 01:32:19 dpvc 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.
33 tex => "TeX", 33 tex => "TeX",
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}; 38 asciimath => "HTML_asciimath",
39
40use constant DISPLAY_MODE_FAILOVER => {
41 TeX => [],
42 HTML => [],
43 HTML_tth => [ "HTML", ],
44 HTML_dpng => [ "HTML_tth", "HTML", ],
45 HTML_jsMath => [ "HTML_dpng", "HTML_tth", "HTML", ],
46 # legacy modes -- these are not supported, but some problems might try to
47 # set the display mode to one of these values manually and some macros may
48 # provide rendered versions for these modes but not the one we want.
49 Latex2HTML => [ "TeX", "HTML", ],
50 HTML_img => [ "HTML_dpng", "HTML_tth", "HTML", ],
51}; 39};
52 40
53sub new { 41sub new {
54 shift; # throw away invocant -- we don't need it 42 shift; # throw away invocant -- we don't need it
55 my ($ce, $user, $key, $set, $problem, $psvn, $formFields, 43 my ($ce, $user, $key, $set, $problem, $psvn, $formFields,
95 $envir{probFileName} = $envir{fileName}; 83 $envir{probFileName} = $envir{fileName};
96 $envir{problemSeed} = $problem->problem_seed; 84 $envir{problemSeed} = $problem->problem_seed;
97 $envir{displayMode} = translateDisplayModeNames($options->{displayMode}); 85 $envir{displayMode} = translateDisplayModeNames($options->{displayMode});
98 $envir{languageMode} = $envir{displayMode}; 86 $envir{languageMode} = $envir{displayMode};
99 $envir{outputMode} = $envir{displayMode}; 87 $envir{outputMode} = $envir{displayMode};
100 $envir{displayModeFailover} = DISPLAY_MODE_FAILOVER();
101 $envir{displayHintsQ} = $options->{showHints}; 88 $envir{displayHintsQ} = $options->{showHints};
102 $envir{displaySolutionsQ} = $options->{showSolutions}; 89 $envir{displaySolutionsQ} = $options->{showSolutions};
103 $envir{texDisposition} = "pdf"; # in webwork2, we use pdflatex 90 $envir{texDisposition} = "pdf"; # in webwork2, we use pdflatex
104 91
105 # Problem Information 92 # Problem Information
106 # ADDED: courseName, formatedDueDate 93 # ADDED: courseName, formatedDueDate
107 94
108 $envir{openDate} = $set->open_date; 95 $envir{openDate} = $set->open_date;
109 $envir{formattedOpenDate} = formatDateTime($envir{openDate}); 96 $envir{formattedOpenDate} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone});
110 $envir{dueDate} = $set->due_date; 97 $envir{dueDate} = $set->due_date;
111 $envir{formattedDueDate} = formatDateTime($envir{dueDate}); 98 $envir{formattedDueDate} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone});
112 $envir{formatedDueDate} = $envir{formattedDueDate}; # typo in many header files 99 $envir{formatedDueDate} = $envir{formattedDueDate}; # typo in many header files
113 $envir{answerDate} = $set->answer_date; 100 $envir{answerDate} = $set->answer_date;
114 $envir{formattedAnswerDate} = formatDateTime($envir{answerDate}); 101 $envir{formattedAnswerDate} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone});
115 $envir{numOfAttempts} = ($problem->num_correct || 0) + ($problem->num_incorrect || 0); 102 $envir{numOfAttempts} = ($problem->num_correct || 0) + ($problem->num_incorrect || 0);
116 $envir{problemValue} = $problem->value; 103 $envir{problemValue} = $problem->value;
117 $envir{sessionKey} = $key; 104 $envir{sessionKey} = $key;
118 $envir{courseName} = $ce->{courseName}; 105 $envir{courseName} = $ce->{courseName};
119 106
147 134
148 # Directories and URLs 135 # Directories and URLs
149 # REMOVED: courseName 136 # REMOVED: courseName
150 # ADDED: dvipngTempDir 137 # ADDED: dvipngTempDir
151 # ADDED: jsMathURL 138 # ADDED: jsMathURL
139 # ADDED: asciimathURL
140 # ADDED: macrosPath
141 # REMOVED: macrosDirectory, courseScriptsDirectory
152 142
153 $envir{cgiDirectory} = undef; 143 $envir{cgiDirectory} = undef;
154 $envir{cgiURL} = undef; 144 $envir{cgiURL} = undef;
155 $envir{classDirectory} = undef; 145 $envir{classDirectory} = undef;
156 $envir{courseScriptsDirectory} = $ce->{pg}->{directories}->{macros}."/"; 146 $envir{macrosPath} = $ce->{pg}->{directories}{macrosPath};
157 $envir{htmlDirectory} = $ce->{courseDirs}->{html}."/"; 147 $envir{htmlDirectory} = $ce->{courseDirs}->{html}."/";
158 $envir{htmlURL} = $ce->{courseURLs}->{html}."/"; 148 $envir{htmlURL} = $ce->{courseURLs}->{html}."/";
159 $envir{macroDirectory} = $ce->{courseDirs}->{macros}."/";
160 $envir{templateDirectory} = $ce->{courseDirs}->{templates}."/"; 149 $envir{templateDirectory} = $ce->{courseDirs}->{templates}."/";
161 $envir{tempDirectory} = $ce->{courseDirs}->{html_temp}."/"; 150 $envir{tempDirectory} = $ce->{courseDirs}->{html_temp}."/";
162 $envir{tempURL} = $ce->{courseURLs}->{html_temp}."/"; 151 $envir{tempURL} = $ce->{courseURLs}->{html_temp}."/";
163 $envir{scriptDirectory} = undef; 152 $envir{scriptDirectory} = undef;
164 $envir{webworkDocsURL} = $ce->{webworkURLs}->{docs}."/"; 153 $envir{webworkDocsURL} = $ce->{webworkURLs}->{docs}."/";
165 $envir{localHelpURL} = $ce->{webworkURLs}->{local_help}."/"; 154 $envir{localHelpURL} = $ce->{webworkURLs}->{local_help}."/";
166 $envir{jsMathURL} = $ce->{webworkURLs}->{jsMath}; 155 $envir{jsMathURL} = $ce->{webworkURLs}->{jsMath};
156 $envir{asciimathURL} = $ce->{webworkURLs}->{asciimath};
167 157
168 # Information for sending mail 158 # Information for sending mail
169 159
170 $envir{mailSmtpServer} = $ce->{mail}->{smtpServer}; 160 $envir{mailSmtpServer} = $ce->{mail}->{smtpServer};
171 $envir{mailSmtpSender} = $ce->{mail}->{smtpSender}; 161 $envir{mailSmtpSender} = $ce->{mail}->{smtpSender};
178 168
179 # ---------------------------------------------------------------------- 169 # ----------------------------------------------------------------------
180 170
181 my $basename = "equation-$envir{psvn}.$envir{probNum}"; 171 my $basename = "equation-$envir{psvn}.$envir{probNum}";
182 $basename .= ".$envir{problemSeed}" if $envir{problemSeed}; 172 $basename .= ".$envir{problemSeed}" if $envir{problemSeed};
183 173
174 # to make grabbing these options easier, we'll pull them out now...
175 my %imagesModeOptions = %{$ce->{pg}->{displayModeOptions}->{images}};
176
184 # Object for generating equation images 177 # Object for generating equation images
185 $envir{imagegen} = WeBWorK::PG::ImageGenerator->new( 178 $envir{imagegen} = WeBWorK::PG::ImageGenerator->new(
186 tempDir => $ce->{webworkDirs}->{tmp}, # global temp dir 179 tempDir => $ce->{webworkDirs}->{tmp}, # global temp dir
187 latex => $envir{externalLaTeXPath}, 180 latex => $envir{externalLaTeXPath},
188 dvipng => $envir{externalDvipngPath}, 181 dvipng => $envir{externalDvipngPath},
189 useCache => 1, 182 useCache => 1,
190 cacheDir => $ce->{webworkDirs}->{equationCache}, 183 cacheDir => $ce->{webworkDirs}->{equationCache},
191 cacheURL => $ce->{webworkURLs}->{equationCache}, 184 cacheURL => $ce->{webworkURLs}->{equationCache},
192 cacheDB => $ce->{webworkFiles}->{equationCacheDB}, 185 cacheDB => $ce->{webworkFiles}->{equationCacheDB},
186 useMarkers => ($imagesModeOptions{dvipng_align} && $imagesModeOptions{dvipng_align} eq 'mysql'),
187 dvipng_align => $imagesModeOptions{dvipng_align},
188 dvipng_depth_db => $imagesModeOptions{dvipng_depth_db},
193 ); 189 );
190
191 # ADDED: jsMath options
192 $envir{jsMath} = {%{$ce->{pg}{displayModeOptions}{jsMath}}};
194 193
195 # Other things... 194 # Other things...
196 $envir{QUIZ_PREFIX} = $options->{QUIZ_PREFIX}; # used by quizzes 195 $envir{QUIZ_PREFIX} = $options->{QUIZ_PREFIX}; # used by quizzes
197 $envir{PROBLEM_GRADER_TO_USE} = $ce->{pg}->{options}->{grader}; 196 $envir{PROBLEM_GRADER_TO_USE} = $ce->{pg}->{options}->{grader};
198 $envir{PRINT_FILE_NAMES_FOR} = $ce->{pg}->{specialPGEnvironmentVars}->{PRINT_FILE_NAMES_FOR}; 197 $envir{PRINT_FILE_NAMES_FOR} = $ce->{pg}->{specialPGEnvironmentVars}->{PRINT_FILE_NAMES_FOR};
198
199 # ADDED: __files__
200 # an array for mapping (eval nnn) to filenames in error messages
201 $envir{__files__} = {
202 root => $ce->{webworkDirs}{root}, # used to shorten filenames
203 pg => $ce->{pg}{directories}{root}, # ditto
204 tmpl => $ce->{courseDirs}{templates}, # ditto
205 };
199 206
200 # variables for interpreting capa problems. 207 # variables for interpreting capa problems and other things to be
201 $envir{CAPA_Tools} = $ce->{pg}->{specialPGEnvironmentVars}->{CAPA_Tools}; 208 # seen in a pg file
202 $envir{CAPA_MCTools} = $ce->{pg}->{specialPGEnvironmentVars}->{CAPA_MCTools}; 209 my $specialPGEnvironmentVarHash = $ce->{pg}->{specialPGEnvironmentVars};
203 $envir{CAPA_Graphics_URL} = $ce->{pg}->{specialPGEnvironmentVars}->{CAPA_Graphics_URL}; 210 for my $SPGEV (keys %{$specialPGEnvironmentVarHash}) {
204 $envir{CAPA_GraphicsDirectory} = $ce->{pg}->{specialPGEnvironmentVars}->{CAPA_GraphicsDirectory}; 211 $envir{$SPGEV} = $specialPGEnvironmentVarHash->{$SPGEV};
212 }
205 213
206 return \%envir; 214 return \%envir;
207} 215}
208 216
209sub translateDisplayModeNames($) { 217sub translateDisplayModeNames($) {

Legend:
Removed from v.2192  
changed lines
  Added in v.3355

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9