[system] / trunk / webwork2 / lib / WeBWorK / PG.pm Repository:
ViewVC logotype

Diff of /trunk/webwork2/lib/WeBWorK/PG.pm

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

Revision 2217 Revision 2983
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: webwork-modperl/lib/WeBWorK/PG.pm,v 1.58 2004/09/13 19:29:55 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
41use 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
55sub new { 41sub 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
108 # ADDED: courseName, formatedDueDate 93 # ADDED: courseName, formatedDueDate
109 94
110 $envir{openDate} = $set->open_date; 95 $envir{openDate} = $set->open_date;
111 $envir{formattedOpenDate} = formatDateTime($envir{openDate}); 96 $envir{formattedOpenDate} = formatDateTime($envir{openDate}, $ce->{siteDefaults}{timezone});
112 $envir{dueDate} = $set->due_date; 97 $envir{dueDate} = $set->due_date;
113 $envir{formattedDueDate} = formatDateTime($envir{dueDate}); 98 $envir{formattedDueDate} = formatDateTime($envir{dueDate}, $ce->{siteDefaults}{timezone});
114 $envir{formatedDueDate} = $envir{formattedDueDate}; # typo in many header files 99 $envir{formatedDueDate} = $envir{formattedDueDate}; # typo in many header files
115 $envir{answerDate} = $set->answer_date; 100 $envir{answerDate} = $set->answer_date;
116 $envir{formattedAnswerDate} = formatDateTime($envir{answerDate}); 101 $envir{formattedAnswerDate} = formatDateTime($envir{answerDate}, $ce->{siteDefaults}{timezone});
117 $envir{numOfAttempts} = ($problem->num_correct || 0) + ($problem->num_incorrect || 0); 102 $envir{numOfAttempts} = ($problem->num_correct || 0) + ($problem->num_incorrect || 0);
118 $envir{problemValue} = $problem->value; 103 $envir{problemValue} = $problem->value;
119 $envir{sessionKey} = $key; 104 $envir{sessionKey} = $key;
120 $envir{courseName} = $ce->{courseName}; 105 $envir{courseName} = $ce->{courseName};
121 106
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 );
189
190 # ADDED: jsMath options
191 $envir{jsMath} = {%{$ce->{pg}{displayModeOptions}{jsMath}}};
198 192
199 # Other things... 193 # Other things...
200 $envir{QUIZ_PREFIX} = $options->{QUIZ_PREFIX}; # used by quizzes 194 $envir{QUIZ_PREFIX} = $options->{QUIZ_PREFIX}; # used by quizzes
201 $envir{PROBLEM_GRADER_TO_USE} = $ce->{pg}->{options}->{grader}; 195 $envir{PROBLEM_GRADER_TO_USE} = $ce->{pg}->{options}->{grader};
202 $envir{PRINT_FILE_NAMES_FOR} = $ce->{pg}->{specialPGEnvironmentVars}->{PRINT_FILE_NAMES_FOR}; 196 $envir{PRINT_FILE_NAMES_FOR} = $ce->{pg}->{specialPGEnvironmentVars}->{PRINT_FILE_NAMES_FOR};
197
198 # ADDED: __files__
199 # an array for mapping (eval nnn) to filenames in error messages
200 $envir{__files__} = {
201 root => $ce->{webworkDirs}{root}, # used to shorten filenames
202 pg => $ce->{pg}{directories}{root}, # ditto
203 tmpl => $ce->{courseDirs}{templates}, # ditto
204 };
203 205
204 # variables for interpreting capa problems and other things to be 206 # variables for interpreting capa problems and other things to be
205 # seen in a pg file 207 # seen in a pg file
206 my $specialPGEnvironmentVarHash = $ce->{pg}->{specialPGEnvironmentVars}; 208 my $specialPGEnvironmentVarHash = $ce->{pg}->{specialPGEnvironmentVars};
207 for my $SPGEV (keys %{$specialPGEnvironmentVarHash}) { 209 for my $SPGEV (keys %{$specialPGEnvironmentVarHash}) {

Legend:
Removed from v.2217  
changed lines
  Added in v.2983

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9