Log Message:
-----------
Modifications to pass answer label for previous answer. This still does not
provide correct functionality because the previous answer is an equation of the form
lhs = rhs while the form being passed to fun_cmp is lhs - rhs
Modified Files:
--------------
pg/macros:
extraAnswerEvaluators.pl
Revision Data
-------------
Index: extraAnswerEvaluators.pl
===================================================================
RCS file: /webwork/cvs/system/pg/macros/extraAnswerEvaluators.pl,v
retrieving revision 1.20
retrieving revision 1.21
diff -Lmacros/extraAnswerEvaluators.pl -Lmacros/extraAnswerEvaluators.pl -u -r1.20 -r1.21
--- macros/extraAnswerEvaluators.pl
+++ macros/extraAnswerEvaluators.pl
@@ -55,7 +55,10 @@
split /=/, $instring;
}
-
+ #FIXME -- this could be improved so that
+ # 1. it uses an answer evaluator object instead of a sub routine
+ # 2. it provides error messages when previous answers are equivalent
+
sub equation_cmp {
my $right_ans = shift;
my %opts = @_;
@@ -66,17 +69,17 @@
my $ans_eval = sub {
my $student = shift;
-
+ my %response_options = @_;
my $ans_hash = new AnswerHash(
- 'score'=>0,
- 'correct_ans'=>$right_ans,
- 'student_ans'=>$student,
- 'original_student_ans' => $student,
- # 'type' => undef,
- 'ans_message'=>'',
- 'preview_text_string'=>'',
- 'preview_latex_string'=>'',
- );
+ 'score'=>0,
+ 'correct_ans'=>$right_ans,
+ 'student_ans'=>$student,
+ 'original_student_ans' => $student,
+ 'type' => 'equation_cmp',
+ 'ans_message'=>'',
+ 'preview_text_string'=>'',
+ 'preview_latex_string'=>'',
+ );
if(! ($student =~ /\S/)) { return $ans_hash; }
@@ -157,7 +160,7 @@
# Finally, use fun_cmp to check the answers
$ae = main::fun_cmp("o*($right[0]-($right[1]))", vars=>$vars, params=>['o'], %opts);
- $res= $ae->evaluate("$studsplit[0]-($studsplit[1])");
+ $res= $ae->evaluate("$studsplit[0]-($studsplit[1])",%response_options);
$ans_hash-> setKeys('score' => $res->{'score'});
return $ans_hash;
|