[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm
banghart
lon-capa-cvs@mail.lon-capa.org
Sat, 27 Aug 2005 19:08:00 -0000
banghart Sat Aug 27 15:08:00 2005 EDT
Modified files:
/loncom/interface lonparmset.pm
Log:
Save instructor defined metadata now sort of works.
Still needs lots (error checking, formatting, etc.)
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.242 loncom/interface/lonparmset.pm:1.243
--- loncom/interface/lonparmset.pm:1.242 Fri Aug 26 20:03:32 2005
+++ loncom/interface/lonparmset.pm Sat Aug 27 15:07:58 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.242 2005/08/27 00:03:32 banghart Exp $
+# $Id: lonparmset.pm,v 1.243 2005/08/27 19:07:58 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2728,8 +2728,8 @@
sub setinstmeta {
my ($r)=@_;
my $next_meta;
- if ($env{'form.nextmeta'}) {
- $next_meta = $env{'form.nextmeta'};
+ if ($env{'form.serial'}) {
+ $next_meta = $env{'form.serial'};
} else {
$next_meta = 1;
}
@@ -2742,6 +2742,7 @@
'Set Instructor Metadata'));
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $key_base = $env{'course.'.$env{'request.course.id'}.'.metadata.'};
if ($env{'form.state'}eq 'add') {
$r->print('<strong>Compose a new metadata item:</strong><br />');
$r->print('<form method="post" action="/adm/parmset">');
@@ -2756,22 +2757,41 @@
$r->print('</form>');
} elsif ($env{'form.state'}eq 'save') {
$r->print('Here we save the metadata');
+ $key_base.=$env{'form.serial'}.'.';
+ $r->print('The title: '.$env{'form.title'}.'<br>');
+ $r->print('The values: '.$env{'form.values'}.'<br>');
+ $r->print('The type: '.$env{'form.type'}.'<br>');
+ $r->print('The number: '.$env{'form.serial'}.'<br>');
+ my $name = 'metadata.'.$env{'form.serial'}.'.title';
+ my $value = $env{'form.title'};
+ my $put_result = &Apache::lonnet::put('environment',
+ {$name=>$value},$dom,$crs);
+ $r->print('the put result was: '.$put_result.'<br />');
+ $name = 'metadata.'.$env{'form.serial'}.'.type';
+ $value = $env{'form.type'};
+ $put_result = &Apache::lonnet::put('environment',
+ {$name=>$value},$dom,$crs);
+ $name = 'metadata.'.$env{'form.serial'}.'.values';
+ $value = $env{'form.values'};
+ $put_result = &Apache::lonnet::put('environment',
+ {$name=>$value},$dom,$crs);
+ &Apache::lonnet::coursedescription($env{'request.course.id'});
} else {
+ my $found_one = 0;
foreach my $key (sort keys %env) {
- my $found_one = 0;
- if ($key=~m/^course\.$env{'request.course.id'}\.metadata\.title/) {
- unless ($found_one) {
+ if ($key=~m/^course\.$env{'request.course.id'}\.metadata\.\d+\.title$/) {
+ unless ($found_one eq 1) {
$found_one = 1;
$r->print('<strong>Existing Metadata</strong><br >');
}
$r->print($env{$key}.'<br />');
- $key=~~m/^course\.$env{'request.course.id'}\.metadata\.title\.(d*)\./;
+ $key=~m/^course\.$env{'request.course.id'}\.metadata\.(\d+)\.title/;
if ($1 ge $next_meta) {
- $next_meta = $1 ++;
+ $next_meta = $1 + 1;
}
}
}
- $r->print('<a href="/adm/parmset?action=setinstmeta&state=add&nextmeta='.$next_meta.'">Add Metadata Item</a><br />');
+ $r->print('<a href="/adm/parmset?action=setinstmeta&state=add&serial='.$next_meta.'">Add Metadata Item</a><br />');
}
$r->print('</body>
</html>');
@@ -2962,7 +2982,7 @@
'pres_marker',
'pres_value',
'pres_type',
- 'udom','uname','symb']);
+ 'udom','uname','symb','serial']);
&Apache::lonhtmlcommon::clear_breadcrumbs();