--- loncom/interface/lonparmset.pm 2010/01/25 21:58:31 1.413.4.3 +++ loncom/interface/lonparmset.pm 2008/11/17 16:57:06 1.415 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.413.4.3 2010/01/25 21:58:31 raeburn Exp $ +# $Id: lonparmset.pm,v 1.415 2008/11/17 16:57:06 schafran Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,276 +46,8 @@ This module sets coursewide and assessme =over 4 -=item parmval() - -Figure out a cascading parameter. - -Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight) - $id - a bighash Id number - $def - the resource's default value 'stupid emacs - -Returns: A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 14 possible levels - - 14- General Course - 13- Map or Folder level in course - 12- resource default - 11- map default - 10- resource level in course - 9 - General for section - 8 - Map or Folder level for section - 7 - resource level in section - 6 - General for group - 5 - Map or Folder level for group - 4 - resource level in group - 3 - General for specific student - 2 - Map or Folder level for specific student - 1 - resource level for specific student - -=item parmval_by_symb() - -=item reset_caches() - -=item cacheparmhash() - -=item parmhash() - -=item symbcache() - -=item preset_defaults() - -=item date_sanity_info() - -=item storeparm() - -Store a parameter by symb - - Takes - - symb - - name of parameter - - level - - new value - - new type - - username - - userdomain - -=item log_parmset() - -=item storeparm_by_symb_inner() - -=item valout() - -Format a value for output. - -Inputs: $value, $type, $editable - -Returns: $value, formatted for output. If $type indicates it is a date, -localtime($value) is returned. -$editable will return an icon to click on - -=item plink() - -Produces a link anchor. - -Inputs: $type,$dis,$value,$marker,$return,$call - -Returns: scalar with html code for a link which will envoke the -javascript function 'pjump'. - -=item page_js() - -=item startpage() - -=item print_row() - -=item print_td() - -=item print_usergroups() - -=item parm_control_group() - -=item extractResourceInformation() : - -Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes. - -Input: See list below: - -=item * B : An array that will contain all of the ids in the course. - -=item * B : hash, id->type, where "type" contains the extension of the file, thus, I. - -=item * B : hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id - - -=item * B : hash, name of parameter->display value (what is the display value?) - -=item * B : hash, part identification->text representation of part, where the text representation is "[Part $part]" - -=item * B : hash, full key to part->display value (what's display value?) - -=item * B : hash, ??? - -=item * B : ??? - -=item * B : hash, ??? - -=item * B : ?? - -=item * B : hash, id->full sym? - - - -=item isdateparm() - -=item parmmenu() - -=item partmenu() - -=item usermenu() - -=item displaymenu() - -=item mapmenu() - -=item levelmenu() - -=item sectionmenu() - -=item keysplit() - -=item keysinorder() - -=item keysinorder_bytype() - -=item keysindisplayorder() - -=item standardkeyorder() - -=item assessparms() : - -Show assessment data and parameters. This is a large routine that should -be simplified and shortened... someday. - -Inputs: $r - -Returns: nothing - -Variables used (guessed by Jeremy): - -=item * B: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type. - -=item * B: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts? - -=item * B<@catmarker> contains list of all possible parameters including part #s - -=item * B<$fullkeyp> contains the full part/id # for the extraction of proper parameters - -=item * B<$tempkeyp> contains part 0 only (no ids - ie, subparts) - When storing information, store as part 0 - When requesting information, request from full part - -=item tablestart() - -=item tableend() - -=item extractuser() - -=item parse_listdata_key() - -=item listdata() - -=item date_interval_selector() - -=item get_date_interval_from_form() - -=item default_selector() - -=item string_selector() - -=item dateshift() - -=item newoverview() - -=item secgroup_lister() - -=item overview() - -=item clean_parameters() - -=item date_shift_one() - -=item date_shift_two() - -=item parse_key() - -=item check_cloners() : - -Checks if new users included in list of allowed cloners -are valid users. Replaces supplied list with -cleaned list containing only users with valid usernames -and domains. - -Inputs: $clonelist, $oldcloner -where $clonelist is ref to array of requested cloners, -and $oldcloner is ref to array of currently allowed -cloners. - -Returns: string - comma separated list of requested -cloners (username:domain) who do not exist in system. - -=item change_clone() : - -Modifies the list of courses a user can clone (stored -in the user's environment.db file), called when a -change is made to the list of users allowed to clone -a course. - -Inputs: $action,$cloner -where $action is add or drop, and $cloner is identity of -user for whom cloning ability is to be changed in course. - - -=item check_cloners() - -=item change_clone() - -=item header() - -Output html header for page - -=item print_main_menu() - -=item output_row() - -Set portfolio metadata - -=item order_meta_fields() - -=item addmetafield() - -=item setrestrictmeta() - -=item get_added_meta_fieldnames() - -=item get_deleted_meta_fieldnames() - -=item defaultsetter() - -=item components() - -=item load_parameter_names() - -=item parm_change_log() - -=item handler() : - -Main handler. Calls &assessparms subroutine. - - -=back - =cut - ################################################################### ################################################################### @@ -335,6 +67,40 @@ use Apache::longroup; use Apache::lonrss; use LONCAPA qw(:DEFAULT :match); + +################################################## +################################################## + +=pod + +=item parmval + +Figure out a cascading parameter. + +Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight) + $id - a bighash Id number + $def - the resource's default value 'stupid emacs + +Returns: A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 14 possible levels + +14- General Course +13- Map or Folder level in course +12- resource default +11- map default +10- resource level in course +9 - General for section +8 - Map or Folder level for section +7 - resource level in section +6 - General for group +5 - Map or Folder level for group +4 - resource level in group +3 - General for specific student +2 - Map or Folder level for specific student +1 - resource level for specific student + +=cut + +################################################## sub parmval { my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_; return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec, @@ -536,7 +302,6 @@ sub reset_caches { } } - sub preset_defaults { my $type=shift; if (&rulescache($type.'_action') eq 'default') { @@ -551,6 +316,7 @@ sub preset_defaults { } } +################################################## sub date_sanity_info { my $checkdate=shift; @@ -605,6 +371,17 @@ sub storeparm { &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,'',$cgroup); } +# +# Store a parameter by symb +# +# Takes +# - symb +# - name of parameter +# - level +# - new value +# - new type +# - username +# - userdomain my %recstack; sub storeparm_by_symb { my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_; @@ -759,6 +536,25 @@ sub storeparm_by_symb_inner { return ''; } +################################################## +################################################## + +=pod + +=item valout + +Format a value for output. + +Inputs: $value, $type, $editable + +Returns: $value, formatted for output. If $type indicates it is a date, +localtime($value) is returned. +$editable will return an icon to click on + +=cut + +################################################## +################################################## sub valout { my ($value,$type,$editable)=@_; my $result = ''; @@ -815,6 +611,24 @@ sub valout { return $result; } +################################################## +################################################## + +=pod + +=item plink + +Produces a link anchor. + +Inputs: $type,$dis,$value,$marker,$return,$call + +Returns: scalar with html code for a link which will envoke the +javascript function 'pjump'. + +=cut + +################################################## +################################################## sub plink { my ($type,$dis,$value,$marker,$return,$call)=@_; my $winvalue=$value; @@ -829,7 +643,6 @@ sub plink { my ($hour,$min,$sec,$val)=&preset_defaults($parmname); unless (defined($winvalue)) { $winvalue=$val; } my $valout = &valout($value,$type,1); - my $unencmarker = $marker; foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call, \$hour, \$min, \$sec) { $$item = &HTML::Entities::encode($$item,'"<>&'); @@ -837,7 +650,7 @@ sub plink { } return '
'. ''. + .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'. $valout.'
'; } @@ -898,6 +711,15 @@ sub startpage { my %loaditems = ('onunload' => "pclose()", 'onload' => "group_or_section('cgroup')",); + if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) + && (!$env{'form.dis'})) || ($env{'form.symb'})) { + &Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters', + text=>"Problem Parameters"}); + } else { + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', + text=>"Table Mode", + help => 'Course_Setting_Parameters'}); + } my $start_page = &Apache::loncommon::start_page('Set/Modify Course Parameters', &page_js(), @@ -908,10 +730,10 @@ sub startpage { $start_page $breadcrumbs
- - - - + + + + ENDHEAD } @@ -943,7 +765,7 @@ sub print_row { my $parm=$$display{$which}; if ($parmlev eq 'full') { - $r->print('' + $r->print('' .$$part{$which}.''); } else { $parm=~s|\[.*\]\s||g; @@ -952,7 +774,7 @@ sub print_row { if ($automatic) { $parm.='
'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'
'; } - $r->print(''.$parm.''); + $r->print(''.$parm.''); my $thismarker=$which; $thismarker=~s/^parameter\_//; @@ -1029,37 +851,31 @@ sub print_row { } } # end of $parmlev if/else - $r->print(''.$effective_parm.''); + $r->print(''.$effective_parm.''); if ($parmlev eq 'full') { my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}. '.'.$$name{$which},$$symbp{$rid}); my $sessionvaltype=$typeoutpar[$result]; if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; } - $r->print(''. + $r->print(''. &valout($sessionval,$sessionvaltype).' '. ''); } + $r->print(''); + $r->print("\n"); } sub print_td { my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_; - $r->print(''); - my $nolink = 0; - if ($which == 11 || $which == 12) { - $nolink = 1; - } elsif ($mprefix =~ /availablestudent\&$/) { - if ($which > 3) { - $nolink = 1; - } - } - if ($nolink) { - $r->print(&valout($$outpar[$which],$$typeoutpar[$which])); + $r->print(''); + if ($which<11 || $which > 12) { + $r->print(&plink($$typeoutpar[$which], + $$display{$value},$$outpar[$which], + $mprefix."$which",'parmform.pres','psub')); } else { - $r->print(&plink($$typeoutpar[$which], - $$display{$value},$$outpar[$which], - $mprefix."$which",'parmform.pres','psub')); + $r->print(&valout($$outpar[$which],$$typeoutpar[$which])); } $r->print(''."\n"); } @@ -1079,11 +895,11 @@ sub print_usergroups { my $grp_parm; if (($coursereply) && ($cgroup ne $resultgroup)) { if ($result > 3) { - $bgcolor = '#AAFFAA'; + $bgcolor = '"#AAFFAA"'; $grp_parm = &valout($coursereply,$resulttype); } $grp_parm = &valout($coursereply,$resulttype); - $output = ''; + $output = ''; if ($resultgroup && $resultlevel) { $output .= ''.$resultgroup.' ('.$resultlevel.'): '.$grp_parm; } else { @@ -1091,7 +907,7 @@ sub print_usergroups { } $output .= ''; } else { - $output .= ' '; + $output .= ' '; } return ($coursereply,$output,$grp_parm,$resultgroup); } @@ -1120,6 +936,40 @@ sub parm_control_group { return($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype); } +=pod + +=item B: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes. + +Input: See list below: + +=over 4 + +=item B: An array that will contain all of the ids in the course. + +=item B: hash, id->type, where "type" contains the extension of the file, thus, I. + +=item B: hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id + +=item B: hash, name of parameter->display value (what is the display value?) + +=item B: hash, part identification->text representation of part, where the text representation is "[Part $part]" + +=item B: hash, full key to part->display value (what's display value?) + +=item B: hash, ??? + +=item B: ??? + +=item B: hash, ??? + +=item B: ?? + +=item B: hash, id->full sym? + +=back + +=cut + sub extractResourceInformation { my $ids = shift; my $typep = shift; @@ -1158,15 +1008,9 @@ sub extractResourceInformation { # my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) { - my ($display,$parmdis); - $display = &standard_parameter_names($name); - if ($display eq '') { - $display= &Apache::lonnet::metadata($srcf,$key.'.display'); - $parmdis = $display; - $parmdis =~ s/\s*\[Part.*$//g; - } else { - $parmdis = &mt($display); - } + my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); + my $parmdis = $display; + $parmdis =~ s/\s*\[Part.*$//g; $$allparms{$name}=$parmdis; if (ref($defkeytype)) { $$defkeytype{$name}= @@ -1292,17 +1136,17 @@ sub parmmenu { ENDSCRIPT $r->print(); - $r->print("\n".''); + $r->print("\n
"); my $cnt=0; foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) { - $r->print("\n".''); + $r->print('>'.($$allparms{$tempkey}=~/\S/ ? &mt($$allparms{$tempkey}) + : &mt($tempkey)) + .''); $cnt++; if ($cnt==3) { $r->print("\n"); @@ -1310,7 +1154,7 @@ ENDSCRIPT } } $r->print('' - .'' + .'' .'
' .'
'.&mt('Parameter Selection').'' .'' @@ -1353,7 +1197,7 @@ ENDSCRIPT sub partmenu { my ($r,$allparts,$psprt)=@_; - $r->print(''); $r->print(''); @@ -1517,7 +1361,7 @@ sub sectionmenu { my %sectionhash = &Apache::loncommon::get_sections(); return if (!%sectionhash); - $r->print(''); foreach my $s ('all',sort keys %sectionhash) { $r->print('
'); &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder); } else { my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); @@ -1876,9 +1716,9 @@ sub assessparms { $coursespan += 3; } - $r->print('

'); - $r->print(''); - $r->print(''); + $r->print('

'.&mt('Any User').'
'); + $r->print(''); + $r->print(''); if ($uname) { if (@usersgroups > 1) { $userspan ++; @@ -1904,18 +1744,18 @@ sub assessparms { 'fr' => 'for Resource' ); $r->print(<$lt{'pie'} - - - + + + + ENDTABLETWO if ($csec) { - $r->print('"); } if ($cgroup) { - $r->print('"); } $r->print(<0) { my $firstrow=1; my $title=&Apache::lonnet::gettitle($symbp{$rid}); - $r->print(''); - $r->print(''); - $r->print(''); + $r->print(''); foreach (&keysinorder_bytype(\%name,\%keyorder)) { unless ($firstrow) { @@ -2040,7 +1871,6 @@ ENDTABLEHEADFOUR \%type,\%display,$defbgone,$defbgtwo, $defbgthree,$parmlev,$uname,$udom,$csec, $cgroup,\@usersgroups); - $r->print(''."\n"); } } } @@ -2050,9 +1880,9 @@ ENDTABLEHEADFOUR } # end of full #--------------------------------------------------- Entry for parm level map if ($parmlev eq 'map') { - my $defbgone = 'E0E099'; - my $defbgtwo = 'FFFF99'; - my $defbgthree = 'FFBB99'; + my $defbgone = '"E0E099"'; + my $defbgtwo = '"FFFF99"'; + my $defbgthree = '"FFBB99"'; my %maplist; @@ -2103,16 +1933,7 @@ ENDTABLEHEADFOUR if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { $part{$tempkeyp}="0"; $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name'); - my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display'); - if ($allparms{$name{$tempkeyp}} ne '') { - my $identifier; - if ($parmdis =~ /(\s*\[Part.*)$/) { - $identifier = $1; - } - $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier; - } else { - $display{$tempkeyp} = $parmdis; - } + $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display'); unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; } $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')'; $display{$tempkeyp} =~ s/_\w+_/_0_/; @@ -2149,30 +1970,27 @@ ENDTABLEHEADFOUR ,''.$coursename.'' ) ."
\n" - ); + ); #---------------------------------------------------------------- print table - $r->print('

'..&Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row(). - '

'. - ''. - ''. - &Apache::loncommon::end_data_table_header_row()); + $r->print('

'.&mt('Any User').'$lt{'csv'}
($csuname $lt{'at'} $csudom)
$lt{'ic'}$lt{'rl'}$lt{'ic'}$lt{'pie'}$lt{'csv'}
($csuname $lt{'at'} $csudom)
$lt{'ic'}$lt{'rl'}$lt{'ic'}'. + $r->print("". &mt("in Section")." $csec'. + $r->print("". &mt("in Group")." $cgroup
'. + $r->print('
'. join(' / ',split(/\//,$uri)). '

'. "print(' ('.$thistitle.')'); } $r->print('

'.$typep{$rid}. + $r->print(''.$typep{$rid}. ''.$maptitles{$mapp{$rid}}.''.$maptitles{$mapp{$rid}}.'
'.&mt('Parameter Name').''.&mt('Default Value').''.&mt('Parameter in Effect').'
'); + $r->print(''); + $r->print(''); + $r->print(''); foreach (&keysinorder(\%name,\%keyorder)) { - $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(''); &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, \%type,\%display,$defbgone,$defbgtwo,$defbgthree, $parmlev,$uname,$udom,$csec,$cgroup); - $r->print(&Apache::loncommon::end_data_table_row()); } - $r->print(&Apache::loncommon::end_data_table().'

'); + $r->print("
'.&mt('Parameter Name').''.&mt('Default Value').''.&mt('Parameter in Effect').'
"); } # end each map } # end of $parmlev eq map #--------------------------------- Entry for parm level general (Course level) if ($parmlev eq 'general') { - my $defbgone = 'E0E099'; - my $defbgtwo = 'FFFF99'; - my $defbgthree = 'FFBB99'; + my $defbgone = '"E0E099"'; + my $defbgtwo = '"FFFF99"'; + my $defbgthree = '"FFBB99"'; #-------------------------------------------- for each map, gather information my $mapid="0.0"; @@ -2203,16 +2021,7 @@ ENDTABLEHEADFOUR if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { $part{$tempkeyp}="0"; $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name'); - my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display'); - if ($allparms{$name{$tempkeyp}} ne '') { - my $identifier; - if ($parmdis =~ /(\s*\[Part.*)$/) { - $identifier = $1; - } - $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier; - } else { - $display{$tempkeyp} = $parmdis; - } + $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display'); unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; } $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')'; $display{$tempkeyp} =~ s/_\w+_/_0_/; @@ -2225,8 +2034,7 @@ ENDTABLEHEADFOUR #---------------------------------------------------- print header information my $setdef=&mt("Set Defaults for All Resources in Course"); $r->print(< -

$setdef +

$setdef $coursename
ENDMAPONE if ($uname) { @@ -2240,21 +2048,18 @@ ENDMAPONE if ($cgroup) {$r->print(&mt("Group")." $cgroup\n")}; $r->print("

\n"); #---------------------------------------------------------------- print table - $r->print('

'.&Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row(). - ''.&mt('Parameter Name').''. - ''.&mt('Default Value').''. - ''.&mt('Parameter in Effect').''. - &Apache::loncommon::end_data_table_header_row()); + $r->print('

'); + $r->print(''); + $r->print(''); + $r->print(''); foreach (&keysinorder(\%name,\%keyorder)) { - $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(''); &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, \%type,\%display,$defbgone,$defbgtwo,$defbgthree, $parmlev,$uname,$udom,$csec,$cgroup); - $r->print(&Apache::loncommon::end_data_table_row()); } - $r->print(&Apache::loncommon::end_data_table().'

'); + $r->print("
'.&mt('Parameter Name').''.&mt('Default Value').''.&mt('Parameter in Effect').'

"); } # end of $parmlev eq general } $r->print(''.&Apache::loncommon::end_page()); @@ -2262,6 +2067,635 @@ ENDMAPONE ################################################## +################################################## + +=pod + +=item crsenv + +Show and set course data and parameters. This is a large routine that should +be simplified and shortened... someday. + +Inputs: $r + +Returns: nothing + +=cut + +################################################## +################################################## +sub crsenv { + my $r=shift; + my $setoutput=''; + + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv', + text=>"Course Environment"}); + my $breadcrumbs = + &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment'); + my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + + my (%crsinfo,$chome); + + # + # Go through list of changes + foreach (keys %env) { + 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.=&mt('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'); + } + } + # + # Deal with the enrollment dates + if ($name =~ /^default_enrollment_(start|end)_date$/) { + $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value'); + } + # + # Deal with the emails + if ($name =~ /\.email$/) { + foreach my $specifier (split(',',$value)) { + my ($user,$sections_or_groups)= + ($specifier=~/^([^\(]+)\(([^\)]+)\)/); + if (!$sections_or_groups) { + $user = $specifier; + } + my ($name,$domain) = split(':',$user); + if (!defined($user) || !defined($domain)) { + $setoutput.= '
'. + &mt("Invalid email address specified, address must be of the form username:domain what was specified was ([_1])",$user). + ''; + undef($value); + } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') { + $setoutput.= '
'. + &mt("Invalid email address specified, user [_1] is unknown.",$name). + ''; + undef($value); + } + } + } + # Get existing cloners + my @oldcloner = (); + if ($name eq 'cloners') { + my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners'); + if ($clonenames{'cloners'} =~ /,/) { + @oldcloner = split/,/,$clonenames{'cloners'}; + } else { + $oldcloner[0] = $clonenames{'cloners'}; + } + } + # + # Let the user know we made the changes + if ($name && defined($value)) { + my %failed_cloners; + if ($name eq 'cloners') { + $value =~ s/\s//g; + $value =~ s/^,//; + $value =~ s/,$//; + # check requested clones are valid users. + %failed_cloners = &check_cloners(\$value,\@oldcloner); + } + my $put_result = &Apache::lonnet::put('environment', + {$name=>$value},$dom,$crs); + if ($put_result eq 'ok') { + $setoutput.=&mt('Set').' '.$name.' '.&mt('to').' '; + if ($name =~ /^default_enrollment_(start|end)_date$/) { + $setoutput .= &Apache::lonlocal::locallocaltime($value); + } elsif ($name eq 'categories') { + $setoutput .= $env{'form.categories_display'}; + } else { + $setoutput .= $value; + } + $setoutput .= '.
'; + if ($name eq 'cloners') { + &change_clone($value,\@oldcloner); + } + # Update environment and nohist_courseids.db + if (($name eq 'description') || ($name eq 'cloners') || + ($name eq 'hidefromcat') || ($name eq 'categories')) { + if ($chome eq '') { + %crsinfo = + &Apache::lonnet::courseiddump($dom,'.',1,'.','.', + $crs,undef,undef,'.'); + $chome = &Apache::lonnet::homeserver($crs,$dom); + } + } + if ($name eq 'description' && defined($value)) { + &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $value}); + if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') { + $crsinfo{$env{'request.course.id'}}{'description'} = $value; + my $putresult = + &Apache::lonnet::courseidput($dom,\%crsinfo, + $chome,'notime'); + } + } + if (($name eq 'cloners') || ($name eq 'hidefromcat') || ($name eq 'categories')) { + if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') { + &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$name => $value}); + $crsinfo{$env{'request.course.id'}}{$name} = $value; + my $putresult = + &Apache::lonnet::courseidput($dom,\%crsinfo, + $chome,'notime'); + } + } + } else { + $setoutput.=&mt('Unable to set').' '.$name.' '.&mt('to'). + ' '.$value.' '.&mt('due to').' '.$put_result.'.
'; + } + if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) { + $setoutput.= &mt('Unable to include').': '; + my @fails; + my $num = 0; + if (defined($failed_cloners{'format'})) { + $fails[$num] .= ''.$failed_cloners{'format'}. + ', '.&mt('reason').' - '. + &mt('Invalid format'); + $num ++; + } + if (defined($failed_cloners{'domain'})) { + $fails[$num] .= ''.$failed_cloners{'domain'}. + ', '.&mt('reason').' - '. + &mt('Domain does not exist'); + $num ++; + } + if (defined($failed_cloners{'newuser'})) { + $fails[$num] .= ''.$failed_cloners{'newuser'}. ', '.&mt('reason').' - '. + &mt('LON-CAPA user(s) do(es) not exist.'). + '.
'.&mt('Please '). + ' '. + &mt('add the user(s)').', '. + &mt('and then return to the '). + ''. + &mt('Course Parameters page').' '. + &mt('to add the new user(s) to the list of possible cloners'); + } + $setoutput .= join(';  ',@fails).'.
'; + } + } + } + + my $start_table =&Apache::loncommon::start_data_table(); + my $start_header_row=&Apache::loncommon::start_data_table_header_row(); + my $end_header_row =&Apache::loncommon::end_data_table_header_row(); +# ------------------------- Re-init course environment entries for this session + + &Apache::lonnet::coursedescription($env{'request.course.id'}, + {'freshen_cache' => 1}); + +# -------------------------------------------------------- Get parameters again + + my %values=&Apache::lonnet::dump('environment',$dom,$crs); + my $SelectStyleFile=&mt('Select Style File'); + my $SelectSpreadsheetFile=&mt('Select Spreadsheet File'); + my $output=''; + my $can_categorize; + if (! exists($values{'con_lost'})) { + my %descriptions= + ('url' => ''.&mt('Top Level Map').'
'. + '". + &mt('Select Map').'
'. + &mt('Modification may make assessment data inaccessible!'). + '', + 'description' => ''.&mt('Course Description').'', + 'courseid' => ''.&mt('Course ID or number'). + '
'. + '('.&mt('internal, optional').')', + 'cloners' => ''.&mt('Users allowed to clone course').'
' + .'("'.&mt('user:domain,user:domain,*:domain').'")
' + .&mt('Users with active Course Coordinator role in this course are permitted to clone and need not be included.').'
' + .&mt('Use [_1] to allow course to be cloned by anyone in the specified domain.','"*:domain"').'
' + .&mt('Use [_1] to allow unrestricted cloning in all domains.','"*"'), + 'grading' => ''.&mt('Grading').'
'. + &mt('[_1], [_2], or [_3]','"standard"','"external"','"spreadsheet"').&Apache::loncommon::help_open_topic('GradingOptions'), + 'task_grading' => ''.&mt('Bridge Task Grading').'
' + .&mt('Instructors and TAs in sections, when grading bridge tasks, should be allowed to grade other sections.').'
' + .'('.&mt('[_1]: they are allowed (this is the default). [_2]: no, they can only grade their own section.','"any"','"section"').')', + 'default_xml_style' => ''.&mt('Default XML Style File').'
'. + '$SelectStyleFile
", + 'question.email' => ''.&mt('Feedback Addresses for Resource Content Question').'
' + .'("'.&mt('user:domain,user:domain(section;section;...;*;...),...').'")', + 'question.email.text' => ''.&mt('Custom Text for Resource Content Question Option in Feedback').'', + 'comment.email' => ''.&mt('Feedback Addresses for Course Content Comments').'
' + .'("'.&mt('user:domain,user:domain(section;section;...;*;...),...').'")', + 'comment.email.text' => ''.&mt('Custom Text for Course Content Option in Feedback').'', + 'policy.email' => ''.&mt('Feedback Addresses for Course Policy').'
' + .'("'.&mt('user:domain,user:domain(section;section;...;*;...),...').'")', + 'policy.email.text' => ''.&mt('Custom Text for Course Policy Option in Feedback').'', + 'hideemptyrows' => ''.&mt('Hide Empty Rows in Spreadsheets').'
' + .'('.&mt('[_1] for default hiding','"yes"').')', + 'pageseparators' => ''.&mt('Visibly Separate Items on Pages').'
' + .'('.&mt('[_1] for visible separation.','"yes"').' ' + .&mt('Changes will not show until next login.').')', + 'student_classlist_view' => ''.&mt('Allow students to view classlist.').'
' + .'('.&mt('[_1]: students can view all sections. [_2]: students can only view their own section. blank or [_3] prevents student view.','"all"','"section"','"disabled"').')', + 'student_classlist_portfiles' => ''.&mt('Include link to accessible portfolio files').'
' + .'('.&mt('[_1] for link to each a listing of each student\'s files.','"yes"').')', + 'student_classlist_opt_in' => ''.&mt("Student's agreement needed for listing in student-viewable roster").'
' + .'('.&mt('[_1] to require students to opt-in to listing in the roster (on the roster page).','"yes"').')', + 'plc.roles.denied'=> ''.&mt('Disallow live chatroom use for Roles').'
' + .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"st"','"ta"','"in"').')
' + .'("'.&mt('role,role,...').'") ' + .Apache::loncommon::help_open_topic("Course_Disable_Discussion"), + 'plc.users.denied' => + ''.&mt('Disallow live chatroom use for Users').'
'. + '("'.&mt('user:domain,user:domain,...').'")', + + 'pch.roles.denied'=> ''.&mt('Disallow Resource Discussion for Roles').'
' + .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"st"','"ta"','"in"') + .'("'.&mt('role,role,...').'") ' + .Apache::loncommon::help_open_topic("Course_Disable_Discussion"), + 'pch.users.denied' => + ''.&mt('Disallow Resource Discussion for Users').'
'. + '("'.&mt('user:domain,user:domain,...').'")', + 'spreadsheet_default_classcalc' + => ''.&mt('Default Course Spreadsheet').' '. + '$SelectSpreadsheetFile
", + 'spreadsheet_default_studentcalc' + => ''.&mt('Default Student Spreadsheet').'
'. + '$SelectSpreadsheetFile
", + 'spreadsheet_default_assesscalc' + => ''.&mt('Default Assessment Spreadsheet').' '. + '$SelectSpreadsheetFile
", + 'allow_limited_html_in_feedback' + => ''.&mt('Allow limited HTML in discussion posts').'
'. + '('.&mt('Set value to [_1] to allow.','"yes"').')', + 'allow_discussion_post_editing' + => ''.&mt('Allow users with specified roles to edit/delete their own discussion posts').'
' + .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"st"','"ta"','"in"').')
' + .'('.&mt('Set value to [_1] to allow all roles.','"yes"').')' + .'("'.&mt('role:section,role:section,...').'")
' + .'('.&mt('Example: "st:001,st:002,in,cc" would permit students in sections 001 and 002 and instructors in any section, and course coordinators to edit their own posts.').')', + 'rndseed' + => ''.&mt('Randomization algorithm used').'
' + .'' + .&mt('Modifying this will make problems have different numbers and answers!') + .'', + 'receiptalg' + => ''.&mt('Receipt algorithm used').'
'. + &mt('This controls how receipt numbers are generated.'), + 'suppress_tries' + => ''.&mt('Suppress number of tries in printing').'
'. + ' ('.&mt('[_1] to suppress, anything else to not suppress','"yes"').')', + 'problem_stream_switch' + => ''.&mt('Allow problems to be split over pages').'
'. + ' ('.&mt('[_1] if allowed, anything else if not','"yes"').')', + 'default_paper_size' + => ''.&mt('Default paper type').'
'. + ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'. + ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'. + ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])', + 'print_header_format' + => ' '.&mt('Print header format').'
' + .&mt('Substitutions:
[_1]: student name, [_2]: course id, [_3]: assignment note. Numbers after the % limit the field size.','"%n"','"%c"','"%a"'), + 'default_enrollment_start_date' => ''.&mt('Default beginning date for student access.').'', + 'default_enrollment_end_date' => ''.&mt('Default ending date for student access.').'', + 'nothideprivileged' => ''.&mt('Privileged users that should not be hidden on staff listings').'
' + .'("'.&mt('user:domain,user:domain,*:domain').'")', + 'languages' => ''.&mt('Languages used').'', + 'disable_receipt_display' + => ''.&mt('Disable display of problem receipts').'
'. + ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', + 'task_messages' + => ''.&mt('Send message to student when clicking Done on Tasks').'
('.&mt('[_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','"only_student"','"student_and_user_notes_screen"').')', + 'disablesigfigs' + => ''.&mt('Disable checking of Significant Figures').'
'. + ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', + 'disableexampointprint' + => ''.&mt('Disable automatically printing point values onto exams.').'
'. + ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', + 'externalsyllabus' + => ''.&mt('URL of Syllabus (not using internal handler)').'', + 'tthoptions' + => ''.&mt('Default set of options to pass to tth/m when converting tex').'', + + 'texengine' + => ''.&mt('Force all students in the course to use a specific math rendering engine.').'
' + .'('.&mt('[_1], [_2] (Convert to Images), [_3] (TeX to HTML), or blank for student\'s preference','"jsMath"','"mimetex"','"tth"').')', + 'timezone' + => ''.&mt('Timezone in which the course takes place').'', + + 'suppress_embed_prompt' + => ''.&mt('Suppress prompt to upload items referenced in a web page being uploaded to portfolio, when current role is student.').'
'. + ' ('.&mt('[_1] to suppress, anything else to not suppress','"yes"').')', + 'hidefromcat' + => ''.&mt('Exclude from course catalog').'
'. + ' ('.&mt('[_1] to exclude, anything else to include - included if assigned an institutional code, or manually catagorized','"yes"').')', + 'categories' + => ''.&mt('Categorize course').' '. + &mt('Display Categories').'', + 'datelocale' + => ''.&mt('Locale used for course calendar').'', + ); + my @Display_Order = ('url','description','courseid','cloners'); + (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom); + if ($can_toggle_cat) { + push(@Display_Order,'hidefromcat'); + } + if ($can_categorize) { + push(@Display_Order,'categories'); + } + push (@Display_Order,('grading', + 'externalsyllabus', + 'default_xml_style','pageseparators', + 'question.email','question.email.text','comment.email', + 'comment.email.text','policy.email','policy.email.text', + 'student_classlist_view', + 'student_classlist_opt_in', + 'student_classlist_portfiles', + 'plc.roles.denied','plc.users.denied', + 'pch.roles.denied','pch.users.denied', + 'allow_limited_html_in_feedback', + 'allow_discussion_post_editing', + 'languages', + 'timezone', + 'datelocale', + 'nothideprivileged', + 'rndseed', + 'receiptalg', + 'problem_stream_switch', + 'suppress_tries', + 'suppress_embed_prompt', + 'default_paper_size', + 'print_header_format', + 'disable_receipt_display', + 'spreadsheet_default_classcalc', + 'spreadsheet_default_studentcalc', + 'spreadsheet_default_assesscalc', + 'hideemptyrows', + 'default_enrollment_start_date', + 'default_enrollment_end_date', + 'tthoptions', + 'texengine', + 'disablesigfigs', + 'disableexampointprint', + 'task_messages','task_grading')); + foreach my $parameter (sort(keys(%values))) { + unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) || + ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/) + || ($parameter eq 'type')) { + if (! $descriptions{$parameter}) { + $descriptions{$parameter}=$parameter; + push(@Display_Order,$parameter); + } + } + } + + 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['".$parameter."_setparmval']". + '.checked=true;"'; + $output .= &Apache::loncommon::start_data_table_row(). + ''.$description.''; + if ($parameter =~ /^default_enrollment_(start|end)_date$/) { + $output .= ''. + &Apache::lonhtmlcommon::date_setter('envform', + $parameter.'_value', + $values{$parameter}, + $onchange). + ''; + } elsif ($parameter eq 'timezone') { + my $includeempty = 1; + my $timezone = &Apache::lonlocal::gettimezone(); + $output .= ''. + &Apache::loncommon::select_timezone($parameter.'_value', + $timezone, + $onchange,$includeempty).''; + } elsif ($parameter eq 'datelocale') { + my $includeempty = 1; + my $locale_obj = &Apache::lonlocal::getdatelocale(); + my $currdatelocale; + if (ref($locale_obj)) { + $currdatelocale = $locale_obj->id(); + } + $output .= ''. + &Apache::loncommon::select_datelocale($parameter.'_value', + $currdatelocale, + $onchange,$includeempty).''; + } elsif ($parameter eq 'categories') { + my $catdisplay; + if ($values{'categories'} ne '') { + my @curritems = split(/\&/,$values{'categories'}); + foreach my $item (@curritems) { + my ($name,$parent,$pos) = split(/:/,$item); + $catdisplay .= &unescape($name).'&'; + } + $catdisplay =~ s/\&$//; + } + $output .= ''. + ''. + ''; + } else { + $output .= ''. + &Apache::lonhtmlcommon::textbox($parameter.'_value', + $values{$parameter}, + 40,$onchange).''; + } + $output .= ''. + &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval'). + ''; + $output .= &Apache::loncommon::end_data_table_row()."\n"; + } + my $onchange = 'onFocus="javascript:window.document.forms'. + '[\'envform\'].elements[\'newp_setparmval\']'. + '.checked=true;"'; + $output.=&Apache::loncommon::start_data_table_row(). + ''.&mt('Create New Environment Variable').'
'. + ''. + ''. + ''. + &Apache::loncommon::end_data_table_row()."\n"; + } + my %lt=&Apache::lonlocal::texthash( + 'par' => 'Parameter', + 'val' => 'Value', + 'set' => 'Set?', + 'sav' => 'Save' + ); + + my $Parameter=&mt('Parameter'); + my $Value=&mt('Value'); + my $Set=&mt('Set'); + my ($jscript,$categorize_js); + my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset'); + if ($can_categorize) { + $categorize_js = <'; + my $start_page = + &Apache::loncommon::start_page('Set Course Environment', + $jscript); + my $end_page = + &Apache::loncommon::end_page(); + my $end_table=&Apache::loncommon::end_data_table(); + $r->print(< +$setoutput +
+$start_table +$start_header_row +$lt{'par'}$lt{'val'}$lt{'set'} +$end_header_row +$output +$end_table + + +$end_page +ENDENV +} + +sub can_modify_catsettings { + my ($dom) = @_; + my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom); + my ($can_toggle_cat,$can_categorize); + if (ref($domconf{'coursecategories'}) eq 'HASH') { + if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') { + $can_toggle_cat = 1; + } + if ($domconf{'coursecategories'}{'categorize'} eq 'crs') { + $can_categorize = 1; + } + } + return ($can_toggle_cat,$can_categorize); +} + +sub assign_course_categories { + my ($r) = @_; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $hascats = 0; + my $cathash; + my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom); + if (ref($domconf{'coursecategories'}) eq 'HASH') { + $cathash = $domconf{'coursecategories'}{'cats'}; + if (ref($cathash) eq 'HASH') { + $hascats = 1; + } + } + my $catwin_js; + if ($hascats) { + my $alert = &mt('Use \"Save\" in the main window to save course categories'); + $catwin_js = < + +function updateCategories() { + var newcategories = ''; + var unescapedcats = ''; + if (document.chgcats.usecategory.length) { + for (var i=0; i 0) { + newcategories = newcategories.slice(0,-1); + } + if (unescapedcats.length > 0) { + unescapedcats = unescapedcats.slice(0,-3); + } + } else { + if (document.chgcats.usecategory.checked == true) { + newcategories = document.chgcats.usecategory.value; + unescapedcats = document.chgcats.catname.value; + } + } + opener.document.envform.categories_value.value = newcategories; + opener.document.envform.categories_display.value = unescapedcats; + opener.document.envform.categories_setparmval.checked = true; + alert("$alert"); + self.close(); + return; +} + + +ENDSCRIPT + } else { + my $onload; + } + my $start_page = + &Apache::loncommon::start_page('Course Categories',$catwin_js, + {'only_body' => 1,}); + my $end_page = &Apache::loncommon::end_page(); + my $categoriesform = '

'.&mt('Categorize Course').'

'; + if ($hascats) { + my %currsettings = + &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum); + $categoriesform .= &mt('Assign one or more categories to this course.').'

'. + '
'."\n" + .&Apache::loncommon::assign_categories_table($cathash, + $currsettings{'categories'})."\n" + .'

'; + } else { + $categoriesform .= &mt('No categories defined for this domain'); + } + $r->print($start_page.$categoriesform.$end_page); + return; +} + +################################################## # Overview mode ################################################## my $tableopen; @@ -2534,17 +2968,15 @@ sub listdata { } if ($part ne $oldpart) { $r->print(&tableend(). - "\n".''.&mt('Part').": $part"); + "\n".&mt('Part').": $part"); $oldpart=$part; } # # Ready to print # - my $parmitem = &standard_parameter_names($name); - $r->print(&tablestart(). &Apache::loncommon::start_data_table_row(). - ''.&mt($parmitem). + ''.&standard_parameter_names($name). ''); $foundkeys++; @@ -2571,7 +3003,7 @@ sub listdata { $r->print(&default_selector($thiskey,$$resourcedata{$thiskey})); } $r->print(''); + $thistype.'">'); $r->print(''.&Apache::loncommon::end_data_table_row()); } } @@ -2694,6 +3126,8 @@ sub newoverview { my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', + text=>"Overview Mode"}); my $start_page = &Apache::loncommon::start_page('Set Parameters'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); $r->print(<'/adm/parmset?action=setoverview', + text=>"Overview Mode"}); my $start_page=&Apache::loncommon::start_page('Modify Parameters'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); $r->print(<print(&tableend().'

'. - ($foundkeys?'':&mt('There are no parameters.')).'

'. + ($foundkeys?'':&mt('There are no parameters.')).'

'. &Apache::loncommon::end_page()); } @@ -2888,6 +3324,8 @@ sub clean_parameters { my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters', + text=>"Clean Parameters"}); my $start_page=&Apache::loncommon::start_page('Clean Parameters'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean'); $r->print(<print(&mt('Parameter: "[_1]" with value: "[_2]"', - $parmitem,$resourcedata->{$thiskey})); + &standard_parameter_names($data{'parameter_name'}), + $resourcedata->{$thiskey})); $r->print('
'); if ($data{'scope_type'} eq 'all') { $r->print(&mt('All users')); @@ -2972,6 +3409,8 @@ sub date_shift_one { my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, + text=>"Shifting Dates"}); my $start_page=&Apache::loncommon::start_page('Shift Dates'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift'); $r->print(<'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, + text=>"Shifting Dates"}); my $start_page=&Apache::loncommon::start_page('Shift Dates'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift'); $r->print(<print(&header()); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager')); $r->print(< @@ -3184,84 +3677,88 @@ ENDMAINFORMHEAD my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'}); my @menu = - ( { divider=>'Settings for Your Course', - }, - { text => 'Edit course configuration', - url => '/adm/courseprefs?origin=params', - permission => $parm_permission, - help => 'Course_Environment', - }, - { text => 'Set Portfolio Metadata', - action => 'setrestrictmeta', - permission => $parm_permission, - }, - { text => 'Manage Course Slots', - url => '/adm/slotrequest?command=showslots', - permission => $vgr, - }, - { text => 'Reset Student Access Times', - url => '/adm/helper/resettimes.helper', - permission => $mgr, - }, - - { text => 'Set Parameter Setting Default Actions', - action => 'setdefaults', - permission => $parm_permission, - }, - { divider => 'New and Existing Parameter Settings for Your Resources', - }, - { text => 'Set/Modify Resource Parameters - Helper Mode', - url => '/adm/helper/parameter.helper', - permission => $parm_permission, - help => 'Parameter_Helper', - }, - { text => 'Set/Modify Resource Parameters - Overview Mode', - action => 'newoverview', - permission => $parm_permission, - help => 'Parameter_Overview', - }, - { text => 'Set/Modify Resource Parameters - Table Mode', - action => 'settable', - permission => $parm_permission, - help => 'Table_Mode', - }, - { divider => 'Existing Parameter Settings for Your Resources', - }, - { text => 'Modify Resource Parameters - Overview Mode', - action => 'setoverview', - permission => $parm_permission, - help => 'Parameter_Overview', - }, - { text => 'Parameter Change Log and Course Blog Posting/User Notification', - action => 'parameterchangelog', - permission => $parm_permission, - }, + ( { categorytitle=>'Settings for Your Course', + items => [ + { linktext => 'Set Course Environment', + url => '/adm/parmset?action=crsenv', + permission => $parm_permission, + help => 'Course_Environment', + }, + { linktext => 'Set Portfolio Metadata', + url => '/adm/parmset?action=setrestrictmeta', + permission => $parm_permission, + }, + { linktext => 'Manage Course Slots', + url => '/adm/slotrequest?command=showslots', + permission => $vgr, + }, + { linktext => 'Reset Student Access Times', + url => '/adm/helper/resettimes.helper', + permission => $mgr, + }, + + { linktext => 'Set Parameter Setting Default Actions', + url => '/adm/parmset?action=setdefaults', + permission => $parm_permission, + }]}, + { categorytitle => 'New and Existing Parameter Settings for Your Resources', + items => [ + { linktext => 'Set/Modify Resource Parameters - Helper Mode', + url => '/adm/helper/parameter.helper', + permission => $parm_permission, + help => 'Parameter_Helper', + }, + { linktext => 'Set/Modify Resource Parameters - Overview Mode', + url => '/adm/parmset?action=newoverview', + permission => $parm_permission, + help => 'Parameter_Overview', + }, + { linktext => 'Set/Modify Resource Parameters - Table Mode', + url => '/adm/parmset?action=settable', + permission => $parm_permission, + help => 'Table_Mode', + }]}, + { categorytitle => 'Existing Parameter Settings for Your Resources', + items => [ + { linktext => 'Modify Resource Parameters - Overview Mode', + url => '/adm/parmset?action=setoverview', + permission => $parm_permission, + help => 'Parameter_Overview', + }, + { linktext => 'Parameter Change Log and Course Blog Posting/User Notification', + url => '/adm/parmset?action=parameterchangelog', + permission => $parm_permission, + }]} ); - my $menu_html = ''; - foreach my $menu_item (@menu) { - if ($menu_item->{'divider'}) { - $menu_html .= '

'.&mt($menu_item->{'divider'}).'

'; - next; - } - next if (! $menu_item->{'permission'}); - $menu_html.='

'; - $menu_html.=''; - if (exists($menu_item->{'url'})) { - $menu_html.=qq{}; - } else { - $menu_html.= - qq{}; - } - $menu_html.= &mt($menu_item->{'text'}).''; - if (exists($menu_item->{'help'})) { - $menu_html.= - &Apache::loncommon::help_open_topic($menu_item->{'help'}); - } - $menu_html.='

'.$/; - } - $r->print($menu_html); +#---- Remove when done ---- +# my $menu_html = ''; +# foreach my $menu_item (@menu) { +# if ($menu_item->{'categorytitle'}) { +# $menu_html .= '

'.&mt($menu_item->{'categorytitle'}).'

'; +# next; +# } +# next if (! $menu_item->{'permission'}); +# $menu_html.='

'; +# $menu_html.=''; +# if (exists($menu_item->{'url'})) { +# $menu_html.=qq{}; +# } else { +# $menu_html.= +# qq{}; +# } +# $menu_html.= &mt($menu_item->{'linktext'}).''; +# if (exists($menu_item->{'help'})) { +# $menu_html.= +# &Apache::loncommon::help_open_topic($menu_item->{'help'}); +# } +# $menu_html.='

'.$/; +# } +# -------------------------- + + $r->print(&Apache::lonhtmlcommon::generate_menu(@menu)); return; } + ### Set portfolio metadata sub output_row { my ($r, $field_name, $field_text, $added_flag) = @_; @@ -3274,7 +3771,7 @@ sub output_row { } if (!($options =~ /deleted/)) { my @options= ( ['active', 'Show to student'], - ['stuadd', 'Provide text area for students to type metadata'], + ['stuadd', 'Provide text area for students to type catalog information'], ['choices','Provide choices for students to select from']); # ['onlyone','Student may select only one choice']); if ($added_flag) { @@ -3299,20 +3796,20 @@ sub output_row { my $single_checked; if ($options =~ m/onlyone/) { $multiple_checked = ""; - $single_checked = ' checked="checked"'; + $single_checked = " CHECKED "; } else { - $multiple_checked = ' checked="checked"'; + $multiple_checked = " CHECKED "; $single_checked = ""; } $output .= &Apache::loncommon::continue_data_table_row(); $output .= ''.(' ' x 10).''; + + Student may select multiple choices from list'; $output .= &Apache::loncommon::end_data_table_row(); $output .= &Apache::loncommon::continue_data_table_row(); $output .= ''.(' ' x 10).''; + + Student may select only one choice from list'; $output .= &Apache::loncommon::end_data_table_row(); } return ($output); @@ -3323,6 +3820,8 @@ sub order_meta_fields { my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; $r->print(&Apache::loncommon::start_page('Order Metadata Fields')); + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', + text=>"Add Metadata Field"}); &Apache::lonhtmlcommon::add_breadcrumb ({href=>"/adm/parmset?action=setrestrictmeta", text=>"Restrict Metadata"}, @@ -3408,6 +3907,8 @@ sub continue { } sub addmetafield { my ($r)=@_; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', + text=>"Add Metadata Field"}); $r->print(&Apache::loncommon::start_page('Add Metadata Field')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field')); my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; @@ -3458,6 +3959,8 @@ sub setrestrictmeta { my $output; my $item_num; my $put_result; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta', + text=>"Restrict Metadata"}); $r->print(&Apache::loncommon::start_page('Restrict Metadata')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata')); my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; @@ -3565,6 +4068,8 @@ sub get_deleted_meta_fieldnames { sub defaultsetter { my ($r) = @_; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults', + text=>"Set Defaults"}); my $start_page = &Apache::loncommon::start_page('Parameter Setting Default Actions'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults'); @@ -3703,12 +4208,12 @@ ENDINPUTDATE } elsif ($defkeytype{$tempkey} eq 'string_yesno') { my $yeschecked=''; my $nochecked=''; - if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked=' checked="checked"'; } - if (&rulescache($tempkey.'_value') eq 'no') { $nochecked=' checked="checked"'; } + if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; } + if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; } $r->print(< $lt{'yes'}
- +
+ ENDYESNO } else { $r->print(''); @@ -3716,8 +4221,8 @@ ENDYESNO $r->print(''.&Apache::loncommon::end_data_table_row()); } $r->print(&Apache::loncommon::end_data_table(). - "\n".''."\n". + "\n\n". &Apache::loncommon::end_page()); return; } @@ -3775,6 +4280,7 @@ sub load_parameter_names { close($config); $standard_parms{'int_pos'} = 'Positive Integer'; $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero'; + %standard_parms=&Apache::lonlocal::texthash(%standard_parms); } sub standard_parameter_names { @@ -3796,6 +4302,8 @@ sub standard_parameter_names { sub parm_change_log { my ($r)=@_; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', + text=>"Parameter Change Log"}); $r->print(&Apache::loncommon::start_page('Parameter Change Log')); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log')); @@ -3888,18 +4396,15 @@ sub parm_change_log { } else { $makenewrow=1; } - my $parmitem = &standard_parameter_names($parmname); $output .=''.$realm.''.$section.''. - &mt($parmitem).''. + &standard_parameter_names($parmname).''. ($part?&mt('Part: [_1]',$part):&mt('All Parts')).''; my $stillactive=0; if ($parmlog{$id}{'delflag'}) { $output .= &mt('Deleted'); } else { if ($typeflag) { - my $parmitem = &standard_parameter_names($value); - $parmitem = &mt($parmitem); - $output .= &mt('Type: [_1]',$parmitem); + $output .= &mt('Type: [_1]',&standard_parameter_names($value)); } else { my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what), $uname,$udom,$issection,$issection,$courseopt); @@ -3917,11 +4422,8 @@ sub parm_change_log { } $output .= ''; if ($stillactive) { - my $parmitem = &standard_parameter_names($parmname); - $parmitem = &mt($parmitem); - my $title=&mt('Changed [_1]',$parmitem); - my $description=&mt('Changed [_1] for [_2] to [_3]', - $parmitem,$realmdescription, + my $title=&mt('Changed [_1]',&standard_parameter_names($parmname)); + my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription, (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value)); if (($uname) && ($udom)) { $output .= @@ -3957,110 +4459,35 @@ sub parm_change_log { $r->print(&Apache::loncommon::end_page()); } -sub update_slots { - my ($slot_name,$cdom,$cnum,$symb,$uname,$udom) = @_; - my %slot=&Apache::lonnet::get_slot($slot_name); - if (!keys(%slot)) { - return 'error: slot does not exist'; - } - my $max=$slot{'maxspace'}; - if (!defined($max)) { $max=99999; } - - my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, - "^$slot_name\0"); - my ($tmp)=%consumed; - if ($tmp=~/^error: 2 / ) { - return 'error: unable to determine current slot status'; - } - my $last=0; - foreach my $key (keys(%consumed)) { - my $num=(split('\0',$key))[1]; - if ($num > $last) { $last=$num; } - if ($consumed{$key}->{'name'} eq $uname.':'.$udom) { - return 'ok'; - } - } - - if (scalar(keys(%consumed)) >= $max) { - return 'error: no space left in slot'; - } - my $wanted=$last+1; - - my %reservation=('name' => $uname.':'.$udom, - 'timestamp' => time, - 'symb' => $symb); - - my $success=&Apache::lonnet::newput('slot_reservations', - {"$slot_name\0$wanted" => - \%reservation}, - $cdom, $cnum); - if ($success eq 'ok') { - my %storehash = ( - symb => $symb, - slot => $slot_name, - action => 'reserve', - context => 'parameter', - ); - &Apache::lonnet::instructor_log('slotreservationslog',\%storehash, - '',$uname,$udom,$cnum,$cdom); - - &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash, - '',$uname,$udom,$uname,$udom); - } - return $success; -} - -sub delete_slots { - my ($slot_name,$cdom,$cnum,$uname,$udom,$symb) = @_; - my $delresult; - my %consumed = &Apache::lonnet::dump('slot_reservations',$cdom, - $cnum, "^$slot_name\0"); - if (&Apache::lonnet::error(%consumed)) { - return 'error: unable to determine current slot status'; - } - my ($tmp)=%consumed; - if ($tmp=~/^error: 2 /) { - return 'error: unable to determine current slot status'; - } - foreach my $key (keys(%consumed)) { - if ($consumed{$key}->{'name'} eq $uname.':'.$udom) { - my $num=(split('\0',$key))[1]; - my $entry = $slot_name.'\0'.$num; - $delresult = &Apache::lonnet::del('slot_reservations',[$entry], - $cdom,$cnum); - if ($delresult eq 'ok') { - my %storehash = ( - symb => $symb, - slot => $slot_name, - action => 'release', - context => 'parameter', - ); - &Apache::lonnet::instructor_log('slotreservationslog',\%storehash, - 1,$uname,$udom,$cnum,$cdom); - &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash, - 1,$uname,$udom,$uname,$udom); - } - } - } - return $delresult; -} - sub check_for_course_info { my $navmap = Apache::lonnavmaps::navmap->new(); return 1 if ($navmap); return 0; } +################################################## +################################################## + +=pod + +=item * handler + +Main handler. Calls &assessparms and &crsenv subroutines. + +=cut + +################################################## +################################################## + sub handler { my $r=shift; &reset_caches(); - if ($r->header_only) { - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; - return OK; - } + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + return OK if $r->header_only; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['action','state', 'pres_marker', @@ -4084,12 +4511,6 @@ sub handler { my $exists = &check_for_course_info(); if ($env{'request.course.id'} && $parm_permission && $exists) { - - # Start Page - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; - - # # Main switch on form.action and form.state, as appropriate # @@ -4097,60 +4518,34 @@ sub handler { # the table mode if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) && (!$env{'form.dis'})) || ($env{'form.symb'})) { - &Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters', - text=>"Problem Parameters"}); &assessparms($r); - } elsif (! exists($env{'form.action'})) { - $r->print(&header()); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager')); &print_main_menu($r,$parm_permission); - } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', - text=>"Overview Mode"}); + } elsif ($env{'form.action'} eq 'crsenv') { + &crsenv($r); + } elsif ($env{'form.action'} eq 'setoverview') { &overview($r); - } elsif ($env{'form.action'} eq 'addmetadata' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', - text=>"Add Metadata Field"}); + } elsif ($env{'form.action'} eq 'addmetadata') { &addmetafield($r); - } elsif ($env{'form.action'} eq 'ordermetadata' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', - text=>"Add Metadata Field"}); + } elsif ($env{'form.action'} eq 'ordermetadata') { &order_meta_fields($r); - } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta', - text=>"Restrict Metadata"}); + } elsif ($env{'form.action'} eq 'setrestrictmeta') { &setrestrictmeta($r); - } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', - text=>"Overview Mode"}); + } elsif ($env{'form.action'} eq 'newoverview') { &newoverview($r); - } elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults', - text=>"Set Defaults"}); + } elsif ($env{'form.action'} eq 'setdefaults') { &defaultsetter($r); - } elsif ($env{'form.action'} eq 'settable' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', - text=>"Table Mode", - help => 'Course_Setting_Parameters'}); + } elsif ($env{'form.action'} eq 'settable') { &assessparms($r); - } elsif ($env{'form.action'} eq 'parameterchangelog' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', - text=>"Parameter Change Log"}); + } elsif ($env{'form.action'} eq 'parameterchangelog') { &parm_change_log($r); - } elsif ($env{'form.action'} eq 'cleanparameters' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters', - text=>"Clean Parameters"}); + } elsif ($env{'form.action'} eq 'cleanparameters') { &clean_parameters($r); - } elsif ($env{'form.action'} eq 'dateshift1' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, - text=>"Shifting Dates"}); + } elsif ($env{'form.action'} eq 'dateshift1') { &date_shift_one($r); - } elsif ($env{'form.action'} eq 'dateshift2' && $parm_permission) { - &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, - text=>"Shifting Dates"}); + } elsif ($env{'form.action'} eq 'dateshift2') { &date_shift_two($r); - } elsif ($env{'form.action'} eq 'categorizecourse' && $parm_permission) { + } elsif ($env{'form.action'} eq 'categorizecourse') { &assign_course_categories($r); } } else { @@ -4172,3 +4567,11 @@ sub handler { 1; __END__ +=pod + +=back + +=cut + + +