| … | |
… | |
| 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 | |
|
|
| 1503 | sub evaluatesToNumber { |
1502 | sub 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 | |
|
|
1516 | sub 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 | ########################################################################## |