Skip to content

Commit f572bbe

Browse files
authored
Merge pull request #589 from openwebwork/PG-2.16
PG 2.16 Release
2 parents a284c3b + 76cf444 commit f572bbe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+5817
-3926
lines changed

README_maketext

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
##### README
22

33

4-
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');
4+
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');
55

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

88

9-
9+

VERSION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$PG_VERSION ='2.15';
2-
$PG_COPYRIGHT_YEARS = '1996-2019';
1+
$PG_VERSION ='2.16';
2+
$PG_COPYRIGHT_YEARS = '1996-2021';
33

44
1;

doc/MathObjects/README.pod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,5 @@ sin 2x return sin(2x) rather than (sin(2))x.
184184

185185
Shows how to switch contexts (in this case, to complex and to vector
186186
contexts), and how this affects the parsing.
187+
188+
=back

lib/AnswerHash.pm

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ BEGIN {
122122
package AnswerHash;
123123
use Exporter;
124124
use PGUtil qw(not_null pretty_print);
125+
use JSON;
125126

126127
# initialization fields
127128
my %fields = ( 'score' => undef,
@@ -247,19 +248,27 @@ sub score {
247248

248249
=head4 stringify_hash
249250
250-
Usage: $rh_ans->stringify_hash;
251+
Usage: $rh_ans->stringify_hash;
251252
252-
Turns all values in the hash into strings (so they won't cause trouble outside
253-
the safe compartment).
253+
Turns all values in the hash into strings (so they won't cause trouble outside
254+
the safe compartment).
255+
256+
Hashes and arrays are converted into a JSON string.
254257
255258
=cut
256259

257260
sub stringify_hash {
258-
my $self = shift;
259-
Parser::Context->current(undef,$self->{correct_value}->context) if $self->{correct_value};
260-
foreach my $key (keys %$self) {
261-
$self->{$key} = "$self->{$key}" if ref($self->{$key});
262-
}
261+
my $self = shift;
262+
Parser::Context->current(undef,$self->{correct_value}->context) if $self->{correct_value};
263+
foreach my $key (keys %$self) {
264+
my $ref = ref($self->{$key});
265+
next if !$ref;
266+
if ($ref eq "HASH" or $ref eq "ARRAY") {
267+
$self->{$key} = JSON->new->utf8->allow_unknown->allow_blessed->encode($self->{$key});
268+
} else {
269+
$self->{$key} = "$self->{$key}";
270+
}
271+
}
263272
}
264273

265274
# error methods
@@ -879,6 +888,9 @@ sub blank_postfilter {
879888
return($rh_ans) unless defined($rh_ans->{error_flag}) and $rh_ans->{error_flag} eq 'BLANK';
880889
$rh_ans->{error_flag} = undef;
881890
$rh_ans->{error_message} = '';
891+
if ( defined($rh_ans->{message_for_blank_answer} ) ) {
892+
$rh_ans->{ans_message} = $rh_ans->{message_for_blank_answer};
893+
}
882894
$rh_ans->{done} =1; # no further checking is needed.
883895
$rh_ans;
884896
};

0 commit comments

Comments
 (0)