Skip to content

Commit

Permalink
Merge pull request #589 from openwebwork/PG-2.16
Browse files Browse the repository at this point in the history
PG 2.16 Release
  • Loading branch information
drgrice1 authored Jul 14, 2021
2 parents a284c3b + 76cf444 commit f572bbe
Show file tree
Hide file tree
Showing 85 changed files with 5,817 additions and 3,926 deletions.
4 changes: 2 additions & 2 deletions README_maketext
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
##### README


Currently (version 1.25) Maketext has a "use strict" line as part of its string parser. This "use strict" interacts badly with WWSafe and fails. Unfortunately the use strict cannot be turned off in Maketext. This means that you can use maketex in PG, but you cannot use any of its features, including simple ones like maketext('Hello [_1] World','Cruel');
Currently (version 1.25) Maketext has a "use strict" line as part of its string parser. This "use strict" interacts badly with WWSafe and fails. Unfortunately the use strict cannot be turned off in Maketext. This means that you can use maketext in PG, but you cannot use any of its features, including simple ones like maketext('Hello [_1] World','Cruel');

If it becomes necessary to use the more advance versions of maketext in PG we will need to fork Maketext.




4 changes: 2 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$PG_VERSION ='2.15';
$PG_COPYRIGHT_YEARS = '1996-2019';
$PG_VERSION ='2.16';
$PG_COPYRIGHT_YEARS = '1996-2021';

1;
2 changes: 2 additions & 0 deletions doc/MathObjects/README.pod
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,5 @@ sin 2x return sin(2x) rather than (sin(2))x.

Shows how to switch contexts (in this case, to complex and to vector
contexts), and how this affects the parsing.

=back
28 changes: 20 additions & 8 deletions lib/AnswerHash.pm
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ BEGIN {
package AnswerHash;
use Exporter;
use PGUtil qw(not_null pretty_print);
use JSON;

# initialization fields
my %fields = ( 'score' => undef,
Expand Down Expand Up @@ -247,19 +248,27 @@ sub score {

=head4 stringify_hash
Usage: $rh_ans->stringify_hash;
Usage: $rh_ans->stringify_hash;
Turns all values in the hash into strings (so they won't cause trouble outside
the safe compartment).
Turns all values in the hash into strings (so they won't cause trouble outside
the safe compartment).
Hashes and arrays are converted into a JSON string.
=cut

sub stringify_hash {
my $self = shift;
Parser::Context->current(undef,$self->{correct_value}->context) if $self->{correct_value};
foreach my $key (keys %$self) {
$self->{$key} = "$self->{$key}" if ref($self->{$key});
}
my $self = shift;
Parser::Context->current(undef,$self->{correct_value}->context) if $self->{correct_value};
foreach my $key (keys %$self) {
my $ref = ref($self->{$key});
next if !$ref;
if ($ref eq "HASH" or $ref eq "ARRAY") {
$self->{$key} = JSON->new->utf8->allow_unknown->allow_blessed->encode($self->{$key});
} else {
$self->{$key} = "$self->{$key}";
}
}
}

# error methods
Expand Down Expand Up @@ -879,6 +888,9 @@ sub blank_postfilter {
return($rh_ans) unless defined($rh_ans->{error_flag}) and $rh_ans->{error_flag} eq 'BLANK';
$rh_ans->{error_flag} = undef;
$rh_ans->{error_message} = '';
if ( defined($rh_ans->{message_for_blank_answer} ) ) {
$rh_ans->{ans_message} = $rh_ans->{message_for_blank_answer};
}
$rh_ans->{done} =1; # no further checking is needed.
$rh_ans;
};
Expand Down
Loading

0 comments on commit f572bbe

Please sign in to comment.