diff --git a/macros/parsers/parserMultiAnswer.pl b/macros/parsers/parserMultiAnswer.pl
index 6677e076b0..c4c2821871 100644
--- a/macros/parsers/parserMultiAnswer.pl
+++ b/macros/parsers/parserMultiAnswer.pl
@@ -55,20 +55,21 @@ sub new {
}
}
bless {
- data => [@data],
- cmp => [@cmp],
- ans => [],
- isValue => 1,
- part => 0,
- singleResult => 0,
- namedRules => 0,
- checkTypes => 1,
- allowBlankAnswers => 0,
- tex_separator => $separator . '\,',
- separator => $separator . ' ',
- tex_format => undef,
- format => undef,
- context => $context,
+ data => [@data],
+ cmp => [@cmp],
+ ans => [],
+ isValue => 1,
+ part => 0,
+ singleResult => 0,
+ namedRules => 0,
+ checkTypes => 1,
+ allowBlankAnswers => 0,
+ tex_separator => $separator . '\,',
+ separator => $separator . ' ',
+ tex_format => undef,
+ format => undef,
+ context => $context,
+ single_ans_messages => [],
}, $class;
}
@@ -201,6 +202,10 @@ sub single_check {
. join('
|
', @errors)
. '';
}
+ if (@{ $self->{single_ans_messages} }) {
+ $ans->{ans_message} = $ans->{error_message} =
+ '' . join('
', @{ $self->{single_ans_messages} }) . '
' . $ans->{ans_message};
+ }
if ($nonblank) {
$ans->{preview_latex_string} =
(
@@ -331,6 +336,15 @@ sub setMessage {
$self->{ans}[ $i - 1 ]{ans_message} = $self->{ans}[ $i - 1 ]{error_message} = $message;
}
+# The user's checker can add messages to the single_ans_messages array,
+# which are joined together along with any ans_messages from the
+# individual answers.
+sub addMessage {
+ my ($self, $message) = @_;
+ return unless $message;
+ push(@{ $self->{single_ans_messages} }, $message);
+}
+
######################################################################
#
@@ -545,6 +559,19 @@ =head2 setMessage
$ma_obj->setMessage(2, "It's like a jungle sometimes..."); # succeeds
$ma_obj->setMessage(3, "It's like a jungle sometimes..."); # fails
+=head2 addMessage
+
+ $multianswer_obj->addMessage($message_string)
+
+Meant for use in C when using C to add feedback messages for the
+combined answer rules. This will add the message to a message array, which will be all
+joined together to create the final message. These messages are then attached to any
+answer rule messages to be displayed to the user.
+
+Note that unlike C, these messages are not tied to any answer rules, and
+unlike C, this will not halt the answer checker allowing both
+partial credit and other messages to also be shown.
+
=head1 USAGE
To create a MultiAnswer pass a list of answers to MultiAnswer() in the order they