--- loncom/interface/lonparmset.pm 2005/09/28 13:29:17 1.252
+++ loncom/interface/lonparmset.pm 2005/09/28 23:19:25 1.253
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.252 2005/09/28 13:29:17 banghart Exp $
+# $Id: lonparmset.pm,v 1.253 2005/09/28 23:19:25 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2751,33 +2751,34 @@ ENDMAINFORMHEAD
}
### Set instructor defined metadata
sub output_row {
- my ($field_name) = @_;
+ my ($r, $field_name) = @_;
my $output;
- my $meta_hash_ref=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name};
- my $values=$$meta_hash_ref{'values'};
+ 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 $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
my $checked;
- unless (defined($$meta_hash_ref{'active'})) {
- $$meta_hash_ref{'active'} = 'no';
- $$meta_hash_ref{'stu_add_values'} = 'yes';
- $$meta_hash_ref{'values'} = 'Type a list of values separated by commas.';
- $$meta_hash_ref{'stu_pick_many'} = 'yes';
+ unless (defined($active)) {
+ $active = 'no';
+ $stuadd = 'yes';
+ $values = 'Type a list of values separated by commas.';
+ $onlyone = 'no';
}
$output.='
'.$field_name.' | ';
- $output.=' | ';
- if ($$meta_hash_ref{'stu_add_values'}eq'yes') {
+ $output.=' | ';
+ if ($onlyone eq 'no') {
$checked = ' CHECKED ';
} else {
$checked = ' ';
}
- $output.=' | ';
- if ($$meta_hash_ref{'stu_pick_many'}eq'yes') {
+ $output.=' | ';
+ if ($stuadd eq 'yes') {
$checked = ' CHECKED ';
} else {
$checked = ' ';
}
- $output.=' | ';
+ $output.=' | ';
$output.='
';
-
return ($output);
}
sub setinstmeta {
@@ -2797,46 +2798,48 @@ 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 %meta_hash;
+ my $stuadd;
+ my $onlyone;
+ my $active;
if ($env{'form.instmeta'}) {
foreach my $field (sort %env) {
if ($field=~m/^form.(.+)_(.+)$/) {
my $meta_field = $1;
my $meta_key = $2;
- if ($save_field eq $meta_field) {
- %meta_hash = {$meta_key=>[$env{$field}]};
- } else {
- if ($save_field ne '') {
- %meta_hash = {active=>'yes'};
- my $value = \%meta_hash;
- my $name = $save_field;
- $r->print('Saving '.$name.' meta
');
- $put_result = &Apache::lonnet::put('environment',
- {$name=>$value},$dom,$crs);
- }
+ if ($save_field ne $meta_field) {
$save_field = $meta_field;
- %meta_hash = {$meta_key=>[$env{$field}]};
+ if ($env{'form.'.$meta_field.'_stuadd'}) {
+ $stuadd='yes';
+ } else {
+ $stuadd='no';
+ }
+ if ($env{'form.'.$meta_field.'_onlyone'}) {
+ $onlyone='no';
+ } else {
+ $onlyone='yes';
+ }
+ $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.'.values'=>$env{'form.'.$meta_field.'_values'},
+ },$dom,$crs);
}
}
-
-
}
- %meta_hash = {active=>'yes'};
- my $value = \%meta_hash;
- my $name = $save_field;
- $r->print('Saving '.$name.' meta
');
- $put_result = &Apache::lonnet::put('environment',
- {$name=>$value},$dom,$crs);
+
}
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);
+ # $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'};
@@ -2845,33 +2848,14 @@ sub setinstmeta {
allow_type=>'no'};
my $value = \%meta_hash;
- $put_result = &Apache::lonnet::put('environment',
- {$name=>$value},$dom,$crs);
+ # $put_result = &Apache::lonnet::put('environment',
+ # {$name=>$value},$dom,$crs);
}
}
&Apache::lonnet::coursedescription($env{'request.course.id'});
- $output.= &output_row("Title");
- $output.= &output_row("Subject");
- $output.= &output_row("Keywords");
-# foreach my $key (sort keys %env) {
-# if ($key=~m/^course\.$env{'request.course.id'}\.metadata\.(.+)$/) {
-# my $meta_data_item = $1;
-# my $meta_hash=$env{$key};
-# # keys are 'values', stu_pick_many, stu_add_values, active
-#
-# $output.=''.$meta_data_item.' | ';
-# $output.='Select one: ';
-# $output.='Select many: | ';
-# $output.=' |
';
-# }
-# }
-# $output.='Create new instructor metadata item ';
-# $output.=' | ';
-# $output.='students must pick only one: ';
-# $output.='Allow student to type extra info: | ';
-# $output.=' |
';
-# $output.='';
-# $output.='';
+ $output.= &output_row($r, "Title");
+ $output.= &output_row($r, "Subject");
+ $output.= &output_row($r, "Keywords");
$r->print(<