Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Value/AnswerChecker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1731,6 +1731,7 @@ sub cmp_postfilter {
return $ans if ($ans->{bypass_equivalence_test});
my $context = $self->context;
Parser::Context->current(undef,$context);
my $flags = Value::contextSet($context,$self->cmp_contextFlags($ans)); # save old context flags
$ans->{prev_formula} = Parser::Formula($ans->{prev_ans});
if (defined($ans->{prev_formula}) && defined($ans->{student_formula})) {
my $prev = eval {$self->promote($ans->{prev_formula})->inherit($self)}; # inherit limits, etc.
Expand All @@ -1744,6 +1745,7 @@ sub cmp_postfilter {
and $ans->{prev_ans} ne $ans->{original_student_ans}) # but not identical
{$ans->{ans_message} = "This answer is equivalent to the one you just submitted."}
}
Value::contextSet($context,%{$flags}); # restore context values
return $ans;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Value/Real.pm
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ sub atan2 {
##################################################

sub string {
my $self = shift; my $equation = shift; my $prec = shift;
my $self = shift; my $equation = shift; shift; shift; my $prec = shift;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra shifts seem to be for "open" and "close" which some such routines need.

my $n = $self->{data}[0];
my $format = $self->getFlag("format",$equation->{format} ||
($equation->{context} || $self->context)->{format}{number});
Expand Down
8 changes: 4 additions & 4 deletions lib/Value/Union.pm
Original file line number Diff line number Diff line change
Expand Up @@ -335,25 +335,25 @@ sub pdot {
}

sub string {
my $self = shift; my $equation = shift; shift; shift; my $prec = shift//0;
my $self = shift; my $equation = shift; shift; shift; my $prec = shift;
my $op = ($equation->{context} || $self->context)->{operators}{'U'};
my @intervals = ();
foreach my $x (@{$self->data}) {
$x->{format} = $self->{format} if defined $self->{format};
push(@intervals,$x->string($equation))
}
my $string = join($op->{string} || ' U ',@intervals);
$string = '('.$string.')' if $prec > ($op->{precedence} || 1.5);
$string = '('.$string.')' if defined($prec) && $prec > ($op->{precedence} || 1.5);
return $string;
}

sub TeX {
my $self = shift; my $equation = shift; shift; shift; my $prec = shift//0; #FIXME find out about precedece
my $self = shift; my $equation = shift; shift; shift; my $prec = shift;
my $op = ($equation->{context} || $self->context)->{operators}{'U'};
my @intervals = ();
foreach my $x (@{$self->data}) {push(@intervals,$x->TeX($equation))}
my $TeX = join($op->{TeX} || $op->{string} || ' U ',@intervals);
$TeX = '\left('.$TeX.'\right)' if $prec > ($op->{precedence} || 1.5);
$TeX = '\left('.$TeX.'\right)' if defined($prec) && $prec > ($op->{precedence} || 1.5);
return $TeX;
}

Expand Down
4 changes: 2 additions & 2 deletions macros/contextFraction.pl
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ sub isReduced {
#

sub string {
my $self = shift; my $equation = shift; my $prec = shift;
my $self = shift; my $equation = shift; shift; shift; my $prec = shift;
my ($a,$b) = @{$self->{data}}; my $n = "";
return "$a" if $b == 1;
if ($self->getFlagWithAlias("showMixedNumbers","showProperFractions") && CORE::abs($a) > $b)
Expand All @@ -903,7 +903,7 @@ sub string {
}

sub TeX {
my $self = shift; my $equation = shift; my $prec = shift;
my $self = shift; my $equation = shift; shift; shift; my $prec = shift;
my ($a,$b) = @{$self->{data}}; my $n = "";
return "$a" if $b == 1;
if ($self->getFlagWithAlias("showMixedNumbers","showProperFractions") && CORE::abs($a) > $b)
Expand Down