[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 320 Revision 381
1#!/usr/local/bin/perl -w 1#!/usr/local/bin/perl -w
2use Safe; 2
3# Copyright (C) 2001 Michael Gage 3# Copyright (C) 2001 Michael Gage
4 4
5############################################################################### 5###############################################################################
6# The initial code simply initializes variables, defines addresses 6# The initial code simply initializes variables, defines addresses
7# for directories, defines some simple subroutines responders used in debugging 7# for directories, defines some simple subroutines responders used in debugging
17 17
18#BEGIN { 18#BEGIN {
19# local $^W=0; 19# local $^W=0;
20# require '/usr/local/lib/perl5/5.6.1/Benchmark.pm'; 20# require '/usr/local/lib/perl5/5.6.1/Benchmark.pm';
21#} 21#}
22print "using the perl version of MIME::Base64\n"; 22print STDERR "using the perl version of MIME::Base64\n";
23use MIME::Base64 qw( encode_base64 decode_base64); 23use MIME::Base64 qw( encode_base64 decode_base64);
24 24
25 25
26# 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
27# only Global.pm is actively used. 27# only Global.pm is actively used.
28 28
29use 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";
30 33
31############################################################################### 34my $COURSETEMPDIRECTORY = '/Users/gage/Sites/demoCoursetmp/';
35my $COURSETEMPURL = 'http://webwork-db.math.rochester.edu/~gage/demoCoursetmp';
32 36
37
38
39my $PASSWORD = 'geometry';
40###############################################################################
33 41
34BEGIN{ 42BEGIN{
35 my $GLOBAL_INIT = "/u/gage/webwork/system/lib/Global.pm"; 43 my $GLOBAL_INIT = "/Users/gage/webwork/system/lib/Global.pm";
36 print "Opening $GLOBAL_INIT\n"; 44 print "Opening $GLOBAL_INIT\n";
37 require $GLOBAL_INIT or die $GLOBAL_INIT; 45 require $GLOBAL_INIT or die $GLOBAL_INIT;
38 import Global; 46 import Global;
39} 47}
40 48
41 49
42my $PGTRANSLATOR = "/u/gage/xmlrpc/daemon/PGtranslator5.pm"; 50
43require $PGTRANSLATOR or die "Can't open $PGTRANSLATOR"; 51require $PGTRANSLATOR or die "Can't open $PGTRANSLATOR";
44 52
45
46
47############################################################################### 53###############################################################################
48# List and address of available problemlibraries 54# List and address myof available problemlibraries
49############################################################################### 55###############################################################################
50 56
51 57
52my $libraryPath = '/u/gage/webwork/ww_prob_lib/'; 58my $libraryPath = '${WEBWORKDIRECTORY}rochester_problib/';
53 59
54my %AVAILABLE_PROBLEM_LIBRARIES = ( ww_prob_lib => '/u/gage/webwork/ww_prob_lib/', 60my %AVAILABLE_PROBLEM_LIBRARIES = ( ww_prob_lib => "${WEBWORKDIRECTORY}rochester_problib/",
55 indiana_prob_lib => '/u/gage/webwork/Indiana_prob_lib/', 61 indiana_prob_lib => "${WEBWORKDIRECTORY}Indiana_prob_lib/",
56 capaOK_lib => '/ww/webwork/courses1/capaOK/templates/', 62 capaOK_lib => '/ww/webwork/courses1/capaOK/templates/',
57 capa_lib => '/ww/webwork/courses/capa/templates/', 63 capa_lib => '/ww/webwork/courses/capa/templates/',
58 prob_lib_cvs => '/ww/webwork/courses/WW_Prob_Lib_CVS/templates/', 64 prob_lib_cvs => '/ww/webwork/courses/WW_Prob_Lib_CVS/templates/',
59 maa_100 => '/ww/webwork/courses/maa100/templates/', 65 maa_100 => '/ww/webwork/courses/maa100/templates/',
60 teitel_physics121 => '/ww/webwork/courses/teitel-phy121/templates/', 66 teitel_physics121 => '/ww/webwork/courses/teitel-phy121/templates/',
61 ); 67 );
62 68
63############################################################################### 69###############################################################################
64# Configure daemon: 70# Configure daemon:
65############################################################################### 71###############################################################################
66my $courseScriptsDirectory = '/u/gage/webwork/system/courseScripts/'; 72my $courseScriptsDirectory = $COURSESCRIPTSDIRECTORY;
67my $macroDirectory = '/ww/webwork/courses/gage_course/templates/macros/'; 73my $macroDirectory = "${courseScriptsDirectory}macros/";
68my $scriptDirectory = '/u/gage/webwork/system/scripts/'; 74my $scriptDirectory = "${WEBWORKDIRECTORY}system/scripts/";
69my $templateDirectory = '/ww/webwork/courses/gage_course/templates/'; 75my $templateDirectory = "${WEBWORKDIRECTORY}courseData/rochester_problib/";
70 76
71$Global::courseTempDirectory = '/ww/htdocs/tmp/gage_course/'; 77$Global::courseTempDirectory = $COURSETEMPDIRECTORY;
72$Global::courseTempURL = 'http://webwork-db.math.rochester.edu/tmp/gage_course/'; 78$Global::courseTempURL = $COURSETEMPURL;
73 79
74 80
75$Global::groupID = "webwork"; 81$Global::groupID = "webadmin";
76$Global::numericalGroupID = 1005; 82$Global::numericalGroupID = 1005;
77 83
78my $displayMode = 'HTML_tth'; 84my $displayMode = 'HTML_tth';
79 85
80my $PG_PL = "${courseScriptsDirectory}PG.pl"; 86my $PG_PL = "${courseScriptsDirectory}PG.pl";
84 "List", "Match","Multiple", "Select", "AlgParser", 90 "List", "Match","Multiple", "Select", "AlgParser",
85 "AnswerHash", "Fraction", "VectorField", "Complex1", 91 "AnswerHash", "Fraction", "VectorField", "Complex1",
86 "Complex", "MatrixReal1", "Matrix","Distributions", 92 "Complex", "MatrixReal1", "Matrix","Distributions",
87 "Regression" 93 "Regression"
88 ); 94 );
89my @EXTRA_PACKAGES = ( "AlgParserWithImplicitExpand", "Expr", 95my @EXTRA_PACKAGES = ( "AlgParserWithImplicitExpand", "Expr",
90 "ExprWithImplicitExpand", "AnswerEvaluator", 96 "ExprWithImplicitExpand", "AnswerEvaluator",
91# "AnswerEvaluatorMaker" 97 "AnswerEvaluatorMaker"
98
92 ); 99 );
100
101my $INITIAL_MACRO_PACKAGES;
102unless (defined ($main::do_not_preload_macros) && $main::do_not_preload_macros == 1) {
93my $INITIAL_MACRO_PACKAGES = <<END_OF_TEXT; 103 $INITIAL_MACRO_PACKAGES = <<END_OF_TEXT;
94 DOCUMENT(); 104 DOCUMENT();
95 loadMacros( 105 loadMacros(
96 "PGcomplexmacros.pl",
97 "PGbasicmacro.pl", 106 "PGbasicmacros.pl",
98 "PGchoicemacros.pl", 107 "PGchoicemacros.pl",
99 "PGanswermacros.pl", 108 "PGanswermacros.pl",
100 "PGnumericalmacros.pl", 109 "PGnumericalmacros.pl",
101 "PGgraphmacros.pl", 110 "PGgraphmacros.pl",
102 "PGauxiliaryFunctions.pl", 111 "PGauxiliaryFunctions.pl",
103 "PGmatrixmacros.pl", 112 "PGmatrixmacros.pl",
113 "PGcomplexmacros.pl",
104 "PGstatisticsmacros.pl" 114 "PGstatisticsmacros.pl"
105 115
106 ); 116 );
107 117
108 ENDDOCUMENT(); 118 ENDDOCUMENT();
109 119
110END_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}
111 143
112############################################################################### 144###############################################################################
113# 145#
114############################################################################### 146###############################################################################
115 147
116############################################################################### 148###############################################################################
117############################################################################### 149###############################################################################
118 150
119#print STDERR "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";
120 152
121 153
122 154
123############################################################################### 155###############################################################################
156#
157# INITIALIZATION
158#
124# The following code initializes an instantiation of PGtranslator5 in the 159# The following code initializes an instantiation of PGtranslator5 in the
125# 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
126# children forked from this parent process by the daemon. 161# children forked from this parent process by the daemon.
127# 162#
128# 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
129# though their namespaces are the same. 164# though their namespaces are the same.
130############################################################################### 165###############################################################################
131 166
132 167print STDERR "Begin intitalization\n";
133my $dummy_envir = { courseScriptsDirectory => $courseScriptsDirectory, 168my $dummy_envir = { courseScriptsDirectory => $courseScriptsDirectory,
134 displayMode => $displayMode, 169 displayMode => $displayMode,
135 macroDirectory => $macroDirectory}; 170 macroDirectory => $macroDirectory};
136my $pt = new PGtranslator5; #pt stands for problem translator; 171my $pt = new PGtranslator5; #pt stands for problem translator;
137$pt ->rh_directories( { courseScriptsDirectory => $courseScriptsDirectory, 172$pt ->rh_directories( { courseScriptsDirectory => $courseScriptsDirectory,
140 templateDirectory => $templateDirectory, 175 templateDirectory => $templateDirectory,
141 tempDirectory => $Global::courseTempDirectory, 176 tempDirectory => $Global::courseTempDirectory,
142 } 177 }
143); 178);
144$pt -> evaluate_modules( @MODULE_LIST); 179$pt -> evaluate_modules( @MODULE_LIST);
145#print STDERR "Completed loading of modules, now loading extra packages\n";
146$pt -> load_extra_packages( @EXTRA_PACKAGES ); 180$pt -> load_extra_packages( @EXTRA_PACKAGES );
147#print STDERR "Completed loading of packages, now loading environment\n";
148$pt -> environment($dummy_envir); 181$pt -> environment($dummy_envir);
149#print STDERR "Completed loading environment, next initialize\n";
150$pt->initialize(); 182$pt->initialize();
151#print STDERR "Initialized. \n";
152$pt -> unrestricted_load($PG_PL ); 183my $loadErrors = $pt -> unrestricted_load($PG_PL );
184print STDERR "$loadErrors\n" if ($loadErrors);
153$pt -> unrestricted_load($DANGEROUS_MACROS_PL); 185$loadErrors = $pt -> unrestricted_load($DANGEROUS_MACROS_PL);
186print STDERR "$loadErrors\n" if ($loadErrors);
154$pt-> set_mask(); 187$pt-> set_mask();
155# 188#
156#print STDERR "Unrestricted loads completed.\n"; 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";
157 193
158$INITIAL_MACRO_PACKAGES =~ tr /\r/\n/; 194$INITIAL_MACRO_PACKAGES =~ tr /\r/\n/; # change everything to unix line endings.
159$pt->source_string( $INITIAL_MACRO_PACKAGES ); 195$pt->source_string( $INITIAL_MACRO_PACKAGES );
160#print STDERR "source strings read in\n";
161$pt ->rf_safety_filter( \&safetyFilter); # install blank safety filter 196$pt ->rf_safety_filter( \&safetyFilter); # install blank safety filter
162$pt ->translate(); 197$pt ->translate();
163 198
164print STDERR "New PGtranslator object inititialization completed.\n"; 199print STDERR "New PGtranslator object inititialization completed.\n";
165################################################################################ 200################################################################################
176sub renderProblem { 211sub renderProblem {
177 my $rh = shift; 212 my $rh = shift;
178 my $beginTime = new Benchmark; 213 my $beginTime = new Benchmark;
179 $Global::WARNINGS = ""; 214 $Global::WARNINGS = "";
180 $pt->environment($rh->{envir}); 215 $pt->environment($rh->{envir});
181 #$pt->{safe_cache} = $safe_cmpt_cache; 216
217# print STDERR pretty_print_rh($rh->{envir}), "\n\n";
218
182 $pt->initialize(); 219 $pt->initialize();
183 $pt -> unrestricted_load($PG_PL); 220 $pt -> unrestricted_load($PG_PL);
184 $pt -> unrestricted_load($DANGEROUS_MACROS_PL); 221 $pt -> unrestricted_load($DANGEROUS_MACROS_PL);
185 $pt-> set_mask(); 222 $pt-> set_mask();
186 223
307 344
308############### 345###############
309 346
310sub echo { 347sub echo {
311 my $in= shift; 348 my $in= shift;
349 print "data $in end data\n";
312 return(ref($in)); 350 return(ref($in));
313} 351}
314sub hello { 352sub hello {
315 print "Receiving request for hello world\n"; 353 print "Receiving request for hello world\n";
316 return "Hello world"; 354 return "Hello world";
329 $out .= "base64 reference " .$$rh; 367 $out .= "base64 reference " .$$rh;
330 } else { 368 } else {
331 $out = $rh; 369 $out = $rh;
332 } 370 }
333 if (defined($type) ) { 371 if (defined($type) ) {
334 $out .= "type = $type \n"; 372 $out .= " (type = $type )\n";
335 } 373 }
336 return $out; 374 return $out;
337} 375}
338 376
339#sub xmlquit { 377#sub xmlquit {
343 381
344############################################################################### 382###############################################################################
345#OTHER SERVICES 383#OTHER SERVICES
346############################################################################### 384###############################################################################
347 385
348my $PASSWORD = 'geometry'; 386
349 387
350use File::stat; 388use File::stat;
351sub readFile { 389sub readFile {
352 my $rh = shift; 390 my $rh = shift;
353 local($|)=1; 391 local($|)=1;

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9