--- loncom/interface/lonparmset.pm 2002/11/19 19:20:50 1.77 +++ loncom/interface/lonparmset.pm 2003/07/24 17:53:59 1.118 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.77 2002/11/19 19:20:50 matthew Exp $ +# $Id: lonparmset.pm,v 1.118 2003/07/24 17:53:59 matthew 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; @@ -72,6 +73,8 @@ my %mapp; my %typep; my %keyp; +my %maptitles; + my $uname; my $udom; my $uhome; @@ -96,13 +99,13 @@ Returns: A list, the first item is the 11- resource default 10- map default 9 - General Course -8 - Map level in course +8 - Map or Folder level in course 7 - resource level in course 6 - General for section -5 - Map level for section +5 - Map or Folder level for section 4 - resource level in section 3 - General for specific student -2 - Map level for specific student +2 - Map or Folder level for specific student 1 - resource level for specific student =cut @@ -282,12 +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(< @@ -300,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(); @@ -341,14 +338,27 @@ sub startpage { newWin.focus(); } +$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: @@ -358,13 +368,13 @@ For User or ID at Domain - +$chooseopt ENDHEAD - + } } sub print_row { @@ -478,9 +488,15 @@ sub print_row { sub print_td { my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_; $r->print(''. - &plink($$typeoutpar[$which],$$display{$value},$$outpar[$which], - $mprefix."$which",'parmform.pres','psub').''."\n"); + ' align="center">'); + if ($which<10) { + $r->print(&plink($$typeoutpar[$which], + $$display{$value},$$outpar[$which], + $mprefix."$which",'parmform.pres','psub')); + } else { + $r->print(&valout($$outpar[$which],$$typeoutpar[$which])); + } + $r->print(''."\n"); } sub get_env_multiple { @@ -544,6 +560,7 @@ sub extractResourceInformation { my $defp = shift; my $mapp = shift; my $symbp = shift; + my $maptitles=shift; foreach (keys %$bighash) { if ($_=~/^src\_(\d+)\.(\d+)$/) { @@ -584,6 +601,9 @@ sub extractResourceInformation { &Apache::lonnet::declutter($$bighash{'map_id_'.$mapid}); $$mapp{$mapid}=$$mapp{$id}; $$allmaps{$mapid}=$$mapp{$id}; + $$maptitles{$mapid}= + $$bighash{'title_'.$$bighash{'ids_'.&Apache::lonnet::clutter($$mapp{$id})}}; + $$maptitles{$$mapp{$id}}=$$maptitles{$mapid}; $$symbp{$id}=$$mapp{$id}. '___'.$resid.'___'. &Apache::lonnet::declutter($srcf); @@ -681,12 +701,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 { @@ -714,8 +734,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 ". @@ -751,10 +771,11 @@ sub assessparms { } # --------------------------------------------------------- Get all assessments - extractResourceInformation(\%bighash, \@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp); + extractResourceInformation(\%bighash, \@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles); $mapp{'0.0'} = ''; $symbp{'0.0'} = ''; + # ---------------------------------------------------------- Anything to store? if ($ENV{'form.pres_marker'}) { my ($sresid,$spnam,$snum)=split(/\&/,$ENV{'form.pres_marker'}); @@ -780,6 +801,8 @@ sub assessparms { if ($snum==5) { $storeunder=$seclevelm; } if ($snum==4) { $storeunder=$seclevelr; } + my $delete; + if ($ENV{'form.pres_value'} eq '') { $delete=1;} my %storecontent = ($storeunder => $ENV{'form.pres_value'}, $storeunder.'.type' => $ENV{'form.pres_type'}); my $reply=''; @@ -796,10 +819,17 @@ sub assessparms { &Apache::lonnet::expirespread('','','assesscalc'); } # Store parameter - $reply=&Apache::lonnet::cput - ('resourcedata',\%storecontent, - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + if ($delete) { + $reply=&Apache::lonnet::del + ('resourcedata',[keys(%storecontent)], + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + } else { + $reply=&Apache::lonnet::cput + ('resourcedata',\%storecontent, + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + } } else { # ------------------------------------------------------------------ Store User # @@ -815,19 +845,26 @@ sub assessparms { &Apache::lonnet::expirespread($uname,$udom,'assesscalc'); } # Store parameter - $reply=&Apache::lonnet::cput - ('resourcedata',\%storecontent,$udom,$uname); + if ($delete) { + $reply=&Apache::lonnet::del + ('resourcedata',[keys(%storecontent)],$udom,$uname); + } else { + $reply=&Apache::lonnet::cput + ('resourcedata',\%storecontent,$udom,$uname); + } } if ($reply=~/^error\:(.*)/) { $message.="Write Error: $1"; } # ---------------------------------------------------------------- Done storing + $message.='

Changes can take up to 10 minutes before being active for all students.'.&Apache::loncommon::help_open_topic('Caching').'

'; } # --------------------------------------------- Devalidate cache for this child - &Apache::lonnet::devalidatecourseresdata( + &Apache::lonnet::devalidatecourseresdata( $ENV{'course.'.$ENV{'request.course.id'}.'.num'}, $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}); + &Apache::lonnet::clear_EXT_cache_status(); # -------------------------------------------------------------- Get coursedata %courseopt = &Apache::lonnet::dump ('resourcedata', @@ -856,7 +893,16 @@ 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) { + untie(%bighash); + untie(%parmhash); + return ''; + } # if ($ENV{'form.url'}) { # $r->print(''); @@ -871,16 +917,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('\n"); } else { @@ -914,7 +951,7 @@ sub assessparms { $r->print(''); + $r->print(' name="showoptions" value="show">Show More Options
'); # $r->print(""); # $r->print(""); # $r->print(""); @@ -964,7 +1001,7 @@ sub assessparms { $r->print('

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

Select Enclosing Map
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
Sort list by'); $r->print('
'); + $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) { @@ -1022,9 +1065,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(''); @@ -1044,17 +1085,17 @@ ENDTABLETWO } $r->print(< - - - + + + ENDTABLEHEADFOUR if ($csec) { - $r->print(''); + $r->print(''); } if ($uname) { - $r->print(''); + $r->print(''); } $r->print(''); @@ -1215,10 +1256,12 @@ ENDTABLEHEADFOUR } # end loop through ids #---------------------------------------------------- print header information + my $foldermap=($maptitle=~/^uploaded/?'Folder':'Map'); + my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':''); $r->print(<

-Set Defaults for All Resources in map -$maptitle
+Set Defaults for All Resources in $foldermap
+$showtitle
Specifically for ENDMAPONE if ($uname) { @@ -1339,7 +1382,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 @@ -1357,51 +1400,71 @@ 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 - # ACK! No way to do this currently!!!!! Bummer! - } + } + # + # Deal with the enrollment dates + if ($name =~ /^default_enrollment_(start|end)_date$/) { + $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value'); + } + # + # 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). - '
'; - } } } +# ------------------------- Re-init course environment entries for this session + + &Apache::lonnet::coursedescription($ENV{'request.course.id'}); + # -------------------------------------------------------- Get parameters again my %values=&Apache::lonnet::dump('environment',$dom,$crs); @@ -1411,16 +1474,20 @@ sub crsenv { ('url' => 'Top Level Map '. '". - 'Browse
'. + 'Select Map
'. 'Modification may make assessment data '. 'inaccessible', 'description' => 'Course Description', 'courseid' => 'Course ID or number
'. '(internal, optional)', + 'grading' => 'Grading'. + '"standard" or any other value. '. + 'Default for new courses is "standard".', + '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;...;*;...),...)', @@ -1431,7 +1498,19 @@ 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)', + + 'plc.roles.denied'=> 'Disallow live chatroom use for '. + 'Roles
"st": '. + 'student, "ta": '. + 'TA, "in": '. + 'instructor;
role,role,...) '. + Apache::loncommon::help_open_topic("Course_Disable_Discussion"), + 'plc.users.denied' => + 'Disallow live chatroom use for Users
'. + '(user:domain,user:domain,...)', + 'pch.roles.denied'=> 'Disallow Resource Discussion for '. 'Roles
"st": '. 'student, "ta": '. @@ -1445,36 +1524,86 @@ 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)' - ); - foreach (keys(%values)) { - unless ($descriptions{$_}) { - $descriptions{$_}=$_; + '(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 allowed, anything else if not)', + 'anonymous_quiz' + => 'Anonimous quiz/exam
'. + ' (yes to avoid print students names )', + 'default_enrollment_start_date' => 'Default beginning date '. + 'when enrolling students', + 'default_enrollment_end_date' => 'Default ending date '. + 'when enrolling students', + 'languages' => 'Languages used', + 'disable_receipt_display' + => 'Disable display of problem receipts
'. + ' ("yes" to disable, anything else if not)' + ); + my @Display_Order = ('url','description','courseid','grading', + 'default_xml_style','pageseparators', + 'question.email','comment.email','policy.email', + 'plc.roles.denied','plc.users.denied', + 'pch.roles.denied','pch.users.denied', + 'allow_limited_html_in_feedback', + 'languages', + 'rndseed', + 'problem_stream_switch', + 'disable_receipt_display', + 'spreadsheet_default_classcalc', + 'spreadsheet_default_studentcalc', + 'spreadsheet_default_assesscalc', + 'hideemptyrows', + 'default_enrollment_start_date', + 'default_enrollment_end_date', + ); + foreach my $parameter (sort(keys(%values))) { + if (! $descriptions{$parameter}) { + $descriptions{$parameter}=$parameter; + push(@Display_Order,$parameter); } } - foreach (sort keys %descriptions) { + foreach my $parameter (@Display_Order) { + my $description = $descriptions{$parameter}; # onchange is javascript to automatically check the 'Set' button. my $onchange = 'onFocus="javascript:window.document.forms'. - '[\'envform\'].elements[\''.$_.'_setparmval\']'. + "['envform'].elements['".$parameter."_setparmval']". '.checked=true;"'; - $output.='

'. - ''. - ''. - ''."\n"; + $output .= ''; + if ($parameter =~ /^default_enrollment_(start|end)_date$/) { + $output .= ''; + } else { + $output .= ''; + } + $output .= ''; + $output .= "\n"; } my $onchange = 'onFocus="javascript:window.document.forms'. '[\'envform\'].elements[\'newp_setparmval\']'. @@ -1535,7 +1664,7 @@ ENDENV =pod -=item handler +=item * handler Main handler. Calls &assessparms and &crsenv subroutines. @@ -1543,6 +1672,7 @@ Main handler. Calls &assessparms and &c ################################################## ################################################## + use Data::Dumper; sub handler { my $r=shift; @@ -1552,10 +1682,14 @@ sub handler { return OK; } &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); + # ----------------------------------------------------- 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 MapPart No.Parameter Namedefaultfrom Enclosing Mapgeneralfor Enclosing Mapfor ResourceEnclosing Map or FolderPartParameter Namedefaultfrom Enclosing Map or Foldergeneralfor Enclosing Map or Folderfor Resourcegeneralfor Enclosing Mapfor Resourcegeneralfor Enclosing Map or Folderfor Resourcegeneralfor Enclosing Mapfor Resourcegeneralfor Enclosing Map or Folderfor Resource
'.$descriptions{$_}.'
'.$description.''. + &Apache::lonhtmlcommon::date_setter('envform', + $parameter.'_value', + $values{$parameter}, + $onchange). + ''. + &Apache::lonhtmlcommon::textbox($parameter.'_value', + $values{$parameter}, + 40,$onchange).''. + &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval'). + '