You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(53) |
Feb
(56) |
Mar
|
Apr
|
May
(30) |
Jun
(78) |
Jul
(121) |
Aug
(155) |
Sep
(77) |
Oct
(61) |
Nov
(45) |
Dec
(94) |
2006 |
Jan
(116) |
Feb
(33) |
Mar
(11) |
Apr
(23) |
May
(60) |
Jun
(89) |
Jul
(130) |
Aug
(109) |
Sep
(124) |
Oct
(63) |
Nov
(82) |
Dec
(45) |
2007 |
Jan
(31) |
Feb
(35) |
Mar
(123) |
Apr
(36) |
May
(18) |
Jun
(134) |
Jul
(133) |
Aug
(241) |
Sep
(126) |
Oct
(31) |
Nov
(15) |
Dec
(5) |
2008 |
Jan
(11) |
Feb
(6) |
Mar
(16) |
Apr
(29) |
May
(43) |
Jun
(149) |
Jul
(27) |
Aug
(29) |
Sep
(37) |
Oct
(20) |
Nov
(4) |
Dec
(6) |
2009 |
Jan
(34) |
Feb
(30) |
Mar
(16) |
Apr
(6) |
May
(1) |
Jun
(32) |
Jul
(22) |
Aug
(7) |
Sep
(18) |
Oct
(50) |
Nov
(22) |
Dec
(8) |
2010 |
Jan
(17) |
Feb
(15) |
Mar
(10) |
Apr
(9) |
May
(67) |
Jun
(30) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
|
From: Mike G. v. a. <we...@ma...> - 2010-06-04 00:47:16
|
Log Message: ----------- make it easy to switch between local server and hosted2 Modified Files: -------------- webwork2/clients: renderProblem.pl Revision Data ------------- Index: renderProblem.pl =================================================================== RCS file: /webwork/cvs/system/webwork2/clients/renderProblem.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -Lclients/renderProblem.pl -Lclients/renderProblem.pl -u -r1.5 -r1.6 --- clients/renderProblem.pl +++ clients/renderProblem.pl @@ -50,27 +50,33 @@ # the rest can be configured later to use a different server +my $use_local = 1; +our ($PROTOCOL,$HOSTNAME, $HOSTPORT, $FULL_URL,$FORM_ACTION_URL, $XML_PASSWORD, $XML_COURSE); +if ($use_local) { # the rest can work!! -# use constant PROTOCOL => 'http'; -# use constant HOSTNAME => 'localhost'; -# use constant HOSTPORT => 80; -# our $FORM_ACTION_URL ='http://localhost/webwork2/html2xml'; + $PROTOCOL = 'http'; + $HOSTNAME = 'localhost'; + $HOSTPORT = 80; + $FULL_URL = "$PROTOCOL://$HOSTNAME:$HOSTPORT"; + $FORM_ACTION_URL = "$FULL_URL/webwork2/html2xml"; + $XML_PASSWORD = 'xmlwebwork'; + $XML_COURSE = 'daemon_course'; +} else { + $PROTOCOL = 'https'; # or 'https'; + $HOSTNAME = "hosted2.webwork.rochester.edu"; # 'localhost'; + $HOSTPORT = 443; #( for secure https) # 80 or 443; + $FULL_URL = "$PROTOCOL://$HOSTNAME:$HOSTPORT"; + $FORM_ACTION_URL = "$FULL_URL/webwork2/html2xml"; # server parameter + $XML_PASSWORD = 'xmlwebwork'; + $XML_COURSE = 'daemon_course'; - -use constant PROTOCOL => 'https'; # or 'http'; -use constant HOSTNAME => 'hosted2.webwork.rochester.edu'; # 'localhost'; -use constant HOSTPORT => 443; #( for secure https) # 80; -our $FULL_URL = PROTOCOL."://".HOSTNAME; # .":".HOSTPORT; -our $FORM_ACTION_URL = "$FULL_URL/webwork2/html2xml"; # server parameter +} use constant TRANSPORT_METHOD => 'XMLRPC::Lite'; use constant REQUEST_CLASS => 'WebworkXMLRPC'; # WebworkXMLRPC is used for soap also!! use constant REQUEST_URI => 'mod_xmlrpc'; -use constant XML_PASSWORD => 'xmlwebwork'; -use constant XML_COURSE => 'daemon_course'; - @@ -141,7 +147,6 @@ $command = 'listLibraries' unless $command; my $requestResult = TRANSPORT_METHOD - #->uri('http://'.HOSTNAME.':'.HOSTPORT.'/'.REQUEST_CLASS) -> proxy($FULL_URL.'/'.REQUEST_URI); my $input = $self->setInputTable(); @@ -160,7 +165,7 @@ $self->{output} = $self->formatRenderedProblem($rh_result); } else { - $self->{output} = 'Error from server: ', join( ",\n ", + $self->{output} = 'Error from server: '. join( ",\n ", $result->faultcode, $result->faultstring); } @@ -171,43 +176,38 @@ encode_base64($source); } - -sub pretty_print_rh { - shift if UNIVERSAL::isa($_[0] => __PACKAGE__); - my $rh = shift; - my $indent = shift || 0; - my $out = ""; - my $type = ref($rh); - - if (defined($type) and $type) { - $out .= " type = $type; "; - } elsif (! defined($rh )) { - $out .= " type = UNDEFINED; "; - } - return $out." " unless defined($rh); - - if ( ref($rh) =~/HASH/ or "$rh" =~/HASH/ ) { - $out .= "{\n"; - $indent++; - foreach my $key (sort keys %{$rh}) { - $out .= " "x$indent."$key => " . pretty_print_rh( $rh->{$key}, $indent ) . "\n"; - } - $indent--; - $out .= "\n"." "x$indent."}\n"; - - } elsif (ref($rh) =~ /ARRAY/ or "$rh" =~/ARRAY/) { - $out .= " ( "; - foreach my $elem ( @{$rh} ) { - $out .= pretty_print_rh($elem, $indent); - - } - $out .= " ) \n"; - } elsif ( ref($rh) =~ /SCALAR/ ) { - $out .= "scalar reference ". ${$rh}; - } elsif ( ref($rh) =~/Base64/ ) { - $out .= "base64 reference " .$$rh; +sub pretty_print { # provides html output -- NOT a method + my $r_input = shift; + my $level = shift; + $level = 4 unless defined($level); + $level--; + return '' unless $level > 0; # only print three levels of hashes (safety feature) + my $out = ''; + if ( not ref($r_input) ) { + $out = $r_input if defined $r_input; # not a reference + $out =~ s/</</g ; # protect for HTML output + } elsif ("$r_input" =~/hash/i) { # this will pick up objects whose '$self' is hash and so works better than ref($r_iput). + local($^W) = 0; + + $out .= "$r_input " ."<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">"; + + + foreach my $key ( sort ( keys %$r_input )) { + $out .= "<tr><TD> $key</TD><TD>=></td><td> ".pretty_print($r_input->{$key}) . "</td></tr>"; + } + $out .="</table>"; + } elsif (ref($r_input) eq 'ARRAY' ) { + my @array = @$r_input; + $out .= "( " ; + while (@array) { + $out .= pretty_print(shift @array, $level) . " , "; + } + $out .= " )"; + } elsif (ref($r_input) eq 'CODE') { + $out = "$r_input"; } else { - $out .= $rh; + $out = $r_input; + $out =~ s/</</g; # protect for HTML output } return $out." "; @@ -216,7 +216,7 @@ sub setInputTable_for_listLib { my $self = shift; my $out = { - pw => XML_PASSWORD(), + pw => $XML_PASSWORD, set => 'set0', library_name => 'Library', command => 'all', @@ -227,11 +227,11 @@ sub setInputTable { my $self = shift; my $out = { - pw => XML_PASSWORD(), + pw => $XML_PASSWORD, library_name => 'Library', command => 'renderProblem', answer_form_submitted => 1, - course => XML_COURSE(), + course => $XML_COURSE, extra_packages_to_load => [qw( AlgParserWithImplicitExpand Expr ExprWithImplicitExpand AnswerEvaluator AnswerEvaluatorMaker @@ -266,7 +266,7 @@ envir => $self->environment(), problem_state => { - num_of_correct_ans => 2, + num_of_correct_ans => 0, num_of_incorrect_ans => 4, recorded_score => 1.0, }, @@ -294,6 +294,7 @@ courseScriptsDirectory=>'not defined', displayMode=>DISPLAYMODE, dueDate=> '4014438528', + effectivePermissionLevel => 10, externalGif2EpsPath=>'not defined', externalPng2EpsPath=>'not defined', externalTTHPath=>'/usr/local/bin/tth', @@ -321,6 +322,7 @@ numZeroLevelDefault =>0.000001, numZeroLevelTolDefault =>0.000001, openDate=> '3014438528', + permissionLevel =>10, PRINT_FILE_NAMES_FOR => [ 'gage'], probFileName => 'set0/prob1a.pg', problemSeed => 1234, @@ -340,6 +342,10 @@ templateDirectory=>'not defined', tempURL=>'not defined', webworkDocsURL => 'not defined', + + showHints => 1, # extra options -- usually passed from the input form + showSolutions => 1, + }; $envir; }; @@ -350,7 +356,7 @@ my $problemNumber = shift; my $answerString = $rh_answer->{original_student_ans}||' '; my $correctAnswer = $rh_answer->{correct_ans}||''; - my $ans_message = $rh_answer->{ans_message}; + my $ans_message = $rh_answer->{ans_message}||''; my $score = ($rh_answer->{score}) ? 'Correct' : 'Incorrect'; my $row = qq{ <tr> @@ -385,8 +391,11 @@ $warnings = "<div style=\"background-color:pink\"> <p >WARNINGS</p><p>".decode_base64($rh_result->{WARNINGS})."</p></div>"; } - - ; + #warn "keys: ", join(" | ", sort keys %{$rh_result }); + my $debug_messages = $rh_result->{flags}->{DEBUG_messages} || []; + $debug_messages = join("<br/>\n", @{ $debug_messages } ); + my $internal_debug_messages = $rh_result->{internal_debug_messages} || []; + $internal_debug_messages = join("<br/>\n", @{ $internal_debug_messages } ); # collect answers my $answerTemplate = q{<hr>ANSWERS <table border="3" align="center">}; my $problemNumber = 1; @@ -400,11 +409,11 @@ my $problemTemplate = <<ENDPROBLEMTEMPLATE; <html> <head> +<base href="$FULL_URL"> <title>WeBWorK Editor</title> </head> <body> $answerTemplate - $warnings <form action="$FORM_ACTION_URL" method="post"> $problemText <input type="hidden" name="answersSubmitted" value="1"> @@ -414,6 +423,18 @@ <input type="hidden" name="pathToProblemFile" value="foobar"> <p><input type="submit" name="submit" value="submit answers"></p> </form> +<HR> +<h3> Warning section </h3> +$warnings +<h3> +Debug message section +</h3> +$debug_messages +<h3> +internal errors +</h3> +$internal_debug_messages + </body> </html> |
From: Mike G. v. a. <we...@ma...> - 2010-06-04 00:40:00
|
Log Message: ----------- refactored pretty_print so that it is only defined in PGcore removed some unused hash entries in PGcore Modified Files: -------------- pg/lib: AnswerHash.pm PGcore.pm PGresponsegroup.pm Revision Data ------------- Index: AnswerHash.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/AnswerHash.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -Llib/AnswerHash.pm -Llib/AnswerHash.pm -u -r1.17 -r1.18 --- lib/AnswerHash.pm +++ lib/AnswerHash.pm @@ -120,6 +120,9 @@ } package AnswerHash; +use Exporter; +use PGcore qw(not_null pretty_print); + # initialization fields my %fields = ( 'score' => undef, 'correct_ans' => undef, @@ -339,39 +342,38 @@ =cut - -sub pretty_print { - my $r_input = shift; - my $level = shift; - $level = 4 unless defined($level); - $level--; - return '' unless $level > 0; # only print three levels of hashes (safety feature) - my $out = ''; - if ( not ref($r_input) ) { - $out = $r_input; # not a reference - $out =~ s/</</g; # protect for HTML output - } elsif (ref($r_input) =~/hash/i) { - local($^W) = 0; - $out .= "<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">"; - foreach my $key (sort keys %$r_input ) { - $out .= "<tr><TD> $key</TD><TD>=></td><td> ".pretty_print($r_input->{$key}, $level) . "</td></tr>"; - } - $out .="</table>"; - } elsif (ref($r_input) eq 'ARRAY' ) { - my @array = @$r_input; - $out .= "( " ; - while (@array) { - $out .= pretty_print(shift @array, $level) . " , "; - } - $out .= " )"; - } elsif (ref($r_input) eq 'CODE') { - $out = "$r_input"; - } else { - $out = $r_input; - $out =~ s/</</g; # protect for HTML output - } - $out; -} +# sub pretty_print { +# my $r_input = shift; +# my $level = shift; +# $level = 4 unless defined($level); +# $level--; +# return '' unless $level > 0; # only print three levels of hashes (safety feature) +# my $out = ''; +# if ( not ref($r_input) ) { +# $out = $r_input; # not a reference +# $out =~ s/</</g; # protect for HTML output +# } elsif (ref($r_input) =~/hash/i) { +# local($^W) = 0; +# $out .= "<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">"; +# foreach my $key (sort keys %$r_input ) { +# $out .= "<tr><TD> $key</TD><TD>=></td><td> ".pretty_print($r_input->{$key}, $level) . "</td></tr>"; +# } +# $out .="</table>"; +# } elsif (ref($r_input) eq 'ARRAY' ) { +# my @array = @$r_input; +# $out .= "( " ; +# while (@array) { +# $out .= pretty_print(shift @array, $level) . " , "; +# } +# $out .= " )"; +# } elsif (ref($r_input) eq 'CODE') { +# $out = "$r_input"; +# } else { +# $out = $r_input; +# $out =~ s/</</g; # protect for HTML output +# } +# $out; +# } # action methods @@ -448,7 +450,8 @@ package AnswerEvaluator; - +use Exporter; +use PGcore qw(not_null pretty_print); =head3 AnswerEvaluator Methods Index: PGcore.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGcore.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -Llib/PGcore.pm -Llib/PGcore.pm -u -r1.7 -r1.8 --- lib/PGcore.pm +++ lib/PGcore.pm @@ -18,7 +18,7 @@ use strict; BEGIN { use Exporter 'import'; - our @EXPORT_OK = qw(not_null); + our @EXPORT_OK = qw(not_null pretty_print); } our $internal_debug_messages = []; @@ -57,6 +57,41 @@ } } +sub pretty_print { # provides html output -- NOT a method + my $r_input = shift; + my $level = shift; + $level = 4 unless defined($level); + $level--; + return '' unless $level > 0; # only print three levels of hashes (safety feature) + my $out = ''; + if ( not ref($r_input) ) { + $out = $r_input if defined $r_input; # not a reference + $out =~ s/</</g ; # protect for HTML output + } elsif ("$r_input" =~/hash/i) { # this will pick up objects whose '$self' is hash and so works better than ref($r_iput). + local($^W) = 0; + + $out .= "$r_input " ."<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">"; + + + foreach my $key ( sort ( keys %$r_input )) { + $out .= "<tr><TD> $key</TD><TD>=></td><td> ".pretty_print($r_input->{$key}) . "</td></tr>"; + } + $out .="</table>"; + } elsif (ref($r_input) eq 'ARRAY' ) { + my @array = @$r_input; + $out .= "( " ; + while (@array) { + $out .= pretty_print(shift @array, $level) . " , "; + } + $out .= " )"; + } elsif (ref($r_input) eq 'CODE') { + $out = "$r_input"; + } else { + $out = $r_input; + $out =~ s/</</g; # protect for HTML output + } + $out; +} ################################## # PGcore object ################################## @@ -70,11 +105,10 @@ my $self = { OUTPUT_ARRAY => [], # holds output body text HEADER_ARRAY => [], # holds output for the header text -# PG_ANSWERS => [], # holds answers with labels -# PG_UNLABELED_ANSWERS => [], # holds +# PG_ANSWERS => [], # holds answers with labels # deprecated +# PG_UNLABELED_ANSWERS => [], # holds unlabeled ans. #deprecated -replaced by PG_ANSWERS_HASH PG_ANSWERS_HASH => {}, # holds label=>answer pairs PERSISTENCE_HASH => {}, # holds other data, besides answers, which persists during a session and beyond -# PG_persistence_hash => {}, # stores information (other than answers) from one session to another answer_eval_count => 0, answer_blank_count => 0, unlabeled_answer_blank_count =>0, @@ -86,7 +120,7 @@ QUIZ_PREFIX => $envir->{QUIZ_PREFIX}, SECTION_PREFIX => '', # might be used for sequential (compound) questions? - PG_ACTIVE => 1, # turn to zero to stop processing + PG_ACTIVE => 1, # toggle to zero to stop processing submittedAnswers => 0, # have any answers been submitted? is this the first time this session? PG_session_persistence_hash =>{}, # stores data from one invoction of the session to the next. PG_original_problem_seed => 0, @@ -404,7 +438,7 @@ my $self = shift; my $label = shift; my $value = shift; - $self->internal_debug_message("record_ans_name $label $value"); + #$self->internal_debug_message("PGcore::record_ans_name: $label $value"); my $response_group = new PGresponsegroup($label,$label,$value); if (defined($self->{PG_ANSWERS_HASH}->{$label}) ) { $self->{PG_ANSWERS_HASH}->{$label}->replace(ans_label => $label, @@ -468,7 +502,7 @@ my $self = shift; my $label = shift; my @content = @_; - $self->internal_debug_message("storing $label in PERSISTENCE_HASH"); + $self->internal_debug_message("PGcore::store_persistent_data: storing $label in PERSISTENCE_HASH"); if (defined($self->{PERSISTENCE_HASH}->{$label}) ) { warn "can' overwrite $label in persistent data"; } else { @@ -512,15 +546,32 @@ # } # } -sub append_debug_message { + + +sub debug_message { my $self = shift; my @str = @_; - push @{$self->{DEBUG_messages}}, @str; + push @{$self->{flags}->{DEBUG_messages}}, @str; } sub get_debug_messages { my $self = shift; - $self->{DEBUG_messages}; + $self->{flags}->{DEBUG_messages}; +} + +sub internal_debug_message { + my $self = shift; + my @str = @_; + push @{$internal_debug_messages}, @str; +} +sub get_internal_debug_messages { + my $self = shift; + $internal_debug_messages; } +sub clear_internal_debug_messages { + my $self = shift; + $internal_debug_messages=[]; +} + sub DESTROY { # doing nothing about destruction, hope that isn't dangerous } @@ -713,18 +764,5 @@ return $path; } -sub internal_debug_message { - my $self = shift; - my @str = @_; - push @{$internal_debug_messages}, @str; -} -sub get_internal_debug_messages { - my $self = shift; - $internal_debug_messages; -} -sub clear_internal_debug_messages { - my $self = shift; - $internal_debug_messages=[]; -} 1; \ No newline at end of file Index: PGresponsegroup.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGresponsegroup.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -Llib/PGresponsegroup.pm -Llib/PGresponsegroup.pm -u -r1.3 -r1.4 --- lib/PGresponsegroup.pm +++ lib/PGresponsegroup.pm @@ -73,10 +73,10 @@ push @{ $self->{response_order}} , $response_label; $self->{responses}->{$response_label} = $response_value; } else { - $self->internal_debug_message( "PGresponsegroup error: there is already an answer labeled $response_label", caller(2),"\n"); + $self->internal_debug_message( "PGresponsegroup::append_response error: there is already an answer labeled $response_label", caller(2),"\n"); } } else { - $self->internal_debug_message( "error undefined or empty response label"); + $self->internal_debug_message( "PGresponsegroup::append_response error: undefined or empty response label"); } #warn "\n content of responses is ",join(' ',%{$self->{responses}}); } @@ -128,7 +128,7 @@ my $response_value = $self->{responses}->{$response_label}; !defined($response_value) && do{ $response_value = {} }; ref($response_value) !~/HASH/ && do{ - $self->internal_debug_message("error in storing hash ", ref($response_value),$response_value); + $self->internal_debug_message("PGresponsegroup::extend_response: error in storing hash ", ref($response_value),$response_value); $response_value = {$response_value=>$selected}; }; #should not happen this means that a non-hash entry was made into this response label @@ -139,7 +139,7 @@ # a hash of key/value pairs -- the key labels the radio button or checkbox, # the value whether it is selected } else { - $self->internal_debug_message("response label |$response_label| not defined") ; + $self->internal_debug_message("PGresponsegroup::extend_response: response label |$response_label| not defined") ; return undef; } |
From: Mike G. v. a. <we...@ma...> - 2010-06-04 00:39:58
|
Log Message: ----------- refactoring pretty_print some other minor changes Modified Files: -------------- pg/macros: PG.pl PGanswermacros.pl Revision Data ------------- Index: PG.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PG.pl,v retrieving revision 1.47 retrieving revision 1.48 diff -Lmacros/PG.pl -Lmacros/PG.pl -u -r1.47 -r1.48 --- macros/PG.pl +++ macros/PG.pl @@ -13,14 +13,15 @@ } sub not_null {PGcore::not_null(@_)}; +sub pretty_print {PGcore::pretty_print(@_)}; our $PG; sub DEBUG_MESSAGE { - $PG->append_debug_message(@_); + my @msg = @_; + $PG->debug_message(@msg); } - sub DOCUMENT { # get environment @@ -29,7 +30,6 @@ $PG = new PGcore($rh_envir, # can add key/value options to modify ); $PG->clear_internal_debug_messages; - # initialize main:: variables $ANSWER_PREFIX = $PG->{ANSWER_PREFIX}; @@ -128,7 +128,6 @@ sub inc_ans_rule_count { #$PG->{unlabeled_answer_blank_count}++; #my $num = $PG->{unlabeled_answer_blank_count}; - DEBUG_MESSAGE( " using PG to inc_ans_rule_count = $num ", caller(2)); warn " using PG to inc_ans_rule_count = $num ", caller(2); $PG->{unlabeled_answer_blank_count}; } Index: PGanswermacros.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGanswermacros.pl,v retrieving revision 1.73 retrieving revision 1.74 diff -Lmacros/PGanswermacros.pl -Lmacros/PGanswermacros.pl -u -r1.73 -r1.74 --- macros/PGanswermacros.pl +++ macros/PGanswermacros.pl @@ -1777,39 +1777,39 @@ # ^function pretty_print # ^uses lex_sort # ^uses pretty_print -sub pretty_print { - my $r_input = shift; - my $out = ''; - if ( not ref($r_input) ) { - $out = $r_input if defined $r_input; # not a reference - $out =~ s/</</g ; # protect for HTML output - } elsif ("$r_input" =~/hash/i) { # this will pick up objects whose '$self' is hash and so works better than ref($r_iput). - local($^W) = 0; - - $out .= "$r_input " ."<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">"; - - - foreach my $key (lex_sort( keys %$r_input )) { - $out .= "<tr><TD> $key</TD><TD>=></td><td> ".pretty_print($r_input->{$key}) . "</td></tr>"; - } - - - - $out .="</table>"; - } elsif (ref($r_input) eq 'ARRAY' ) { - my @array = @$r_input; - $out .= "( " ; - while (@array) { - $out .= pretty_print(shift @array) . " , "; - } - $out .= " )"; - } elsif (ref($r_input) eq 'CODE') { - $out = "$r_input"; - } else { - $out = $r_input; - $out =~ s/</</g ; # protect for HTML output - } - $out; -} +# sub pretty_print { +# my $r_input = shift; +# my $out = ''; +# if ( not ref($r_input) ) { +# $out = $r_input if defined $r_input; # not a reference +# $out =~ s/</</g ; # protect for HTML output +# } elsif ("$r_input" =~/hash/i) { # this will pick up objects whose '$self' is hash and so works better than ref($r_iput). +# local($^W) = 0; +# +# $out .= "$r_input " ."<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">"; +# +# +# foreach my $key (lex_sort( keys %$r_input )) { +# $out .= "<tr><TD> $key</TD><TD>=></td><td> ".pretty_print($r_input->{$key}) . "</td></tr>"; +# } +# +# +# +# $out .="</table>"; +# } elsif (ref($r_input) eq 'ARRAY' ) { +# my @array = @$r_input; +# $out .= "( " ; +# while (@array) { +# $out .= pretty_print(shift @array) . " , "; +# } +# $out .= " )"; +# } elsif (ref($r_input) eq 'CODE') { +# $out = "$r_input"; +# } else { +# $out = $r_input; +# $out =~ s/</</g ; # protect for HTML output +# } +# $out; +# } 1; |
From: Mike G. v. a. <we...@ma...> - 2010-06-04 00:39:57
|
Log Message: ----------- Adjusted warnings handle PGcore object Modified Files: -------------- webwork2/lib/WeBWorK/PG: Local.pm Revision Data ------------- Index: Local.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/PG/Local.pm,v retrieving revision 1.29 retrieving revision 1.30 diff -Llib/WeBWorK/PG/Local.pm -Llib/WeBWorK/PG/Local.pm -u -r1.29 -r1.30 --- lib/WeBWorK/PG/Local.pm +++ lib/WeBWorK/PG/Local.pm @@ -97,8 +97,8 @@ # install a local warn handler to collect warnings my $warnings = ""; - local $SIG{__WARN__} = sub { $warnings .= shift } - if $ce->{pg}->{options}->{catchWarnings}; + local $SIG{__WARN__} = sub { $warnings .= shift }; + #if $ce->{pg}->{options}->{catchWarnings}; # create a Translator #warn "PG: creating a Translator\n"; @@ -326,8 +326,9 @@ result => {}, state => {}, errors => "Failed to read the problem source file.", - warnings => $warnings, + warnings => "$warnings", flags => {error_flag => 1}, + pgcore => $translator->{rh_pgcore}, }, $class; } @@ -435,6 +436,7 @@ errors => $translator->errors, warnings => $warnings, flags => $translator->rh_flags, + pgcore => $translator->{rh_pgcore}, }, $class; } |
From: Mike G. v. a. <we...@ma...> - 2010-06-04 00:29:29
|
Log Message: ----------- handled renaming of the hash keys in PGcore Modified Files: -------------- webwork2/lib/WebworkWebservice: RenderProblem.pm Revision Data ------------- Index: RenderProblem.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WebworkWebservice/RenderProblem.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -Llib/WebworkWebservice/RenderProblem.pm -Llib/WebworkWebservice/RenderProblem.pm -u -r1.9 -r1.10 --- lib/WebworkWebservice/RenderProblem.pm +++ lib/WebworkWebservice/RenderProblem.pm @@ -212,7 +212,7 @@ my $problemValue = (defined($rh->{envir}->{problemValue})) ? $rh->{envir}->{problemValue} : 1 ; my $num_correct = $rh->{problem_state}->{num_correct} || 0 ; my $num_incorrect = $rh->{problem_state}->{num_incorrect} || 0 ; - my $problemAttempted = ($num_correct && $num_incorrect); + my $problemAttempted = ($num_correct || $num_incorrect); my $lastAnswer = ''; my $setRecord = $db->getMergedSet($effectiveUserName, $setName); @@ -291,10 +291,12 @@ showSolutions => $rh->{envir}->{showSolutions}, refreshMath2img => $rh->{envir}->{showHints} || $rh->{envir}->{showSolutions}, processAnswers => 1, + catchWarnings => 1, # methods for supplying the source, r_source => $r_problem_source, # reference to a source file string. # if reference is not defined then the path is obtained # from the problem object. + permissionLevel => 10, # $rh->{envir}->{permissionLevel}; r_envirOverrides => $rh, }; @@ -355,11 +357,13 @@ header_text => encode_base64( $pg->{head_text} ), answers => $pg->{answers}, errors => $pg->{errors}, - WARNINGS => encode_base64($pg->{warnings} ), + WARNINGS => encode_base64( $pg->{warnings} ), problem_result => $pg->{result}, problem_state => $pg->{state}, - PG_flag => $pg->{flags}, + flags => $pg->{flags}, + internal_debug_messages => $pg->{pgcore}->get_internal_debug_messages, }; + # Filter out bad reference types ################### # DEBUGGING CODE @@ -377,7 +381,7 @@ close(DEBUGCODE) if $debugXmlCode; ################### - $out2->{PG_flag}->{PROBLEM_GRADER_TO_USE} = undef; + $out2->{flags}->{PROBLEM_GRADER_TO_USE} = undef; my $endTime = new Benchmark; $out2->{compute_time} = logTimingInfo($beginTime, $endTime); # warn "flags are" , WebworkWebservice::pretty_print_rh($pg->{flags}); |
From: Mike G. v. a. <we...@ma...> - 2010-06-04 00:28:00
|
Log Message: ----------- change how permissionLevel is defined Modified Files: -------------- pg/macros: PGbasicmacros.pl Revision Data ------------- Index: PGbasicmacros.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGbasicmacros.pl,v retrieving revision 1.67 retrieving revision 1.68 diff -Lmacros/PGbasicmacros.pl -Lmacros/PGbasicmacros.pl -u -r1.67 -r1.68 --- macros/PGbasicmacros.pl +++ macros/PGbasicmacros.pl @@ -333,7 +333,7 @@ $answer_value =~ tr/\\$@`//d; ## make sure student answers can not be interpolated by e.g. EV3 $answer_value =~ s/\s+/ /g; ## remove excessive whitespace from student answer - DEBUG_MESSAGE( "RECORD_ANS_NAME($name, $answer_value)"); + $name = RECORD_ANS_NAME($name, $answer_value); #INSERT_RESPONSE($name,$name,$answer_value); #FIXME -- why can't we do this inside RECORD_ANS_NAME? @@ -1050,9 +1050,9 @@ sub hint { my @in = @_; my $out = ''; - my $permissionLevel = PG_restricted_eval(q!$main::envir{permissionLevel}!); #user permission level - my $PRINT_FILE_NAMES_PERMISSION_LEVEL = (PG_restricted_eval(q!defined( $main::envir{'PRINT_FILE_NAMES_PERMISSION_LEVEL'} )!))? - PG_restricted_eval(q!$main::envir{'PRINT_FILE_NAMES_PERMISSION_LEVEL'}!) : 10000; # protect against undefined values + my $permissionLevel = $envir->{permissionLevel}; #PG_restricted_eval(q!$main::envir{permissionLevel}!); #user permission level + # protect against undefined values + my $PRINT_FILE_NAMES_PERMISSION_LEVEL = ( defined( $envir->{'PRINT_FILE_NAMES_PERMISSION_LEVEL'} ) ) ? $envir->{'PRINT_FILE_NAMES_PERMISSION_LEVEL'} : 10000; my $printHintForInstructor = $permissionLevel >= $PRINT_FILE_NAMES_PERMISSION_LEVEL; my $showHint = PG_restricted_eval(q!$main::showHint!); my $displayHint = PG_restricted_eval(q!$main::envir{'displayHintsQ'}!); |
From: Mike G. v. a. <we...@ma...> - 2010-06-04 00:25:45
|
Log Message: ----------- Fixed propagation of PGcore object to Local.pm Modified Files: -------------- pg/lib/WeBWorK/PG: Translator.pm Revision Data ------------- Index: Translator.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/WeBWorK/PG/Translator.pm,v retrieving revision 1.27 retrieving revision 1.28 diff -Llib/WeBWorK/PG/Translator.pm -Llib/WeBWorK/PG/Translator.pm -u -r1.27 -r1.28 --- lib/WeBWorK/PG/Translator.pm +++ lib/WeBWorK/PG/Translator.pm @@ -943,7 +943,7 @@ =cut - my ($PG_PROBLEM_TEXT_REF, $PG_HEADER_TEXT_REF, $PG_ANSWER_HASH_REF, $PG_FLAGS_REF) + my ($PG_PROBLEM_TEXT_REF, $PG_HEADER_TEXT_REF, $PG_ANSWER_HASH_REF, $PG_FLAGS_REF, $PGcore) =$safe_cmpt->reval(" $evalString"); #warn "using safe compartment ", $safe_cmpt->root; # This section could use some more error messages. In particular if a problem doesn't produce the right output, the user needs @@ -1033,6 +1033,7 @@ $PG_ANSWER_HASH_REF -- Reference to an array containing the answer evaluators. $PG_FLAGS_REF -- Reference to a hash containing flags and other references: 'error_flag' is set to 1 if there were errors in rendering + $PGcore -- the PGcore object =cut @@ -1051,7 +1052,10 @@ $self ->{ PG_HEADER_TEXT_REF } = $PG_HEADER_TEXT_REF; $self ->{ rh_correct_answers } = $PG_ANSWER_HASH_REF; $self ->{ PG_FLAGS_REF } = $PG_FLAGS_REF; - $self ->{errors}; + $self ->{ rh_pgcore } = $PGcore; + + #warn "PGcore is ", ref($PGcore), " in Translator"; + #$self ->{errors}; } # end translate |
From: dpvc v. a. <we...@ma...> - 2010-06-03 21:02:00
|
Log Message: ----------- Fix problem with negating mixed numbers Modified Files: -------------- pg/macros: contextFraction.pl Revision Data ------------- Index: contextFraction.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextFraction.pl,v retrieving revision 1.13 retrieving revision 1.14 diff -Lmacros/contextFraction.pl -Lmacros/contextFraction.pl -u -r1.13 -r1.14 --- macros/contextFraction.pl +++ macros/contextFraction.pl @@ -441,7 +441,7 @@ if ($isFraction) { $self->Error("Mixed numbers are not allowed; you must use a pure fraction") if ($self->context->flag("requirePureFractions")); - $self->{bop} = " "; + $self->{isFraction} = 1; $self->{bop} = " "; $self->{def} = $self->context->{operators}{$self->{bop}}; if ($self->{lop}->class eq 'MINUS') { # @@ -463,6 +463,15 @@ } # +# Indicate if the value is a fraction or not +# +sub class { + my $self = shift; + return "FRACTION" if $self->{isFraction}; + return $self->SUPER::class; +} + +# # Reduce the fraction # sub reduce { |
From: Mike G. v. a. <we...@ma...> - 2010-05-31 23:46:24
|
Log Message: ----------- attempted fix for finding applets automatically. Modified Files: -------------- pg/lib: PGalias.pm Revision Data ------------- Index: PGalias.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGalias.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -Llib/PGalias.pm -Llib/PGalias.pm -u -r1.6 -r1.7 --- lib/PGalias.pm +++ lib/PGalias.pm @@ -111,6 +111,8 @@ $self->{displayMode} = $envir->{displayMode}; $self->{externalGif2EpsPath} = $envir->{externalGif2EpsPath}; $self->{externalPng2EpsPath} = $envir->{externalPng2EpsPath}; + + $self->{appletPath} = $self->{envir}->{pgDirectories}->{appletPath}; # # Find auxiliary files even when the main file is in tempates/tmpEdit # @@ -757,22 +759,23 @@ sub findAppletCodebase { my $self = shift; my $fileName = shift; # probably the name of a jar file - return $appletCodebaseLocations{$fileName} #check cache first + #check cache first + return $appletCodebaseLocations{$fileName} if defined($appletCodebaseLocations{$fileName}) and $appletCodebaseLocations{$fileName} =~/\S/; - + my $appletPath = $self->{appletPath}; foreach my $appletLocation (@{$appletPath}) { if ($appletLocation =~ m|^/|) { $appletLocation = "$server_root_url$appletLocation"; } return $appletLocation; # --hack workaround -- just pick the first location and use that -- no checks -#hack to workaround conflict between lwp-request and apache2 +# hack to workaround conflict between lwp-request and apache2 # comment out the check_url block -# my $url = "$appletLocation/$fileName"; -# if ($self->check_url($url)) { -# $appletCodebaseLocations{$fileName} = $appletLocation; #update cache -# return $appletLocation # return codebase part of url -# } + my $url = "$appletLocation/$fileName"; + if ($self->check_url($url)) { + $appletCodebaseLocations{$fileName} = $appletLocation; #update cache + return $appletLocation # return codebase part of url + } } return "Error: $fileName not found at ". join(", ", @{$appletPath} ); # no file found } |
From: Mike G. v. a. <we...@ma...> - 2010-05-31 19:05:50
|
Log Message: ----------- brings the pg copy in line with the copy in NPL/macros/Union Modified Files: -------------- pg/macros: LiveGraphics3D.pl Revision Data ------------- Index: LiveGraphics3D.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/LiveGraphics3D.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -Lmacros/LiveGraphics3D.pl -Lmacros/LiveGraphics3D.pl -u -r1.2 -r1.3 --- macros/LiveGraphics3D.pl +++ macros/LiveGraphics3D.pl @@ -65,7 +65,9 @@ sub LiveGraphics3D { my %options = ( size => [250,250], - jar => findAppletCodebase("live.jar")."/live.jar", + jar => "live.jar", # "${htmlURL}live.jar", + codebase => findAppletCodebase("live.jar"), + # codebase => "http://hosted2.webwork.rochester.edu/webwork2_files/applets/", # used for testing background => "#FFFFFF", scale => 1., tex_size => 500, @@ -103,7 +105,7 @@ # start the applet # $out .= qq{ - <APPLET ARCHIVE="$options{jar}" CODE="Live.class" WIDTH="$w" HEIGHT="$h"> + <APPLET CODEBASE="$options{codebase}" ARCHIVE="$options{jar}" CODE="Live.class" WIDTH="$w" HEIGHT="$h"> <PARAM NAME="BGCOLOR" VALUE="$options{background}"> <PARAM NAME="MAGNIFICATION" VALUE="$options{scale}"> }; |
From: Gavin L. v. a. <we...@ma...> - 2010-05-31 16:12:05
|
Log Message: ----------- Relax error checking on user_id. This allows user_id values to look like set-level proctor ids (that is, to prepend set_id: and append ,g), which isn't what we want for the user_id check in most cases, but shouldn't be a significant difficulty. The ideal is to know something about the set for which we're checking the id, but that requires sending more information into DB than we're sending now. Modified Files: -------------- webwork2/lib/WeBWorK: DB.pm Revision Data ------------- Index: DB.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/DB.pm,v retrieving revision 1.111 retrieving revision 1.112 diff -Llib/WeBWorK/DB.pm -Llib/WeBWorK/DB.pm -u -r1.111 -r1.112 --- lib/WeBWorK/DB.pm +++ lib/WeBWorK/DB.pm @@ -1784,10 +1784,6 @@ sub countProblemVersions { return scalar shift->listProblemVersions(@_) } # versioned analog of listUserProblems -# for consistency, we should name this "listProblemVersions", but that is -# confusing, as that sounds as if we're listing the versions of a problem. -# however, that's nonsensical, so we appropriate it here and don't worry -# about the confusion. sub listProblemVersions { my ($self, $userID, $setID, $versionID) = shift->checkArgs(\@_, qw/user_id set_id version_id/); my $where = [user_id_eq_set_id_eq_version_id_eq => $userID,$setID,$versionID]; @@ -1945,7 +1941,8 @@ } elsif ($versioned and $keyfield eq "set_id") { croak "invalid characters in '$keyfield' field: '$value' (valid characters are [-a-zA-Z0-9_.,])" unless $value =~ m/^[-a-zA-Z0-9_.,]*$/; - } elsif ($versioned and $keyfield eq "user_id") { + # } elsif ($versioned and $keyfield eq "user_id") { + } elsif ($keyfield eq "user_id") { check_user_id($value); # (valid characters are [-a-zA-Z0-9_.,]) see above. } elsif ($keyfield eq "ip_mask") { croak "invalid characters in '$keyfield' field: '$value' (valid characters are [-a-fA-F0-9_.:/])" |
From: Gavin L. v. a. <we...@ma...> - 2010-05-31 15:59:42
|
Log Message: ----------- Back out previous commit; the semicolon flags a field that's set in tandem with another. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator/Instructor: ProblemSetDetail.pm Revision Data ------------- Index: ProblemSetDetail.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm,v retrieving revision 1.81 retrieving revision 1.82 diff -Llib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm -Llib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm -u -r1.81 -r1.82 --- lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm +++ lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm @@ -38,7 +38,7 @@ # but they are functionally and semantically different # these constants determine which fields belong to what type of record -use constant SET_FIELDS => [qw(set_header hardcopy_header open_date due_date answer_date published enable_reduced_scoring restrict_ip relax_restrict_ip assignment_type attempts_per_version version_time_limit time_limit_cap versions_per_interval time_interval problem_randorder problems_per_page hide_score hide_score_by_problem hide_work)]; +use constant SET_FIELDS => [qw(set_header hardcopy_header open_date due_date answer_date published enable_reduced_scoring restrict_ip relax_restrict_ip assignment_type attempts_per_version version_time_limit time_limit_cap versions_per_interval time_interval problem_randorder problems_per_page hide_score:hide_score_by_problem hide_work)]; use constant PROBLEM_FIELDS =>[qw(source_file value max_attempts)]; use constant USER_PROBLEM_FIELDS => [qw(problem_seed status num_correct num_incorrect)]; @@ -1557,7 +1557,6 @@ my $forOneUser = $forUsers == 1; my $howManyCan = $properties{$field}->{override}; - return 0 if $howManyCan eq "none"; return 1 if $howManyCan eq "any"; return 1 if $howManyCan eq "one" && $forOneUser; |
From: Gavin L. v. a. <we...@ma...> - 2010-05-31 14:50:29
|
Log Message: ----------- Correct typo in set fields. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator/Instructor: ProblemSetDetail.pm Revision Data ------------- Index: ProblemSetDetail.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm,v retrieving revision 1.80 retrieving revision 1.81 diff -Llib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm -Llib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm -u -r1.80 -r1.81 --- lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm +++ lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm @@ -38,7 +38,7 @@ # but they are functionally and semantically different # these constants determine which fields belong to what type of record -use constant SET_FIELDS => [qw(set_header hardcopy_header open_date due_date answer_date published enable_reduced_scoring restrict_ip relax_restrict_ip assignment_type attempts_per_version version_time_limit time_limit_cap versions_per_interval time_interval problem_randorder problems_per_page hide_score:hide_score_by_problem hide_work)]; +use constant SET_FIELDS => [qw(set_header hardcopy_header open_date due_date answer_date published enable_reduced_scoring restrict_ip relax_restrict_ip assignment_type attempts_per_version version_time_limit time_limit_cap versions_per_interval time_interval problem_randorder problems_per_page hide_score hide_score_by_problem hide_work)]; use constant PROBLEM_FIELDS =>[qw(source_file value max_attempts)]; use constant USER_PROBLEM_FIELDS => [qw(problem_seed status num_correct num_incorrect)]; |
From: Mike G. v. a. <we...@ma...> - 2010-05-29 13:07:25
|
Log Message: ----------- check that a tex output actually exists before typesetting the correct answer. This effort is still a hack. Problem.pm needs to be written from the ground up. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: Problem.pm Revision Data ------------- Index: Problem.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm,v retrieving revision 1.225 retrieving revision 1.226 diff -Llib/WeBWorK/ContentGenerator/Problem.pm -Llib/WeBWorK/ContentGenerator/Problem.pm -u -r1.225 -r1.226 --- lib/WeBWorK/ContentGenerator/Problem.pm +++ lib/WeBWorK/ContentGenerator/Problem.pm @@ -384,6 +384,8 @@ # so we'll just deal with each case explicitly here. there's some code # duplication that can be dealt with later by abstracting out tth/dvipng/etc. + return "" unless defined( $answerResult->{correct_value} ) and ref( $answerResult->{correct_value} ); + my $tex = $answerResult->{correct_value}->TeX; return "" unless defined $tex and $tex ne ""; |
From: Mike G. v. a. <we...@ma...> - 2010-05-28 21:53:51
|
Log Message: ----------- added tooltip for the answer preview -- this shows the actual entry -- with this we could get rid of the first "parsed" entry in each row, saving some space. Something similar (but more complicated) would give us a tooltip showing the typeset version of the correct answer. (We want the untypeset version to be available for cutting and pasting when instructors are checking problems for correctness so the method ("title" attribute) used for the answer preview won't work. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: Problem.pm Revision Data ------------- Index: Problem.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm,v retrieving revision 1.224 retrieving revision 1.225 diff -Llib/WeBWorK/ContentGenerator/Problem.pm -Llib/WeBWorK/ContentGenerator/Problem.pm -u -r1.224 -r1.225 --- lib/WeBWorK/ContentGenerator/Problem.pm +++ lib/WeBWorK/ContentGenerator/Problem.pm @@ -242,6 +242,7 @@ my $preview = ($showAttemptPreview ? $self->previewAnswer($answerResult, $imgGen, \$tthPreambleCache) : ""); + my $correctAnswerPreview = $self->previewCorrectAnswer($answerResult, $imgGen, \$tthPreambleCache); my $correctAnswer = $answerResult->{correct_ans}; my $answerScore = $answerResult->{score}; my $answerMessage = $showMessages ? $answerResult->{ans_message} : ""; @@ -260,8 +261,8 @@ my $row; #$row .= CGI::td($name); $row .= $showAttemptAnswers ? CGI::td($self->nbsp($studentAnswer)) : ""; - $row .= $showAttemptPreview ? CGI::td($self->nbsp($preview)) : ""; - $row .= $showCorrectAnswers ? CGI::td($self->nbsp($correctAnswer)) : ""; + $row .= $showAttemptPreview ? CGI::td({title=>"$studentAnswer"}, $self->nbsp($preview)) : ""; + $row .= $showCorrectAnswers ? CGI::td({title=> "$correctAnswerPreview"}, $self->nbsp($correctAnswer)) : ""; $row .= $showAttemptResults ? CGI::td($self->nbsp($resultString)) : ""; $row .= $showMessages ? CGI::td({-class=>"Message"},$self->nbsp($answerMessage)) : ""; push @tableRows, $row; @@ -370,6 +371,70 @@ return '<SPAN CLASS="math">\\displaystyle{'.$tex.'}</SPAN>'; } } +sub previewCorrectAnswer { + my ($self, $answerResult, $imgGen, $tthPreambleCache) = @_; + my $ce = $self->r->ce; + my $effectiveUser = $self->{effectiveUser}; + my $set = $self->{set}; + my $problem = $self->{problem}; + my $displayMode = $self->{displayMode}; + + # note: right now, we have to do things completely differently when we are + # rendering math from INSIDE the translator and from OUTSIDE the translator. + # so we'll just deal with each case explicitly here. there's some code + # duplication that can be dealt with later by abstracting out tth/dvipng/etc. + + my $tex = $answerResult->{correct_value}->TeX; + + return "" unless defined $tex and $tex ne ""; + + if ($displayMode eq "plainText") { + return $tex; + } elsif ($displayMode eq "formattedText") { + + # read the TTH preamble, or use the cached copy passed in from the caller + my $tthPreamble=''; + if (defined $$tthPreambleCache) { + $tthPreamble = $$tthPreambleCache; + } else { + my $tthPreambleFile = $ce->{courseDirs}->{templates} . "/tthPreamble.tex"; + if (-r $tthPreambleFile) { + $tthPreamble = readFile($tthPreambleFile); + # thanks to Jim Martino. each line in the definition file should end with + #a % to prevent adding supurious paragraphs to output: + $tthPreamble =~ s/(.)\n/$1%\n/g; + # solves the problem if the file doesn't end with a return: + $tthPreamble .="%\n"; + # store preamble in cache: + $$tthPreambleCache = $tthPreamble; + } else { + } + } + + # construct TTH command line + my $tthCommand = $ce->{externalPrograms}->{tth} + . " -L -f5 -u -r 2> /dev/null <<END_OF_INPUT; echo > /dev/null\n" + . $tthPreamble . "\\[" . $tex . "\\]\n" + . "END_OF_INPUT\n"; + + # call tth + my $result = `$tthCommand`; + if ($?) { + return "<b>[tth failed: $? $@]</b>"; + } else { + # avoid border problems in tables and remove unneeded initial <br> + $result =~ s/(<table [^>]*)>/$1 CLASS="ArrayLayout">/gi; + $result =~ s!\s*<br clear="all" />!!; + return $result; + } + + } elsif ($displayMode eq "images") { + $imgGen->add($tex); + } elsif ($displayMode eq "jsMath") { + $tex =~ s/</</g; $tex =~ s/>/>/g; + return '<SPAN CLASS="math">\\displaystyle{'.$tex.'}</SPAN>'; + } +} ################################################################################ # Template escape implementations |
From: Mike G. v. a. <we...@ma...> - 2010-05-28 21:49:47
|
Log Message: ----------- Updating required modules. Modified Files: -------------- webwork2/bin: check_modules.pl Revision Data ------------- Index: check_modules.pl =================================================================== RCS file: /webwork/cvs/system/webwork2/bin/check_modules.pl,v retrieving revision 1.19 retrieving revision 1.20 diff -Lbin/check_modules.pl -Lbin/check_modules.pl -u -r1.19 -r1.20 --- bin/check_modules.pl +++ bin/check_modules.pl @@ -70,6 +70,7 @@ Net::LDAPS Net::SMTP Opcode + PadWalker PHP::Serialization Pod::Usage Pod::WSDL |
From: Gavin L. v. a. <we...@ma...> - 2010-05-27 14:26:20
|
Log Message: ----------- Correct logical bug in GatewayQuiz module that didn't honor time_limit_cap, gracefully deal with null values of problem_value in the database (which occurs when creating a set from the Library Browser), round reported allowed time (which may be useful when time_limit_cap is specified). Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: GatewayQuiz.pm ProblemSets.pm Revision Data ------------- Index: GatewayQuiz.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm,v retrieving revision 1.54 retrieving revision 1.55 diff -Llib/WeBWorK/ContentGenerator/GatewayQuiz.pm -Llib/WeBWorK/ContentGenerator/GatewayQuiz.pm -u -r1.54 -r1.55 --- lib/WeBWorK/ContentGenerator/GatewayQuiz.pm +++ lib/WeBWorK/ContentGenerator/GatewayQuiz.pm @@ -829,9 +829,13 @@ $set->due_date(); $set->version_creation_time( $timeNow ); $set->open_date( $timeNow ); - $set->due_date( $timeNow+$timeLimit ) - if (! $set->time_limit_cap || - $timeNow+$timeLimit<$set->due_date); + # figure out the due date, taking into account + # any time limit cap + my $dueTime = + ( $set->time_limit_cap && + $timeNow+$timeLimit > $set->due_date ) ? + $set->due_date : $timeNow+$timeLimit; + $set->due_date( $dueTime ); $set->answer_date($set->due_date + $ansOffset); $set->version_last_attempt_time( 0 ); @@ -1677,8 +1681,9 @@ my $recordedScore = 0; my $totPossible = 0; foreach ( @problems ) { - $totPossible += $_->value(); - $recordedScore += $_->status*$_->value() if (defined($_->status)); + my $pv = ( $_->value() ) ? $_->value() : 1; + $totPossible += $pv; + $recordedScore += $_->status*$pv if (defined($_->status)); push( @probStatus, ($r->param("probstatus" . $_->problem_id) || $_->status || 0) ); } @@ -1693,7 +1698,7 @@ if ( $submitAnswers || $checkAnswers ) { my $i=0; foreach my $pg ( @pg_results ) { - my $pValue = $problems[$i]->value(); + my $pValue = $problems[$i]->value() ? $problems[$i]->value() : 1; my $pScore = 0; my $numParts = 0; if ( ref( $pg ) ) { # then we have a pg object @@ -1713,9 +1718,8 @@ } } - # we want to print elapsed and allowed times; allowed is easy (we assume - # this is an even number of minutes) - my $allowed = ($set->due_date - $set->open_date)/60; + # we want to print elapsed and allowed times; allowed is easy + my $allowed = sprintf( "%.0f", 10*($set->due_date - $set->open_date)/6 )/100; # elapsed is a little harder; we're counting to the last submission # time, or to the current time if the test hasn't been submitted, # and if the submission fell in the grace period round it to the @@ -2067,8 +2071,9 @@ print CGI::start_div({class=>"gwProblem"}); my $i1 = $i+1; - my $points = ($problems[$probOrder[$i]]->value() > 1) ? - " (" . $problems[$probOrder[$i]]->value() . " points)" : + my $pv = $problems[$probOrder[$i]]->value() ? $problems[$probOrder[$i]]->value() : 1; + my $points = ($pv > 1) ? + " (" . $$pv . " points)" : " (1 point)"; print CGI::a({-name=>"#$i1"},""); print CGI::strong("Problem $problemNumber."), Index: ProblemSets.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/ProblemSets.pm,v retrieving revision 1.94 retrieving revision 1.95 diff -Llib/WeBWorK/ContentGenerator/ProblemSets.pm -Llib/WeBWorK/ContentGenerator/ProblemSets.pm -u -r1.94 -r1.95 --- lib/WeBWorK/ContentGenerator/ProblemSets.pm +++ lib/WeBWorK/ContentGenerator/ProblemSets.pm @@ -508,13 +508,14 @@ my $possible = 0; $score = 0; foreach my $pRec ( @problemRecords ) { + my $pval = $pRec->value() ? $pRec->value() : 1; if ( defined( $pRec ) && $score ne 'undef' ) { - $score += $pRec->status()*$pRec->value() || 0; + $score += $pRec->status()*$pval || 0; } else { $score = 'undef'; } - $possible += $pRec->value(); + $possible += $pval; } $score = "$score/$possible"; } else { |
From: Mike G. v. a. <we...@ma...> - 2010-05-27 04:17:22
|
Log Message: ----------- corrected typos. Modified Files: -------------- pg/macros: PG.pl Revision Data ------------- Index: PG.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PG.pl,v retrieving revision 1.46 retrieving revision 1.47 diff -Lmacros/PG.pl -Lmacros/PG.pl -u -r1.46 -r1.47 --- macros/PG.pl +++ macros/PG.pl @@ -105,11 +105,11 @@ #prepend labels with the quiz and section prefixes. while (@in ) { my $label = shift @in; - $label = join("", $self->{QUIZ_PREFIX}, $self->{SECTION_PREFIX}, $label); + $label = join("", $PG->{QUIZ_PREFIX}, $PG->{SECTION_PREFIX}, $label); $ans_eval = shift @in; push @out, $label, $ans_eval; } - pus$PG->LABELED_ANS(@out); # returns pointer to the labeled answer group + $PG->LABELED_ANS(@out); # returns pointer to the labeled answer group } sub NAMED_ANS { |
From: Mike G. v. a. <we...@ma...> - 2010-05-27 02:46:53
|
Log Message: ----------- changed parts of LABELED_ANS (and PGcore::new) so that it properly handles the QUIZ_PREFIX needed by gateway quizzes. Modified Files: -------------- pg/lib: PGcore.pm pg/macros: PG.pl Revision Data ------------- Index: PGcore.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGcore.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -Llib/PGcore.pm -Llib/PGcore.pm -u -r1.6 -r1.7 --- lib/PGcore.pm +++ lib/PGcore.pm @@ -83,7 +83,7 @@ ANSWER_PREFIX => 'AnSwEr', ARRAY_PREFIX => 'ArRaY', vec_num => 0, # for distinguishing matrices - QUIZ_PREFIX => '', + QUIZ_PREFIX => $envir->{QUIZ_PREFIX}, SECTION_PREFIX => '', # might be used for sequential (compound) questions? PG_ACTIVE => 1, # turn to zero to stop processing @@ -287,7 +287,7 @@ my @in = @_; while (@in ) { my $label = shift @in; - $label = join("", $self->{QUIZ_PREFIX}, $self->{SECTION_PREFIX}, $label); + #$label = join("", $self->{QUIZ_PREFIX}, $self->{SECTION_PREFIX}, $label); my $ans_eval = shift @in; $self->WARN("<BR><B>Error in LABELED_ANS:|$label|</B> -- inputs must be references to AnswerEvaluator objects or subroutines<BR>") Index: PG.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PG.pl,v retrieving revision 1.45 retrieving revision 1.46 diff -Lmacros/PG.pl -Lmacros/PG.pl -u -r1.45 -r1.46 --- macros/PG.pl +++ macros/PG.pl @@ -100,11 +100,20 @@ } sub LABELED_ANS { - $PG->LABELED_ANS(@_); # returns pointer to the labeled answer group + my @in = @_; + my @out = (); + #prepend labels with the quiz and section prefixes. + while (@in ) { + my $label = shift @in; + $label = join("", $self->{QUIZ_PREFIX}, $self->{SECTION_PREFIX}, $label); + $ans_eval = shift @in; + push @out, $label, $ans_eval; + } + pus$PG->LABELED_ANS(@out); # returns pointer to the labeled answer group } sub NAMED_ANS { - $PG->LABELED_ANS(@_); # returns pointer to the labeled answer group + &LABELED_ANS(@_); # returns pointer to the labeled answer group } sub ANS { |
From: Mike G. v. a. <we...@ma...> - 2010-05-26 00:11:59
|
Log Message: ----------- removed extraneous line that temporarily fixed the not_null problem. I believe the not_null problem has now been resolved in PGcore.pm Modified Files: -------------- webwork2/lib: WeBWorK.pm Revision Data ------------- Index: WeBWorK.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK.pm,v retrieving revision 1.104 retrieving revision 1.105 diff -Llib/WeBWorK.pm -Llib/WeBWorK.pm -u -r1.104 -r1.105 --- lib/WeBWorK.pm +++ lib/WeBWorK.pm @@ -359,7 +359,7 @@ writeTimingLogEntry($ce, "[".$r->uri."]", sprintf("runTime = %.3f sec", $cg_duration)." ".$ce->{dbLayoutName}, ""); debug("returning result: " . (defined $result ? $result : "UNDEF") . "\n"); - @LimitedPolynomial::BOP::ISA; #FIXME this is needed to zero out + # @LimitedPolynomial::BOP::ISA; #FIXME this is needed to zero out #\@LimitedPolynomial::BOP::ISA and prevent error messages of the form #[Sat May 15 14:23:08 2010] [warn] [client 127.0.0.1] [/webwork2/gage_course/test_set/6/] #Can't locate package LimitedPolynomial::BOP for @LimitedPolynomial::BOP::add::ISA at /opt/webwork/webwork2/lib/Apache/WeBWorK.pm line 115., referer: http://localhost/webwork2/gage_course/test_set/6/ no one knows why |
From: Mike G. v. a. <we...@ma...> - 2010-05-25 23:11:50
|
Log Message: ----------- Fixed the not_null bug? perhaps. Insure that the Exporter 'import' subroutine is available in the BEGIN statement of PGcore Modified Files: -------------- pg/lib: PGcore.pm PGresponsegroup.pm Revision Data ------------- Index: PGcore.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGcore.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -Llib/PGcore.pm -Llib/PGcore.pm -u -r1.5 -r1.6 --- lib/PGcore.pm +++ lib/PGcore.pm @@ -17,12 +17,12 @@ use strict; BEGIN { - use Exporter; + use Exporter 'import'; our @EXPORT_OK = qw(not_null); } our $internal_debug_messages = []; -our @ISA = qw(Exporter); + use PGanswergroup; use PGresponsegroup; use PGrandom; Index: PGresponsegroup.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGresponsegroup.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -Llib/PGresponsegroup.pm -Llib/PGresponsegroup.pm -u -r1.2 -r1.3 --- lib/PGresponsegroup.pm +++ lib/PGresponsegroup.pm @@ -159,7 +159,7 @@ if ( ! not_null ($self->{answergroup_label}) ) { #if $answergroup is not yet defined $self->{answergroup_label} = ${$self->{response_order}}[0]; } - if ( not_null ($self->{answergroup_label}) ) { #if $answergroup is not yet defined + if ( not_null ($self->{answergroup_label}) ) { #if $answergroup is now defined return $self->{answergroup_label}; } else { warn "This answer group has no labeled responses."; |
From: Mike G. v. a. <we...@ma...> - 2010-05-25 22:46:25
|
Log Message: ----------- added Exporter to the inheritance tree of PGcore Modified Files: -------------- pg/lib: PGcore.pm Revision Data ------------- Index: PGcore.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGcore.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -Llib/PGcore.pm -Llib/PGcore.pm -u -r1.4 -r1.5 --- lib/PGcore.pm +++ lib/PGcore.pm @@ -18,10 +18,11 @@ use strict; BEGIN { use Exporter; - our @EXPORT_OK = qw( not_null); + our @EXPORT_OK = qw(not_null); } our $internal_debug_messages = []; +our @ISA = qw(Exporter); use PGanswergroup; use PGresponsegroup; use PGrandom; |
From: Mike G. v. a. <we...@ma...> - 2010-05-25 22:37:49
|
Log Message: ----------- regularizing calls to no_null -- something puzzling is going on here since it appears to work on some systems but not others. Modified Files: -------------- pg/lib: PGanswergroup.pm PGresponsegroup.pm Revision Data ------------- Index: PGanswergroup.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGanswergroup.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -Llib/PGanswergroup.pm -Llib/PGanswergroup.pm -u -r1.1 -r1.2 --- lib/PGanswergroup.pm +++ lib/PGanswergroup.pm @@ -15,7 +15,7 @@ ################################################################################ package PGanswergroup; use Exporter; -use PGcore qw( not_null); +use PGcore qw(not_null); use PGresponsegroup; our @ISA=qw(PGcore); Index: PGresponsegroup.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/PGresponsegroup.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -Llib/PGresponsegroup.pm -Llib/PGresponsegroup.pm -u -r1.1 -r1.2 --- lib/PGresponsegroup.pm +++ lib/PGresponsegroup.pm @@ -17,7 +17,7 @@ use strict; use Exporter; -use PGcore( qw( not_null ) ); +use PGcore qw(not_null) ; use PGanswergroup; use Tie::IxHash; @@ -68,7 +68,7 @@ my $self = shift; my $response_label = shift; my $response_value =shift; - if (PGcore::not_null($response_label) ) { + if (not_null($response_label) ) { if (not exists ($self->{responses}->{$response_label}) ) { push @{ $self->{response_order}} , $response_label; $self->{responses}->{$response_label} = $response_value; |
From: Mike G. v. a. <we...@ma...> - 2010-05-25 22:28:10
|
Log Message: ----------- Remove unneeded warning. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: Problem.pm Revision Data ------------- Index: Problem.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm,v retrieving revision 1.223 retrieving revision 1.224 diff -Llib/WeBWorK/ContentGenerator/Problem.pm -Llib/WeBWorK/ContentGenerator/Problem.pm -u -r1.223 -r1.224 --- lib/WeBWorK/ContentGenerator/Problem.pm +++ lib/WeBWorK/ContentGenerator/Problem.pm @@ -1131,9 +1131,9 @@ ) if defined($self->{editMode}) and $self->{editMode} eq 'temporaryFile'; # this is a security risk -- students can use this to find the source code for the problem + my $permissionLevel = $db->getPermissionLevel($user)->permission; my $professorPermissionLevel = $ce->{userRoles}->{professor}; - warn "checking permssionlevel", $permissionLevel>= $professorPermissionLevel; print( CGI::hidden( -name => 'sourceFilePath', -value => $self->{problem}->{source_file} @@ -1143,6 +1143,7 @@ -name => 'problemSeed', -value => $r->param("problemSeed") )) if defined($r->param("problemSeed")) and $permissionLevel>= $professorPermissionLevel; # only allow this for professors + # end of main form print CGI::endform(); |
From: Mike G. v. a. <we...@ma...> - 2010-05-25 18:46:10
|
Log Message: ----------- print problemSourceFile and problemSeed when the instructor is viewing a problem. This enables the "temporary file" capability of the problem editor. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: Problem.pm Revision Data ------------- Index: Problem.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm,v retrieving revision 1.222 retrieving revision 1.223 diff -Llib/WeBWorK/ContentGenerator/Problem.pm -Llib/WeBWorK/ContentGenerator/Problem.pm -u -r1.222 -r1.223 --- lib/WeBWorK/ContentGenerator/Problem.pm +++ lib/WeBWorK/ContentGenerator/Problem.pm @@ -1131,15 +1131,18 @@ ) if defined($self->{editMode}) and $self->{editMode} eq 'temporaryFile'; # this is a security risk -- students can use this to find the source code for the problem -# print( CGI::hidden( -# -name => 'sourceFilePath', -# -value => $self->{problem}->{source_file} -# )) if defined($self->{problem}->{source_file}); + my $permissionLevel = $db->getPermissionLevel($user)->permission; + my $professorPermissionLevel = $ce->{userRoles}->{professor}; + warn "checking permssionlevel", $permissionLevel>= $professorPermissionLevel; + print( CGI::hidden( + -name => 'sourceFilePath', + -value => $self->{problem}->{source_file} + )) if defined($self->{problem}->{source_file}) and $permissionLevel>= $professorPermissionLevel; # only allow this for professors -# print( CGI::hidden( -# -name => 'problemSeed', -# -value => $r->param("problemSeed") -# )) if defined($r->param("problemSeed")); + print( CGI::hidden( + -name => 'problemSeed', + -value => $r->param("problemSeed") + )) if defined($r->param("problemSeed")) and $permissionLevel>= $professorPermissionLevel; # only allow this for professors # end of main form print CGI::endform(); |