[LON-CAPA-cvs] cvs: loncom /interface lonmeta.pm
banghart
lon-capa-cvs@mail.lon-capa.org
Mon, 17 Oct 2005 21:36:47 -0000
banghart Mon Oct 17 17:36:47 2005 EDT
Modified files:
/loncom/interface lonmeta.pm
Log:
Create separate fieldname sets for non-course restricted metadata
and restricted metadata.
Read courses from %env where restricted are defined, and
display choice of courses. Not working yet.
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.112 loncom/interface/lonmeta.pm:1.113
--- loncom/interface/lonmeta.pm:1.112 Fri Oct 14 12:34:17 2005
+++ loncom/interface/lonmeta.pm Mon Oct 17 17:36:44 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.112 2005/10/14 16:34:17 banghart Exp $
+# $Id: lonmeta.pm,v 1.113 2005/10/17 21:36:44 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -237,8 +237,25 @@
# The field names
sub fieldnames {
my $file_type=shift;
- my %fields =
- ('metadata.title' => 'Title',
+ my %fields;
+ if ($file_type eq 'portfolio') {
+ %fields =
+ (%fields,
+ 'title' => 'Title',
+ 'author' =>'Author(s)',
+ 'authorspace' => 'Author Space',
+ 'modifyinguser' => 'Last Modifying User',
+ 'subject' => 'Subject',
+ 'keywords' => 'Keyword(s)',
+ 'notes' => 'Notes',
+ 'abstract' => 'Abstract',
+ 'lowestgradelevel' => 'Lowest Grade Level',
+ 'highestgradelevel' => 'Highest Grade Level');
+ }
+ if ($file_type eq 'restrictedportfolio') {
+ %fields =
+ (%fields,
+ 'metadata.title' => 'Title',
'metadata.author' =>'Author(s)',
'metadata.authorspace' => 'Author Space',
'metadata.modifyinguser' => 'Last Modifying User',
@@ -248,6 +265,7 @@
'metadata.abstract' => 'Abstract',
'metadata.lowestgradelevel' => 'Lowest Grade Level',
'metadata.highestgradelevel' => 'Highest Grade Level');
+ }
if (! defined($file_type) || $file_type ne 'portfolio') {
%fields =
(%fields,
@@ -290,40 +308,32 @@
sub select_course {
my ($r)=@_;
- my @courses;
+ my %courses;
foreach my $key (keys (%env)) {
-
- if ($key =~ m/^(course\..+)\.metadata\..+\.options/) {
- my $course_key = $1;
- $course_key .= '.description';
- $r->print($env{$course_key}.' of '.$course_key.'<br />');
- push @courses, $key;
+ if ($key =~ m/\.metadata\./) {
+ $key =~ m/^course\.(.+)(\.metadata.+$)/;
+ my $course = $1;
+ my $coursekey = 'course.'.$course.'.description';
+ my $value = $env{$coursekey};
+ $courses{$coursekey} = $value;
}
}
- foreach (@courses) {
- $r->print($_.' was found<br />');
- }
- $r->print('<h3>Portfolio Meta-Data</h3><br />');
+ $r->print('<h3>Course Related Meta-Data</h3><br />');
$r->print('<form action="" method="post">');
$r->print('Select your test course<br />');
$r->print('<select name="metacourse" >');
my $meta_not_found = 1;
- foreach my $key (keys (%env)) {
-
- if ($key =~ /\.metadata\./) {
- if ($meta_not_found) {
- undef($meta_not_found);
- $r->print('<h3>Portfolio Meta-Data</h3><br />');
- $r->print('<form action="" method="post">');
- $r->print('Select your course<br />');
- $r->print('<select name="metacourse" >');
- }
- my $course_key = $key;
- $course_key =~ s/\.metadata\..*//;
- $r->print('<option value="'.$course_key.'">');
- $r->print($env{$course_key.'.description'});
- $r->print('</option>');
- }
+ foreach my $key (keys (%courses)) {
+ if ($meta_not_found) {
+ undef($meta_not_found);
+ $r->print('<h3>Portfolio Meta-Data</h3><br />');
+ $r->print('<form action="" method="post">');
+ $r->print('Select your course<br />');
+ $r->print('<select name="metacourse" >');
+ }
+ $r->print('<option value="'.$key.'">');
+ $r->print($courses{$key});
+ $r->print('</option>');
}
unless ($meta_not_found) {
$r->print('</select><br />');
@@ -1015,7 +1025,7 @@
my $output;
my @fields;
if ($file_type eq 'portfolio') {
- @fields = ('author','metadata.title','metadata.subject','metadata.keywords','abstract','notes','lowestgradelevel',
+ @fields = ('author','title','subject','keywords','abstract','notes','lowestgradelevel',
'highestgradelevel');
} else {
@fields = ('author','title','subject','keywords','abstract','notes',