--- loncom/interface/lonparmset.pm 2003/04/04 20:38:36 1.86 +++ 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.86 2003/04/04 20:38:36 bowersj2 Exp $ +# $Id: lonparmset.pm,v 1.106 2003/06/20 14:56:09 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -56,6 +56,7 @@ package Apache::lonparmset; use strict; use Apache::lonnet; use Apache::Constants qw(:common :http REDIRECT); +use Apache::lonhtmlcommon(); use Apache::loncommon; use GDBM_File; use Apache::lonhomework; @@ -284,16 +285,14 @@ sub plink { sub startpage { - my ($r,$id,$udom,$csec,$uname)=@_; - $r->content_type('text/html'); - $r->send_http_header; - + my ($r,$id,$udom,$csec,$uname,$have_assesments)=@_; + my $bodytag=&Apache::loncommon::bodytag('Set Course Parameters','', 'onUnload="pclose()"'); my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. &Apache::loncommon::selectstudent_link('parmform','uname','udom'); my $selscript=&Apache::loncommon::studentbrowser_javascript(); - + my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); $r->print(< @@ -306,15 +305,7 @@ sub startpage { parmwin.close(); } - function pjump(type,dis,value,marker,ret,call) { - document.parmform.pres_marker.value=''; - parmwin=window.open("/adm/rat/parameter.html?type="+escape(type) - +"&value="+escape(value)+"&marker="+escape(marker) - +"&return="+escape(ret) - +"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms", - "height=350,width=350,scrollbars=no,menubar=no"); - - } + $pjump_def function psub() { pclose(); @@ -350,12 +341,24 @@ sub startpage { $selscript $bodytag +

Course Environment

+

Course Assessments

+ +Use Assignment Parameter Helper, a +simpler interface to set open, due, or answer open dates for problems or +sequences.
 
+ENDHEAD + + if (!$have_assesments) { + $r->print('There are no assesment parameters in this course to set.
'); + } else { + $r->print(< Section/Group: @@ -371,7 +374,7 @@ $chooseopt ENDHEAD - + } } sub print_row { @@ -692,12 +695,12 @@ sub assessparms { my $url=$ENV{'form.url'}; $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; $pssymb=&Apache::lonnet::symbread($url); - @pscat='all'; + if (!@pscat) { @pscat=('all'); } $pschp=''; $parmlev = 'full'; } elsif ($ENV{'form.symb'}) { $pssymb=$ENV{'form.symb'}; - @pscat='all'; + if (!@pscat) { @pscat=('all'); } $pschp=''; $parmlev = 'full'; } else { @@ -725,8 +728,8 @@ sub assessparms { "Unknown user '$uname' at domain '$udom'"; $uname=''; } else { - $csec=&Apache::lonnet::usection($udom,$uname, - $ENV{'request.course.id'}); + $csec=&Apache::lonnet::getsection($udom,$uname, + $ENV{'request.course.id'}); if ($csec eq '-1') { $message="". "User '$uname' at domain '$udom' not ". @@ -766,6 +769,7 @@ sub assessparms { $mapp{'0.0'} = ''; $symbp{'0.0'} = ''; + # ---------------------------------------------------------- Anything to store? if ($ENV{'form.pres_marker'}) { my ($sresid,$spnam,$snum)=split(/\&/,$ENV{'form.pres_marker'}); @@ -882,7 +886,12 @@ sub assessparms { if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);} # ------------------------------------------------------------------ Start page - &startpage($r,$id,$udom,$csec,$uname); + my $have_assesments=1; + if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; } + + &startpage($r,$id,$udom,$csec,$uname,$have_assesments); + + if (!$have_assesments) { return ''; } # if ($ENV{'form.url'}) { # $r->print(''); @@ -897,16 +906,9 @@ sub assessparms { $r->print('

'.$message.'

'); - $r->print(''); - my $submitmessage; - if (($prevvisit) || ($pschp) || ($pssymb)) { - $submitmessage = "Update Display"; - } else { - $submitmessage = "Display"; - } if (!$pssymb) { - $r->print('\n"); - - $r->print(''); - $r->print(''); + $r->print(''); $r->print(''); $r->print(''); + $r->print(' name="showoptions" value="show">Show More Options
'); # $r->print(""); # $r->print(""); # $r->print(""); @@ -1025,7 +1025,13 @@ sub assessparms { } } - $r->print('

Select Parameter Level'); + $r->print('
Select Parameter Level'); $r->print('

Select Enclosing Map or Folder

print(" checked ");} - $r->print(' name="showoptions" value="show" onclick="form.submit();">Show More Options
Show: $showoptions
pscat: @pscat
psprt: @psprt
'); + $r->print('
'); + if (($prevvisit) || ($pschp) || ($pssymb)) { + $submitmessage = "Update Course Assessment Parameter Display"; + } else { + $submitmessage = "Set Course Assessment Parameters"; + } + $r->print(''); # my @temp_psprt; # foreach my $t (@psprt) { @@ -1048,9 +1054,7 @@ sub assessparms { my $csuname=$ENV{'user.name'}; my $csudom=$ENV{'user.domain'}; - if ($parmlev eq 'full' || $parmlev eq 'brief') { - my $coursespan=$csec?8:5; $r->print('

'); $r->print(''); @@ -1070,7 +1074,7 @@ ENDTABLETWO } $r->print(< - + ENDTABLEHEADFOUR @@ -1367,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 @@ -1385,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); @@ -1438,7 +1455,7 @@ sub crsenv { ('url' => 'Top Level Map '. '". - 'Browse
'. + 'Select Map
'. 'Modification may make assessment data '. 'inaccessible', 'description' => 'Course Description', @@ -1447,7 +1464,7 @@ sub crsenv { 'default_xml_style' => 'Default XML Style File '. 'Browse
", + ",'sty')\">Select Style File
", 'question.email' => 'Feedback Addresses for Resource Content '. 'Questions
(user:domain,'. 'user:domain(section;section;...;*;...),...)', @@ -1458,7 +1475,8 @@ sub crsenv { 'hideemptyrows' => 'Hide Empty Rows in Spreadsheets
'. '("yes" for default hiding)', 'pageseparators' => 'Visibly Separate Items on Pages
'. - '("yes" for visible separation)', + '("yes" for visible separation, '. + 'changes will not show until next login)', 'pch.roles.denied'=> 'Disallow Resource Discussion for '. 'Roles
"st": '. 'student, "ta": '. @@ -1472,20 +1490,27 @@ sub crsenv { => 'Default Course Spreadsheet '. 'Browse
", + ",'spreadsheet')\">Select Spreadsheet File
", 'spreadsheet_default_studentcalc' => 'Default Student Spreadsheet '. 'Browse
", + ",'spreadsheet')\">Select Spreadsheet File
", 'spreadsheet_default_assesscalc' => 'Default Assessment Spreadsheet '. 'Browse
", + ",'spreadsheet')\">Select Spreadsheet File
", 'allow_limited_html_in_feedback' => 'Allow limited HTML in discussion posts
'. - '(Set value to yes to allow)' + '(Set value to yes to allow)', + 'rndseed' + => 'Randomization algorithm used
'. + 'Modifying this will make problems '. + 'have different numbers and answers', + 'problem_stream_switch' + => 'Allow problems to be split over pages
'. + ' (yes if allow anything else if not)' ); foreach (keys(%values)) { unless ($descriptions{$_}) { @@ -1581,14 +1606,13 @@ sub handler { } &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); - $r->content_type('text/html'); - $r->send_http_header; - $r->print("\n\n"); - # ----------------------------------------------------- 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'};
Assessment URL and TitleTypeEnclosing Map or FolderPart No.Parameter NameEnclosing Map or FolderPartParameter Name defaultfrom Enclosing Map or Folder generalfor Enclosing Map or Folderfor Resource