Parent Directory
|
Revision Log
Bringing this client up-to-date with the current version of the xmlrpc daemon. -- Mike
1 #!/usr/bin/perl -w 2 3 # configuration section 4 use constant HOSTURL => 'devel.webwork.rochester.edu'; 5 use constant HOSTPORT => 8002; 6 7 my @COMMANDS = qw( listLibraries renderProblem ); #listLib tex2pdf 8 9 # $pg{displayModes} = [ 10 # "plainText", # display raw TeX for math expressions 11 # "formattedText", # format math expressions using TtH 12 # "images", # display math expressions as images generated by dvipng 13 # "jsMath", # render TeX math expressions on the client side using jsMath 14 # "asciimath", # render TeX math expressions on the client side using ASCIIMathML 15 # ]; 16 use constant DISPLAYMODE => 'images'; 17 18 # end configuration section 19 use MIME::Base64 qw( encode_base64 decode_base64); 20 21 22 # -- SOAP::Lite -- soaplite.com -- Copyright (C) 2001 Paul Kulchenko -- 23 24 # use XMLRPC::Lite; 25 # 26 # print XMLRPC::Lite 27 # -> proxy('http://devel.webwork.rochester.edu:11002/mod_xmlrpc') 28 # -> call('Demo:bye', 25) 29 # -> result; 30 print STDERR "inputs are ", join (" | ", @ARGV), "\n"; 31 our $source; 32 33 if (@ARGV) { 34 my $command = $ARGV[0]; 35 36 warn "executing WebworkXMLRPC.$command"; 37 $source = (defined $ARGV[1]) ? `cat $ARGV[1]` : '' ; 38 xmlrpcCall($command); 39 40 41 } else { 42 43 print STDERR "Useage: .xmlrpc_client4.pl command file_name\n"; 44 print STDERR "For example: .xmlrpc_client4.pl renderProblem input.txt\n"; 45 print STDERR "Commands are: ", join(" ", @COMMANDS), "\n"; 46 47 } 48 49 50 51 52 53 54 sub xmlrpcCall { 55 my $command = shift; 56 $command = 'listLibraries' unless $command; 57 use XMLRPC::Lite; 58 my $xmlrpc = XMLRPC::Lite 59 # ->uri('http://webwork-db.math.rochester.edu/Demo/') 60 -> proxy('http://'.HOSTURL.':'.HOSTPORT.'/mod_xmlrpc'); 61 62 my $test = [3,4,5,6]; 63 my $input = setInputTable(); 64 print "displayMode=",$input->{envir}->{displayMode},"\n"; 65 local( $result); 66 eval { $result = $xmlrpc->call("WebworkXMLRPC.$command",$input) }; 67 print STDERR "There were a lot of errors\n" if $@; 68 print "Errors: \n $@\n End Errors\n" if $@; 69 70 print "result is|", ref($result),"|"; 71 72 unless (ref($result) and $result->fault) { 73 74 if (ref($result->result())=~/HASH/ and defined($result->result()->{text}) ) { 75 $result->result()->{text} = decode_base64($result->result()->{text}); 76 } 77 print pretty_print_rh($result->result()),"\n"; #$result->result() 78 } else { 79 print 'oops ', join ', ', 80 $result->faultcode, 81 $result->faultstring; 82 } 83 } 84 85 sub source { 86 encode_base64($source); 87 } 88 sub pretty_print_rh { 89 shift if UNIVERSAL::isa($_[0] => __PACKAGE__); 90 my $rh = shift; 91 my $indent = shift || 0; 92 my $out = ""; 93 my $type = ref($rh); 94 95 if (defined($type) and $type) { 96 $out .= " type = $type; "; 97 } elsif (! defined($rh )) { 98 $out .= " type = UNDEFINED; "; 99 } 100 if ( ref($rh) =~/HASH/ or "$rh" =~/HASH/ ) { 101 $out .= "{\n"; 102 $indent++; 103 foreach my $key (sort keys %{$rh}) { 104 $out .= " "x$indent."$key => " . pretty_print_rh( $rh->{$key}, $indent ) . "\n"; 105 } 106 $indent--; 107 $out .= "\n"." "x$indent."}\n"; 108 109 } elsif (ref($rh) =~ /ARRAY/ or "$rh" =~/ARRAY/) { 110 $out .= " ( "; 111 foreach my $elem ( @{$rh} ) { 112 $out .= pretty_print_rh($elem, $indent); 113 114 } 115 $out .= " ) \n"; 116 } elsif ( ref($rh) =~ /SCALAR/ ) { 117 $out .= "scalar reference ". ${$rh}; 118 } elsif ( ref($rh) =~/Base64/ ) { 119 $out .= "base64 reference " .$$rh; 120 } else { 121 $out .= $rh; 122 } 123 124 return $out." "; 125 } 126 127 sub setInputTable_for_listLib { 128 $out = { 129 #password => 'geometry', 130 pw => 'geometry', 131 set => 'set0', 132 library_name => 'rochesterLibrary', 133 command => 'all', 134 }; 135 136 $out; 137 } 138 sub setInputTable { 139 $out = { 140 #password => 'geometry', 141 pw => 'geometry', 142 set => 'set0', 143 library_name => 'rochesterLibrary', 144 command => 'all', 145 answer_form_submitted => 1, 146 course => 'daemon_course', 147 extra_packages_to_load => [qw( AlgParserWithImplicitExpand Expr 148 ExprWithImplicitExpand AnswerEvaluator 149 AnswerEvaluatorMaker 150 )], 151 mode => 'HTML_dpng', 152 modules_to_evaluate => [ qw( 153 Exporter 154 155 DynaLoader 156 157 158 GD 159 WWPlot 160 Fun 161 Circle 162 Label 163 164 165 PGrandom 166 Units 167 Hermite 168 169 List 170 171 172 Match 173 Multiple 174 Select 175 176 177 AlgParser 178 179 AnswerHash 180 181 182 Fraction 183 VectorField 184 185 186 Complex1 187 Complex 188 189 190 MatrixReal1 Matrix 191 192 193 Distributions 194 195 Regression 196 197 )], 198 envir => environment(), 199 problem_state => { 200 201 num_of_correct_ans => 2, 202 num_of_incorrect_ans => 4, 203 recorded_score => 1.0, 204 }, 205 source => source(), #base64 encoded 206 207 208 209 }; 210 211 $out; 212 } 213 214 sub environment { 215 my $envir = { 216 answerDate => '4014438528', 217 CAPA_Graphics_URL=>'http://webwork-db.math.rochester.edu/capa_graphics/', 218 CAPA_GraphicsDirectory =>'/ww/webwork/CAPA/CAPA_Graphics/', 219 CAPA_MCTools=>'/ww/webwork/CAPA/CAPA_MCTools/', 220 CAPA_Tools=>'/ww/webwork/CAPA/CAPA_Tools/', 221 cgiDirectory=>'Not defined', 222 cgiURL => 'Not defined', 223 classDirectory=> 'Not defined', 224 courseName=>'Not defined', 225 courseScriptsDirectory=>'/ww/webwork/system/courseScripts/', 226 displayMode=>DISPLAYMODE, 227 dueDate=> '4014438528', 228 externalGif2EpsPath=>'not defined', 229 externalPng2EpsPath=>'not defined', 230 externalTTHPath=>'/usr/local/bin/tth', 231 fileName=>'set0/prob1a.pg', 232 formattedAnswerDate=>'6/19/00', 233 formattedDueDate=>'6/19/00', 234 formattedOpenDate=>'6/19/00', 235 functAbsTolDefault=> 0.0000001, 236 functLLimitDefault=>0, 237 functMaxConstantOfIntegration=> 1000000000000.0, 238 functNumOfPoints=> 5, 239 functRelPercentTolDefault=> 0.000001, 240 functULimitDefault=>1, 241 functVarDefault=> 'x', 242 functZeroLevelDefault=> 0.000001, 243 functZeroLevelTolDefault=>0.000001, 244 htmlDirectory =>'/ww/webwork/courses/gage_course/html/', 245 htmlURL =>'http://webwork-db.math.rochester.edu/gage_course/', 246 inputs_ref => { 247 AnSwEr1 => '', 248 AnSwEr2 => '', 249 AnSwEr3 => '', 250 }, 251 macroDirectory=>'/ww/webwork/courses/gage_course/templates/macros/', 252 numAbsTolDefault=>0.0000001, 253 numFormatDefault=>'%0.13g', 254 numOfAttempts=> 0, 255 numRelPercentTolDefault => 0.0001, 256 numZeroLevelDefault =>0.000001, 257 numZeroLevelTolDefault =>0.000001, 258 openDate=> '3014438528', 259 PRINT_FILE_NAMES_FOR => [ 'gage'], 260 probFileName => 'set0/prob1a.pg', 261 problemSeed => 1234, 262 problemValue =>1, 263 probNum => 13, 264 psvn => 54321, 265 psvnNumber=> 54321, 266 questionNumber => 1, 267 scriptDirectory => 'Not defined', 268 sectionName => 'Gage', 269 sectionNumber => 1, 270 sessionKey=> 'Not defined', 271 setNumber =>'MAAtutorial', 272 studentLogin =>'gage', 273 studentName => 'Mike Gage', 274 tempDirectory => '/ww/htdocs/tmp/gage_course/', 275 templateDirectory=>'/ww/webwork/courses/gage_course/templates/', 276 tempURL=>'http://webwork-db.math.rochester.edu/tmp/gage_course/', 277 webworkDocsURL => 'http://webwork.math.rochester.edu/webwork_gage_system_html', 278 }; 279 $envir; 280 };
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |