--- loncom/interface/lonparmset.pm 2003/06/20 14:21:03 1.104
+++ loncom/interface/lonparmset.pm 2003/06/20 14:34:04 1.105
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.104 2003/06/20 14:21:03 matthew Exp $
+# $Id: lonparmset.pm,v 1.105 2003/06/20 14:34:04 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1371,7 +1371,7 @@ ENDMAPONE
=item crsenv
-Show course data and parameters. This is a large routine that should
+Show and set course data and parameters. This is a large routine that should
be simplified and shortened... someday.
Inputs: $r
@@ -1389,50 +1389,63 @@ sub crsenv {
'Set Course Environment Parameters');
my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
-# -------------------------------------------------- Go through list of changes
+
+ #
+ # Go through list of changes
foreach (keys %ENV) {
- if ($_=~/^form\.(.+)\_setparmval$/) {
- my $name=$1;
- my $value=$ENV{'form.'.$name.'_value'};
- if ($name eq 'newp') {
- $name=$ENV{'form.newp_name'};
- }
- if ($name eq 'url') {
- $value=~s/^\/res\///;
- my $bkuptime=time;
- my @tmp = &Apache::lonnet::get
- ('environment',['url'],$dom,$crs);
- $setoutput.='Backing up previous URL: '.
- &Apache::lonnet::put
- ('environment',
- {'top level map backup '.$bkuptime => $tmp[1] },
- $dom,$crs).
- '
';
+ next if ($_!~/^form\.(.+)\_setparmval$/);
+ my $name = $1;
+ my $value = $ENV{'form.'.$name.'_value'};
+ if ($name eq 'newp') {
+ $name = $ENV{'form.newp_name'};
+ }
+ if ($name eq 'url') {
+ $value=~s/^\/res\///;
+ my $bkuptime=time;
+ my @tmp = &Apache::lonnet::get
+ ('environment',['url'],$dom,$crs);
+ $setoutput.='Backing up previous URL: '.
+ &Apache::lonnet::put
+ ('environment',
+ {'top level map backup '.$bkuptime => $tmp[1] },
+ $dom,$crs).
+ '
';
+ }
+ #
+ # Deal with modified default spreadsheets
+ if ($name =~ /^spreadsheet_default_(classcalc|
+ studentcalc|
+ assesscalc)$/x) {
+ my $sheettype = $1;
+ if ($sheettype eq 'classcalc') {
+ # no need to do anything since viewing the sheet will
+ # cause it to be updated.
+ } elsif ($sheettype eq 'studentcalc') {
+ # expire all the student spreadsheets
+ &Apache::lonnet::expirespread('','','studentcalc');
+ } else {
+ # expire all the assessment spreadsheets
+ # this includes non-default spreadsheets, but better to
+ # be safe than sorry.
+ &Apache::lonnet::expirespread('','','assesscalc');
+ # expire all the student spreadsheets
+ &Apache::lonnet::expirespread('','','studentcalc');
}
- if ($name =~ /^spreadsheet_default_(classcalc|
- studentcalc|
- assesscalc)$/x) {
- my $sheettype = $1;
- if ($sheettype eq 'classcalc') {
- # no need to do anything since viewing the sheet will
- # cause it to be updated.
- } elsif ($sheettype eq 'studentcalc') {
- # expire all the student spreadsheets
- &Apache::lonnet::expirespread('','','studentcalc');
- } else {
- # expire all the default assessment spreadsheets
- }
+ }
+ #
+ # Let the user know we made the changes
+ if ($name) {
+ my $put_result = &Apache::lonnet::put('environment',
+ {$name=>$value},$dom,$crs);
+ if ($put_result eq 'ok') {
+ $setoutput.='Set '.$name.' to '.$value.'.
';
+ } else {
+ $setoutput.='Unable to set '.$name.' to '.
+ ''.$value.' due to '.$put_result.'.
';
}
-
- if ($name) {
- $setoutput.='Setting '.$name.' to '.
- $value.': '.
- &Apache::lonnet::put
- ('environment',{$name=>$value},$dom,$crs).
- '
';
- }
}
}
+
# -------------------------------------------------------- Get parameters again
my %values=&Apache::lonnet::dump('environment',$dom,$crs);