[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm
banghart
lon-capa-cvs@mail.lon-capa.org
Thu, 29 Sep 2005 21:10:33 -0000
banghart Thu Sep 29 17:10:33 2005 EDT
Modified files:
/loncom/interface lonparmset.pm
Log:
Single key for metadata options (active, stuadd, onlyone),
remove useless code.
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.253 loncom/interface/lonparmset.pm:1.254
--- loncom/interface/lonparmset.pm:1.253 Wed Sep 28 19:19:25 2005
+++ loncom/interface/lonparmset.pm Thu Sep 29 17:10:32 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.253 2005/09/28 23:19:25 banghart Exp $
+# $Id: lonparmset.pm,v 1.254 2005/09/29 21:10:32 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2753,31 +2753,28 @@
sub output_row {
my ($r, $field_name) = @_;
my $output;
- my $active=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.active'};
- my $onlyone=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.onlyone'};
- my $stuadd=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.stuadd'};
+ my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
my $checked;
- unless (defined($active)) {
- $active = 'no';
- $stuadd = 'yes';
+ unless (defined($options)) {
+ $options = 'active,stuadd';
$values = 'Type a list of values separated by commas.';
- $onlyone = 'no';
}
$output.='<tr><td><strong>'.$field_name.'</strong></td>';
$output.='<td><input name="'.$field_name.'_values" type="text" value="'.$values.'" /></td>';
- if ($onlyone eq 'no') {
+ if ($options =~ m/onlyone/) {
$checked = ' CHECKED ';
} else {
- $checked = ' ';
+ $checked = ' ';
}
$output.='<td><center><input type="checkbox" name="'.$field_name.'_onlyone"" value="yes"'.$checked.' /></center></td>';
- if ($stuadd eq 'yes') {
+ if ($options =~ m/stuadd/) {
$checked = ' CHECKED ';
} else {
$checked = ' ';
}
$output.='<td><input type="checkbox" name="'.$field_name.'_stuadd" value="yes"'.$checked.' /></td>';
+
$output.='</tr>';
return ($output);
}
@@ -2798,32 +2795,26 @@
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
my $key_base = $env{'course.'.$env{'request.course.id'}.'.metadata.'};
my $save_field = '';
- my $stuadd;
- my $onlyone;
- my $active;
if ($env{'form.instmeta'}) {
- foreach my $field (sort %env) {
+ foreach my $field (sort(keys(%env))) {
if ($field=~m/^form.(.+)_(.+)$/) {
+ my $options;
my $meta_field = $1;
my $meta_key = $2;
if ($save_field ne $meta_field) {
$save_field = $meta_field;
if ($env{'form.'.$meta_field.'_stuadd'}) {
- $stuadd='yes';
- } else {
- $stuadd='no';
- }
+ $options.='stuadd,';
+ }
if ($env{'form.'.$meta_field.'_onlyone'}) {
- $onlyone='no';
- } else {
- $onlyone='yes';
+ $options.='onlyone,';
+ }
+ if ($env{'form.'.$meta_field.'_active'}) {
+ $options.='active,';
}
- $active='yes';
my $name = 'metadata.'.$save_field;
$put_result = &Apache::lonnet::put('environment',
- {'metadata.'.$meta_field.'.stuadd'=>$stuadd,
- 'metadata.'.$meta_field.'.onlyone'=>$onlyone,
- 'metadata.'.$meta_field.'.active'=>$active,
+ {'metadata.'.$meta_field.'.options'=>$options,
'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
},$dom,$crs);
}
@@ -2831,27 +2822,6 @@
}
}
- foreach my $field (%env) {
- # start by looking for populated fields
- if ($field=~m/type(\d+)/) {
- my $name;
- my $value;
- # $put_result = &Apache::lonnet::put('environment',
- # {$name=>$value},$dom,$crs);
- # $put_result = &Apache::lonnet::put('environment',
- # {$name=>$value},$dom,$crs);
- }
- if ($field=~m/newfield/) {
- 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);
- }
- }
&Apache::lonnet::coursedescription($env{'request.course.id'});
$output.= &output_row($r, "Title");
$output.= &output_row($r, "Subject");