[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm

banghart lon-capa-cvs@mail.lon-capa.org
Wed, 14 Sep 2005 17:56:27 -0000


banghart		Wed Sep 14 13:56:27 2005 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  	Changing instructor defined metadata. (check boxes for
  	select one/many, student add items) and saving as 
  	hash. Not at all done. Saving work in progress.
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.249 loncom/interface/lonparmset.pm:1.250
--- loncom/interface/lonparmset.pm:1.249	Fri Sep  2 18:36:38 2005
+++ loncom/interface/lonparmset.pm	Wed Sep 14 13:56:25 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.249 2005/09/02 22:36:38 albertel Exp $
+# $Id: lonparmset.pm,v 1.250 2005/09/14 17:56:25 banghart Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2752,11 +2752,6 @@
     my $output;
     my $item_num;
     my $put_result;
-    if ($env{'form.serial'}) {
-        $next_meta = $env{'form.serial'};
-    } else {
-        $next_meta = 1;
-    }
     $r->print(&Apache::lonxml::xmlbegin());
     $r->print('<head>
             <title>LON-CAPA Set Instructor Metadata</title>
@@ -2770,54 +2765,39 @@
     foreach my $field (%env) {
         # start by looking for populated fields
         if ($field=~m/type(\d+)/) {
-            my $item_num = $1;
-            my $name = 'metadata.'.$item_num.'.type';
-            my $value = $env{'form.type'.$item_num};
+	    	my $name;
+    		my $value;
             $put_result = &Apache::lonnet::put('environment',
                                                   {$name=>$value},$dom,$crs);
-            $name = 'metadata.'.$item_num.'.values';
-            $value = $env{'form.values'.$item_num};
             $put_result = &Apache::lonnet::put('environment',
                                                   {$name=>$value},$dom,$crs);
         }
         if ($field=~m/newfield/) {
-            my $item_num = $env{'form.serial'};
-            my $name = 'metadata.'.$item_num.'.type';
-            my $value = $env{'form.typenew'};
-            $put_result = &Apache::lonnet::put('environment',
-                                                  {$name=>$value},$dom,$crs);
-            $name = 'metadata.'.$item_num.'.values';
-            $value = $env{'form.valuesnew'};
+            my $name = 'metadata.'.$env{'form.titlenew'};
+            my %meta_hash = {values=>[$env{'form.valuesnew'}],
+            				allow_pick=>'many',
+            				allow_type=>'no'};
+            				
+            my $value = \%meta_hash;
             $put_result = &Apache::lonnet::put('environment',
                                                   {$name=>$value},$dom,$crs);
-            $name = 'metadata.'.$item_num.'.title';
-            $value = $env{'form.titlenew'};
-            $put_result = &Apache::lonnet::put('environment',
-                                                  {$name=>$value},$dom,$crs);
-            
         }
-        
-              
     } 
     &Apache::lonnet::coursedescription($env{'request.course.id'});      
     foreach my $key (sort keys %env) {
-        if ($key=~m/^course\.$env{'request.course.id'}\.metadata\.\d+\.title$/) {
-            $key=~m/(^course\.$env{'request.course.id'}\.metadata\.)(\d+)\.title/;
-            $key_base = $1;
-            $item_num = $2;
-            if ($item_num ge $next_meta) {
-                $next_meta = $item_num + 1;
-            }
-            $output.='<tr><td>'.$env{$key}.'</td>';
-            $output.='<td>Select one: <input type="radio" name="type'.$item_num.'" value="one" /><br />';
-            $output.='Select many: <input type="radio" name="type'.$item_num.'" value="many" /></td>';
-            $output.='<td><input name="values'.$item_num.'" type="text" value="'.$env{$key_base.$item_num.'.values'}.'" /></td></tr>';
+        if ($key=~m/^course\.$env{'request.course.id'}\.metadata\.(.+)$/) {
+            my $meta_data_item = $1;
+            my $meta_hash=$env{$key};
+            $output.='<tr><td>'.$meta_data_item.'</td>';
+            $output.='<td>Select one: <input type="checkbox" name="" value="one" /><br />';
+            $output.='Select many: <input type="checkbox" name="type" value="many" /></td>';
+            $output.='<td><input name="values" type="text" value="$env{$key_base.$item_num.'.'" /></td></tr>';
         }
     }
     $output.='<tr><td><i>Create new instructor metadata item</i><br />';
     $output.='<input type="text" name="titlenew" /></td>';
-    $output.='<td>Select one: <input type="radio" name="typenew" value="one" /><br />';
-    $output.='Select many: <input type="radio" name="typenew" value="many" /></td>';
+    $output.='<td>students must pick only one: <input type="checkbox" name="pickonenew" value="one" /><br />';
+    $output.='Allow student to type extra info: <input type="checkbox" name="typeextranew" value="extra" /></td>';
     $output.='<td><input name="valuesnew" type="text" value="" /></td></tr>';
     $output.='<input type="hidden" name="serial" value="'.$next_meta.'" />';
     $output.='<input type="hidden" name="state" value="save" /></tr>';