[system] / trunk / pg / macros / PGanswermacros.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/PGanswermacros.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 3715 Revision 3756
1999 ); 1999 );
2000 2000
2001 # 2001 #
2002 # Parse the previous answer, if any 2002 # Parse the previous answer, if any
2003 # 2003 #
2004 $cmp->install_pre_filter( 2004 $cmp->install_evaluator(
2005 sub { 2005 sub {
2006 my $rh_ans = shift; 2006 my $rh_ans = shift;
2007 $rh_ans->{_filter_name} = "parse_previous_answer"; 2007 $rh_ans->{_filter_name} = "parse_previous_answer";
2008 return $rh_ans unless defined $rh_ans->{prev_ans}; 2008 return $rh_ans unless defined $rh_ans->{prev_ans};
2009 my $oldContext = &$Context();
2010 &$Context($rh_ans->{correct_value}{context});
2009 $rh_ans->{prev_formula} = Parser::Formula($rh_ans->{prev_ans}); 2011 $rh_ans->{prev_formula} = Parser::Formula($rh_ans->{prev_ans});
2012 &$Context($oldContext);
2010 $rh_ans; 2013 $rh_ans;
2011 } 2014 }
2012 ); 2015 );
2013 2016
2014 # 2017 #
2032 $cmp->install_post_filter( 2035 $cmp->install_post_filter(
2033 sub { 2036 sub {
2034 my $rh_ans = shift; 2037 my $rh_ans = shift;
2035 $rh_ans->{_filter_name} = "produce_equivalence_message"; 2038 $rh_ans->{_filter_name} = "produce_equivalence_message";
2036 return $rh_ans unless $rh_ans->{prev_equals_current} && $rh_ans->{score} == 0; 2039 return $rh_ans unless $rh_ans->{prev_equals_current} && $rh_ans->{score} == 0;
2040 #
2041 # If the match is exact don't give an error since the previous entry
2042 # might have been from the preview button, or because there are multiple
2043 # entry blanks and the student is trying to get one of the other ones
2044 # right. We should only give this message when the student is actually
2045 # working on this answer.
2046 #
2037 return $rh_ans if $rh_ans->{prev_ans} eq $rh_ans->{original_student_ans}; 2047 return $rh_ans if $rh_ans->{prev_ans} eq $rh_ans->{original_student_ans};
2038 $rh_ans->{ans_message} = "This answer is equivalent to the one you just submitted or previewed."; 2048 $rh_ans->{ans_message} = "This answer is equivalent to the one you just submitted or previewed.";
2039 $rh_ans; 2049 $rh_ans;
2040 } 2050 }
2041 ); 2051 );
3131sub anstext { 3141sub anstext {
3132 my $num = shift; 3142 my $num = shift;
3133 my $ans_eval_template = store_ans_at(\$QUESTIONNAIRE_ANSWERS); 3143 my $ans_eval_template = store_ans_at(\$QUESTIONNAIRE_ANSWERS);
3134 my $psvnNumber = PG_restricted_eval(q!$main::psvnNumber!); 3144 my $psvnNumber = PG_restricted_eval(q!$main::psvnNumber!);
3135 my $probNum = PG_restricted_eval(q!$main::probNum!); 3145 my $probNum = PG_restricted_eval(q!$main::probNum!);
3146 my $courseName = PG_restricted_eval(q!$main::courseName!);
3147 my $setNumber = PG_restricted_eval(q!$main::setNumber!);
3148
3136 my $ans_eval = sub { 3149 my $ans_eval = sub {
3137 my $text = shift; 3150 my $text = shift;
3138 $text = '' unless defined($text); 3151 $text = '' unless defined($text);
3139 my $new_text = "\n$psvnNumber-Problem-$probNum-Question-$num:\n $text "; # modify entered text 3152 my $new_text = "\n$setNumber$courseName$psvnNumber-Problem-$probNum-Question-$num:\n $text "; # modify entered text
3140 my $out = &$ans_eval_template($new_text); # standard evaluator 3153 my $out = &$ans_eval_template($new_text); # standard evaluator
3141 #warn "$QUESTIONNAIRE_ANSWERS"; 3154 #warn "$QUESTIONNAIRE_ANSWERS";
3142 $out->{student_ans} = escapeHTML($text); # restore original entered text 3155 $out->{student_ans} = escapeHTML($text); # restore original entered text
3143 $out->{correct_ans} = "Question $num answered"; 3156 $out->{correct_ans} = "Question $num answered";
3144 $out->{original_student_ans} = escapeHTML($text); 3157 $out->{original_student_ans} = escapeHTML($text);

Legend:
Removed from v.3715  
changed lines
  Added in v.3756

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9