--- loncom/homework/optionresponse.pm 2002/11/07 16:45:55 1.58 +++ loncom/homework/optionresponse.pm 2002/11/13 16:53:11 1.63 @@ -1,7 +1,7 @@ # LearningOnline Network with CAPA # option list style responses # -# $Id: optionresponse.pm,v 1.58 2002/11/07 16:45:55 sakharuk Exp $ +# $Id: optionresponse.pm,v 1.63 2002/11/13 16:53:11 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -318,18 +318,30 @@ sub displayfoils { my @whichopt = &whichfoils($max,$randomize); my $part=$Apache::inputtags::part; my $id=$Apache::inputtags::response[-1]; + my $break; if (($Apache::lonhomework::history{"resource.$part.solved"} =~ /^correct/) || ($Apache::inputtags::status[-1] eq 'SHOW_ANSWER')) { my $temp=1; #### foreach $name (@whichopt) { - if ($target eq 'web') { - $result.="
"; + my $text=$Apache::response::foilgroup{$name.'.text'}; + if ($text!~/^\s*$/) { + if ($target eq 'tex') { + $break='\vskip 0 mm '; + } elsif ($target eq 'web') { + $break='
'; + } + } + $result.=$break; + if ($target eq 'web') { + my $value=$Apache::response::foilgroup{$name.'.value'}; + if (!($text=~s||$value|)) { + if ($text=~/^\s*$/) { + $text=$value.$text; + } else { + $text=$value.': '.$text; + } + } + $result.=$text."\n"; } elsif ($target eq 'tex') { - $result.='\vskip 0 mm '; - } - if ($target ne 'tex') { - $result .=$Apache::response::foilgroup{$name.'.value'}. - ":".$Apache::response::foilgroup{$name.'.text'}."\n"; - } else { $Apache::response::foilgroup{$name.'.text'}=~s/\\item//; $result .='\item \textit{'.$Apache::response::foilgroup{$name.'.value'}.'}'. ":".$Apache::response::foilgroup{$name.'.text'}."\n"; @@ -347,6 +359,14 @@ sub displayfoils { my $temp=1; my %lastresponse=&Apache::lonnet::str2hash($Apache::lonhomework::history{"resource.$part.$id.submission"}); foreach $name (@whichopt) { + my $text=$Apache::response::foilgroup{$name.'.text'}; + if ($text!~/^\s*$/) { + if ($target eq 'tex') { + $break='\vskip 0 mm '; + } elsif ($target eq 'web') { + $break='
'; + } + } my $lastopt=$lastresponse{$name}; my $optionlist="\n"; my $option; @@ -358,22 +378,30 @@ sub displayfoils { } } if ($target ne 'tex') { - $result.="
\n".$Apache::response::foilgroup{$name.'.text'}."\n"; + $optionlist='\n"; + my $text=$Apache::response::foilgroup{$name.'.text'}; + if (!($text=~s||$optionlist|)) { + $text=$optionlist.$text; + } + $result.=$break.$text."\n"; if ($Apache::lonhomework::type eq 'exam') { $result.=&webbubbles(\@opt,\@alphabet); } $temp++; } else { + my $texoptionlist = &optionlist_correction($optionlist); if ($displayoptionintex == 0) { - my $texoptionlist = &optionlist_correction($optionlist); - if ($Apache::lonhomework::type eq 'exam') {$texoptionlist='';} + if ($Apache::lonhomework::type eq 'exam') {$texoptionlist='';} #if exam we do not need to show optionlist if ($Apache::response::foilgroup{$name.'.text'}=~m/\\item /) { - if ($Apache::lonhomework::type eq 'exam') { - $Apache::response::foilgroup{$name.'.text'}=~s/\\item/\\item[\\textbf{$Apache::lonxml::counter}\.]/; - } - $result.= $texoptionlist.$Apache::response::foilgroup{$name.'.text'}; + if ($Apache::lonhomework::type eq 'exam') { + $Apache::response::foilgroup{$name.'.text'}=~s/\\item/\\item[\\textbf{$Apache::lonxml::counter}\.]/; + } + if ($Apache::response::foilgroup{$name.'.text'}=~//) { + $Apache::response::foilgroup{$name.'.text'}=~s|| \\makebox\[0\.3in\]\[b\]\{\\hrulefill\} |; + } + $result.= $texoptionlist.$Apache::response::foilgroup{$name.'.text'}; } else { if ($Apache::lonhomework::type eq 'exam') { $result.= $texoptionlist.'\vspace*{-2 mm}\item[\textbf{'.$Apache::lonxml::counter.'}.]'.$Apache::response::foilgroup{$name.'.text'}; @@ -390,7 +418,10 @@ sub displayfoils { if ($Apache::lonhomework::type eq 'exam') { $Apache::response::foilgroup{$name.'.text'}=~s/\\item/\\item[\\textbf{$Apache::lonxml::counter}\.]/; } - $result.= $Apache::response::foilgroup{$name.'.text'}; + if ($Apache::response::foilgroup{$name.'.text'}=~//) { + $Apache::response::foilgroup{$name.'.text'}=~s|| \\makebox\[0\.3in\]\[b\]\{\\hrulefill\} |; + } + $result.= $Apache::response::foilgroup{$name.'.text'}; } else { if ($Apache::lonhomework::type eq 'exam') { $result.= '\item[\textbf{'.$Apache::lonxml::counter.'}.]'.$Apache::response::foilgroup{$name.'.text'}; @@ -402,13 +433,12 @@ sub displayfoils { $result.=&bubbles(\@alphabet,\@opt); } } - } + } } - } - if ($target ne 'tex') { - return $result."
"; } - else { + if ($target ne 'tex') { + return $result.$break; + } else { return $result; } }