--- loncom/homework/optionresponse.pm 2011/10/08 23:03:42 1.173.2.1 +++ loncom/homework/optionresponse.pm 2011/03/03 21:05:35 1.174 @@ -1,7 +1,7 @@ # LearningOnline Network with CAPA # option list style responses # -# $Id: optionresponse.pm,v 1.173.2.1 2011/10/08 23:03:42 raeburn Exp $ +# $Id: optionresponse.pm,v 1.174 2011/03/03 21:05:35 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -155,9 +155,13 @@ ENDTABLE splice(@options,$delopt-1,1); $optchanged=1; } - if ($env{"form.$Apache::lonxml::curdepth.options"} ne '') { + if ($env{"form.$Apache::lonxml::curdepth.options"}) { my $newopt = $env{"form.$Apache::lonxml::curdepth.options"}; - push(@options,$newopt); + if ($options[0]) { + push(@options,$newopt); + } else { + $options[0]=$newopt; + } $optchanged=1; } my $rebuildtag = &Apache::edit::get_new_args($token,$parstack,$safeeval, @@ -221,6 +225,26 @@ sub end_foilgroup { my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]"; push (@{ $Apache::lonhomework::analyze{"$part_id.options"} },@opt); } elsif ( $target eq 'grade') { + my $nonlenient=0; + my $part=$Apache::inputtags::part; + my $lenientparm=&Apache::lonnet::EXT("resource.$part.lenient"); + + &Apache::lonnet::logthis("Parameter ".$part." ".$lenientparm); + + if ($Apache::lonhomework::scantronmode) { + $nonlenient=0; +# Grading an exam: we are grading lenient unless told not to + if ($lenientparm=~/^0|off|no$/i) { + $nonlenient=1; + } + } else { +# Web mode: we are non-lenient unless told to + $nonlenient=1; + if ($lenientparm=~/^1|on|yes$/i) { + $nonlenient=0; + } + } + &Apache::lonnet::logthis("Non-Lenient set to ".$nonlenient); if ( &Apache::response::submitted()) { my @whichopt = &whichfoils($max,$randomize); my $temp=1;my $name; @@ -282,7 +306,11 @@ sub end_foilgroup { my $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='MISSING_ANSWER'; &Apache::response::handle_previous(\%previous,$ad); } - } elsif (!$Apache::lonhomework::scantronmode) { + } elsif ($nonlenient) { +# +# Non-lenient mode. All right or all wrong +# + &Apache::lonnet::logthis("In non-lenient"); my $ad; if ($wrong==0 && $ignored==0) { $ad='EXACT_ANS'; @@ -298,6 +326,10 @@ sub end_foilgroup { $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad; &Apache::response::handle_previous(\%previous,$ad); } else { +# +# This is lenient mode +# + &Apache::lonnet::logthis("This is in lenient mode ... nice"); my $ad; if ($wrong==0 && $right==0) { #nothing submitted only assign a score if we