File:  [LON-CAPA] / loncom / homework / optionresponse.pm
Revision 1.181: download - view: text, annotated - select for diffs
Fri Oct 7 22:39:59 2011 UTC (12 years, 7 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Bug 2802.
  Move determination of lenient vs non-lenient to subroutine to facilitate reuse
.
  - Support lenient parameter for matchresponse as well as optionresponse.
  - Use response::get_param_response() to retrieve lenient parm.

    1: # LearningOnline Network with CAPA
    2: # option list style responses
    3: #
    4: # $Id: optionresponse.pm,v 1.181 2011/10/07 22:39:59 raeburn Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: 
   29: 
   30: 
   31: 
   32: 
   33: package Apache::optionresponse;
   34: use strict;
   35: use Apache::response();
   36: use Apache::lonlocal;
   37: use Apache::lonnet;
   38: 
   39: BEGIN {
   40:   &Apache::lonxml::register('Apache::optionresponse',('optionresponse'));
   41: }
   42: 
   43: sub start_optionresponse {
   44:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   45:   my $result='';
   46:   #when in a option response use these
   47:   &Apache::lonxml::register('Apache::optionresponse',('foilgroup','foil','conceptgroup','drawoptionlist'));
   48:   push (@Apache::lonxml::namespace,'optionresponse');
   49:   my $id = &Apache::response::start_response($parstack,$safeeval);
   50:   %Apache::hint::option=();
   51:   undef(%Apache::response::foilnames);
   52:   if ($target eq 'edit') {
   53:     $result.=&Apache::edit::start_table($token)
   54:        .'<tr><td><span class="LC_nobreak">'.&mt('Multiple Option Response Question').'</span> '
   55:        .&Apache::loncommon::help_open_topic('Option_Response_Problems')."</td>"
   56:        .'<td><span class="LC_nobreak">'.&mt('Delete?').' '
   57:        .&Apache::edit::deletelist($target,$token)
   58:        .'</span></td>'
   59:        ."<td>&nbsp;"
   60:        .&Apache::edit::end_row()
   61:        .&Apache::edit::start_spanning_row()
   62:        ."\n";
   63:     $result.=&Apache::edit::text_arg('Max Number Of Shown Foils:','max',
   64: 				     $token,'4').
   65:         &Apache::edit::select_arg('Randomize Foil Order:','randomize',
   66: 				  ['yes','no'],$token).
   67:         &Apache::edit::select_arg(&mt('Display of options when printed'),'TeXlayout',
   68: 				  [['horizontal','Normal list'],
   69: 				   ['vertical','Listed in a vertical column']],$token).
   70:         &Apache::edit::end_row().&Apache::edit::start_spanning_row();
   71:   } elsif ($target eq 'modified') {
   72:     my $constructtag=&Apache::edit::get_new_args($token,$parstack,
   73: 						 $safeeval,'max','randomize',
   74: 						 'TeXlayout');
   75:     if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
   76:   } elsif ($target eq 'meta') {
   77:     $result=&Apache::response::meta_package_write('optionresponse');
   78:   } elsif ($target eq 'analyze') {
   79:     my $part_id="$Apache::inputtags::part.$id";
   80:     $Apache::lonhomework::analyze{"$part_id.type"} = 'optionresponse';
   81:     push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id);
   82:     push (@{ $Apache::lonhomework::analyze{"$part_id.bubble_lines"} }, 1);
   83: 
   84:   }
   85:   return $result;
   86: }
   87: 
   88: sub end_optionresponse {
   89:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   90:   &Apache::response::end_response;
   91:   pop @Apache::lonxml::namespace;
   92:   &Apache::lonxml::deregister('Apache::optionresponse',('foilgroup','foil','conceptgroup','drawoptionlist'));
   93:   my $result;
   94:   if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
   95:   undef(%Apache::response::foilnames);
   96:   return $result;
   97: }
   98: 
   99: %Apache::response::foilgroup=();
  100: sub start_foilgroup {
  101:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  102: 
  103:   my $result='';
  104:   %Apache::response::foilgroup=();
  105:   $Apache::optionresponse::conceptgroup=0;
  106:   &Apache::response::pushrandomnumber(undef,$target);
  107:   if ($target eq 'edit') {
  108:     my $optionlist="<option></option>\n";
  109:     my $option;
  110:     my @opt;
  111:     eval '@opt ='. &Apache::lonxml::get_param('options',$parstack,$safeeval);
  112:     my $count=1;
  113:     foreach $option (@opt) {
  114:       $optionlist.="<option value=\"$count\">$option</option>\n";
  115:       $count++;
  116:     }
  117:     my $insertlist=&Apache::edit::insertlist($target,$token);
  118:     $result.=&Apache::edit::start_table($token);
  119:     $result.= (<<ENDTABLE);
  120:       <tr><td>Select Options</td>
  121:         <td>
  122: 	  Add new Option: <input type="text" name="$Apache::lonxml::curdepth.options" />
  123:         </td>
  124:         <td>Delete an Option:
  125: 	  <select name="$Apache::lonxml::curdepth.deleteopt">$optionlist</select>
  126:         </td>
  127: ENDTABLE
  128:     $result.= '<td>'.&Apache::edit::checked_arg('Print options:','texoptions',
  129: 					 [ ['nochoice','Don\'t show option list'] ]
  130: 					 ,$token).'</td>';
  131:     $result.= '<td><label>'.&mt('Two-option checkboxes for:').
  132:               '<select name="checkboxvalue_'.$Apache::lonxml::curdepth.'">';
  133:     foreach $option (('',@opt)) {
  134:        $result.='<option value="'.$option.'"';
  135:        if ($option eq &Apache::lonxml::get_param('checkboxvalue',$parstack,$safeeval)) {
  136:           $result.=' selected="selected"';
  137:        }
  138:        $result.='>'.$option.'</option>';
  139:     }
  140:     $result.='</select></label>';
  141:     $result.=&Apache::edit::checked_arg('Checkbox options:','checkboxoptions',
  142:                                          [ ['nochoice','Don\'t show option list'] ]
  143:                                          ,$token).'</td>';
  144:     $result.= &Apache::edit::end_row();
  145:     $result.= &Apache::edit::start_spanning_row();
  146:     $result.= $insertlist.'<br />';
  147:   }
  148:   if ($target eq 'modified') {
  149:     my @options;
  150:     my $optchanged=0;
  151:     eval '@options ='.&Apache::lonxml::get_param('options',$parstack,$safeeval);
  152:     if ($env{"form.$Apache::lonxml::curdepth.deleteopt"}) {
  153:       my $delopt=$env{"form.$Apache::lonxml::curdepth.deleteopt"};
  154:       &Apache::lonxml::debug("Deleting :$delopt:");
  155:       splice(@options,$delopt-1,1);
  156:       $optchanged=1;
  157:     }
  158:     if ($env{"form.$Apache::lonxml::curdepth.options"} ne '') {
  159:       my $newopt = $env{"form.$Apache::lonxml::curdepth.options"};
  160:       push(@options,$newopt);
  161:       $optchanged=1;
  162:     }
  163:     my $rebuildtag = &Apache::edit::get_new_args($token,$parstack,$safeeval,
  164: 						 'texoptions','checkboxvalue','checkboxoptions');
  165:     if ($optchanged || $rebuildtag ) {
  166:       $result = "<foilgroup options=\"(";
  167:       foreach my $option (@options) {
  168: 	$option=~s/\'/\\\'/g;
  169: 	&Apache::lonxml::debug("adding option :$option:");
  170: 	$result .="'".$option."',";
  171:       }
  172:       chop $result;
  173:       $result.=')" ';
  174:       $result .= 'texoptions="'.$token->[2]{'texoptions'}.'" ';
  175:       $result .= 'checkboxoptions="'.$token->[2]{'checkboxoptions'}.'" ';
  176:       $result .= 'checkboxvalue="'.$token->[2]{'checkboxvalue'}.'"';
  177:       $result .= '>';
  178:     } # else nothing changed so just use the default mechanism
  179:   }
  180:   if ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {
  181:     if($env{'form.pdfFormFields'} ne 'yes') {
  182:       $result .= ' \begin{itemize} ';
  183:     } else {
  184:       $result .= "\\\\";
  185:     }
  186:   }
  187:   return $result;
  188: }
  189: 
  190: sub end_foilgroup {
  191:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  192:   
  193:   my $result;
  194:   if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
  195:       $target eq 'tex' || $target eq 'analyze') {
  196:     my $tex_option_switch=&Apache::lonxml::get_param('texoptions',$parstack,$safeeval);
  197:     my $name;
  198:     my @opt;
  199:     eval '@opt ='.&Apache::lonxml::get_param('options',$parstack,$safeeval);
  200:     &Apache::lonxml::debug("options:".join(':',@opt));
  201: 
  202:     my $TeXlayout=&Apache::lonxml::get_param('TeXlayout',$parstack,$safeeval,
  203: 					     -2,0);
  204:     my $checkboxvalue=&Apache::lonxml::get_param('checkboxvalue',$parstack,$safeeval);
  205:     my $checkboxchoices=(&Apache::lonxml::get_param('checkboxoptions',$parstack,$safeeval) ne 'nochoice');
  206:     if ($target eq 'tex' && $tex_option_switch eq 'nochoice') {@opt=();}
  207:     &Apache::lonxml::debug("Options are $#opt");
  208:     my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');
  209:     my $randomize = &Apache::lonxml::get_param('randomize',$parstack,
  210: 					       $safeeval,'-2');
  211:     if ($target eq 'web' || $target eq 'tex') {
  212:       $result.=&displayfoils($target,$max,$randomize,$TeXlayout,$checkboxvalue,$checkboxchoices,@opt);
  213:       $Apache::lonxml::post_evaluate=0;
  214:     } elsif ( $target eq 'answer') {
  215:       $result.=&displayanswers($max,$randomize,@opt);
  216:       
  217:     } elsif ( $target eq 'analyze') {
  218: 	my @shown = &whichfoils($max,$randomize);
  219: 	&Apache::response::analyze_store_foilgroup(\@shown,
  220: 						  ['text','value','location']);
  221: 	my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
  222: 	push (@{ $Apache::lonhomework::analyze{"$part_id.options"} },@opt);
  223:     } elsif ( $target eq 'grade') {
  224: 
  225:       if ( &Apache::response::submitted()) {
  226: 
  227: 	my @whichopt = &whichfoils($max,$randomize);
  228: 	my $temp=1;my $name;
  229: 	my %responsehash;
  230: 	my %grade;
  231: 	my $right=0;
  232: 	my $wrong=0;
  233: 	my $ignored=0;
  234:         my ($numrows,$bubbles_per_row);
  235:         if ($Apache::lonhomework::scantronmode) {
  236:             my $numitems = scalar(@opt);
  237:             ($numrows,$bubbles_per_row) =
  238:                 &Apache::optionresponse::getnumrows($numitems);
  239:         }
  240:         if ($numrows < 1) {
  241:             $numrows = 1;
  242:         }
  243: 	foreach $name (@whichopt) {
  244: 	  my $response;
  245:           if ($env{'form.submitted'} eq 'scantron') {
  246:               if ($numrows > 1) {
  247:                   my $num = $temp;
  248:                   my $totalnum;
  249:                   for (my $i=0; $i<$numrows; $i++) {
  250:                       my $item = &Apache::response::getresponse($num);
  251:                       if ($item =~ /^\d+$/) {
  252:                           $totalnum = $i*$bubbles_per_row + $item;
  253:                       }
  254:                       $num ++;
  255:                   }
  256:                   if ($totalnum =~ /^\d+$/) {
  257:                       $response = $opt[$totalnum];
  258:                   }
  259:                   $temp += $numrows;
  260:               } else {
  261:                   $response=&Apache::response::getresponse($temp);
  262:                   if ($response=~/\S/) {
  263:                       $response = $opt[$response];
  264:                   }
  265:                   $temp ++;
  266:               }
  267: 	  } else {
  268:               $response=&Apache::response::getresponse($temp);
  269:               $temp ++;
  270:           }
  271: 	  if ( $response =~ /[^\s]/) {
  272: 	    $responsehash{$name}=$response;
  273: 	    my $value=$Apache::response::foilgroup{$name.'.value'};
  274: 	    &Apache::lonxml::debug("submitted a $response for $value<br />\n");
  275: 	    if ($value eq $response) {
  276: 		$grade{$name}='1'; $right++;
  277: 	    } else {
  278: 		$grade{$name}='0'; $wrong++;
  279: 	    }
  280: 	  } else {
  281: 	    $ignored++;
  282: 	  }
  283: 	}
  284: 	my $part=$Apache::inputtags::part;
  285:         my $nonlenient=&is_nonlenient($part);
  286: 	my $id = $Apache::inputtags::response['-1'];
  287: 	my $responsestr=&Apache::lonnet::hash2str(%responsehash);
  288: 	my $gradestr   =&Apache::lonnet::hash2str(%grade);
  289: 	my %previous=&Apache::response::check_for_previous($responsestr,
  290: 							   $part,$id);
  291: 	&Apache::lonxml::debug("Got $right right and $wrong wrong, and $ignored were ignored");
  292: 	$Apache::lonhomework::results{"resource.$part.$id.submission"}=
  293: 	    $responsestr;
  294: 	$Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}=$gradestr;
  295:         if ($Apache::lonhomework::type eq 'randomizetry') {
  296:             $Apache::lonhomework::results{"resource.$part.$id.foilorder"} = &Apache::lonnet::array2str(@whichopt);
  297:         }
  298: 	if (($Apache::lonhomework::type eq 'survey') ||
  299:             ($Apache::lonhomework::type eq 'surveycred') ||
  300:             ($Apache::lonhomework::type eq 'anonsurvey') ||
  301:             ($Apache::lonhomework::type eq 'anonsurveycred')) {
  302: 	    if ($ignored == 0) {
  303:                 my $ad;
  304:                 if ($Apache::lonhomework::type eq 'anonsurveycred') {
  305:                     $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='ANONYMOUS_CREDIT';
  306:                 } elsif ($Apache::lonhomework::type eq 'anonsurvey') {
  307:                     $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='ANONYMOUS';
  308:                 } elsif ($Apache::lonhomework::type eq 'surveycred') {
  309:                     $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='SUBMITTED_CREDIT';
  310:                 } else {
  311: 		    $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='SUBMITTED';
  312:                 }
  313: 		&Apache::response::handle_previous(\%previous,$ad);
  314: 	    } elsif ($wrong==0 && $right==0) {
  315: 	    } else {
  316: 		my $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='MISSING_ANSWER';
  317: 		&Apache::response::handle_previous(\%previous,$ad);
  318: 	    }
  319: 	} elsif ($nonlenient) {
  320: #
  321: # Non-lenient mode. All right or all wrong
  322: #
  323: 	    my $ad;
  324: 	    if ($wrong==0 && $ignored==0) {
  325: 		$ad='EXACT_ANS';
  326: 	    } elsif ($wrong==0 && $right==0) {
  327: 		#nothing submitted
  328: 	    } else {
  329: 		if ($ignored==0) {
  330: 		    $ad='INCORRECT';
  331: 		} else {
  332: 		    $ad='MISSING_ANSWER';
  333: 		}
  334: 	    }
  335: 	    $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
  336: 	    &Apache::response::handle_previous(\%previous,$ad);
  337: 	} else {
  338: #
  339: # This is lenient mode
  340: #
  341: 	    my $ad;
  342: 	    if ($wrong==0 && $right==0) {
  343: 		#nothing submitted only assign a score if we 
  344: 		#need to override a previous grade
  345: 		if (defined($Apache::lonhomework::history{"resource.$part.$id.awarddetail"})) {
  346: 		    $ad='ASSIGNED_SCORE';
  347: 		}
  348: 	    } else {
  349: 		$ad='ASSIGNED_SCORE';
  350: 	    }
  351: 	    $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
  352: 	    $Apache::lonhomework::results{"resource.$part.$id.awarded"}=
  353: 		$right/(scalar(@whichopt));
  354: 	    $Apache::lonhomework::results{"resource.$part.$id.numfoils"}=
  355: 		scalar(@whichopt);
  356: 	}
  357:       }
  358:     }
  359:     my $part_id     = $Apache::inputtags::part;
  360:     my $response_id = $Apache::inputtags::response[-1];
  361:     my ($numrows,$bubbles_per_row);
  362:     if (($target eq 'tex') && ($Apache::lonhomework::type eq 'exam')) {
  363:         ($numrows,$bubbles_per_row) =
  364:             &Apache::optionresponse::getnumrows(scalar(@opt));
  365:     }
  366:     if ($numrows < 1) {
  367:         $numrows = 1;
  368:     }
  369:     my $increment = &getfoilcounts($max) * $numrows;
  370:     &Apache::lonxml::increment_counter($increment,"$part_id.$response_id");
  371:     if ($target eq 'analyze') {
  372: 	&Apache::lonhomework::set_bubble_lines();
  373:     }
  374: 
  375:   } elsif ($target eq 'edit') {
  376:     $result.=&Apache::edit::end_table();
  377:   }
  378:   if ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {
  379:     if($env{'form.pdfFormFields'} ne 'yes') {
  380:       $result .= '\end{itemize}'; 
  381:     } else {
  382:       $result .= "\\\\";
  383:     }
  384:   }
  385:   &Apache::response::poprandomnumber();
  386:   return $result;
  387: }
  388: 
  389: sub is_nonlenient {
  390:     my ($part) = @_;
  391: # Web mode: we are non-lenient unless told otherwise 
  392:     my $defaultparm = 'off';
  393:     my $nonlenient = 0;
  394: # Grading a bubblesheet exam: we are grading lenient unless told otherwise 
  395:     if ($Apache::lonhomework::scantronmode) {
  396:         $defaultparm = 'on';
  397:         $nonlenient = 1;
  398:     }
  399:     my $lenientparm = 
  400:         &Apache::response::get_response_param($part,'lenient',$defaultparm);  
  401:     if ($lenientparm=~/^0|off|no$/i) {
  402:         $nonlenient = 1;
  403:     } elsif ($lenientparm=~/^1|on|yes$/i) {
  404:         $nonlenient = 0;
  405:     }
  406:     return $nonlenient;
  407: }
  408: 
  409: sub getfoilcounts {
  410:   my ($max)=@_;
  411:   # +1 since instructors will count from 1
  412:   my $count = $#{ $Apache::response::foilgroup{'names'} }+1;
  413:   if (&Apache::response::showallfoils()) { $max=$count; }
  414:   if ($count>$max) { $count=$max } 
  415:   &Apache::lonxml::debug("Count is $count from $max");
  416:   return $count;
  417: }
  418: 
  419: sub whichfoils {
  420:     my ($max,$randomize)=@_;
  421:     return &Apache::response::whichorder($max,$randomize,
  422: 					 &Apache::response::showallfoils(),
  423: 					 \%Apache::response::foilgroup);
  424: }
  425: 
  426: sub displayanswers {
  427:     my ($max,$randomize,@opt)=@_;
  428:     if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;}
  429:     my @names = @{ $Apache::response::foilgroup{'names'} };
  430:     my @whichopt = &whichfoils($max,$randomize);
  431:     my $result;
  432:     if ($Apache::lonhomework::type eq 'exam') {
  433: 	my $i = 0;
  434: 	my %opt = map { ($_,$i++) } @opt;
  435: 	
  436: 	$i = 0;
  437: 	my @alphabet = ('A'..'Z');
  438: 	foreach my $name (@whichopt) {
  439: 	    $result.=&Apache::response::answer_header('optionresponse',$i++);
  440: 	    $result.=&Apache::response::answer_part('optionresponse',
  441: 						    $alphabet[$opt{$Apache::response::foilgroup{$name.'.value'}}]);
  442: 	    $result.=&Apache::response::answer_part('optionresponse',
  443: 						    $Apache::response::foilgroup{$name.'.value'});
  444: 	    $result.=&Apache::response::answer_footer('optionresponse');
  445: 	}
  446:     } else {
  447: 	$result=&Apache::response::answer_header('optionresponse');
  448: 	foreach my $name (@whichopt) {
  449: 	    $result.=&Apache::response::answer_part('optionresponse',
  450: 						    $Apache::response::foilgroup{$name.'.value'});
  451: 	}
  452: 	$result.=&Apache::response::answer_footer('optionresponse');
  453:     }
  454:     return $result;
  455: }
  456: 
  457: sub check_box_opt {
  458:     my ($target,$checkboxvalue,@opt)=@_;
  459: # Check if we are in checkbox mode: checkboxvalue specified, on web, only two options.
  460: # If so, return "checked" value
  461:     if ($#opt!=1) { return ''; }
  462:     if ($target ne 'web') { return ''; }
  463:     return $checkboxvalue;
  464: }
  465: 
  466: sub check_for_invalid {
  467:     my ($names,$options) = @_;
  468:     my %bad_names;
  469:     foreach my $name (@{ $names }) {
  470: 	my $value=$Apache::response::foilgroup{$name.'.value'};
  471: 	my $found=0;
  472: 	foreach my $option (@{ $options }) {
  473: 	    if ($value eq $option) { $found=1; }
  474: 	}
  475: 	if (!$found) { $bad_names{$name}=$value; }
  476:     }
  477:     if (%bad_names) {
  478: 	my $error=&mt('The question can not be gotten correct, '.
  479: 	    'the following foils in the &lt;optionresponse&gt; '.
  480: 	    'have invalid correct options').' <br /><tt>'.
  481: 	    join('<br />',(map { $_=&mt("[_1] with value [_2]",$_,$bad_names{$_}) } (keys(%bad_names)))).
  482: 	    "</tt>";
  483: 	&Apache::lonxml::error($error);
  484:     }
  485: }
  486: 
  487: sub displayfoils {
  488:   my ($target,$max,$randomize,$TeXlayout,$checkboxvalue,$checkboxchoices,@opt)=@_;
  489:   if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;}
  490:   my @names = @{ $Apache::response::foilgroup{'names'} };
  491:   my @truelist;
  492:   my @falselist;
  493:   my $result;  
  494:   my $name;
  495:   my $displayoptionintex=1;
  496:   my @alphabet = ('A'..'Z');
  497:   my @whichopt = &whichfoils($max,$randomize);
  498:   &check_for_invalid(\@whichopt,\@opt);
  499:   my $part=$Apache::inputtags::part;
  500:   my $id=$Apache::inputtags::response[-1];
  501:   my $break;
  502:   if ( ($target ne 'tex') &&
  503:        &Apache::response::show_answer() ) {
  504:     my $temp=1;
  505:     foreach $name (@whichopt) {
  506: 	my $text=$Apache::response::foilgroup{$name.'.text'};
  507:         my $lastresp;
  508:         unless ((($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurvey') || ($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurveycred')) && (defined($env{'form.grade_symb'}))) {
  509:             $lastresp = $Apache::lonhomework::history{"resource.$part.$id.submission"};
  510:         }
  511: 	my %lastresponse=&Apache::lonnet::str2hash($lastresp);
  512: 	my $lastopt=$lastresponse{$name};
  513: 	if ($text!~/^\s*$/) { $break='<br />'; }
  514: 	$result.=$break;
  515: 	if ($target eq 'web') {
  516: 	    my $value=$Apache::response::foilgroup{$name.'.value'};
  517: 	    if (!($text=~s|<drawoptionlist\s*/>|$value|)) {
  518: 		if ($text=~/^\s*$/) {
  519: 		    $text=$value.$text;
  520: 		} else {
  521: 		    $text='<b>'.$value.':</b> '.$text;
  522: 		}
  523: 	    } else {
  524:                 if (@whichopt > 1) {
  525:                     $text='&#149;'.$text;
  526:                 }
  527: 	    }
  528: 	    $result.=$text."\n";
  529: 	}
  530:       if ($Apache::lonhomework::type eq 'exam') {
  531: 	  $result.=&webbubbles(\@opt,\@alphabet,$temp,$lastopt);
  532:       }
  533:       $temp++;
  534:     }
  535:   } else {
  536:     my $temp=1;
  537:     my %lastresponse;
  538:     my $newvariation;
  539:     if ((($Apache::lonhomework::history{"resource.$part.type"} eq 'randomizetry') ||
  540:         ($Apache::lonhomework::type eq 'randomizetry')) &&
  541:         ($Apache::inputtags::status[-1] eq 'CAN_ANSWER')) {
  542:         if ($env{'form.'.$part.'.rndseed'} ne
  543:             $Apache::lonhomework::history{"resource.$part.rndseed"}) {
  544:             $newvariation = 1;
  545:         }
  546:     }
  547:     unless ($newvariation) {
  548:         %lastresponse=&Apache::lonnet::str2hash($Apache::lonhomework::history{"resource.$part.$id.submission"});
  549:     }
  550:     my $internal_counter=$Apache::lonxml::counter;
  551:     my $checkboxopt=&check_box_opt($target,$checkboxvalue,@opt);
  552:     if ($checkboxopt) {
  553:        $result.='<br />'.
  554:                 ($checkboxchoices?&mt('Choices: ').'<b>'.$opt[0].','.$opt[1].'</b>. ':'').
  555:                  &mt('Select all that are <b>[_1]</b>.',$checkboxopt);
  556:     }
  557:     foreach $name (@whichopt) {
  558:       my $text=$Apache::response::foilgroup{$name.'.text'};
  559:       if ($text!~/^\s*$/) {
  560: 	  if ($target eq 'tex') {
  561: 	      $break='\vskip 0 mm ';
  562: 	  } elsif ($target eq 'web') {
  563: 	      $break='<br />';
  564: 	  }
  565:       }
  566:       my $lastopt=$lastresponse{$name};
  567:       my $optionlist="<option></option>\n";
  568: 
  569:       if($target eq 'tex' and $env{'form.pdfFormFields'} eq 'yes'
  570:          && $Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
  571:           my $fieldname = $env{'request.symb'}.'&part_'.$Apache::inputtags::part.'&optionresponse'.'&HWVAL_'.$Apache::inputtags::response['-1'].':'.$temp;
  572:           $optionlist =  &Apache::lonxml::print_pdf_start_combobox($fieldname);
  573:       }
  574: 
  575:       foreach my $option (@opt) {
  576: 	  my $escopt=&HTML::Entities::encode($option,'\'"&<>');
  577:           if ($option eq $lastopt) {
  578:               if ($target eq 'tex' && $env{'form.pdfFormFields'} eq 'yes'
  579:                   && $Apache::inputtags::status[-1] eq 'CAN_ANSWER'
  580:                   && $Apache::lonhomework::type ne 'exam') {
  581:                   $optionlist .= &Apache::lonxml::print_pdf_add_combobox_option($option);
  582:               } else {
  583:                   $optionlist.="<option value='".$escopt."' selected=\"selected\">$option</option>\n";
  584:               }
  585:           } else {
  586:               if ($target eq 'tex' && $env{'form.pdfFormFields'} eq 'yes'
  587:                   && $Apache::inputtags::status[-1] eq 'CAN_ANSWER'
  588:                   && $Apache::lonhomework::type ne 'exam') {
  589:                   $optionlist .= &Apache::lonxml::print_pdf_add_combobox_option($option);
  590:               } else {
  591:                   $optionlist.="<option value='".$escopt."'>$option</option>\n";
  592:               }
  593:           }
  594:       }
  595:       if ($target ne 'tex') {
  596: 	  if ($Apache::lonhomework::type ne 'exam') {
  597: # we are on the web, this is not an exam, and the problem can be answered
  598:               if ($checkboxopt) {
  599: # generate checkboxes
  600:                   my $fieldname=$Apache::inputtags::response['-1'].':'.$temp;
  601:                   my $altopt=$opt[0];
  602:                   if ($opt[0] eq $checkboxopt) {
  603:                      $altopt=$opt[1];
  604:                   }
  605:                   my $defopt=$lastopt;
  606:                   unless ($defopt) { $defopt=$altopt; }
  607:                   my $escdefopt=&HTML::Entities::encode($defopt,'\'"&<>');
  608:                   my $esccheckboxopt=&HTML::Entities::encode($checkboxopt,'\'"&<>');
  609:                   my $escaltopt=&HTML::Entities::encode($altopt,'\'"&<>');
  610: # checkboxopt is how the box is labelled
  611: # altopt is the alternative option
  612: # lastopt is what the user submitted before
  613: # defopt is what the field is going to start out with: either previous choice or altopt
  614: # fieldname is this input field's name after HWVAL_
  615:                   $optionlist='<input type="hidden" name="HWVAL_'.$fieldname.'" value="'.$escdefopt.'" />'.
  616:                   '<input type="checkbox" name="HWCHK_'.$fieldname.'" onclick="javascript:if (this.form.elements[\'HWCHK_'.
  617:                   $fieldname.'\'].checked) { this.form.elements[\'HWVAL_'.$fieldname.'\'].value=\''.$esccheckboxopt.'\'; } else { this.form.elements[\'HWVAL_'.$fieldname.'\'].value=\''.$escaltopt.'\'; };setSubmittedPart(\''.$part.'\');"'.($defopt eq $checkboxopt?' checked="checked"':'')." />\n";
  618:               } else {
  619: # classic selection list
  620: 	          $optionlist='<select onchange="javascript:setSubmittedPart(\''.
  621: 		  $part.'\');" name="HWVAL_'.
  622: 		  $Apache::inputtags::response['-1'].':'.$temp.'">'.
  623: 		  $optionlist."</select>\n";
  624:               }
  625: 	  } else {
  626: 	      $optionlist='<u>'.('&nbsp;'x10).'</u>';
  627: 	  }
  628: 	  if ($text=~s|<drawoptionlist\s*/>|$optionlist|) {
  629: 	      if ($Apache::lonhomework::type ne 'exam') {
  630:                   if (@whichopt > 1) {  
  631:                       $text='&#149;'.$text;
  632:                   }
  633: 	      }
  634: 	  } else {
  635: 	      if ($Apache::lonhomework::type ne 'exam') {
  636: 		  $text=$optionlist.$text;
  637: 	      }
  638: 	  }
  639: 	  $result.=$break.$text."\n";
  640: 	  if ($Apache::lonhomework::type eq 'exam') {
  641: 	      $result.=&webbubbles(\@opt,\@alphabet,$temp,$lastopt);
  642: 	  }
  643: 	  $temp++;
  644:       } else {
  645: 	  my $texoptionlist='';
  646: 	  if ($displayoptionintex &&
  647: 	      $Apache::lonhomework::type ne 'exam') {
  648: 	      $texoptionlist = &optionlist_correction($TeXlayout,@opt);
  649: 	  }
  650: 	  if ($text=~/<drawoptionlist\s*\/>/) {
  651: 	      $text=~s|<drawoptionlist\s*\/>| \\makebox\[0\.3in\]\[b\]\{\\hrulefill\} |g;
  652: 	  }
  653: 
  654: 	  if ($text=~m/\\item /) {
  655: 	      if ($Apache::lonhomework::type eq 'exam') {
  656: 	          $text=~s/\\item/\\vskip 2 mm/;
  657: 	      } elsif ($env{'form.pdfFormFields'} ne 'yes') {
  658:                   $result.= $texoptionlist.$text;
  659:               }
  660:           } else {
  661: 	      if ($Apache::lonhomework::type eq 'exam') {
  662: 		  $result.= $texoptionlist.'  '.$text;
  663: 	      } elsif ($env{'form.pdfFormFields'} ne 'yes') {
  664: 		  if ($text=~/\S/) {
  665:                       $result.= $texoptionlist.'\vspace*{-2 mm}\item '.$text;
  666:                   } else {
  667:                       $result.= $texoptionlist;
  668:                   }
  669: 	      }
  670: 	  }
  671: 	  if ($Apache::lonhomework::type eq 'exam') {
  672: 	      $result.='\vskip -1 mm\noindent';
  673:               my ($numrows,$bubbles_per_row) = &getnumrows(scalar(@opt)); 
  674:               if ($numrows == 1) {  
  675:                   $result .= '\textbf{'.$internal_counter.'}. \vskip -3mm';
  676:               } else {
  677:                   my $linetext;
  678:                   for (my $i=0; $i<$numrows; $i++) {
  679:                       $linetext .= $internal_counter+$i.', ';
  680:                   }
  681:                   $linetext =~ s/,\s$//;
  682:                   $result .= '\small {\textbf{'.$linetext.'}} '.
  683:                              '\hskip 2 mm {\footnotesize '.
  684:                              &mt('(Bubble once in [_1] lines)',$numrows).
  685:                              '} \vskip 1 mm';
  686:               }
  687:               $result.= &bubbles(\@alphabet,\@opt,undef,undef,$numrows,
  688:                                  $bubbles_per_row,$internal_counter).
  689:                         ' \strut ';
  690: 	      $internal_counter += $numrows;
  691: 	  }
  692:           if ($target eq 'tex' && $env{'form.pdfFormFields'} eq 'yes'
  693:               && $Apache::inputtags::status[-1] eq 'CAN_ANSWER'
  694:               && $Apache::lonhomework::type ne 'exam') {
  695:               $text =~ s/\\item//m;
  696:               $result .= " $optionlist ". &Apache::lonxml::print_pdf_end_combobox($text).'\strut \\\\';
  697:               $temp++;
  698:           }
  699: 	  $displayoptionintex=0;
  700:       }
  701:     }
  702:   }
  703: 
  704:   if ($target eq 'web') {
  705:       my $data = [\@whichopt,'submissiongrading'];
  706:       my $questiontype;
  707:       if ($Apache::lonhomework::type eq 'randomizetry') {
  708:           $questiontype = $Apache::lonhomework::type,
  709:       }
  710:       &Apache::response::setup_prior_tries_hash(\&Apache::rankresponse::format_prior_answer,$data,$questiontype);
  711:   }
  712: 
  713:   if ($target ne 'tex') {
  714:       return $result.$break;
  715:   } else {
  716:       return $result;
  717:   }
  718: }
  719: 
  720: 
  721: sub optionlist_correction {
  722:     my ($TeXlayout,@options) = @_;
  723:     my $texoptionlist='\\item [] '.&mt('Choices:').' ';
  724:     if ($TeXlayout eq 'vertical') {$texoptionlist='\\item []';}
  725:     if (scalar(@options) > 0) {
  726: 	foreach my $option (@options) {
  727: 	    $texoptionlist.='{\bf '.
  728: 		&Apache::lonxml::latex_special_symbols($option).
  729: 		'}';
  730: 	    if ($TeXlayout eq 'vertical') {
  731: 		$texoptionlist.=' \vskip 0 mm ',
  732: 	    } else {
  733: 		$texoptionlist.=', ';
  734: 	    }
  735: 	}
  736: 	$texoptionlist=~s/, $//;
  737: 	if ($TeXlayout ne 'vertical') {$texoptionlist.='.';}
  738:     } else {
  739: 	if ($TeXlayout ne 'vertical') {$texoptionlist='\\item [] \\vskip -5 mm';}
  740:     }
  741:     return $texoptionlist;
  742: }
  743: 
  744: 
  745: sub webbubbles {
  746:     my ($ropt,$ralphabet,$temp,$lastopt)=@_;
  747:     my @opt=@$ropt; 
  748:     my @alphabet=@$ralphabet;
  749:     my $result='';
  750:     my $number_of_bubbles = $#opt + 1;
  751:     $result.= '<table border="1"><tr>';
  752:     for (my $ind=0;$ind<$number_of_bubbles;$ind++) {
  753: 	my $checked='';
  754: 	if ($lastopt eq $opt[$ind]) {
  755: 	    $checked=' checked="on" ';
  756: 	}
  757: 	$result.='<td><input type="radio" name="HWVAL_'.
  758: 	    $Apache::inputtags::response['-1'].':'.$temp.
  759: 	    '" value="'.$opt[$ind].'" '.$checked.' />';
  760: 	if ($alphabet[$ind]) {
  761: 	    $result.=$alphabet[$ind].': ';
  762: 	}
  763: 	$result.=$opt[$ind].'</td>';
  764:     }
  765:     $result.='</tr></table>';
  766:     return $result;
  767: }
  768: 
  769: 
  770: sub bubbles {
  771:     my ($ralphabet,$ropt,$response,$max_width,$numrows,$bubbles_per_row,
  772:         $internal_counter) = @_;
  773:     my @alphabet = @$ralphabet;
  774:     my @opt = @$ropt;
  775:     my ($result,$head,$line) =('','','');
  776:     my $number_of_bubbles = $#opt + 1;
  777:     my $current_length = 0;
  778:     my $textwidth;
  779:     if (defined($max_width)) {
  780: 	$textwidth=$max_width;
  781: 	&Apache::lonxml::debug("Max width passed in: $max_width");
  782:     } elsif ($env{'form.textwidth'} ne '') {
  783: 	$env{'form.textwidth'}=~/(\d+)/;
  784: 	$textwidth=$1;
  785: 	&Apache::lonxml::debug("Max width from form: $textwidth");
  786:     } else {
  787: 	$env{'form.textwidth'}=~/(\d*)\.?(\d*)/;
  788: 	$textwidth=$1.'.'.$2;
  789: 	&Apache::lonxml::debug("Max width defaults? $textwidth");
  790:     }
  791:     &Apache::lonxml::debug("Final maxwidth: $textwidth");
  792:     for (my $ind=0;$ind<=$number_of_bubbles;$ind++) {
  793:         my $item;
  794:         if ($numrows > 1) {
  795:             my $num = $internal_counter+int($ind/$bubbles_per_row);
  796:             my $idx = int($ind % $bubbles_per_row);
  797:             $item = $num.$alphabet[$idx];
  798:         } else {
  799:             $item = $alphabet[$ind];
  800:         }
  801: 	my $leftmargin;
  802: 	$opt[$ind]=&Apache::lonxml::latex_special_symbols($opt[$ind]);
  803: 	if ($response eq 'rankresponse') {$opt[$ind]='Rank '.$opt[$ind];}
  804: 	if ($ind==0) {$leftmargin=6;} else {$leftmargin=10;}
  805: 
  806: 	$current_length += (length($opt[$ind])+length($item)+4)*2;
  807:         
  808: 	if ($current_length<($textwidth-$leftmargin) and $ind!=$number_of_bubbles) {
  809:             
  810: 	    $line.='\hskip 4 mm {\small \textbf{'.$item.'}}$\bigcirc$\hskip -1 mm & \hskip -3 mm {\small '.$opt[$ind].'} & ';
  811: 	    $head.='lr';
  812: 	} else {
  813: 	    $line=~s/\&\s*$//;
  814: 	    $result.='\vskip -1 mm\noindent\setlength{\tabcolsep}{2 mm}\renewcommand{\arraystretch}{1.25}\begin{tabular}{'.$head.'}'.$line.'\\\\\end{tabular}\vskip 0 mm';
  815: 	    $line = '\hskip 4 mm {\small \textbf{'.$item.'}}$\bigcirc$\hskip -1 mm & \hskip -3 mm {\small '.$opt[$ind].'} & ';
  816: 	    $head ='lr';
  817: 	    $current_length = (length($opt[$ind])+length($item))*2;
  818: 	}
  819: 
  820:     }
  821:     return $result;
  822: }
  823: 
  824: sub start_conceptgroup {
  825:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  826:   $Apache::optionresponse::conceptgroup=1;
  827:   %Apache::response::conceptgroup=();
  828:   my $result;
  829:   if ($target eq 'edit') {
  830:     $result.=&Apache::edit::tag_start($target,$token,"Concept Grouped Foils");
  831:     $result.=&Apache::edit::text_arg('Concept:','concept',$token,'50').
  832:         &Apache::edit::end_row().&Apache::edit::start_spanning_row();
  833:   }
  834:   if ($target eq 'modified') {
  835:     my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'concept');
  836:     if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
  837:   }
  838:   return $result;
  839: }
  840: 
  841: sub end_conceptgroup {
  842:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  843:   $Apache::optionresponse::conceptgroup=0;
  844:   my $result='';
  845:   if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
  846:       $target eq 'tex' || $target eq 'analyze') {
  847:     #if not there aren't any foils to display and thus no question
  848:       &Apache::response::pick_foil_for_concept($target,
  849: 					       ['value','text','location'],
  850: 					       \%Apache::hint::option,
  851: 					       $parstack,$safeeval);
  852:   } elsif ($target eq 'edit') {
  853:     $result=&Apache::edit::end_table();
  854:   }
  855:   return $result;
  856: }
  857: 
  858: sub insert_conceptgroup {
  859:   my $result="\n\t\t<conceptgroup concept=\"\">".&insert_foil()."\n\t\t</conceptgroup>\n";
  860:   return $result;
  861: }
  862: 
  863: sub start_foil {
  864:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  865:   my $result='';
  866:   if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze' ) {
  867:       &Apache::lonxml::startredirection;
  868:       if ($target eq 'analyze') {
  869: 	  &Apache::response::check_if_computed($token,$parstack,$safeeval,'value');
  870:       }
  871:   } elsif ($target eq 'edit') {
  872:     $result=&Apache::edit::tag_start($target,$token,"Foil");
  873:     my $level='-2';
  874:     if ($$tagstack['-2'] eq 'conceptgroup') { $level = '-3'; }
  875:     my @opt;
  876:     eval '@opt ='.&Apache::lonxml::get_param('options',$parstack,$safeeval,$level);
  877:     $result.=&Apache::edit::text_arg('Name:','name',$token);
  878:     $result.= &Apache::edit::select_or_text_arg('Correct Option:','value',
  879: 					       ['unused',(@opt)],$token,'15');
  880:     my $randomize=&Apache::lonxml::get_param('randomize',$parstack,
  881: 					     $safeeval,'-3');
  882:     if ($randomize ne 'no') {
  883: 	$result.=&Apache::edit::select_arg('Location:','location',
  884: 					   ['random','top','bottom'],$token);
  885:     }
  886:     $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
  887:   } elsif ($target eq 'modified') {
  888:     my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,
  889: 						 'value','name','location');
  890:     if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
  891:   } 
  892:   return $result;
  893: }
  894: 
  895: sub end_foil {
  896:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  897:   my $text ='';
  898:   my $result = '';
  899:   if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') { 
  900:       $text=&Apache::lonxml::endredirection;
  901:       if ($target eq 'tex') {$text=~s/\\strut\s*\\\\\s*\\strut/\\vskip 0 mm/;}
  902:       if (($target eq 'tex') and ($Apache::lonhomework::type ne 'exam') and ($text=~/\S/)) {$text = '\vspace*{-2 mm}\item '.$text;} 
  903:   }
  904:   if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' 
  905:       || $target eq 'tex' || $target eq 'analyze') {
  906:     my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
  907:     if ($target eq 'tex' && $Apache::lonhomework::type eq 'exam') {
  908: 	$text='\vskip 5mm $\triangleright$ '.$text;
  909:     }
  910:     if ($value ne 'unused') {
  911:       my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
  912:       &Apache::lonxml::debug("Got a name of :$name:");
  913:       if ($name eq "") {
  914: 	  &Apache::lonxml::warning(&mt('Foils without names exist. This can cause problems to malfunction.'));
  915: 	  $name=$Apache::lonxml::curdepth;
  916:       }
  917:       &Apache::lonxml::debug("Using a name of :$name:");
  918:       if (defined($Apache::response::foilnames{$name})) {
  919: 	  &Apache::lonxml::error(&mt("Foil name [_1] appears more than once. Foil names need to be unique.",'<b><tt>'.$name.'</tt></b>'));
  920:       }
  921:       $Apache::response::foilnames{$name}++;
  922:       my $location =&Apache::lonxml::get_param('location',$parstack,$safeeval);
  923:       if ( $Apache::optionresponse::conceptgroup
  924: 	   && !&Apache::response::showallfoils() ) {
  925: 	push @{ $Apache::response::conceptgroup{'names'} }, $name;
  926: 	$Apache::response::conceptgroup{"$name.value"} = $value;
  927: 	$Apache::response::conceptgroup{"$name.text"} = $text;
  928: 	$Apache::response::conceptgroup{"$name.location"} = $location;
  929:       } else {
  930: 	push @{ $Apache::response::foilgroup{'names'} }, $name;
  931: 	$Apache::response::foilgroup{"$name.value"} = $value;
  932: 	$Apache::response::foilgroup{"$name.text"} = $text;
  933: 	$Apache::response::foilgroup{"$name.location"} = $location;
  934:       }
  935:     }
  936:   }
  937:   if ($target eq 'edit') {
  938:     $result.= &Apache::edit::tag_end($target,$token,'');
  939:   }
  940:   return $result;
  941: }
  942: 
  943: sub start_drawoptionlist {
  944:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  945:     if ($target !~ /^(?:meta|answer|modified|edit)$/) {
  946: 	return $token->[4];
  947:     }
  948: }
  949: 
  950: sub end_drawoptionlist {
  951:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  952:     if ($target !~ /^(?:meta|answer|modified|edit)$/) {
  953: 	return $token->[2];
  954:     }
  955: }
  956: 
  957: sub insert_foil {
  958:     return '
  959: <foil name="" value="unused">
  960: <startouttext />
  961: <endouttext />
  962: </foil>';
  963: }
  964: 
  965: sub insert_drawoptionlist {
  966:     return '<drawoptionlist />';
  967: }
  968: 
  969: sub getnumrows {
  970:     my ($numitems) = @_;
  971:     my $bubbles_per_row;
  972:     my $default_numbubbles = 10;
  973:     if (($env{'form.bubbles_per_row'} =~ /^\d+$/) &&
  974:         ($env{'form.bubbles_per_row'} > 0)) {
  975:         $bubbles_per_row = $env{'form.bubbles_per_row'};
  976:     } else {
  977:         $bubbles_per_row = $default_numbubbles;
  978:     }
  979:     my $numrows = int ($numitems/$bubbles_per_row);
  980:     if (($numitems % $bubbles_per_row) != 0) {
  981:         $numrows ++;
  982:     }
  983:     return ($numrows,$bubbles_per_row);
  984: }
  985: 
  986: 1;
  987: __END__
  988:  
  989: =head1 NAME
  990: 
  991: Apache::optionresponse.pm;
  992: 
  993: =head1 SYNOPSIS
  994: 
  995: Handles tags associated with showing a list of
  996: options.
  997: 
  998: This is part of the LearningOnline Network with CAPA project
  999: described at http://www.lon-capa.org.
 1000: 
 1001: =head1 HANDLER SUBROUTINE
 1002: 
 1003: start_optionresponse()
 1004: 
 1005: =head1 OTHER SUBROUTINES
 1006: 
 1007: =over
 1008: 
 1009: =item end_optionresponse()
 1010: 
 1011: =item start_foilgroup()
 1012: 
 1013: =item end_foilgroup()
 1014: 
 1015: =item getfoilcounts()
 1016: 
 1017: =item displayanswers()
 1018: 
 1019: =item check_for_invalid()
 1020: 
 1021: =item displayfoils()
 1022: 
 1023: =item optionlist_correction()
 1024: 
 1025: =item webbubbles()
 1026: 
 1027: =item bubbles()
 1028: 
 1029: =item start_conceptgroup()
 1030: 
 1031: =item end_conceptgroup()
 1032: 
 1033: =item insert_conceptgroup()
 1034: 
 1035: =item start_foil()
 1036: 
 1037: =item end_foil()
 1038: 
 1039: =item start_drawoptionlist()
 1040: 
 1041: =item end_drawoptionlist()
 1042: 
 1043: =item insert_foil()
 1044: 
 1045: =item insert_drawoptionlist()
 1046: 
 1047: =back
 1048: 
 1049: =cut

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>