[LON-CAPA-cvs] cvs: loncom /homework optionresponse.pm

www www@source.lon-capa.org
Fri, 05 Feb 2010 23:02:40 -0000


www		Fri Feb  5 23:02:40 2010 EDT

  Modified files:              
    /loncom/homework	optionresponse.pm 
  Log:
  Bug #2294: checkboxes for simple two-option optionresponses
  
  
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.161 loncom/homework/optionresponse.pm:1.162
--- loncom/homework/optionresponse.pm:1.161	Fri Feb  5 21:38:41 2010
+++ loncom/homework/optionresponse.pm	Fri Feb  5 23:02:39 2010
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.161 2010/02/05 21:38:41 www Exp $
+# $Id: optionresponse.pm,v 1.162 2010/02/05 23:02:39 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -123,10 +123,21 @@
         </td>
         <td>Delete an Option:
 	  <select name="$Apache::lonxml::curdepth.deleteopt">$optionlist</select>
+        </td>
 ENDTABLE
-    $result.= &Apache::edit::checked_arg('Print options:','texoptions',
+    $result.= '<td>'.&Apache::edit::checked_arg('Print options:','texoptions',
 					 [ ['nochoice','Don\'t show option list'] ]
-					 ,$token);
+					 ,$token).'</td>';
+    $result.= '<td><label>'.&mt('Two-option checkboxes for:').
+              '<select name="checkboxvalue_'.$Apache::lonxml::curdepth.'">';
+    foreach $option (('',@opt)) {
+       $result.='<option value="'.$option.'"';
+       if ($option eq &Apache::lonxml::get_param('checkboxvalue',$parstack,$safeeval)) {
+          $result.=' selected="selected"';
+       }
+       $result.='>'.$option.'</option>';
+    }
+    $result.='</select></label>';  
     $result.= &Apache::edit::end_row();
     $result.= &Apache::edit::start_spanning_row();
     $result.= $insertlist.'<br />';
@@ -151,7 +162,7 @@
       $optchanged=1;
     }
     my $rebuildtag = &Apache::edit::get_new_args($token,$parstack,$safeeval,
-						 ('texoptions'));
+						 'texoptions','checkboxvalue');
     if ($optchanged || $rebuildtag ) {
       $result = "<foilgroup options=\"(";
       foreach my $option (@options) {
@@ -162,6 +173,7 @@
       chop $result;
       $result.=')" ';
       $result .= 'texoptions="'.$token->[2]{'texoptions'}.'" ';
+      $result .= 'checkboxvalue="'.$token->[2]{'checkboxvalue'}.'"';
       $result .= '>';
     } # else nothing changed so just use the default mechanism
   }