--- loncom/interface/lonparmset.pm 2005/09/28 23:19:25 1.253
+++ loncom/interface/lonparmset.pm 2005/09/29 21:10:32 1.254
@@ -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 @@ ENDMAINFORMHEAD
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.='
'.$field_name.' | ';
$output.=' | ';
- if ($onlyone eq 'no') {
+ if ($options =~ m/onlyone/) {
$checked = ' CHECKED ';
} else {
- $checked = ' ';
+ $checked = ' ';
}
$output.=' | ';
- if ($stuadd eq 'yes') {
+ if ($options =~ m/stuadd/) {
$checked = ' CHECKED ';
} else {
$checked = ' ';
}
$output.=' | ';
+
$output.='
';
return ($output);
}
@@ -2798,32 +2795,26 @@ sub setinstmeta {
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 @@ sub setinstmeta {
}
}
- 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");