| … | |
… | |
| 60 | StringifyAsTeX => 0, # reset this, just in case. |
60 | StringifyAsTeX => 0, # reset this, just in case. |
| 61 | no_parameters => 1, # don't let students enter parameters |
61 | no_parameters => 1, # don't let students enter parameters |
| 62 | showExtraParens => 1, # make student answer painfully unambiguous |
62 | showExtraParens => 1, # make student answer painfully unambiguous |
| 63 | reduceConstants => 0, # don't combine student constants |
63 | reduceConstants => 0, # don't combine student constants |
| 64 | reduceConstantFunctions => 0, # don't reduce constant functions |
64 | reduceConstantFunctions => 0, # don't reduce constant functions |
|
|
65 | ($ans->{requireParenMatch}? (): ignoreEndpointTypes => 1), # for Intervals |
|
|
66 | $self->cmp_contextFlags($ans), # any additional ones from the object itself |
| 65 | ); |
67 | ); |
| 66 | $ans->{isPreview} = $self->getPG('$inputs_ref->{previewAnswers}'); |
68 | $ans->{isPreview} = $self->getPG('$inputs_ref->{previewAnswers}'); |
| 67 | $ans->{cmp_class} = $self->cmp_class($ans) unless $ans->{cmp_class}; |
69 | $ans->{cmp_class} = $self->cmp_class($ans) unless $ans->{cmp_class}; |
| 68 | $ans->{error_message} = $ans->{ans_message} = ''; # clear any old messages |
70 | $ans->{error_message} = $ans->{ans_message} = ''; # clear any old messages |
| 69 | $ans->{preview_latex_string} = $ans->{preview_text_string} = ''; |
71 | $ans->{preview_latex_string} = $ans->{preview_text_string} = ''; |
| … | |
… | |
| 90 | $self->cmp_equal($ans); |
92 | $self->cmp_equal($ans); |
| 91 | $self->cmp_postprocess($ans) if !$ans->{error_message}; |
93 | $self->cmp_postprocess($ans) if !$ans->{error_message}; |
| 92 | } |
94 | } |
| 93 | } else { |
95 | } else { |
| 94 | $self->cmp_error($ans); |
96 | $self->cmp_error($ans); |
| 95 | $self->cmp_collect($ans); |
97 | $self->cmp_collect($ans); ## FIXME: why is this here a second time? |
| 96 | } |
98 | } |
| 97 | contextSet($context,%{$flags}); # restore context values |
99 | contextSet($context,%{$flags}); # restore context values |
| 98 | Parser::Context->current(undef,$current); # put back the old context |
100 | Parser::Context->current(undef,$current); # put back the old context |
| 99 | return $ans; |
101 | return $ans; |
| 100 | } |
102 | } |
| … | |
… | |
| 226 | |
228 | |
| 227 | # |
229 | # |
| 228 | # filled in by sub-classes |
230 | # filled in by sub-classes |
| 229 | # |
231 | # |
| 230 | sub cmp_postprocess {} |
232 | sub cmp_postprocess {} |
|
|
233 | sub cmp_contextFlags {return ()} |
| 231 | |
234 | |
| 232 | # |
235 | # |
| 233 | # create answer rules of various types |
236 | # create answer rules of various types |
| 234 | # |
237 | # |
| 235 | sub ans_rule {shift; pgCall('ans_rule',@_)} |
238 | sub ans_rule {shift; pgCall('ans_rule',@_)} |
| … | |
… | |
| 771 | ($other->{close} eq ')' || $other->{close} eq ']') |
774 | ($other->{close} eq ')' || $other->{close} eq ']') |
| 772 | if $other->type =~ m/^(Point|List)$/; |
775 | if $other->type =~ m/^(Point|List)$/; |
| 773 | $other->type =~ m/^(Interval|Union|Set)$/; |
776 | $other->type =~ m/^(Interval|Union|Set)$/; |
| 774 | } |
777 | } |
| 775 | |
778 | |
| 776 | sub cmp_compare { |
|
|
| 777 | my $self = shift; my $other = shift; my $ans = shift; |
|
|
| 778 | my $oldignore = $self->{requireParenMatch}; |
|
|
| 779 | $self->{ignoreEndpointTypes} = !$ans->{requireParenMatch}; |
|
|
| 780 | my $equal = $self->SUPER::cmp_compare($other,$ans); |
|
|
| 781 | $self->{ignoreEndpointTypes} = $oldignore; |
|
|
| 782 | return $equal; |
|
|
| 783 | } |
|
|
| 784 | |
|
|
| 785 | # |
779 | # |
| 786 | # Check for wrong enpoints and wrong type of endpoints |
780 | # Check for wrong enpoints and wrong type of endpoints |
| 787 | # |
781 | # |
| 788 | sub cmp_postprocess { |
782 | sub cmp_postprocess { |
| 789 | my $self = shift; my $ans = shift; |
783 | my $self = shift; my $ans = shift; |
| … | |
… | |
| 838 | # otherwise use the standard compare (to get better |
832 | # otherwise use the standard compare (to get better |
| 839 | # error messages |
833 | # error messages |
| 840 | # |
834 | # |
| 841 | sub cmp_equal { |
835 | sub cmp_equal { |
| 842 | my ($self,$ans) = @_; |
836 | my ($self,$ans) = @_; |
| 843 | Value::List::cmp_equal(@_) |
|
|
| 844 | if $ans->{student_value}->type eq 'Set'; |
837 | Value::List::cmp_equal(@_) if $ans->{student_value}->type eq 'Set'; |
| 845 | Value::cmp_equal(@_); |
838 | Value::cmp_equal(@_); |
| 846 | } |
839 | } |
| 847 | |
840 | |
| 848 | ############################################################# |
841 | ############################################################# |
| 849 | |
842 | |
| … | |
… | |
| 895 | list_type => undef, |
888 | list_type => undef, |
| 896 | typeMatch => $element, |
889 | typeMatch => $element, |
| 897 | extra => $element, |
890 | extra => $element, |
| 898 | requireParenMatch => 1, |
891 | requireParenMatch => 1, |
| 899 | removeParens => 1, |
892 | removeParens => 1, |
| 900 | ); |
893 | ); |
| 901 | } |
894 | } |
| 902 | |
895 | |
| 903 | # |
896 | # |
| 904 | # Match anything but formulas |
897 | # Match anything but formulas |
| 905 | # |
898 | # |