[system] / trunk / xmlrpc / daemon / Webwork.pm Repository:
ViewVC logotype

Diff of /trunk/xmlrpc/daemon/Webwork.pm

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

Revision 279 Revision 381
12package Webwork; 12package Webwork;
13 13
14use strict; 14use strict;
15use sigtrap; 15use sigtrap;
16use Carp; 16use Carp;
17
17#BEGIN { 18#BEGIN {
18# local $^W=0; 19# local $^W=0;
19# require '/usr/local/lib/perl5/5.6.1/Benchmark.pm'; 20# require '/usr/local/lib/perl5/5.6.1/Benchmark.pm';
20#} 21#}
21print "using the perl version of MIME::Base64\n"; 22print STDERR "using the perl version of MIME::Base64\n";
22use MIME::Base64 qw( encode_base64 decode_base64); 23use MIME::Base64 qw( encode_base64 decode_base64);
23 24
24 25
25# These libraries contain files which must at least be available, even though 26# These libraries contain files which must at least be available, even though
26# only Global.pm is actively used. 27# only Global.pm is actively used.
27 28
28use lib "/u/gage/webwork/system/lib/", "/u/gage/webwork/system/courseScripts"; 29use lib "/Users/gage/webwork/system/lib/", "/Users/gage/webwork/system/courseScripts/";
30my $WEBWORKDIRECTORY = '/Users/gage/webwork/';
31my $COURSESCRIPTSDIRECTORY = "/Users/gage/webwork/system/courseScripts/";
32my $PGTRANSLATOR = "PGtranslator5.pm";
29 33
34my $COURSETEMPDIRECTORY = '/Users/gage/Sites/demoCoursetmp/';
35my $COURSETEMPURL = 'http://webwork-db.math.rochester.edu/~gage/demoCoursetmp';
36
37
38
39my $PASSWORD = 'geometry';
30############################################################################### 40###############################################################################
31 41
32BEGIN{ 42BEGIN{
33 my $GLOBAL_INIT = "/u/gage/webwork/system/lib/Global.pm"; 43 my $GLOBAL_INIT = "/Users/gage/webwork/system/lib/Global.pm";
34 print "Opening $GLOBAL_INIT\n"; 44 print "Opening $GLOBAL_INIT\n";
35 require $GLOBAL_INIT or die $GLOBAL_INIT; 45 require $GLOBAL_INIT or die $GLOBAL_INIT;
36 import Global; 46 import Global;
37} 47}
38 48
39my $PGTRANSLATOR = "PGtranslator5.pm"; 49
40 50
41require $PGTRANSLATOR or die "Can't open $PGTRANSLATOR"; 51require $PGTRANSLATOR or die "Can't open $PGTRANSLATOR";
42 52
43############################################################################### 53###############################################################################
44# List and address myof available problemlibraries 54# List and address myof available problemlibraries
45############################################################################### 55###############################################################################
46 56
47 57
48my $libraryPath = '/u/gage/webwork/ww_prob_lib/'; 58my $libraryPath = '${WEBWORKDIRECTORY}rochester_problib/';
49 59
50my %AVAILABLE_PROBLEM_LIBRARIES = ( ww_prob_lib => '/u/gage/webwork/ww_prob_lib/', 60my %AVAILABLE_PROBLEM_LIBRARIES = ( ww_prob_lib => "${WEBWORKDIRECTORY}rochester_problib/",
51 indiana_prob_lib => '/u/gage/webwork/Indiana_prob_lib/', 61 indiana_prob_lib => "${WEBWORKDIRECTORY}Indiana_prob_lib/",
52 capaOK_lib => '/ww/webwork/courses1/capaOK/templates/', 62 capaOK_lib => '/ww/webwork/courses1/capaOK/templates/',
53 capa_lib => '/ww/webwork/courses/capa/templates/', 63 capa_lib => '/ww/webwork/courses/capa/templates/',
54 prob_lib_cvs => '/ww/webwork/courses/WW_Prob_Lib_CVS/templates/', 64 prob_lib_cvs => '/ww/webwork/courses/WW_Prob_Lib_CVS/templates/',
55 maa_100 => '/ww/webwork/courses/maa100/templates/', 65 maa_100 => '/ww/webwork/courses/maa100/templates/',
56 teitel_physics121 => '/ww/webwork/courses/teitel-phy121/templates/', 66 teitel_physics121 => '/ww/webwork/courses/teitel-phy121/templates/',
57 ); 67 );
58 68
59############################################################################### 69###############################################################################
60# Configure daemon: 70# Configure daemon:
61############################################################################### 71###############################################################################
62my $courseScriptsDirectory = '/u/gage/webwork/system/courseScripts/'; 72my $courseScriptsDirectory = $COURSESCRIPTSDIRECTORY;
63my $macroDirectory = '/u/gage/xmlrpc/experiments/macros/'; 73my $macroDirectory = "${courseScriptsDirectory}macros/";
64my $scriptDirectory = '/u/gage/webwork/system/scripts/'; 74my $scriptDirectory = "${WEBWORKDIRECTORY}system/scripts/";
65my $templateDirectory = '/u/gage/webwork/ww_prob_lib/'; 75my $templateDirectory = "${WEBWORKDIRECTORY}courseData/rochester_problib/";
66 76
67$Global::courseTempDirectory = '/ww/htdocs/tmp/gage_course/'; 77$Global::courseTempDirectory = $COURSETEMPDIRECTORY;
68$Global::courseTempURL = 'http://webwork-db.math.rochester.edu/tmp/gage_course/'; 78$Global::courseTempURL = $COURSETEMPURL;
69 79
70 80
71$Global::groupID = "webadmin"; 81$Global::groupID = "webadmin";
72$Global::numericalGroupID = 1005; 82$Global::numericalGroupID = 1005;
73 83
74my $displayMode = 'HTML'; 84my $displayMode = 'HTML_tth';
75 85
76my $PG_PL = "${courseScriptsDirectory}PG.pl"; 86my $PG_PL = "${courseScriptsDirectory}PG.pl";
77my $DANGEROUS_MACROS_PL = "${courseScriptsDirectory}dangerousMacros.pl"; 87my $DANGEROUS_MACROS_PL = "${courseScriptsDirectory}dangerousMacros.pl";
78my @MODULE_LIST = ( "Exporter", "DynaLoader", "GD", "WWPlot", "Fun", 88my @MODULE_LIST = ( "Exporter", "DynaLoader", "GD", "WWPlot", "Fun",
79 "Circle", "Label", "PGrandom", "Units", "Hermite", 89 "Circle", "Label", "PGrandom", "Units", "Hermite",
83 "Regression" 93 "Regression"
84 ); 94 );
85my @EXTRA_PACKAGES = ( "AlgParserWithImplicitExpand", "Expr", 95my @EXTRA_PACKAGES = ( "AlgParserWithImplicitExpand", "Expr",
86 "ExprWithImplicitExpand", "AnswerEvaluator", 96 "ExprWithImplicitExpand", "AnswerEvaluator",
87 "AnswerEvaluatorMaker" 97 "AnswerEvaluatorMaker"
98
88 ); 99 );
100
101my $INITIAL_MACRO_PACKAGES;
102unless (defined ($main::do_not_preload_macros) && $main::do_not_preload_macros == 1) {
89my $INITIAL_MACRO_PACKAGES = <<END_OF_TEXT; 103 $INITIAL_MACRO_PACKAGES = <<END_OF_TEXT;
90 DOCUMENT(); 104 DOCUMENT();
91 loadMacros( 105 loadMacros(
92 "PGbasicmacros.pl", 106 "PGbasicmacros.pl",
93 "PGchoicemacros.pl", 107 "PGchoicemacros.pl",
94 "PGanswermacros.pl", 108 "PGanswermacros.pl",
95 "PGnumericalmacros.pl", 109 "PGnumericalmacros.pl",
96 "PGgraphmacros.pl", 110 "PGgraphmacros.pl",
97 "PGauxiliaryFunctions.pl", 111 "PGauxiliaryFunctions.pl",
98 "PGmatrixmacros.pl", 112 "PGmatrixmacros.pl",
99 "PGcomplexmacros.pl", 113 "PGcomplexmacros.pl",
100 "PGstatisticsmacros.pl" 114 "PGstatisticsmacros.pl"
101 115
102 ); 116 );
103 117
104 ENDDOCUMENT(); 118 ENDDOCUMENT();
105 119
106END_OF_TEXT 120END_OF_TEXT
121} else {
122 $INITIAL_MACRO_PACKAGES = <<END_OF_TEXT;
123 DOCUMENT();
124 loadMacros(
125# "PGbasicmacros.pl",
126# "PGchoicemacros.pl",
127# "PGanswermacros.pl",
128# "PGnumericalmacros.pl",
129# "PGgraphmacros.pl",
130# "PGauxiliaryFunctions.pl",
131# "PGmatrixmacros.pl",
132# "PGcomplexmacros.pl",
133# "PGstatisticsmacros.pl"
134
135 );
136
137 ENDDOCUMENT();
138
139END_OF_TEXT
140
141
142}
107 143
108############################################################################### 144###############################################################################
109# 145#
110############################################################################### 146###############################################################################
111 147
112############################################################################### 148###############################################################################
113############################################################################### 149###############################################################################
114 150
115print "ok so far reading file /u/gage/xmlrpc/daemon/Webwork.pm\n"; 151print STDERR "ok so far reading file ${WEBWORKDIRECTORY}xmlrpc/daemon/Webwork.pm\n";
116 152
117 153
118 154
119############################################################################### 155###############################################################################
156#
157# INITIALIZATION
158#
120# The following code initializes an instantiation of PGtranslator5 in the 159# The following code initializes an instantiation of PGtranslator5 in the
121# parent process. This initialized object is then share with each of the 160# parent process. This initialized object is then share with each of the
122# children forked from this parent process by the daemon. 161# children forked from this parent process by the daemon.
123# 162#
124# As far as I can tell, the child processes don't share any variable values even 163# As far as I can tell, the child processes don't share any variable values even
125# though their namespaces are the same. 164# though their namespaces are the same.
126############################################################################### 165###############################################################################
127 166
128 167print STDERR "Begin intitalization\n";
129my $dummy_envir = { courseScriptsDirectory => $courseScriptsDirectory, 168my $dummy_envir = { courseScriptsDirectory => $courseScriptsDirectory,
130 displayMode => $displayMode, 169 displayMode => $displayMode,
131 macroDirectory => $macroDirectory}; 170 macroDirectory => $macroDirectory};
132my $pt = new PGtranslator5; #pt stands for problem translator; 171my $pt = new PGtranslator5; #pt stands for problem translator;
133$pt ->rh_directories( { courseScriptsDirectory => $courseScriptsDirectory, 172$pt ->rh_directories( { courseScriptsDirectory => $courseScriptsDirectory,
139); 178);
140$pt -> evaluate_modules( @MODULE_LIST); 179$pt -> evaluate_modules( @MODULE_LIST);
141$pt -> load_extra_packages( @EXTRA_PACKAGES ); 180$pt -> load_extra_packages( @EXTRA_PACKAGES );
142$pt -> environment($dummy_envir); 181$pt -> environment($dummy_envir);
143$pt->initialize(); 182$pt->initialize();
144$pt -> unrestricted_load($PG_PL ); 183my $loadErrors = $pt -> unrestricted_load($PG_PL );
184print STDERR "$loadErrors\n" if ($loadErrors);
145$pt -> unrestricted_load($DANGEROUS_MACROS_PL); 185$loadErrors = $pt -> unrestricted_load($DANGEROUS_MACROS_PL);
186print STDERR "$loadErrors\n" if ($loadErrors);
146$pt-> set_mask(); 187$pt-> set_mask();
147# 188#
189# print STDERR "\nPG.pl: $PG_PL\n";
190# print STDERR "DANGEROUS_MACROS_PL: $DANGEROUS_MACROS_PL\n";
191# print STDERR "Print dummy environment\n";
192# print STDERR pretty_print_rh($dummy_envir), "\n\n";
148 193
149 194$INITIAL_MACRO_PACKAGES =~ tr /\r/\n/; # change everything to unix line endings.
150$INITIAL_MACRO_PACKAGES =~ tr /\r/\n/;
151$pt->source_string( $INITIAL_MACRO_PACKAGES ); 195$pt->source_string( $INITIAL_MACRO_PACKAGES );
152$pt ->rf_safety_filter( \&safetyFilter); # install blank safety filter 196$pt ->rf_safety_filter( \&safetyFilter); # install blank safety filter
153$pt ->translate(); 197$pt ->translate();
198
199print STDERR "New PGtranslator object inititialization completed.\n";
154################################################################################ 200################################################################################
155## This ends the initialization of the PGtranslator object 201## This ends the initialization of the PGtranslator object
156################################################################################ 202################################################################################
157 203
158############################################################################### 204###############################################################################
165sub renderProblem { 211sub renderProblem {
166 my $rh = shift; 212 my $rh = shift;
167 my $beginTime = new Benchmark; 213 my $beginTime = new Benchmark;
168 $Global::WARNINGS = ""; 214 $Global::WARNINGS = "";
169 $pt->environment($rh->{envir}); 215 $pt->environment($rh->{envir});
170 #$pt->{safe_cache} = $safe_cmpt_cache; 216
217# print STDERR pretty_print_rh($rh->{envir}), "\n\n";
218
171 $pt->initialize(); 219 $pt->initialize();
172 $pt -> unrestricted_load($PG_PL); 220 $pt -> unrestricted_load($PG_PL);
173 $pt -> unrestricted_load($DANGEROUS_MACROS_PL); 221 $pt -> unrestricted_load($DANGEROUS_MACROS_PL);
174 $pt-> set_mask(); 222 $pt-> set_mask();
175 223
296 344
297############### 345###############
298 346
299sub echo { 347sub echo {
300 my $in= shift; 348 my $in= shift;
349 print "data $in end data\n";
301 return(ref($in)); 350 return(ref($in));
302} 351}
303sub hello { 352sub hello {
304 print "Receiving request for hello world\n"; 353 print "Receiving request for hello world\n";
305 return "Hello world"; 354 return "Hello world";
318 $out .= "base64 reference " .$$rh; 367 $out .= "base64 reference " .$$rh;
319 } else { 368 } else {
320 $out = $rh; 369 $out = $rh;
321 } 370 }
322 if (defined($type) ) { 371 if (defined($type) ) {
323 $out .= "type = $type \n"; 372 $out .= " (type = $type )\n";
324 } 373 }
325 return $out; 374 return $out;
326} 375}
327 376
328#sub xmlquit { 377#sub xmlquit {
332 381
333############################################################################### 382###############################################################################
334#OTHER SERVICES 383#OTHER SERVICES
335############################################################################### 384###############################################################################
336 385
337my $PASSWORD = 'geometry'; 386
338 387
339use File::stat; 388use File::stat;
340sub readFile { 389sub readFile {
341 my $rh = shift; 390 my $rh = shift;
342 local($|)=1; 391 local($|)=1;

Legend:
Removed from v.279  
changed lines
  Added in v.381

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9