Log Message:
-----------
Added a ->cmp method for checking the answers.
It needs further improvement but it is a first
step toward making the List elements more
compatible with MathObjects.
The ->cmp method will be inherited by the
Select, Match and so forth objects
Modified Files:
--------------
pg/lib:
List.pm
Revision Data
-------------
Index: List.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/List.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -Llib/List.pm -Llib/List.pm -u -r1.3 -r1.4
--- lib/List.pm
+++ lib/List.pm
@@ -217,7 +217,7 @@
# *** Utility methods ***
-
+#internal
#choose k random numbers out of n
sub NchooseK {
my $self = shift;
@@ -235,7 +235,7 @@
return @out;
}
-
+#internal
#return an array of random numbers
sub shuffle {
my $self = shift;
@@ -248,7 +248,7 @@
# *** Utility subroutines ***
-
+#internal
#swap subscripts with their respective values
sub invert {
my @array = @_;
@@ -260,7 +260,7 @@
return @out;
}
-
+#internal
#slice of the alphabet
sub ALPHABET {
return ('A'..'ZZ')[@_];
@@ -296,6 +296,12 @@
#Input answers
#defaults to inputting 'question', 'answer', 'question', etc (should be overloaded for other types of questions)
+
+=head3 qa
+ Usage: $ml->qa( qw( question1 answer1 question2 answer2 ) );
+
+=cut
+
sub qa {
my $self = shift;
my @questANDanswer = @_;
@@ -315,6 +321,7 @@
#Output questions
#Doesn't do actual output, refers to method given in call to 'new' (rf_print_q)
+
sub print_q {
my $self = shift;
@@ -336,6 +343,23 @@
return $self->{selected_a};
}
+=head3 cmp
+
+ Usage ANS($ml -> cmp);
+
+provides a MathObject like comparison method
+returns a string of comparison methods for checking the list object
+
+=cut
+
+sub cmp {
+ my $self = shift;
+ my @answers = @{$self->{selected_a}};
+ @answers = map {Value::makeValue($_)} @answers; # make sure answers are all MathObjects
+ @answers = map {$_->cmp} @answers; # replace the MathObjects by their AnswerEvaluators
+ return @answers;
+}
+
#Match and Select return references to arrays while Multiple justs returns a string
#so Match and Select use ra_correct_ans while Multiple uses correct_ans
sub correct_ans {
|