[LON-CAPA-cvs] cvs: loncom /interface lonmeta.pm
banghart
lon-capa-cvs@mail.lon-capa.org
Fri, 18 Nov 2005 23:47:33 -0000
banghart Fri Nov 18 18:47:33 2005 EDT
Modified files:
/loncom/interface lonmeta.pm
Log:
Handle "student can type" along with instructor defined lists.
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.127 loncom/interface/lonmeta.pm:1.128
--- loncom/interface/lonmeta.pm:1.127 Tue Nov 15 14:20:12 2005
+++ loncom/interface/lonmeta.pm Fri Nov 18 18:47:33 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.127 2005/11/15 19:20:12 banghart Exp $
+# $Id: lonmeta.pm,v 1.128 2005/11/18 23:47:33 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -483,9 +483,13 @@
if (! defined($size)) {
$size = 80;
}
+ my $output;
if (defined($course_key)) {
my $stu_add;
my $only_one;
+ my %meta_options;
+ my @cur_values_inst;
+ my $cur_values_stu;
my $values = $env{$course_key.'.metadata.'.$_.'.values'};
if ($env{$course_key.'.metadata.'.$_.'.options'} =~ m/stuadd/) {
$stu_add = 'true';
@@ -493,6 +497,22 @@
if ($env{$course_key.'.metadata.'.$_.'.options'} =~ m/onlyone/) {
$only_one = 'true';
}
+ # need to take instructor values out of list where instructor and student
+ # values may be mixed.
+ if ($values && $stu_add) {
+ foreach (split(/,/,$values)) {
+ $_ =~ s/^\s+//;
+ $meta_options{$_} = $_;
+ }
+ foreach (split(/,/,$value)) {
+ $_ =~ s/^\s+//;
+ if ($meta_options{$_}) {
+ push(@cur_values_inst,$_);
+ } else {
+ $cur_values_stu .= $_.',';
+ }
+ }
+ }
if ($type eq 'author') {
return
'<input type="text" name="'.$fieldname.'" size="'.$size.'" '.
@@ -511,21 +531,18 @@
if ($type eq 'subject') {
}
if ($type eq 'keywords') {
- my %hash;
- my @cur_values;
- foreach (split(/,/,$value)) {
- $_ =~ s/^\s+//;
- push(@cur_values,$_);
- }
- foreach (split(/,/,$values)) {
- $_ =~ s/^\s+//;
- $hash{$_} = $_;
- }
if ($only_one) {
- return(&Apache::loncommon::select_form($value,'new_keywords',%hash));
+ $output .= (&Apache::loncommon::select_form($value,'new_keywords',%meta_options));
} else {
- return (&Apache::loncommon::multiple_select_form('new_keywords',\@cur_values,undef,\%hash));
+ $output .= (&Apache::loncommon::multiple_select_form('new_keywords',\@cur_values_inst,undef,\%meta_options));
+ }
+ if ($stu_add) {
+ $output .= '<input type="text" name="'.$fieldname.'" size="'.$size.'" '.
+ 'value="'.$cur_values_stu.'" />'.
+ &relatedfield(1,$relatedsearchflag,$relatedsep,$fieldname,
+ $relatedvalue);
}
+ return ($output);
}
if ($type eq 'notes') {
}