[system] / trunk / webwork-modperl / lib / WebworkWebservice / RenderProblem.pm Repository:
ViewVC logotype

Diff of /trunk/webwork-modperl/lib/WebworkWebservice/RenderProblem.pm

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

Revision 6229 Revision 6230
19 19
20use strict; 20use strict;
21use sigtrap; 21use sigtrap;
22use Carp; 22use Carp;
23use Safe; 23use Safe;
24use Apache; 24#use Apache;
25use WeBWorK::CourseEnvironment; 25use WeBWorK::CourseEnvironment;
26use WeBWorK::PG::Translator; 26use WeBWorK::PG::Translator;
27use WeBWorK::PG::Local; 27use WeBWorK::PG::Local;
28use WeBWorK::DB; 28use WeBWorK::DB;
29use WeBWorK::Constants; 29use WeBWorK::Constants;
356 answers => $pg->{answers}, 356 answers => $pg->{answers},
357 errors => $pg->{errors}, 357 errors => $pg->{errors},
358 WARNINGS => encode_base64($pg->{warnings} ), 358 WARNINGS => encode_base64($pg->{warnings} ),
359 problem_result => $pg->{result}, 359 problem_result => $pg->{result},
360 problem_state => $pg->{state}, 360 problem_state => $pg->{state},
361 #PG_flag => $pg->{flags}, 361 PG_flag => $pg->{flags},
362
363
364
365 }; 362 };
366 # Filter out bad reference types 363 # Filter out bad reference types
367 ################### 364 ###################
368 # DEBUGGING CODE 365 # DEBUGGING CODE
369 ################### 366 ###################
372 my $xmlDebugLog = "$logDirectory/xml_debug.txt"; 369 my $xmlDebugLog = "$logDirectory/xml_debug.txt";
373 warn "Opening debug log $xmlDebugLog\n" ; 370 warn "Opening debug log $xmlDebugLog\n" ;
374 open (DEBUGCODE, ">>$xmlDebugLog") || die "Can't open $xmlDebugLog"; 371 open (DEBUGCODE, ">>$xmlDebugLog") || die "Can't open $xmlDebugLog";
375 print DEBUGCODE "\n\nStart xml encoding\n"; 372 print DEBUGCODE "\n\nStart xml encoding\n";
376 } 373 }
377 xml_filter($out2->{answers});
378 374
375 $out2->{answers} = xml_filter($out2->{answers}); # check this -- it might not be working correctly
379 ################## 376 ##################
380 close(DEBUGCODE) if $debugXmlCode; 377 close(DEBUGCODE) if $debugXmlCode;
381 ################### 378 ###################
382 379
383 $out2->{PG_flag}->{PROBLEM_GRADER_TO_USE} = undef; 380 $out2->{PG_flag}->{PROBLEM_GRADER_TO_USE} = undef;
387 384
388 $out2; 385 $out2;
389 386
390} 387}
391 388
392 389# insures proper conversion to xml structure.
393sub xml_filter { 390sub xml_filter {
394 my $input = shift; 391 my $input = shift;
395 my $level = shift || 0; 392 my $level = shift || 0;
396 my $space=" "; 393 my $space=" ";
397 # Hack to filter out CODE references 394 # Hack to filter out CODE references
398 my $type = ref($input); 395 my $type = ref($input);
399 if (!defined($type) or !$type ) { 396 if (!defined($type) or !$type ) {
400 print DEBUGCODE $space x $level." : scalar -- not converted\n" if $debugXmlCode; 397 print DEBUGCODE $space x $level." : scalar -- not converted\n" if $debugXmlCode;
401 } elsif( $type =~/HASH/i or "$input"=~/HASH/i) { 398 } elsif( $type =~/HASH/i or "$input"=~/HASH/i) {
402 print DEBUGCODE "HASH reference with ".%{$input}." elements will be investigated\n" if $debugXmlCode; 399 print DEBUGCODE "HASH reference with ".%{$input}." elements will be investigated\n" if $debugXmlCode;
403 $level++; 400 $level++;
408 $level--; 405 $level--;
409 print DEBUGCODE " "x$level."HASH reference completed \n" if $debugXmlCode; 406 print DEBUGCODE " "x$level."HASH reference completed \n" if $debugXmlCode;
410 } elsif( $type=~/ARRAY/i or "$input"=~/ARRAY/i) { 407 } elsif( $type=~/ARRAY/i or "$input"=~/ARRAY/i) {
411 print DEBUGCODE " "x$level."ARRAY reference with ".@{$input}." elements will be investigated\n" if $debugXmlCode; 408 print DEBUGCODE " "x$level."ARRAY reference with ".@{$input}." elements will be investigated\n" if $debugXmlCode;
412 $level++; 409 $level++;
410 my $tmp = [];
413 foreach my $item (@{$input}) { 411 foreach my $item (@{$input}) {
414 $item = xml_filter($item,$level); 412 $item = xml_filter($item,$level);
413 push @$tmp, $item;
415 } 414 }
415 $input = $tmp;
416 $level--; 416 $level--;
417 print DEBUGCODE " "x$level."ARRAY reference completed \n" if $debugXmlCode; 417 print DEBUGCODE " "x$level."ARRAY reference completed",join(" ",@$input),"\n" if $debugXmlCode;
418 } elsif($type =~ /CODE/i or "$input" =~/CODE/i) { 418 } elsif($type =~ /CODE/i or "$input" =~/CODE/i) {
419 $input = "CODE reference"; 419 $input = "CODE reference";
420 print DEBUGCODE " "x$level."CODE reference, converted $input\n" if $debugXmlCode; 420 print DEBUGCODE " "x$level."CODE reference, converted $input\n" if $debugXmlCode;
421 } else { 421 } else {
422 print DEBUGCODE " "x$level." $type and was converted to string\n" if $debugXmlCode; 422 print DEBUGCODE " "x$level." $type and was converted to string\n" if $debugXmlCode;

Legend:
Removed from v.6229  
changed lines
  Added in v.6230

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9