--- loncom/homework/optionresponse.pm 2001/05/04 21:19:37 1.6 +++ loncom/homework/optionresponse.pm 2001/05/31 22:34:33 1.9 @@ -11,21 +11,39 @@ sub BEGIN { sub start_optionresponse { my ($target,$token,$parstack,$parser,$safeeval,$style)=@_; + my $result=''; #when in a radiobutton response use these &Apache::lonxml::register('Apache::optionresponse',('foilgroup','foil','conceptgroup')); + push (@Apache::lonxml::namespace,'optionresponse'); my $id = &Apache::response::start_response($parstack,$safeeval); - return ''; + if ($target eq 'edit') { + $result.=" +
Multiple Option Response QuestionDelete:". + &Apache::edit::deletelist($target,$token) +."
\n"; + } + + return $result; } sub end_optionresponse { &Apache::response::end_response; + pop @Apache::lonxml::namespace; return ''; } +sub insert_optionresponse { + return ' + + + +'; +} + %Apache::response::foilgroup={}; sub start_foilgroup { %Apache::response::foilgroup={}; - $Apache::optionresponse::conceptgroup=0; + $Apache::optionresponse::conceptgroup=0; &Apache::response::setrandomnumber(); return ''; } @@ -52,6 +70,7 @@ sub end_foilgroup { my $allresponse; my $right=0; my $wrong=0; + my $ignored=0; foreach $name (@whichopt) { my $response = $ENV{'form.HWVAL_'.$Apache::inputtags::response['-1'].":$temp"}; $allresponse.="$response:"; @@ -59,13 +78,15 @@ sub end_foilgroup { &Apache::lonxml::debug("submitted a $response
\n"); my $value=$Apache::response::foilgroup{$name.'.value'}; if ($value eq $response) {$right++;} else {$wrong++;} + } else { + $ignored++; } $temp++; } my $id = $Apache::inputtags::response['-1']; $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.submission"}=$allresponse; - &Apache::lonxml::debug("Got $right right and $wrong wrong"); - if ($wrong==0) { + &Apache::lonxml::debug("Got $right right and $wrong wrong, and $ignored were ignored"); + if ($wrong==0 && $ignored==0) { $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.awarddetail"}='EXACT_ANS'; } else { $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.awarddetail"}='INCORRECT'; @@ -81,7 +102,8 @@ sub getfoilcounts { my $rrargs =''; if ( $#$parstack > 0 ) { $rrargs=$$parstack['-2']; } my $max = &Apache::run::run("{$rrargs;".'return $max}',$safeeval); - my $count = $#{ $Apache::response::foilgroup{'names'} }; + # +1 since instructors will count from 1 + my $count = $#{ $Apache::response::foilgroup{'names'} }+1; return ($count,$max); } @@ -89,8 +111,9 @@ sub whichfoils { my ($max)=@_; my @names = @{ $Apache::response::foilgroup{'names'} }; my @whichopt =(); - while ((($#whichopt) < $max) && ($#names > -1)) { - my $aopt=int rand $#names; + while ((($#whichopt+1) < $max) && ($#names > -1)) { + &Apache::lonxml::debug("Have $#whichopt max is $max"); + my $aopt=int(rand($#names+1)); &Apache::lonxml::debug("From $#whichopt $max $#names elms, picking $aopt"); $aopt=splice(@names,$aopt,1); &Apache::lonxml::debug("Picked $aopt"); @@ -193,6 +216,11 @@ sub end_foil { return ''; } +sub insert_foil { + return ' + +'; +} 1; __END__