[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 374 Revision 375
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
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 STDERR "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 "PGbasicmacros.pl", 106 "PGbasicmacros.pl",
97 "PGchoicemacros.pl", 107 "PGchoicemacros.pl",
98 "PGanswermacros.pl", 108 "PGanswermacros.pl",
99 "PGnumericalmacros.pl", 109 "PGnumericalmacros.pl",
100 "PGgraphmacros.pl", 110 "PGgraphmacros.pl",
101 "PGauxiliaryFunctions.pl", 111 "PGauxiliaryFunctions.pl",
102 "PGmatrixmacros.pl", 112 "PGmatrixmacros.pl",
103 "PGstatisticsmacros.pl",
104 "PGcomplexmacros.pl", 113 "PGcomplexmacros.pl",
114 "PGstatisticsmacros.pl"
115
105 ); 116 );
106 117
107 ENDDOCUMENT(); 118 ENDDOCUMENT();
108 119
109END_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}
110 143
111############################################################################### 144###############################################################################
112# 145#
113############################################################################### 146###############################################################################
114 147
115############################################################################### 148###############################################################################
116############################################################################### 149###############################################################################
117 150
118#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";
119 152
120 153
121 154
122############################################################################### 155###############################################################################
156#
157# INITIALIZATION
158#
123# The following code initializes an instantiation of PGtranslator5 in the 159# The following code initializes an instantiation of PGtranslator5 in the
124# 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
125# children forked from this parent process by the daemon. 161# children forked from this parent process by the daemon.
126# 162#
127# 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
128# though their namespaces are the same. 164# though their namespaces are the same.
129############################################################################### 165###############################################################################
130 166
131 167print STDERR "Begin intitalization\n";
132my $dummy_envir = { courseScriptsDirectory => $courseScriptsDirectory, 168my $dummy_envir = { courseScriptsDirectory => $courseScriptsDirectory,
133 displayMode => $displayMode, 169 displayMode => $displayMode,
134 macroDirectory => $macroDirectory}; 170 macroDirectory => $macroDirectory};
135my $pt = new PGtranslator5; #pt stands for problem translator; 171my $pt = new PGtranslator5; #pt stands for problem translator;
136$pt ->rh_directories( { courseScriptsDirectory => $courseScriptsDirectory, 172$pt ->rh_directories( { courseScriptsDirectory => $courseScriptsDirectory,
139 templateDirectory => $templateDirectory, 175 templateDirectory => $templateDirectory,
140 tempDirectory => $Global::courseTempDirectory, 176 tempDirectory => $Global::courseTempDirectory,
141 } 177 }
142); 178);
143$pt -> evaluate_modules( @MODULE_LIST); 179$pt -> evaluate_modules( @MODULE_LIST);
144#print STDERR "Completed loading of modules, now loading extra packages\n";
145$pt -> load_extra_packages( @EXTRA_PACKAGES ); 180$pt -> load_extra_packages( @EXTRA_PACKAGES );
146#print STDERR "Completed loading of packages, now loading environment\n";
147$pt -> environment($dummy_envir); 181$pt -> environment($dummy_envir);
148#print STDERR "Completed loading environment, next initialize\n";
149$pt->initialize(); 182$pt->initialize();
150#print STDERR "Initialized. \n";
151$pt -> unrestricted_load($PG_PL ); 183my $loadErrors = $pt -> unrestricted_load($PG_PL );
184print STDERR "$loadErrors\n" if ($loadErrors);
152$pt -> unrestricted_load($DANGEROUS_MACROS_PL); 185$loadErrors = $pt -> unrestricted_load($DANGEROUS_MACROS_PL);
186print STDERR "$loadErrors\n" if ($loadErrors);
153$pt-> set_mask(); 187$pt-> set_mask();
154# 188#
155#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";
156 193
157$INITIAL_MACRO_PACKAGES =~ tr /\r/\n/; 194$INITIAL_MACRO_PACKAGES =~ tr /\r/\n/; # change everything to unix line endings.
158$pt->source_string( $INITIAL_MACRO_PACKAGES ); 195$pt->source_string( $INITIAL_MACRO_PACKAGES );
159#print STDERR "source strings read in\n";
160$pt ->rf_safety_filter( \&safetyFilter); # install blank safety filter 196$pt ->rf_safety_filter( \&safetyFilter); # install blank safety filter
161$pt ->translate(); 197$pt ->translate();
162 198
163print STDERR "New PGtranslator object inititialization completed.\n"; 199print STDERR "New PGtranslator object inititialization completed.\n";
164################################################################################ 200################################################################################
175sub renderProblem { 211sub renderProblem {
176 my $rh = shift; 212 my $rh = shift;
177 my $beginTime = new Benchmark; 213 my $beginTime = new Benchmark;
178 $Global::WARNINGS = ""; 214 $Global::WARNINGS = "";
179 $pt->environment($rh->{envir}); 215 $pt->environment($rh->{envir});
180 #$pt->{safe_cache} = $safe_cmpt_cache; 216
217# print STDERR pretty_print_rh($rh->{envir}), "\n\n";
218
181 $pt->initialize(); 219 $pt->initialize();
182 $pt -> unrestricted_load($PG_PL); 220 $pt -> unrestricted_load($PG_PL);
183 $pt -> unrestricted_load($DANGEROUS_MACROS_PL); 221 $pt -> unrestricted_load($DANGEROUS_MACROS_PL);
184 $pt-> set_mask(); 222 $pt-> set_mask();
185 223
306 344
307############### 345###############
308 346
309sub echo { 347sub echo {
310 my $in= shift; 348 my $in= shift;
349 print "data $in end data\n";
311 return(ref($in)); 350 return(ref($in));
312} 351}
313sub hello { 352sub hello {
314 print "Receiving request for hello world\n"; 353 print "Receiving request for hello world\n";
315 return "Hello world"; 354 return "Hello world";
328 $out .= "base64 reference " .$$rh; 367 $out .= "base64 reference " .$$rh;
329 } else { 368 } else {
330 $out = $rh; 369 $out = $rh;
331 } 370 }
332 if (defined($type) ) { 371 if (defined($type) ) {
333 $out .= "type = $type \n"; 372 out .= " (type = $type )\n";
334 } 373 }
335 return $out; 374 return $out;
336} 375}
337 376
338#sub xmlquit { 377#sub xmlquit {
342 381
343############################################################################### 382###############################################################################
344#OTHER SERVICES 383#OTHER SERVICES
345############################################################################### 384###############################################################################
346 385
347my $PASSWORD = 'geometry'; 386
348 387
349use File::stat; 388use File::stat;
350sub readFile { 389sub readFile {
351 my $rh = shift; 390 my $rh = shift;
352 local($|)=1; 391 local($|)=1;

Legend:
Removed from v.374  
changed lines
  Added in v.375

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9