--- loncom/interface/lonparmset.pm 2003/06/19 21:49:53 1.103 +++ loncom/interface/lonparmset.pm 2003/06/20 14:56:09 1.106 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.103 2003/06/19 21:49:53 albertel Exp $ +# $Id: lonparmset.pm,v 1.106 2003/06/20 14:56:09 www 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); @@ -1496,7 +1509,7 @@ sub crsenv { 'Modifying this will make problems '. 'have different numbers and answers', 'problem_stream_switch' - => 'Allow problems to be splitted over pages
'. + => 'Allow problems to be split over pages
'. ' (yes if allow anything else if not)' ); foreach (keys(%values)) { @@ -1593,12 +1606,13 @@ sub handler { } &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); - $r->content_type('text/html'); - $r->send_http_header; # ----------------------------------------------------- Needs to be in a course if (($ENV{'request.course.id'}) && (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) { + + $r->content_type('text/html'); + $r->send_http_header; $coursename=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};