version 1.125, 2005/04/07 06:56:22
|
version 1.133, 2006/03/09 01:04:43
|
Line 114 sub start_foilgroup {
|
Line 114 sub start_foilgroup {
|
<td>Delete an Option: |
<td>Delete an Option: |
<select name="$Apache::lonxml::curdepth.deleteopt">$optionlist</select> |
<select name="$Apache::lonxml::curdepth.deleteopt">$optionlist</select> |
ENDTABLE |
ENDTABLE |
|
$result.= &Apache::edit::checked_arg('Print options:','texoptions', |
|
[ ['nochoice','Don\'t show option list'] ] |
|
,$token); |
$result.= &Apache::edit::end_row(); |
$result.= &Apache::edit::end_row(); |
$result.= &Apache::edit::start_spanning_row(); |
$result.= &Apache::edit::start_spanning_row(); |
$result.= $insertlist.'<br />'; |
$result.= $insertlist.'<br />'; |
Line 137 ENDTABLE
|
Line 140 ENDTABLE
|
} |
} |
$optchanged=1; |
$optchanged=1; |
} |
} |
if ($optchanged) { |
my $rebuildtag = &Apache::edit::get_new_args($token,$parstack,$safeeval, |
|
('texoptions')); |
|
if ($optchanged || $rebuildtag ) { |
$result = "<foilgroup options=\"("; |
$result = "<foilgroup options=\"("; |
foreach my $option (@options) { |
foreach my $option (@options) { |
$option=~s/\'/\\\'/g; |
$option=~s/\'/\\\'/g; |
Line 145 ENDTABLE
|
Line 150 ENDTABLE
|
$result .="'".$option."',"; |
$result .="'".$option."',"; |
} |
} |
chop $result; |
chop $result; |
$result.=')">'; |
$result.=')" '; |
|
$result .= 'texoptions="'.$token->[2]{'texoptions'}.'" '; |
|
$result .= '>'; |
} # else nothing changed so just use the default mechanism |
} # else nothing changed so just use the default mechanism |
} |
} |
if ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') { |
if ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') { |
Line 165 sub end_foilgroup {
|
Line 172 sub end_foilgroup {
|
my $name; |
my $name; |
my @opt; |
my @opt; |
eval '@opt ='.&Apache::lonxml::get_param('options',$parstack,$safeeval); |
eval '@opt ='.&Apache::lonxml::get_param('options',$parstack,$safeeval); |
|
&Apache::lonxml::debug("options:".join(':',@opt)); |
|
|
my $TeXlayout=&Apache::lonxml::get_param('TeXlayout',$parstack,$safeeval, |
my $TeXlayout=&Apache::lonxml::get_param('TeXlayout',$parstack,$safeeval, |
-2,0); |
-2,0); |
if ($target eq 'tex' && $tex_option_switch eq 'nochoice') {@opt=();} |
if ($target eq 'tex' && $tex_option_switch eq 'nochoice') {@opt=();} |
Line 293 sub whichfoils {
|
Line 302 sub whichfoils {
|
} |
} |
|
|
sub displayanswers { |
sub displayanswers { |
my ($max,$randomize,@opt)=@_; |
my ($max,$randomize,@opt)=@_; |
if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;} |
if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;} |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @whichopt = &whichfoils($max,$randomize); |
my @whichopt = &whichfoils($max,$randomize); |
my $result=&Apache::response::answer_header('optionresponse'); |
my $result; |
foreach my $name (@whichopt) { |
if ($Apache::lonhomework::type eq 'exam') { |
$result.=&Apache::response::answer_part('optionresponse', |
my $i = 0; |
$Apache::response::foilgroup{$name.'.value'}) |
my %opt = map { ($_,$i++) } @opt; |
} |
|
$result.=&Apache::response::answer_footer('optionresponse'); |
$i = 0; |
return $result; |
my @alphabet = ('A'..'Z'); |
|
foreach my $name (@whichopt) { |
|
$result.=&Apache::response::answer_header('optionresponse',$i++); |
|
$result.=&Apache::response::answer_part('optionresponse', |
|
$alphabet[$opt{$Apache::response::foilgroup{$name.'.value'}}]); |
|
$result.=&Apache::response::answer_part('optionresponse', |
|
$Apache::response::foilgroup{$name.'.value'}); |
|
$result.=&Apache::response::answer_footer('optionresponse'); |
|
} |
|
} else { |
|
$result=&Apache::response::answer_header('optionresponse'); |
|
foreach my $name (@whichopt) { |
|
$result.=&Apache::response::answer_part('optionresponse', |
|
$Apache::response::foilgroup{$name.'.value'}); |
|
} |
|
$result.=&Apache::response::answer_footer('optionresponse'); |
|
} |
|
return $result; |
} |
} |
|
|
sub check_for_invalid { |
sub check_for_invalid { |
Line 358 sub displayfoils {
|
Line 384 sub displayfoils {
|
if ($text=~/^\s*$/) { |
if ($text=~/^\s*$/) { |
$text=$value.$text; |
$text=$value.$text; |
} else { |
} else { |
$text=$value.': '.$text; |
$text='<b>'.$value.':</b> '.$text; |
} |
} |
} else { |
} else { |
$text='•'.$text; |
$text='•'.$text; |
Line 385 sub displayfoils {
|
Line 411 sub displayfoils {
|
} |
} |
my $lastopt=$lastresponse{$name}; |
my $lastopt=$lastresponse{$name}; |
my $optionlist="<option></option>\n"; |
my $optionlist="<option></option>\n"; |
my $option; |
foreach my $option (@opt) { |
foreach $option (@opt) { |
my $escopt=&HTML::Entities::encode($option,'\'"&<>'); |
if ($option eq $lastopt) { |
if ($option eq $lastopt) { |
$optionlist.="<option selected=\"on\">$option</option>\n"; |
$optionlist.="<option value='".$escopt."' selected=\"selected\">$option</option>\n"; |
} else { |
} else { |
$optionlist.="<option>$option</option>\n"; |
$optionlist.="<option value='".$escopt."'>$option</option>\n"; |
} |
} |
} |
} |
if ($target ne 'tex') { |
if ($target ne 'tex') { |
if ($Apache::lonhomework::type ne 'exam') { |
if ($Apache::lonhomework::type ne 'exam') { |
Line 530 sub bubbles {
|
Line 556 sub bubbles {
|
$head.='lr'; |
$head.='lr'; |
} else { |
} else { |
$line=~s/\&\s*$//; |
$line=~s/\&\s*$//; |
$result.='\vskip -2 mm\noindent\begin{tabular}{'.$head.'}'.$line.'\\\\\end{tabular}\vskip 0 mm'; |
$result.='\vskip -2 mm\noindent\setlength{\tabcolsep}{2 mm}\begin{tabular}{'.$head.'}'.$line.'\\\\\end{tabular}\vskip 0 mm'; |
$line = '\hskip -1 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$\hskip -1 mm & \hskip -3 mm {\small '.$opt[$ind].'} & ';; |
$line = '\hskip -1 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$\hskip -1 mm & \hskip -3 mm {\small '.$opt[$ind].'} & ';; |
$head ='lr'; |
$head ='lr'; |
$current_length = (length($opt[$ind])+length($alphabet[$ind]))*2; |
$current_length = (length($opt[$ind])+length($alphabet[$ind]))*2; |
Line 630 sub end_foil {
|
Line 656 sub end_foil {
|
if ($value ne 'unused') { |
if ($value ne 'unused') { |
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); |
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); |
&Apache::lonxml::debug("Got a name of :$name:"); |
&Apache::lonxml::debug("Got a name of :$name:"); |
if (!$name) { |
if ($name eq "") { |
&Apache::lonxml::error("Foils without names exist. This can cause problems to malfunction."); |
&Apache::lonxml::warning("Foils without names exist. This can cause problems to malfunction."); |
$name=$Apache::lonxml::curdepth; |
$name=$Apache::lonxml::curdepth; |
} |
} |
&Apache::lonxml::debug("Using a name of :$name:"); |
&Apache::lonxml::debug("Using a name of :$name:"); |