--- trunk/webwork2/lib/WeBWorK/PG.pm 2004/01/05 01:02:41 1703 +++ trunk/webwork2/lib/WeBWorK/PG.pm 2004/05/24 02:01:25 2200 @@ -1,7 +1,7 @@ ################################################################################ # WeBWorK Online Homework Delivery System # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ -# $CVSHeader: webwork-modperl/lib/WeBWorK/PG.pm,v 1.46 2003/12/09 01:12:30 sh002i Exp $ +# $CVSHeader: webwork-modperl/lib/WeBWorK/PG.pm,v 1.50 2004/05/24 01:03:04 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under # the terms of either: (a) the GNU General Public License as published by the @@ -28,6 +28,30 @@ use WeBWorK::PG::ImageGenerator; use WeBWorK::Utils qw(runtime_use formatDateTime makeTempDirectory); +use constant DISPLAY_MODES => { + # display name # mode name + tex => "TeX", + plainText => "HTML", + formattedText => "HTML_tth", + images => "HTML_dpng", + jsMath => "HTML_jsMath", + asciimath => "HTML_asciimath", +}; + +use constant DISPLAY_MODE_FAILOVER => { + TeX => [], + HTML => [], + HTML_tth => [ "HTML", ], + HTML_dpng => [ "HTML_tth", "HTML", ], + HTML_jsMath => [ "HTML_dpng", "HTML_tth", "HTML", ], + HTML_asciimath => [ "HTML_dpng", "HTML_tth", "HTML", ], + # legacy modes -- these are not supported, but some problems might try to + # set the display mode to one of these values manually and some macros may + # provide rendered versions for these modes but not the one we want. + Latex2HTML => [ "TeX", "HTML", ], + HTML_img => [ "HTML_dpng", "HTML_tth", "HTML", ], +}; + sub new { shift; # throw away invocant -- we don't need it my ($ce, $user, $key, $set, $problem, $psvn, $formFields, @@ -62,22 +86,23 @@ # any changes are noted by "ADDED:" or "REMOVED:" # Vital state information - # ADDED: displayHintsQ, displaySolutionsQ, refreshMath2img, - # texDisposition + # ADDED: displayModeFailover, displayHintsQ, displaySolutionsQ, + # refreshMath2img, texDisposition - $envir{psvn} = $set->psvn; - $envir{psvnNumber} = $envir{psvn}; - $envir{probNum} = $problem->problem_id; - $envir{questionNumber} = $envir{probNum}; - $envir{fileName} = $problem->source_file; - $envir{probFileName} = $envir{fileName}; - $envir{problemSeed} = $problem->problem_seed; - $envir{displayMode} = translateDisplayModeNames($options->{displayMode}); - $envir{languageMode} = $envir{displayMode}; - $envir{outputMode} = $envir{displayMode}; - $envir{displayHintsQ} = $options->{showHints}; - $envir{displaySolutionsQ} = $options->{showSolutions}; - $envir{texDisposition} = "pdf"; # in webwork2, we use pdflatex + $envir{psvn} = $set->psvn; + $envir{psvnNumber} = $envir{psvn}; + $envir{probNum} = $problem->problem_id; + $envir{questionNumber} = $envir{probNum}; + $envir{fileName} = $problem->source_file; + $envir{probFileName} = $envir{fileName}; + $envir{problemSeed} = $problem->problem_seed; + $envir{displayMode} = translateDisplayModeNames($options->{displayMode}); + $envir{languageMode} = $envir{displayMode}; + $envir{outputMode} = $envir{displayMode}; + $envir{displayModeFailover} = DISPLAY_MODE_FAILOVER(); + $envir{displayHintsQ} = $options->{showHints}; + $envir{displaySolutionsQ} = $options->{showSolutions}; + $envir{texDisposition} = "pdf"; # in webwork2, we use pdflatex # Problem Information # ADDED: courseName, formatedDueDate @@ -125,6 +150,8 @@ # Directories and URLs # REMOVED: courseName # ADDED: dvipngTempDir + # ADDED: jsMathURL + # ADDED: asciimathURL $envir{cgiDirectory} = undef; $envir{cgiURL} = undef; @@ -138,6 +165,9 @@ $envir{tempURL} = $ce->{courseURLs}->{html_temp}."/"; $envir{scriptDirectory} = undef; $envir{webworkDocsURL} = $ce->{webworkURLs}->{docs}."/"; + $envir{localHelpURL} = $ce->{webworkURLs}->{local_help}."/"; + $envir{jsMathURL} = $ce->{webworkURLs}->{jsMath}; + $envir{asciimathURL} = $ce->{webworkURLs}->{asciimath}; # Information for sending mail @@ -182,12 +212,7 @@ sub translateDisplayModeNames($) { my $name = shift; - return { - tex => "TeX", - plainText => "HTML", - formattedText => "HTML_tth", - images => "HTML_dpng", # "HTML_img", - }->{$name}; + return DISPLAY_MODES()->{$name}; } sub oldSafetyFilter {