[system] / trunk / webwork / system / courseScripts / PGanswermacros.pl Repository:
ViewVC logotype

Diff of /trunk/webwork/system/courseScripts/PGanswermacros.pl

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

Revision 49 Revision 50
1497 } 1497 }
1498 $rh_ans->{correct_ans} = $rh_ans->{original_correct_ans}; 1498 $rh_ans->{correct_ans} = $rh_ans->{original_correct_ans};
1499 $rh_ans; 1499 $rh_ans;
1500} 1500}
1501 1501
1502
1503sub evaluatesToNumber { 1502sub evaluatesToNumber {
1504 my ($rh_ans, %options) = @_; 1503 my ($rh_ans, %options) = @_;
1505 my $testString = $rh_ans->{student_ans}; 1504 if (is_a_numeric_expression($rh_ans->{student_ans})) {
1506 my $is_a_number = 0;
1507 my ($inVal,$PG_eval_errors,$PG_full_error_report) = PG_answer_eval($rh_ans->{student_ans}); 1505 my ($inVal,$PG_eval_errors,$PG_full_error_report) = PG_answer_eval($rh_ans->{student_ans});
1506 if ($PG_eval_errors) { # this if statement should never be run
1507 # change nothing
1508 } else {
1509 # change this
1510 $rh_ans->{student_ans} = prfmt($inVal,$options{format});
1511 }
1512 }
1513 $rh_ans;
1514}
1515
1516sub is_a_numeric_expression {
1517 my $testString = shift;
1518 my $is_a_numeric_expression = 0;
1519 my ($inVal,$PG_eval_errors,$PG_full_error_report) = PG_answer_eval($testString);
1508 if ($PG_eval_errors) { 1520 if ($PG_eval_errors) {
1509 $is_a_number = 0; 1521 $is_a_numeric_expression = 0;
1510 } else { 1522 } else {
1511 $is_a_number = 1; 1523 $is_a_numeric_expression = 1;
1512 $rh_ans->{student_ans} = prfmt($inVal,$options{format}); 1524
1513 } 1525 }
1514 1526
1515 $rh_ans; 1527 $is_a_numeric_expression;
1516} 1528}
1517 1529
1518 1530
1519########################################################################## 1531##########################################################################
1520########################################################################## 1532##########################################################################

Legend:
Removed from v.49  
changed lines
  Added in v.50

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9