--- loncom/interface/lonparmset.pm 2021/03/08 13:29:24 1.522.2.28.2.1 +++ loncom/interface/lonparmset.pm 2015/08/16 20:45:41 1.552 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.522.2.28.2.1 2021/03/08 13:29:24 raeburn Exp $ +# $Id: lonparmset.pm,v 1.552 2015/08/16 20:45:41 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,8 +36,7 @@ lonparmset - Handler to set parameters f =head1 SYNOPSIS -lonparmset provides an interface to setting content parameters in a -course. +lonparmset provides an interface to setting course parameters. =head1 DESCRIPTION @@ -130,7 +129,7 @@ javascript function 'pjump'. =item print_td() -=item check_other_groups() +=item print_usergroups() =item parm_control_group() @@ -150,7 +149,7 @@ Input: See list below =back -Outputs: See list below +Outputs: See list below: =over 4 @@ -324,6 +323,31 @@ use HTML::Entities; use LONCAPA qw(:DEFAULT :match); +sub startSettingsScreen { + my ($r,$mode,$crstype)=@_; + + my $tabtext = &mt('Course Settings'); + if ($crstype eq 'Community') { + $tabtext = &mt('Community Settings'); + } + $r->print("\n".''."\n"); + $r->print('
'); +} + +sub endSettingsScreen { + my ($r)=@_; + $r->print('
'); +} + + + sub parmval { my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_; return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec, @@ -767,17 +791,7 @@ sub valout { } } else { if ($type eq 'date_interval') { - my ($totalsecs,$donesuffix) = split(/_/,$value,2); - my ($usesdone,$donebuttontext,$proctor,$secretkey); - if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) { - $donebuttontext = $1; - (undef,$proctor,$secretkey) = split(/_/,$2); - $usesdone = 'done'; - } elsif ($donesuffix =~ /^done(|_.+)$/) { - $donebuttontext = &mt('Done'); - ($usesdone,$proctor,$secretkey) = split(/_/,$donesuffix); - } - my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($totalsecs); + my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value); my @timer; $year=$year-70; $mday--; @@ -810,13 +824,6 @@ sub valout { push(@timer,&mt('[quant,_1,sec]',0)); } $result.=join(", ",@timer); - if ($usesdone eq 'done') { - if ($secretkey) { - $result .= ' '.&mt('+ "[_1]" with proctor key: [_2]',$donebuttontext,$secretkey); - } else { - $result .= ' + "'.$donebuttontext.'"'; - } - } } elsif (&isdateparm($type)) { $result = &Apache::lonlocal::locallocaltime($value). &date_sanity_info($value); @@ -834,12 +841,8 @@ sub plink { my ($type,$dis,$value,$marker,$return,$call)=@_; my $winvalue=$value; unless ($winvalue) { - if ((&isdateparm($type)) || (&is_specialstring($type))) { + if (&isdateparm($type)) { $winvalue=$env{'form.recent_'.$type}; - } elsif ($type eq 'string_yesno') { - if ($env{'form.recent_string'} =~ /^(yes|no)$/i) { - $winvalue=$env{'form.recent_string'}; - } } else { $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]}; } @@ -872,22 +875,20 @@ sub page_js { $pjump_def function psub() { - var specstring = /^string_!(yesno|any)/i; if (document.parmform.pres_marker.value!='') { document.parmform.action+='#'+document.parmform.pres_marker.value; var typedef=new Array(); typedef=document.parmform.pres_type.value.split('_'); - if (document.parmform.pres_type.value!='') { - if ((typedef[0]=='date') || - (specstring.test(document.parmform.pres_type.value))) { - eval('document.parmform.recent_'+ - document.parmform.pres_type.value+ - '.value=document.parmform.pres_value.value;'); - } else { - eval('document.parmform.recent_'+typedef[0]+ - '.value=document.parmform.pres_value.value;'); - } + if (document.parmform.pres_type.value!='') { + if (typedef[0]=='date') { + eval('document.parmform.recent_'+ + document.parmform.pres_type.value+ + '.value=document.parmform.pres_value.value;'); + } else { + eval('document.parmform.recent_'+typedef[0]+ + '.value=document.parmform.pres_value.value;'); } + } document.parmform.submit(); } else { document.parmform.pres_value.value=''; @@ -902,7 +903,9 @@ sub page_js { var newWin = window.open(url, wdwName, options); newWin.focus(); } + // ]]> + $selscript ENDJS @@ -929,35 +932,126 @@ function showHide_courseContent() { COURSECONTENTSCRIPT } +sub toggleparmtextbox_js { + return <<"ENDSCRIPT"; + +if (!document.getElementsByClassName) { + function getElementsByClassName(node, classname) { + var a = []; + var re = new RegExp('(^| )'+classname+'( |$)'); + var els = node.getElementsByTagName("*"); + for(var i=0,j=els.length; i "group_or_section('cgroup')", @@ -1048,13 +1116,14 @@ sub startpage { '; my $start_page = - &Apache::loncommon::start_page('Set/Modify Course Parameters',$js, - {'add_entries' => \%loaditems,}); + &Apache::loncommon::start_page('Set/Modify Course Parameters',$js, + {'add_entries' => \%loaditems,}); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode'); my $escfilter=&Apache::lonhtmlcommon::entity_encode($env{'form.filter'}); my $escpart=&Apache::lonhtmlcommon::entity_encode($env{'form.part'}); $r->print($start_page.$breadcrumbs); + &startSettingsScreen($r,'parmset',$crstype); $r->print(< @@ -1069,8 +1138,7 @@ ENDHEAD sub print_row { my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone, - $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp, - $readonly)=@_; + $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups)=@_; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); @@ -1113,33 +1181,32 @@ sub print_row { my ($othergrp,$grp_parm,$controlgrp); if ($parmlev eq 'general') { - if ($uname) { - &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } elsif ($cgroup) { - &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly); + &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } elsif ($csec) { - &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } else { - &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } } elsif ($parmlev eq 'map') { if ($uname) { - &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } elsif ($cgroup) { - &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly); + &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } elsif ($csec) { - &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } else { - &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } } else { if ($uname) { if (@{$usersgroups} > 1) { my ($coursereply,$grp_parm,$controlgrp); ($coursereply,$othergrp,$grp_parm,$controlgrp) = - &check_other_groups($$part{$which}.'.'.$$name{$which}, + &print_usergroups($r,$$part{$which}.'.'.$$name{$which}, $rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt); if ($coursereply && $result > 3) { if (defined($controlgrp)) { @@ -1152,33 +1219,32 @@ sub print_row { } } - &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); - - &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); - &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); - &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); - &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); - - if ($csec) { - &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); - &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); - &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); - } + &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + + if ($csec) { + &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + } if ($cgroup) { - &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly); - &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly); - &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly); + &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); } - if ($uname) { + if ($uname) { if ($othergrp) { $r->print($othergrp); } - &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); - &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); - &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); - } + &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display); + } } # end of $parmlev if/else $r->print(''.$effective_parm.''); @@ -1197,27 +1263,21 @@ sub print_row { } sub print_td { - my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly)=@_; + my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_; $r->print(''); my $nolink = 0; - if ($readonly) { + if ($which == 11 || $which == 12) { $nolink = 1; - } else { - if ($which == 11 || $which == 12) { - $nolink = 1; - } elsif (($env{'request.course.sec'} ne '') && ($which > 9)) { + } elsif (($env{'request.course.sec'} ne '') && ($which > 9)) { + $nolink = 1; + } elsif ($mprefix =~ /availablestudent\&$/) { + if ($which > 3) { $nolink = 1; - } elsif ($which == 4 || $which == 5 || $which == 6) { - if ($noeditgrp) { - $nolink = 1; - } - } elsif ($mprefix =~ /availablestudent\&$/) { + } + } elsif ($mprefix =~ /examcode\&$/) { + unless ($which == 2) { $nolink = 1; - } elsif ($mprefix =~ /examcode\&$/) { - unless ($which == 2) { - $nolink = 1; - } } } if ($nolink) { @@ -1230,8 +1290,8 @@ sub print_td { $r->print(''."\n"); } -sub check_other_groups { - my ($what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_; +sub print_usergroups { + my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_; my $courseid = $env{'request.course.id'}; my $output; my $symb = &symbcache($rid); @@ -1246,6 +1306,7 @@ sub check_other_groups { if (($coursereply) && ($cgroup ne $resultgroup)) { if ($result > 3) { $bgcolor = '#AAFFAA'; + $grp_parm = &valout($coursereply,$resulttype); } $grp_parm = &valout($coursereply,$resulttype); $output = ''; @@ -1391,21 +1452,14 @@ sub isdateparm { return (($type=~/^date/) && (!($type eq 'date_interval'))); } -# Determine if parameter type is specialized string type (i.e., -# not just string or string_yesno. - -sub is_specialstring { - my $type=shift; - return (($type=~/^string_/) && (($type ne 'string_yesno'))); -} - # # parmmenu displays a list of the selected parameters. # It also offers a link to show/hide the complete parameter list # from which you can select all desired parameters. # sub parmmenu { - my ($r)=@_; + my ($r,$allparms,$pscat,$keyorder)=@_; + my $tempkey; $r->print(< // print('
'); - &shortCuts($r); + &shortCuts($r,$allparms,$pscat,$keyorder); $r->print('
'); } # return a hash @@ -1548,8 +1602,8 @@ sub lookUpTableParameter { 'lenient' => 'grading', 'retrypartial' => 'tries', 'discussvote' => 'misc', - 'examcode' => 'high_level_randomization', - ); + 'examcode' => 'high_level_randomization', + ); } sub whatIsMyCategory { @@ -1600,9 +1654,7 @@ sub category_order { sub parmboxes { my ($r,$allparms,$pscat,$keyorder)=@_; - my $tempkey; - my $tempparameter; - my %categories = &categories; + my %categories = &categories(); my %category_order = &category_order(); my %categoryList = ( 'time_settings' => [], @@ -1617,41 +1669,35 @@ sub parmboxes { 'misc' => [], ); - foreach $tempparameter (keys %$allparms) { + foreach my $tempparameter (keys(%$allparms)) { &whatIsMyCategory($tempparameter, \%categoryList); } #part to print the parm-list - $r->print('
'."\n"); - - #Print parameters - for my $key (sort { $category_order{$a} <=> $category_order{$b} } keys %categoryList) { - next if(@{$categoryList{$key}} == 0); + foreach my $key (sort { $category_order{$a} <=> $category_order{$b} } keys(%categoryList)) { + next if (@{$categoryList{$key}} == 0); + next if ($key eq ''); $r->print('
' - .'

' - .&mt($categories{$key}) - .'

'."\n"); - foreach $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) { - next if ($tempkey eq ''); + .'

'.&mt($categories{$key}).'

'."\n"); + foreach my $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) { $r->print('' .'
'."\n"); } - $r->print("
\n"); + $r->print('
'); } - - $r->print("\n"); + $r->print("\n"); } # # This function offers some links on the parameter section to get with one click a group a parameters # sub shortCuts { - my ($r)=@_; + my ($r,$allparms,$pscat,$keyorder)=@_; # Parameter Selection $r->print( @@ -1710,49 +1756,16 @@ sub partmenu { } sub usermenu { - my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups,$pssymb)=@_; + my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_; my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. - &Apache::loncommon::selectstudent_link('parmform','uname','udom','condition'). - &Apache::lonhtmlcommon::scripttag(<'. - $stuonly.'  '. - ''; my $sections=''; my %sectionhash = &Apache::loncommon::get_sections(); my $groups; - my %grouphash; - if (($pssymb) || &Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { - %grouphash = &Apache::longroup::coursegroups(); - } elsif ($env{'request.course.groups'} ne '') { - map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'}); - } + my %grouphash = &Apache::longroup::coursegroups(); my $g_s_header=''; my $g_s_footer=''; @@ -1769,7 +1782,7 @@ ENDJS $sections .= qq| onchange="group_or_section('csec')" |; } $sections .= '>'; - foreach my $section ('',sort keys %sectionhash) { + foreach my $section ('',sort(keys(%sectionhash))) { $sections.=''; @@ -1814,7 +1827,7 @@ function group_or_section(caller) { $groups .= qq| onchange="group_or_section('cgroup')" |; } $groups .= '>'; - foreach my $grp ('',sort keys %grouphash) { + foreach my $grp ('',sort(keys(%grouphash))) { $groups.='\n"; + $r->print('>'.$s."\n"); } - $output .= "\n"; - return $output; + $r->print("\n"); } sub groupmenu { - my ($selectedgroups)=@_; - my %grouphash; - if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { - %grouphash = &Apache::longroup::coursegroups(); - } elsif ($env{'request.course.groups'} ne '') { - map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'}); - } - return '' if (!%grouphash); + my ($r,$selectedgroups)=@_; + my %grouphash = &Apache::longroup::coursegroups(); + return if (!%grouphash); - my $output = ''); foreach my $group (sort(keys(%grouphash))) { - $output .= ' \n"; + $r->print('>'.$group."\n"); } - $output .= "\n"; - return $output; + $r->print("\n"); } + sub keysplit { my $keyp=shift; return (split(/\,/,$keyp)); @@ -2089,7 +2103,7 @@ sub keysinorder { my ($name,$keyorder)=@_; return sort { $$keyorder{$a} <=> $$keyorder{$b}; - } (keys %{$name}); + } (keys(%{$name})); } sub keysinorder_bytype { @@ -2101,14 +2115,14 @@ sub keysinorder_bytype { return ($a cmp $b); } $$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb}; - } (keys %{$name}); + } (keys(%{$name})); } sub keysindisplayorder { my ($name,$keyorder)=@_; return sort { $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b}; - } (keys %{$name}); + } (keys(%{$name})); } sub sortmenu { @@ -2155,7 +2169,8 @@ sub standardkeyorder { sub assessparms { - my ($r,$parm_permission) = @_; + my $r=shift; + # -------------------------------------------------------- Variable declaration @@ -2202,17 +2217,7 @@ sub assessparms { $csec = $env{'request.course.sec'}; } -# Check group privs. $cgroup=$env{'form.cgroup'}; - my $noeditgrp; - if ($cgroup ne '') { - unless (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { - if (($env{'request.course.groups'} eq '') || - (!grep(/^\Q$cgroup\E$/,split(/:/,$env{'request.course.groups'})))) { - $noeditgrp = 1; - } - } - } if ($udom=$env{'form.udom'}) { } elsif ($udom=$env{'request.role.domain'}) { @@ -2227,7 +2232,7 @@ sub assessparms { my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); - if (!@psprt) { $psprt[0]='0'; } + if (!@psprt) { $psprt[0]='all'; } if (($env{'form.part'}) && ($psprt[0] ne 'all')) { $psprt[0]=$env{'form.part'}; } my $pssymb=''; @@ -2265,8 +2270,10 @@ sub assessparms { $id=''; } else { $message= - ''.&mt("Unknown ID")." '$id' ". - &mt('at domain')." '$udom'"; + '

'. + &mt('Unknown ID [_1] at domain [_2]', + "'".$id."'","'".$udom."'"). + '

'; } } else { $uname=$env{'form.uname'}; @@ -2277,131 +2284,36 @@ sub assessparms { $uhome=&Apache::lonnet::homeserver($uname,$udom); if ($uhome eq 'no_host') { $message= - ''.&mt("Unknown user")." '$uname' ". - &mt("at domain")." '$udom'"; + '

'. + &mt('Unknown user [_1] at domain [_2]', + "'".$uname."'","'".$udom."'"). + '

'; $uname=''; } else { $csec=&Apache::lonnet::getsection($udom,$uname, $env{'request.course.id'}); if ($csec eq '-1') { - my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; - if ($env{'form.userroles'} eq 'any') { - if (($env{'user.name'} eq $uname) && ($env{'user.domain'} eq $udom)) { - $csec = $env{'request.course.sec'}; - $message = ''; - if ($crstype eq 'Community') { - $message .= &mt('User [_1] at domain [_2] has a non-member role in this community', - $uname,$udom); - } else { - $message .= &mt('User [_1] at domain [_2] has a non-student role in this course', - $uname,$udom); - } - $message .= ''; - } else { - my @possroles = ('in','ep','ta','cr'); - if ($crstype eq 'Community') { - unshift(@possroles,'co'); - } else { - unshift(@possroles,'cc'); - } - my %not_student_roles = - &Apache::lonnet::get_my_roles($uname,$udom,'userroles',['active'], - \@possroles,[$udom],1,1); - my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - my %sections_by_role; - foreach my $role (keys(%not_student_roles)) { - if ($role =~ /^\Q$cnum:$cdom:\E([^:]+):(|[^:]+)$/) { - my ($rolename,$sec) = ($1,$2); - if ($rolename =~ m{^cr/}) { - $rolename = 'cr'; - } - push(@{$sections_by_role{$rolename}},$sec); - } - } - my $numroles = scalar(keys(%sections_by_role)); - if ($numroles) { - foreach my $role (@possroles) { - if (ref($sections_by_role{$role}) eq 'ARRAY') { - my @secs = sort { $a <=> $b } @{$sections_by_role{$role}}; - $csec = $secs[0]; - last; - } - } - } - if ($csec eq '-1') { - $message = ''; - if ($crstype eq 'Community') { - $message .= &mt('User [_1] at domain [_2] does not have a role in this community', - $uname,$udom); - } else { - $message .= &mt('User [_1] at domain [_2] does not have a role in this course', - $uname,$udom); - } - $message .= ''; - $uname=''; - if ($env{'request.course.sec'} ne '') { - $csec=$env{'request.course.sec'}; - } else { - $csec=$env{'form.csec'}; - } - $cgroup=$env{'form.cgroup'}; - } else { - $message = ''; - if ($crstype eq 'Community') { - $message .= &mt('User [_1] at domain [_2] has a non-member role in this community', - $uname,$udom); - } else { - $message .= &mt('User [_1] at domain [_2] has a non-student role in this course', - $uname,$udom); - } - $message .= ''; - } - } - } else { - $message = ''; - if ($crstype eq 'Community') { - $message .= &mt('User [_1] at domain [_2] does not have a member role in this community', - $uname,$udom); - } else { - $message .= &mt('User [_1] at domain [_2] does not have a student role in this course', - $uname,$udom); - } - $message .= ''; - $uname=''; - if ($env{'request.course.sec'} ne '') { - $csec=$env{'request.course.sec'}; - } else { - $csec=$env{'form.csec'}; - } - $cgroup=$env{'form.cgroup'}; - } - } elsif ($env{'request.course.sec'} ne '') { - if ($csec ne $env{'request.course.sec'}) { - $message=''. - &mt("User '[_1]' at domain '[_2]' not in section '[_3]'", - $uname,$udom,$env{'request.course.sec'}). - ''; - $uname=''; - $csec=$env{'request.course.sec'}; - } + $message= + '

'. + &mt('User [_1] at domain [_2] not in this course', + "'".$uname."'","'".$udom."'"). + '

'; + $uname=''; + $csec=$env{'form.csec'}; $cgroup=$env{'form.cgroup'}; - } - if ($uname ne '') { + } else { my %name=&Apache::lonnet::userenvironment($udom,$uname, ('firstname','middlename','lastname','generation','id')); - $message .= "\n

\n".&mt('Full Name').': ' - .$name{'firstname'}.' '.$name{'middlename'}.' ' - .$name{'lastname'}.' '.$name{'generation'} - ."
\n".&mt('Student/Employee ID').': '.$name{'id'}.'

'; - @usersgroups = &Apache::lonnet::get_users_groups( - $udom,$uname,$env{'request.course.id'}); - if (@usersgroups > 0) { - unless (grep(/^\Q$cgroup\E$/,@usersgroups)) { - $cgroup = $usersgroups[0]; - } - } else { - $cgroup = ''; + $message="\n

\n".&mt("Full Name").": ". + $name{'firstname'}.' '.$name{'middlename'}.' ' + .$name{'lastname'}.' '.$name{'generation'}. + "
\n".&mt('Student/Employee ID').": ".$name{'id'}.'

'; + } + @usersgroups = &Apache::lonnet::get_users_groups( + $udom,$uname,$env{'request.course.id'}); + if (@usersgroups > 0) { + unless (grep(/^\Q$cgroup\E$/,@usersgroups)) { + $cgroup = $usersgroups[0]; } } } @@ -2419,7 +2331,7 @@ sub assessparms { $symbp{'0.0'} = ''; # ---------------------------------------------------------- Anything to store? - if ($env{'form.pres_marker'} && $parm_permission->{'edit'}) { + if ($env{'form.pres_marker'}) { my @markers=split(/\&\&\&/,$env{'form.pres_marker'}); my @values=split(/\&\&\&/,$env{'form.pres_value'}); my @types=split(/\&\&\&/,$env{'form.pres_type'}); @@ -2434,9 +2346,6 @@ sub assessparms { if (($env{'request.course.sec'} ne '') && ($markers[$i] =~ /\&(7|8|9)$/)) { next if ($csec ne $env{'request.course.sec'}); } - if ($markers[$i] =~ /\&(6|5|4)$/) { - next if ($noeditgrp); - } if ($markers[$i] =~ /^[\d.]+\&0_availablestudent\&(1|2|3)$/) { my (@ok_slots,@fail_slots,@del_slots); my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); @@ -2467,9 +2376,10 @@ sub assessparms { } } } - } elsif ($markers[$i] =~ /_(type|lenient|retrypartial|discussvote|examcode|printstartdate|printenddate)\&\d+$/) { + } elsif ($markers[$i] =~ /_(type|lenient|retrypartial|discussvote|examcode|printstartdate|printenddate|acc)\&\d+$/) { $name = $1; my $val = $values[$i]; + my $valmatch = ''; if ($name eq 'examcode') { if (&Apache::lonnet::validCODE($values[$i])) { $val = 'valid'; @@ -2479,22 +2389,39 @@ sub assessparms { if ($val > $now) { $val = 'future'; } - } + } } elsif ($name eq 'printenddate') { if ($val =~ /^\d+$/) { if ($val < $now) { $val = 'past'; } } + } elsif (($name eq 'lenient') || ($name eq 'acc')) { + my $stringtype = &get_stringtype($name); + my $stringmatch = &standard_string_matches($stringtype); + if (ref($stringmatch) eq 'ARRAY') { + foreach my $item (@{$stringmatch}) { + if (ref($item) eq 'ARRAY') { + my ($regexpname,$pattern) = @{$item}; + if ($pattern ne '') { + if ($val =~ /$pattern/) { + $valmatch = $regexpname; + $val = ''; + last; + } + } + } + } + } } $needsrelease = - $Apache::lonnet::needsrelease{"parameter:$name:$val"}; + $Apache::lonnet::needsrelease{"parameter:$name:$val:$valmatch"}; if ($needsrelease) { unless ($got_chostname) { ($chostname,$cmajor,$cminor) = ¶meter_release_vars(); $got_chostname = 1; - } - $needsnewer = ¶meter_releasecheck($name,$val, + } + $needsnewer = ¶meter_releasecheck($name,$val,$valmatch, $needsrelease, $cmajor,$cminor); } @@ -2519,18 +2446,16 @@ sub assessparms { } } #----------------------------------------------- if all selected, fill in array - if ($pscat[0] eq "all") {@pscat = (keys %allparms);} + if ($pscat[0] eq "all") {@pscat = (keys(%allparms));} if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries','type','problemstatus') }; - if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);} + if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys(%allparts));} # ------------------------------------------------------------------ Start page - &startpage($r,$pssymb); + my $crstype = &Apache::loncommon::course_type(); + &startpage($r,$pssymb,$crstype); foreach my $item ('tolerance','date_default','date_start','date_end', - 'date_interval','int','float','string','string_lenient', - 'string_examcode','string_deeplink','string_discussvote', - 'string_useslots','string_problemstatus','string_ip', - 'string_questiontype') { + 'date_interval','int','float','string') { $r->print(''). '" name="recent_'.$item.'" />'); @@ -2579,12 +2504,12 @@ ENDPARMSELSCRIPT # Step 2 $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2')); - &displaymenu($r,\%allparms,\@pscat,\%keyorder,'parmmenuscroll'); + &displaymenu($r,\%allparms,\@pscat,\@psprt,\%keyorder,'parmmenuscroll'); # Step 3 $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3')); $r->print(&Apache::lonhtmlcommon::start_pick_box()); - &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb); + &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups); $r->print(&Apache::lonhtmlcommon::row_closure(1)); $r->print(&Apache::lonhtmlcommon::end_pick_box()); @@ -2607,7 +2532,6 @@ ENDPARMSELSCRIPT .'' .'

'); } else { - $r->print(); # parameter screen for a single resource. my ($map,$iid,$resource)=&Apache::lonnet::decode_symb($pssymb); my $title = &Apache::lonnet::gettitle($pssymb); @@ -2617,13 +2541,7 @@ ENDPARMSELSCRIPT '
'); $r->print(&Apache::lonhtmlcommon::topic_bar('',&mt('Additional Display Specification (optional)'))); $r->print(&Apache::lonhtmlcommon::start_pick_box()); - $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')). - ''); - &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb); + &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups); $r->print(&Apache::lonhtmlcommon::row_closure(1)); $r->print(&Apache::lonhtmlcommon::end_pick_box()); $r->print('

' @@ -2647,15 +2565,12 @@ ENDPARMSELSCRIPT @pscat = @temp_pscat; + if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) { # ----------------------------------------------------------------- Start Table my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat; my $csuname=$env{'user.name'}; my $csudom=$env{'user.domain'}; - my $readonly = 1; - if ($parm_permission->{'edit'}) { - undef($readonly); - } if ($parmlev eq 'full') { # @@ -2678,7 +2593,7 @@ ENDPARMSELSCRIPT $userspan ++; } $r->print(''); - $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom"); + $r->print(&mt('User [_1] at Domain [_2]',"'".$uname."'","'".$udom."'").''); } my %lt=&Apache::lonlocal::texthash( 'pie' => "Parameter in Effect", @@ -2741,9 +2656,8 @@ ENDTABLEHEADFOUR my $defbgtwo=''; my $defbgthree = ''; - foreach (@ids) { + foreach my $rid (@ids) { - my $rid=$_; my ($inmapid)=($rid=~/\.(\d+)$/); if ((!$pssymb && @@ -2777,35 +2691,34 @@ ENDTABLEHEADFOUR my $uri=&Apache::lonnet::declutter($uris{$rid}); my $filter=$env{'form.filter'}; - foreach (&keysplit($keyp{$rid})) { - my $tempkeyp = $_; + foreach my $tempkeyp (&keysplit($keyp{$rid})) { if (grep $_ eq $tempkeyp, @catmarker) { - my $parmname=&Apache::lonnet::metadata($uri,$_.'.name'); + my $parmname=&Apache::lonnet::metadata($uri,$tempkeyp.'.name'); # We may only want certain parameters listed if ($filter) { unless ($filter=~/\Q$parmname\E/) { next; } } - $name{$_}=$parmname; - $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part'); + $name{$tempkeyp}=$parmname; + $part{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp.'.part'); - my $parmdis=&Apache::lonnet::metadata($uri,$_.'.display'); - if ($allparms{$name{$_}} ne '') { + my $parmdis=&Apache::lonnet::metadata($uri,$tempkeyp.'.display'); + if ($allparms{$name{$tempkeyp}} ne '') { my $identifier; if ($parmdis =~ /(\s*\[Part.*)$/) { $identifier = $1; } - $display{$_} = $allparms{$name{$_}}.$identifier; + $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier; } else { - $display{$_} = $parmdis; + $display{$tempkeyp} = $parmdis; } - unless ($display{$_}) { $display{$_}=''; } - $display{$_}.=' ('.$name{$_}.')'; - $default{$_}=&Apache::lonnet::metadata($uri,$_); - $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type'); - $thistitle=&Apache::lonnet::metadata($uri,$_.'.title'); + unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; } + $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')'; + $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp); + $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp.'.type'); + $thistitle=&Apache::lonnet::metadata($uri,$tempkeyp.'.title'); } } - my $totalparms=scalar keys %name; + my $totalparms=scalar(keys(%name)); if ($totalparms>0) { my $firstrow=1; my $title=&Apache::lonnet::gettitle($symbp{$rid}); @@ -2831,17 +2744,16 @@ ENDTABLEHEADFOUR $r->print(''.$maptitles{$mapp{$rid}}.''); - foreach (&keysinorder_bytype(\%name,\%keyorder)) { - + foreach my $item (&keysinorder_bytype(\%name,\%keyorder)) { unless ($firstrow) { $r->print(''); } else { undef $firstrow; } - &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default, + &print_row($r,$item,\%part,\%name,\%symbp,$rid,\%default, \%type,\%display,$defbgone,$defbgtwo, $defbgthree,$parmlev,$uname,$udom,$csec, - $cgroup,\@usersgroups,$noeditgrp,$readonly); + $cgroup,\@usersgroups); } } } @@ -2865,7 +2777,7 @@ ENDTABLEHEADFOUR #-------------------------------------------- for each map, gather information my $mapid; - foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) { + foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys(%maplist)) { my $maptitle = $maplist{$mapid}; #----------------------- loop through ids and get all parameter types for map @@ -2879,9 +2791,9 @@ ENDTABLEHEADFOUR # $r->print("Catmarker: @catmarker
\n"); - foreach (@ids) { - ($map)=(/([\d]*?)\./); - my $rid = $_; + foreach my $id (@ids) { + ($map)=($id =~ /([\d]*?)\./); + my $rid = $id; # $r->print("$mapid:$map: $rid
\n"); @@ -2896,12 +2808,11 @@ ENDTABLEHEADFOUR # When storing information, store as part 0 # When requesting information, request from full part #------------------------------------------------------------------- - foreach (&keysplit($keyp{$rid})) { - my $tempkeyp = $_; - my $fullkeyp = $tempkeyp; - $tempkeyp =~ s/_\w+_/_0_/; + foreach my $fullkeyp (&keysplit($keyp{$rid})) { + my $tempkeyp = $fullkeyp; + $tempkeyp =~ s/_\w+_/_0_/; - if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { + 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'); @@ -2960,12 +2871,11 @@ ENDTABLEHEADFOUR .&Apache::loncommon::end_data_table_header_row() ); - foreach (&keysinorder(\%name,\%keyorder)) { + foreach my $item (&keysinorder(\%name,\%keyorder)) { $r->print(&Apache::loncommon::start_data_table_row()); - &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, + &print_row($r,$item,\%part,\%name,\%symbp,$mapid,\%default, \%type,\%display,$defbgone,$defbgtwo,$defbgthree, - $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp, - $readonly); + $parmlev,$uname,$udom,$csec,$cgroup); } $r->print(&Apache::loncommon::end_data_table().'

' .'' @@ -2988,8 +2898,8 @@ ENDTABLEHEADFOUR my %type = (); my %default = (); - foreach (@ids) { - my $rid = $_; + foreach $id (@ids) { + my $rid = $id; my $uri=&Apache::lonnet::declutter($uris{$rid}); @@ -3000,11 +2910,10 @@ ENDTABLEHEADFOUR # When storing information, store as part 0 # When requesting information, request from full part #------------------------------------------------------------------- - foreach (&keysplit($keyp{$rid})) { - my $tempkeyp = $_; - my $fullkeyp = $tempkeyp; - $tempkeyp =~ s/_\w+_/_0_/; - if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) { + foreach my $fullkeyp (&keysplit($keyp{$rid})) { + my $tempkeyp = $fullkeyp; + $tempkeyp =~ s/_\w+_/_0_/; + 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'); @@ -3052,12 +2961,11 @@ ENDMAPONE .&Apache::loncommon::end_data_table_header_row() ); - foreach (&keysinorder(\%name,\%keyorder)) { + foreach my $item (&keysinorder(\%name,\%keyorder)) { $r->print(&Apache::loncommon::start_data_table_row()); - &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default, - \%type,\%display,$defbgone,$defbgtwo,$defbgthree, - $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp, - $readonly); + &print_row($r,$item,\%part,\%name,\%symbp,$mapid,\%default, + \%type,\%display,$defbgone,$defbgtwo,$defbgthree, + $parmlev,$uname,$udom,$csec,$cgroup); } $r->print(&Apache::loncommon::end_data_table() .'

' @@ -3066,6 +2974,7 @@ ENDMAPONE } # end of $parmlev eq general } $r->print(''); + &endSettingsScreen($r); $r->print(&Apache::loncommon::end_page()); } # end sub assessparms @@ -3107,19 +3016,19 @@ sub readdata { # Read userdata my $classlist=&Apache::loncoursedata::get_classlist(); - foreach (keys %$classlist) { - if ($_=~/^($match_username)\:($match_domain)$/) { - my ($tuname,$tudom)=($1,$2); - my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom); - foreach my $userkey (keys %{$useropt}) { - if ($userkey=~/^$env{'request.course.id'}/) { + foreach my $user (keys(%$classlist)) { + if ($user=~/^($match_username)\:($match_domain)$/) { + my ($tuname,$tudom)=($1,$2); + my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom); + foreach my $userkey (keys(%{$useropt})) { + if ($userkey=~/^\Q$env{'request.course.id'}\E/) { my $newkey=$userkey; - $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./; - $$resourcedata{$newkey}=$$useropt{$userkey}; - } + $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./; + $$resourcedata{$newkey}=$$useropt{$userkey}; + } + } } } - } if (wantarray) { return ($resourcedata,$classlist); } else { @@ -3145,16 +3054,17 @@ sub storedata { if ($key =~ /^form\.([a-z]+)\_(.+)$/) { my $cmd=$1; my $thiskey=$2; - next if ($cmd eq 'setipallow' || $cmd eq 'setipdeny'); + next if ($cmd eq 'settext' || $cmd eq 'setipallow' || $cmd eq 'setipdeny'); my ($tuname,$tudom)=&extractuser($thiskey); my $tkey=$thiskey; if ($tuname) { $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./; } if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') { - my ($data, $typeof, $text, $name, $valchk); + my ($data, $typeof, $text, $name, $valchk, $valmatch); if ($cmd eq 'set') { $data=$env{$key}; + $valmatch = ''; $valchk = $data; $typeof=$env{'form.typeof_'.$thiskey}; $text = &mt('Saved modified parameter for'); @@ -3162,6 +3072,21 @@ sub storedata { $name = 'type'; } elsif ($typeof eq 'string_lenient') { $name = 'lenient'; + my $stringmatch = &standard_string_matches($typeof); + if (ref($stringmatch) eq 'ARRAY') { + foreach my $item (@{$stringmatch}) { + if (ref($item) eq 'ARRAY') { + my ($regexpname,$pattern) = @{$item}; + if ($pattern ne '') { + if ($data =~ /$pattern/) { + $valmatch = $regexpname; + $valchk = ''; + last; + } + } + } + } + } } elsif ($typeof eq 'string_discussvote') { $name = 'discussvote'; } elsif ($typeof eq 'string_examcode') { @@ -3200,13 +3125,13 @@ sub storedata { } if ($name ne '') { my ($needsrelease,$needsnewer); - $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$valchk"}; + $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$valchk:$valmatch"}; if ($needsrelease) { unless ($got_chostname) { ($chostname,$cmajor,$cminor)=¶meter_release_vars(); $got_chostname = 1; } - $needsnewer = ¶meter_releasecheck($name,$valchk, + $needsnewer = ¶meter_releasecheck($name,$valchk,$valmatch, $needsrelease, $cmajor,$cminor); if ($needsnewer) { @@ -3253,7 +3178,7 @@ sub storedata { } # Store all course level my $delentries=$#deldata+1; - my @newdatakeys=keys %newdata; + my @newdatakeys=keys(%newdata); my $putentries=$#newdatakeys+1; if ($delentries) { if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') { @@ -3304,7 +3229,8 @@ sub parse_listdata_key { } sub listdata { - my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist,$readonly)=@_; + my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist)=@_; + # Start list output my $oldsection=''; @@ -3314,16 +3240,11 @@ sub listdata { $tableopen=0; my $foundkeys=0; my %keyorder=&standardkeyorder(); - my $readonlyall = $readonly; my ($secidx,%grouphash); if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) { $secidx = &Apache::loncoursedata::CL_SECTION(); - if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { - %grouphash = &Apache::longroup::coursegroups(); - } elsif ($env{'request.course.groups'} ne '') { - map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'}); - } + %grouphash = &Apache::longroup::coursegroups(); } foreach my $thiskey (sort { @@ -3365,8 +3286,9 @@ sub listdata { } $result; - } keys %{$listdata}) { + } keys(%{$listdata})) { + my $readonly; if ($$listdata{$thiskey.'.type'}) { my $thistype=$$listdata{$thiskey.'.type'}; if ($$resourcedata{$thiskey.'.type'}) { @@ -3375,9 +3297,6 @@ sub listdata { my ($middle,$part,$name)= ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); my $section=&mt('All Students'); - $readonly = $readonlyall; - my $userscope; - my $showval = $$resourcedata{$thiskey}; if ($middle=~/^\[(.*)\]/) { my $issection=$1; if ($issection=~/^useropt\:($match_username)\:($match_domain)/) { @@ -3385,12 +3304,11 @@ sub listdata { if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) { if (ref($classlist) eq 'HASH') { if (ref($classlist->{$stuname.':'.$studom}) eq 'ARRAY') { - next unless ($classlist->{$stuname.':'.$studom}->[$secidx] eq $env{'request.course.sec'}); + next unless ($classlist->{$stuname.':'.$studom}->[$secidx] eq $env{'request.course.sec'}); } } } - $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2); - $userscope = 1; + $section=&mt('User').": ".&Apache::loncommon::plainname($stuname,$studom); } else { if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) { if (exists($grouphash{$issection})) { @@ -3398,7 +3316,7 @@ sub listdata { } elsif ($issection eq $env{'request.course.sec'}) { $section = &mt('Section').': '.$issection; } else { - next; + next; } } else { $section=&mt('Group/Section').': '.$issection; @@ -3411,7 +3329,6 @@ sub listdata { $middle=~s/\.+$//; $middle=~s/^\.+//; my $realm=''.&mt('All Resources').''; - if ($middle=~/^(.+)\_\_\_\(all\)$/) { $realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).'
('.$1.')
'; } elsif ($middle) { @@ -3455,13 +3372,8 @@ sub listdata { ''.&mt($parmitem). ''); unless ($readonly) { - my $disabled; - if (($name eq 'availablestudent') && - (($showval eq '') || ($userscope))) { - $disabled = ' disabled="disabled"'; - } $r->print(''); + $thiskey.'" />'); } $r->print(''); $foundkeys++; @@ -3477,21 +3389,18 @@ sub listdata { $jskey, $$resourcedata{$thiskey}, '',1,$state)); - unless ($readonly) { + unless ($readonly) { $r->print( ''. (($$resourcedata{$thiskey}!=0)?''. &mt('Shift all dates based on this date').'':''). &date_sanity_info($$resourcedata{$thiskey}) - ); + ); } } elsif ($thistype eq 'date_interval') { - $r->print(&date_interval_selector($thiskey,$name, + $r->print(&date_interval_selector($thiskey, $$resourcedata{$thiskey},$readonly)); } elsif ($thistype =~ m/^string/) { - if ($name eq 'availablestudent') { - $readonly = 1; - } $r->print(&string_selector($thistype,$thiskey, $$resourcedata{$thiskey},$name,$readonly)); } else { @@ -3509,9 +3418,8 @@ sub listdata { sub date_interval_selector { - my ($thiskey, $pname, $showval, $readonly) = @_; - my ($result,%skipval); - my $currval = $showval; + my ($thiskey, $showval, $readonly) = @_; + my $result; foreach my $which (['days', 86400, 31], ['hours', 3600, 23], ['minutes', 60, 59], @@ -3525,51 +3433,6 @@ sub date_interval_selector { \%select,'',$readonly); $result .= ' '.&mt($name); } - if ($pname eq 'interval') { - unless ($skipval{'done'}) { - my $checkedon = ''; - my $checkedproc = ''; - my $currproctorkey = ''; - my $currprocdisplay = 'hidden'; - my $currdonetext = &mt('Done'); - my $checkedoff = ' checked="checked"'; - if ($currval =~ /^(?:\d+)_done$/) { - $checkedon = ' checked="checked"'; - $checkedoff = ''; - } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:$/) { - $currdonetext = $1; - $checkedon = ' checked="checked"'; - $checkedoff = ''; - } elsif ($currval =~ /^(?:\d+)_done_proctor_(.+)$/) { - $currproctorkey = $1; - $checkedproc = ' checked="checked"'; - $checkedoff = ''; - $currprocdisplay = 'text'; - } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:_proctor_(.+)$/) { - $currdonetext = $1; - $currproctorkey = $2; - $checkedproc = ' checked="checked"'; - $checkedoff = ''; - $currprocdisplay = 'text'; - } - my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"'; - my $disabled; - if ($readonly) { - $disabled = ' disabled="disabled"'; - } - $result .= '
'.&mt('Include "done" button'). - ''.(' 'x2). - ''.(' 'x2). - ''. - '&').'"'.$disabled.' />
'. - ''.&mt('Button text').': '. - '&').'"'.$disabled.' />'; - } - } unless ($readonly) { $result .= ''; } @@ -3630,7 +3493,7 @@ sub string_ip_selector { @{$access{'deny'}} = (''); } my ($disabled,$addmore); - if ($readonly) { + if ($disabled) { $disabled=' disabled="disabled"'; } else { $addmore = "\n".''; @@ -3646,7 +3509,7 @@ sub string_ip_selector { foreach my $curr (@{$access{$acctype}}) { $output .= '
'; if ($num > 0) { - $output .= ''.&mt('Remove').''; + $output .= ''.&mt('Remove').''; } $output .= '
'."\n"; $num ++; @@ -3663,7 +3526,6 @@ sub string_ip_selector { } { - my %strings = ( 'string_yesno' @@ -3678,7 +3540,7 @@ my %strings = => [[ 'problem', 'Standard Problem'], [ 'survey', 'Survey'], [ 'anonsurveycred', 'Anonymous Survey (credit for submission)'], - [ 'exam', 'Exam'], + [ 'exam', 'Bubblesheet Exam'], [ 'anonsurvey', 'Anonymous Survey'], [ 'randomizetry', 'New Randomization Each N Tries (default N=1)'], [ 'practice', 'Practice'], @@ -3686,16 +3548,34 @@ my %strings = 'string_lenient' => [['yes', 'Yes' ], [ 'no', 'No' ], - [ 'default', 'Default - only bubblesheet grading is lenient' ]], + [ 'default', 'Default - only bubblesheet grading is lenient' ], + [ 'weighted', 'Yes, weighted (optionresponse in checkbox mode)' ]], 'string_discussvote' => [['yes','Yes'], ['notended','Yes, unless discussion ended'], ['no','No']], 'string_ip' => [['_allowfrom_','Hostname(s), or IP(s) from which access is allowed'], - ['_denyfrom_','Hostname(s) or IP(s) from which access is disallowed']], + ['_denyfrom_',], 'Hostname(s) or IP(s) from which access is disallowed'], ); +my %stringmatches = ( + 'string_lenient' + => [['weighted','^\-?[.\d]+,\-?[.\d]+,\-?[.\d]+,\-?[.\d]+$'],], + 'string_ip' + => [['_allowfrom_','[^\!]+'], + ['_denyfrom_','\!']], + ); + +my %stringtypes = ( + type => 'string_questiontype', + lenient => 'string_lenient', + retrypartial => 'string_yesno', + discussvote => 'string_discussvote', + examcode => 'string_examcode', + acc => 'string_ip', + ); + sub standard_string_options { my ($string_type) = @_; if (ref($strings{$string_type}) eq 'ARRAY') { @@ -3704,41 +3584,74 @@ sub standard_string_options { return; } +sub standard_string_matches { + my ($string_type) = @_; + if (ref($stringmatches{$string_type}) eq 'ARRAY') { + return $stringmatches{$string_type}; + } + return; +} + +sub get_stringtype { + my ($name) = @_; + if (exists($stringtypes{$name})) { + return $stringtypes{$name}; + } + return; +} + sub string_selector { my ($thistype, $thiskey, $showval, $name, $readonly) = @_; if (!exists($strings{$thistype})) { - return &default_selector($thiskey,$showval,$readonly); + return &default_selector($thiskey,$showval,$readonly); } my %skiptype; if (($thistype eq 'string_questiontype') || ($thistype eq 'string_lenient') || ($thistype eq 'string_discussvote') || + ($thistype eq 'string_ip') || ($name eq 'retrypartial')) { my ($got_chostname,$chostname,$cmajor,$cminor); foreach my $possibilities (@{ $strings{$thistype} }) { next unless (ref($possibilities) eq 'ARRAY'); my ($parmval, $description) = @{ $possibilities }; - my $needsrelease=$Apache::lonnet::needsrelease{"parameter:$name:$parmval"}; + my $parmmatch; + if (ref($stringmatches{$thistype}) eq 'ARRAY') { + foreach my $item (@{$stringmatches{$thistype}}) { + if (ref($item) eq 'ARRAY') { + if ($parmval eq $item->[0]) { + $parmmatch = $parmval; + $parmval = ''; + last; + } + } + } + } + my $needsrelease=$Apache::lonnet::needsrelease{"parameter:$name:$parmval:$parmmatch"}; if ($needsrelease) { unless ($got_chostname) { ($chostname,$cmajor,$cminor)=¶meter_release_vars(); $got_chostname = 1; } - my $needsnewer=¶meter_releasecheck($name,$parmval,$needsrelease, - $cmajor,$cminor); + my $needsnewer=¶meter_releasecheck($name,$parmval,$parmmatch, + $needsrelease,$cmajor,$cminor); if ($needsnewer) { - $skiptype{$parmval} = 1; + if ($parmmatch ne '') { + $skiptype{$parmmatch} = 1; + } elsif ($parmval ne '') { + $skiptype{$parmval} = 1; + } } } } } if ($thistype eq 'string_ip') { - return &string_ip_selector($thiskey,$showval,$readonly); + return &string_ip_selector($thiskey,$showval,$readonly); } - + my ($result,$disabled); if ($readonly) { @@ -3758,7 +3671,7 @@ sub string_selector { foreach my $possibilities (@{ $strings{$thistype} }) { next unless (ref($possibilities) eq 'ARRAY'); my ($name, $description) = @{ $possibilities }; - next if ($skiptype{$name}); + next if ($skiptype{$name}); $rem = $i%($numinrow); if ($rem == 0) { if ($i > 0) { @@ -3766,24 +3679,66 @@ sub string_selector { } $result .= ''; } - $result .= ''. + my $colspan; + if ($i == @{ $strings{$thistype} }-1) { + $rem = @{ $strings{$thistype} }%($numinrow); + if ($rem) { + my $colsleft = $numinrow - $rem; + if ($colsleft) { + $colspan = $colsleft+1; + $colspan = ' colspan="'.$colspan.'"'; + } + } + } + my ($add,$onchange,$css_class); + if ($thistype eq 'string_lenient') { + if ($name eq 'weighted') { + my $display; + my %relatives = &Apache::lonlocal::texthash( + corrchkd => 'Correct (checked)', + corrunchkd => 'Correct (unchecked)', + incorrchkd => 'Incorrect (checked)', + incorrunchkd => 'Incorrect (unchecked)', + ); + my %textval = ( + corrchkd => '1.0', + corrunchkd => '1.0', + incorrchkd => '0.0', + incorrunchkd => '0.0', + ); + if ($showval =~ /^([\-\d\.]+)\,([\-\d\.]+)\,([\-\d\.]+)\,([\-\d\.]+)$/) { + $textval{'corrchkd'} = $1; + $textval{'corrunchkd'} = $2; + $textval{'incorrchkd'} = $3; + $textval{'incorrunchkd'} = $4; + $display = 'inline'; + $showval = $name; + } else { + $display = 'none'; + } + $add = '
'. + ''; + foreach my $reltype ('corrchkd','corrunchkd','incorrchkd','incorrunchkd') { + $add .= ''."\n". + ''; + } + $add .= '
'.&mt("Foil's submission status").''.&mt('Points').'
 '.$relatives{$reltype}.''. + '
'."\n"; + } + $onchange = ' onclick="javascript:toggleParmTextbox(this.form,'."'$thiskey'".');"'; + $css_class = ' class="LC_lenient_radio"'; + } + $result .= ''. ''; + $result .= ' />'.&mt($description).''.$add.''; $i++; } - $rem = @{ $strings{$thistype} }%($numinrow); - my $colsleft = $numinrow - $rem; - if ($colsleft > 1 ) { - $result .= ''. - ' '; - } elsif ($colsleft == 1) { - $result .= ' '; - } $result .= ''; } if ($result) { @@ -3795,21 +3750,30 @@ sub string_selector { sub oldversion_warning { my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_; my $desc; - my %stringtypes = ( - type => 'string_questiontype', - lenient => 'string_lenient', - retrypartial => 'string_yesno', - discussvote => 'string_discussvote', - examcode => 'string_examcode', - ); - if (exists($stringtypes{$name})) { + my $stringtype = &get_stringtype($name); + if ($stringtype ne '') { if ($name eq 'examcode') { $desc = $value; } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') { foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) { next unless (ref($possibilities) eq 'ARRAY'); my ($parmval, $description) = @{ $possibilities }; - if ($parmval eq $value) { + my $parmmatch; + if (ref($stringmatches{$stringtypes{$name}}) eq 'ARRAY') { + foreach my $item (@{$stringmatches{$stringtypes{$name}}}) { + if (ref($item) eq 'ARRAY') { + my ($regexpname,$pattern) = @{$item}; + if ($parmval eq $regexpname) { + if ($value =~ /$pattern/) { + $desc = $description; + $parmmatch = 1; + last; + } + } + } + } + last if ($parmmatch); + } elsif ($parmval eq $value) { $desc = $description; last; } @@ -3846,25 +3810,12 @@ sub oldversion_warning { # sub dateshift { - my ($shift,$numchanges)=@_; + my ($shift)=@_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $sec = $env{'request.course.sec'}; - my $secgrpregex; - if ($sec ne '') { - my @groups; - if ($env{'request.course.groups'} ne '') { - @groups = split(/:/,$env{'request.course.groups'}); - } - if (@groups) { - $secgrpregex = '(?:'.join('|',($sec,@groups)).')'; - } else { - $secgrpregex = $sec; - } - } my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs); # ugly retro fix for broken version of types - foreach my $key (keys %data) { + foreach my $key (keys(%data)) { if ($key=~/\wtype$/) { my $newkey=$key; $newkey=~s/type$/\.type/; @@ -3874,13 +3825,9 @@ sub dateshift { } my %storecontent=(); # go through all parameters and look for dates - foreach my $key (keys %data) { + foreach my $key (keys(%data)) { if ($data{$key.'.type'}=~/^date_(start|end)$/) { - if ($sec ne '') { - next unless ($key =~ /^$env{'request.course.id'}\.\[$secgrpregex\]\./); - } my $newdate=$data{$key}+$shift; - $$numchanges ++; $storecontent{$key}=$newdate; } } @@ -3894,19 +3841,16 @@ sub dateshift { } sub newoverview { - my ($r,$parm_permission) = @_; + my ($r) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $readonly = 1; - if ($parm_permission->{'edit'}) { - undef($readonly); - } + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', text=>"Overview Mode"}); my %loaditems = ( - 'onload' => "showHide_courseContent(); resize_scrollbox('mapmenuscroll','1','1');", + 'onload' => "showHide_courseContent(); resize_scrollbox('mapmenuscroll','1','1'); showHideLenient();", ); my $js = ' '; + my $start_page = &Apache::loncommon::start_page('Set Parameters',$js, {'add_entries' => \%loaditems,}); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); $r->print($start_page.$breadcrumbs); + &startSettingsScreen($r,'parmset',$crstype); $r->print(< +
ENDOVER my @ids=(); my %typep=(); @@ -3950,7 +3898,7 @@ ENDOVER my $pschp=$env{'form.pschp'}; my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); - if (!@psprt) { $psprt[0]='0'; } + if (!@psprt) { $psprt[0]='all'; } my @selected_sections = &Apache::loncommon::get_env_multiple('form.Section'); @@ -4002,26 +3950,16 @@ ENDOVER &displaymenu($r,\%allparms,\@pscat,\%keyorder); $r->print(&Apache::lonhtmlcommon::start_pick_box()); $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View'))); - my $sectionselector = §ionmenu(\@selected_sections); - my $groupselector = &groupmenu(\@selected_groups); $r->print(''. - ''); - if ($sectionselector) { - $r->print(''); - } - if ($groupselector) { - $r->print(''); - } - $r->print(''); - if ($sectionselector) { - $r->print(''); - } - if ($groupselector) { - $r->print(''); - } - $r->print('
'.&mt('Parts').''.&mt('Section(s)').''.&mt('Group(s)').'
'); + '
'.&mt('Parts').''.&mt('Section(s)'). + ''.&mt('Group(s)').'
'); &partmenu($r,\%allparts,\@psprt); - $r->print(''.$sectionselector.''.$groupselector.'
'); + $r->print(''); + §ionmenu($r,\@selected_sections); + $r->print(''); + &groupmenu($r,\@selected_groups); + $r->print(''); + #$r->print(''); $r->print(&Apache::lonhtmlcommon::row_closure(1)); $r->print(&Apache::lonhtmlcommon::end_pick_box()); $r->print(''); @@ -4055,13 +3993,12 @@ ENDOVER # List data - &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly); - } - $r->print(&tableend()); - unless ($readonly) { - $r->print(((($env{'form.store'}) || ($env{'form.dis'}))?'

':'')); + &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview'); } - $r->print('
'); + $r->print(&tableend(). + ((($env{'form.store'}) || ($env{'form.dis'}))?'

':''). + ''); + &endSettingsScreen($r); $r->print(&Apache::loncommon::end_page()); } @@ -4080,7 +4017,7 @@ sub secgroup_lister { $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat}; } elsif ($parmlev eq 'map') { # map-level parameter - foreach my $mapid (keys %{$allmaps}) { + foreach my $mapid (keys(%{$allmaps})) { if (($pschp ne 'all') && ($pschp ne $mapid)) { next; } my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat; $$listdata{$newparmkey}=1; @@ -4101,30 +4038,32 @@ sub secgroup_lister { } sub overview { - my ($r,$parm_permission) = @_; + my ($r) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; my $js = ''."\n"; - my $readonly = 1; - if ($parm_permission->{'edit'}) { - undef($readonly); - } &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', text=>"Overview Mode"}); - my $start_page=&Apache::loncommon::start_page('Modify Parameters',$js); + my %loaditems = ( + 'onload' => "showHideLenient();", + ); + + my $start_page=&Apache::loncommon::start_page('Modify Parameters',$js,{'add_entries' => \%loaditems,}); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); $r->print($start_page.$breadcrumbs); - $r->print('
'); + &startSettingsScreen($r,'parmset',$crstype); + $r->print(''); # Store modified - unless ($readonly) { - &storedata($r,$crs,$dom); - } + + &storedata($r,$crs,$dom); # Read modified data @@ -4135,26 +4074,12 @@ sub overview { unless ($sortorder) { $sortorder='realmstudent'; } &sortmenu($r,$sortorder); - my $submitbutton = ''; - - if ($readonly) { - $r->print('

'.$submitbutton.'

'); - } - - # List data - my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder,'overview',$classlist,$readonly); - - $r->print(&tableend().'

'); - if ($foundkeys) { - unless ($readonly) { - $r->print('

'.$submitbutton.'

'); - } - } else { - $r->print('

'.&mt('There are no parameters.').'

'); - } - $r->print('
'.&Apache::loncommon::end_page()); + my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder,'overview',$classlist); + $r->print(&tableend().'

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

'. + &Apache::loncommon::end_page()); } sub clean_parameters { @@ -4216,8 +4141,10 @@ ENDOVER $r->print(&mt('All users')); } elsif ($data{'scope_type'} eq 'user') { $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}}))); - } elsif ($data{'scope_type'} eq 'secgroup') { - $r->print(&mt('Group/Section: [_1]',$data{'scope'})); + } elsif ($data{'scope_type'} eq 'section') { + $r->print(&mt('Section: [_1]',$data{'scope'})); + } elsif ($data{'scope_type'} eq 'group') { + $r->print(&mt('Group: [_1]',$data{'scope'})); } $r->print('
'); if ($data{'realm_type'} eq 'all') { @@ -4228,8 +4155,8 @@ ENDOVER my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'}); $r->print(&mt('Resource: [_1]with ID: [_2]in folder [_3]', - $url.'
   ', - $resid.'
   ',$map)); + $url.'
   ', + $resid.'
   ',$map)); } $r->print('
   '.&mt('Part: [_1]',$data{'parameter_part'})); $r->print(''); @@ -4239,6 +4166,7 @@ ENDOVER $r->print(&Apache::loncommon::end_data_table().'

'. ''. '

'); + &endSettingsScreen($r); $r->print(&Apache::loncommon::end_page()); } @@ -4246,24 +4174,14 @@ sub date_shift_one { my ($r) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $sec = $env{'request.course.sec'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; + &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'}, text=>"Shifting Dates"}); - my $submit_text = &mt('Shift all dates accordingly'); - if ($sec ne '') { - my @groups; - if ($env{'request.course.groups'} ne '') { - @groups = split(/:/,$env{'request.course.groups'}); - } - if (@groups) { - $submit_text = &mt("Shift dates set just for your section/group(s), accordingly"); - } else { - $submit_text = &mt("Shift dates set just for your section, accordingly"); - } - } my $start_page=&Apache::loncommon::start_page('Shift Dates'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift'); $r->print($start_page.$breadcrumbs); + &startSettingsScreen($r,'parmset',$crstype); $r->print('
'. ''. @@ -4275,7 +4193,8 @@ sub date_shift_one { '
'.&mt('Currently set date:').''. &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'
'. ''. ''. - '
'); + ''); + &endSettingsScreen($r); $r->print(&Apache::loncommon::end_page()); } @@ -4283,57 +4202,26 @@ sub date_shift_two { my ($r) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - my $sec = $env{'request.course.sec'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; &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($start_page.$breadcrumbs); + &startSettingsScreen($r,'parmset',$crstype); my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted'); - $r->print('

'.&mt('Shift Dates').'

'); - if ($sec ne '') { - my @groups; - if ($env{'request.course.groups'} ne '') { - @groups = split(/:/,$env{'request.course.groups'}); - } - if (@groups) { - $r->print('

'. - &mt("Shift dates set just for your section/group(s), such that [_1] becomes [_2]", - &Apache::lonlocal::locallocaltime($env{'form.timebase'}), - &Apache::lonlocal::locallocaltime($timeshifted)). - '

'); - } else { - $r->print('

'. - &mt("Shift dates set just for your section, such that [_1] becomes [_2]", - &Apache::lonlocal::locallocaltime($env{'form.timebase'}), - &Apache::lonlocal::locallocaltime($timeshifted)). - '

'); - } - } else { - $r->print('

'.&mt('Shifting all dates such that [_1] becomes [_2]', - &Apache::lonlocal::locallocaltime($env{'form.timebase'}), - &Apache::lonlocal::locallocaltime($timeshifted)). - '

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

'.&mt('Shift Dates').'

'. + '

'.&mt('Shifting all dates such that [_1] becomes [_2]', + &Apache::lonlocal::locallocaltime($env{'form.timebase'}), + &Apache::lonlocal::locallocaltime($timeshifted)).'

'); my $delta=$timeshifted-$env{'form.timebase'}; - my $numchanges = 0; - my $result = &dateshift($delta,\$numchanges); - if ($result eq 'ok') { - $r->print( - &Apache::lonhtmlcommon::confirm_success(&mt('Completed shifting of [quant,_1,date setting]', - $numchanges))); - } elsif ($result eq 'con_delayed') { - $r->print( - &Apache::lonhtmlcommon::confirm_success(&mt('Queued shifting of [quant,_1,date setting]', - $numchanges))); - } else { - $r->print( - &Apache::lonhtmlcommon::confirm_success(&mt('An error occurred attempting to shift dates'),1)); - } + &dateshift($delta); $r->print( + &Apache::lonhtmlcommon::confirm_success(&mt('Done')). '

'. &Apache::lonhtmlcommon::actionbox( [''.&mt('Content and Problem Settings').''])); + &endSettingsScreen($r); $r->print(&Apache::loncommon::end_page()); } @@ -4349,7 +4237,8 @@ sub parse_key { $data{'scope_type'} = 'user'; $data{'scope'} = [$1,$2]; } else { - $data{'scope_type'} = 'secgroup'; + #FIXME check for group scope + $data{'scope_type'} = 'section'; } $middle=~s/^\[(.*)\]//; } @@ -4377,7 +4266,7 @@ sub parse_key { sub header { - return &Apache::loncommon::start_page('Content and Problem Settings'); + return &Apache::loncommon::start_page('Settings'); } @@ -4390,6 +4279,7 @@ sub print_main_menu { my $crstype = &Apache::loncommon::course_type(); my $lc_crstype = lc($crstype); + &startSettingsScreen($r,'parmset',$crstype); $r->print(< @@ -4400,73 +4290,35 @@ ENDMAINFORMHEAD my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'}); my $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'}); - my $vcb = &Apache::lonnet::allowed('vcb',$env{'request.course.id'}); - my $vpa = &Apache::lonnet::allowed('vpa',$env{'request.course.id'}); if ((!$dcm) && ($env{'request.course.sec'} ne '')) { $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'}. '/'.$env{'request.course.sec'}); } - if ((!$vcb) && ($env{'request.course.sec'} ne '')) { - $vcb = &Apache::lonnet::allowed('vcb',$env{'request.course.id'}. - '/'.$env{'request.course.sec'}); - } - my (%linktext,%linktitle,%url); - if ($parm_permission->{'edit'}) { - %linktext = ( - newoverview => 'Edit Resource Parameters - Overview Mode', - settable => 'Edit Resource Parameters - Table Mode', - setoverview => 'Modify Resource Parameters - Overview Mode', - ); - %linktitle = ( - newoverview => 'Set/Modify resource parameters in overview mode.', - settable => 'Set/Modify resource parameters in table mode.', - setoverview => 'Set/Modify existing resource parameters in overview mode.', - ); - } else { - %linktext = ( - newoverview => 'View Resource Parameters - Overview Mode', - settable => 'View Resource Parameters - Table Mode', - setoverview => 'View Resource Parameters - Overview Mode', - ); - %linktitle = ( - newoverview => 'Display resource parameters in overview mode.', - settable => 'Display resource parameters in table mode.', - setoverview => 'Display existing resource parameters in overview mode.', - ); - } - if ($mgr) { - $linktext{'resettimes'} = 'Reset Student Access Times'; - $linktitle{'resettimes'} = "Reset access times for folders/maps, resources or the $lc_crstype."; - $url{'resettimes'} = '/adm/helper/resettimes.helper'; - } elsif ($vgr) { - $linktext{'resettimes'} = 'Display Student Access Times', - $linktitle{'resettimes'} = "Display access times for folders/maps, resources or the $lc_crstype.", - $url{'resettimes'} = '/adm/accesstimes'; - } + my @menu = ( { categorytitle=>"Content Settings for this $crstype", items => [ { linktext => 'Portfolio Metadata', url => '/adm/parmset?action=setrestrictmeta', - permission => $parm_permission->{'setrestrictmeta'}, + permission => $parm_permission, linktitle => "Restrict metadata for this $lc_crstype." , icon =>'contact-new.png' , }, - { linktext => $linktext{'resettimes'}, - url => $url{'resettimes'}, - permission => ($vgr || $mgr), - linktitle => $linktitle{'resettimes'}, - icon => 'start-here.png', + { linktext => 'Reset Student Access Times', + url => '/adm/helper/resettimes.helper', + permission => $mgr, + linktitle => "Reset access times for folders/maps, resources or the $lc_crstype." , + icon => 'start-here.png' , }, { linktext => 'Blocking Communication/Resource Access', url => '/adm/setblock', - permission => ($vcb || $dcm), + permission => $dcm, linktitle => 'Configure blocking of communication/collaboration and access to resources during an exam', icon => 'comblock.png', }, { linktext => 'Set Parameter Setting Default Actions', url => '/adm/parmset?action=setdefaults', - permission => $parm_permission->{'setdefaults'}, + permission => $parm_permission, linktitle =>'Set default actions for parameters.' , icon => 'folder-new.png' , }]}, @@ -4474,43 +4326,45 @@ ENDMAINFORMHEAD items => [ { linktext => 'Edit Resource Parameters - Helper Mode', url => '/adm/helper/parameter.helper', - permission => $parm_permission->{'helper'}, + permission => $parm_permission, linktitle =>'Set/Modify resource parameters in helper mode.' , icon => 'dialog-information.png' , #help => 'Parameter_Helper', }, - { linktext => $linktext{'newoverview'}, + { linktext => 'Edit Resource Parameters - Overview Mode', url => '/adm/parmset?action=newoverview', - permission => $parm_permission->{'newoverview'}, - linktitle => $linktitle{'newoverview'}, - icon => 'edit-find.png', + permission => $parm_permission, + linktitle =>'Set/Modify resource parameters in overview mode.' , + icon => 'edit-find.png' , #help => 'Parameter_Overview', }, - { linktext => $linktext{'settable'}, + { linktext => 'Edit Resource Parameters - Table Mode', url => '/adm/parmset?action=settable', - permission => $parm_permission->{'settable'}, - linktitle => $linktitle{'settable'}, - icon => 'edit-copy.png', + permission => $parm_permission, + linktitle =>'Set/Modify resource parameters in table mode.' , + icon => 'edit-copy.png' , #help => 'Table_Mode', }]}, { categorytitle => 'Existing Parameter Settings for Resources', items => [ - { linktext => $linktext{'setoverview'}, + { linktext => 'Modify Resource Parameters - Overview Mode', url => '/adm/parmset?action=setoverview', - permission => $parm_permission->{'setoverview'}, - linktitle => $linktitle{'setoverview'}, - icon => 'preferences-desktop-wallpaper.png', + permission => $parm_permission, + linktitle =>'Set/Modify existing resource parameters in overview mode.' , + icon => 'preferences-desktop-wallpaper.png' , #help => 'Parameter_Overview', }, { linktext => 'Change Log', url => '/adm/parmset?action=parameterchangelog', - permission => $parm_permission->{'parameterchangelog'}, + permission => $parm_permission, linktitle =>"View parameter and $lc_crstype blog posting/user notification change log." , icon => 'document-properties.png', }]} ); $r->print(&Apache::lonhtmlcommon::generate_menu(@menu)); - $r->print(''.&Apache::loncommon::end_page()); + $r->print(''); + &endSettingsScreen($r); + $r->print(&Apache::loncommon::end_page()); return; } @@ -4578,6 +4432,7 @@ sub order_meta_fields { my $idx = 1; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};; $r->print(&Apache::loncommon::start_page('Order Metadata Fields')); &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', text=>"Add Metadata Field"}); @@ -4586,11 +4441,12 @@ sub order_meta_fields { text=>"Restrict Metadata"}, {text=>"Order Metadata"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata')); + &startSettingsScreen($r,'parmset',$crstype); if ($env{'form.storeorder'}) { my $newpos = $env{'form.newpos'} - 1; my $currentpos = $env{'form.currentpos'} - 1; my @neworder = (); - my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}; + my @oldorder = split(/,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}); my $i; if ($newpos > $currentpos) { # moving stuff up @@ -4624,10 +4480,10 @@ sub order_meta_fields { } my $fields = &get_added_meta_fieldnames($env{'request.course.id'}); my $ordered_fields; - my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}; + my @fields_in_order = split(/,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}); if (!@fields_in_order) { # no order found, pick sorted order then create metadata.addedorder key. - foreach my $key (sort keys %$fields) { + foreach my $key (sort(keys(%$fields))) { push @fields_in_order, $key; $ordered_fields = join ",", @fields_in_order; } @@ -4655,6 +4511,7 @@ sub order_meta_fields { $idx ++; } $r->print(''); + &endSettingsScreen($r); return 'ok'; } @@ -4663,7 +4520,7 @@ sub continue { my $output; $output .= '
'; $output .= ''; - $output .= ''; + $output .= ''; return ($output); } @@ -4676,6 +4533,8 @@ sub addmetafield { $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field')); my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; + &startSettingsScreen($r,'parmset',$crstype); if (exists($env{'form.undelete'})) { my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield'); foreach my $meta_field(@meta_fields) { @@ -4685,10 +4544,7 @@ sub addmetafield { my $put_result = &Apache::lonnet::put('environment', {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs); - $r->print(&mt('Undeleted Metadata Field [_1] with result [_2]', - ''.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}. - '',$put_result). - '
'); + $r->print('Undeleted Metadata Field '.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}." with result ".$put_result.'
'); } $r->print(&continue()); } elsif (exists($env{'form.fieldname'})) { @@ -4700,17 +4556,12 @@ sub addmetafield { {'metadata.'.$meta_field.'.values'=>"", 'metadata.'.$meta_field.'.added'=>"$display_field", 'metadata.'.$meta_field.'.options'=>""},$dom,$crs); - $r->print(&mt('Added new Metadata Field [_1] with result [_2]', - ''.$env{'form.fieldname'}.'',$put_result). - '
'); + $r->print('Added new Metadata Field '.$env{'form.fieldname'}." with result ".$put_result.'
'); $r->print(&continue()); } else { my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'}); if ($fields) { - $r->print(&mt('You may undelete previously deleted fields.'). - '
'. - &mt('Check those you wish to undelete and click Undelete.'). - '
'); + $r->print('You may undelete previously deleted fields.
Check those you wish to undelete and click Undelete.
'); $r->print(''); foreach my $key(keys(%$fields)) { $r->print(''.$$fields{$key}.'
print(''); $r->print('
'); } - $r->print('
'. - &mt('[_1]Or[_2] you may enter a new metadata field name.', - '',''). - '
'); + $r->print('
Or you may enter a new metadata field name.print('
'); - $r->print(''); + $r->print(''); } $r->print('
'); + &endSettingsScreen($r); } @@ -4742,13 +4591,10 @@ sub setrestrictmeta { $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata')); my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; + &startSettingsScreen($r,'parmset',$crstype); my $key_base = $env{'course.'.$env{'request.course.id'}.'.'}; my $save_field = ''; - my %lt = &Apache::lonlocal::texthash( - addm => 'Add Metadata Field', - ordm => 'Order Metadata Fields', - save => 'Save', - ); if ($env{'form.restrictmeta'}) { foreach my $field (sort(keys(%env))) { if ($field=~m/^form.(.+)_(.+)$/) { @@ -4787,25 +4633,28 @@ sub setrestrictmeta { my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); # Now get possible added metadata fields my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'}); + my $row_alt = 1; $output .= &Apache::loncommon::start_data_table(); foreach my $field (sort(keys(%metadata_fields))) { if ($field ne 'courserestricted') { + $row_alt = $row_alt ? 0 : 1; $output.= &output_row($r, $field, $metadata_fields{$field}); } } my $buttons = (< +
- +

- + ENDButtons my $added_flag = 1; foreach my $field (sort(keys(%$added_metadata_fields))) { - $output.= &output_row($r,$field,$$added_metadata_fields{$field},$added_flag); + $row_alt = $row_alt ? 0 : 1; + $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt); } $output .= &Apache::loncommon::end_data_table(); $r->print(< ENDenv + &endSettingsScreen($r); $r->print(&Apache::loncommon::end_page()); return 'ok'; } @@ -4854,14 +4704,16 @@ sub defaultsetter { &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults', text=>"Set Defaults"}); + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; my $start_page = - &Apache::loncommon::start_page('Parameter Setting Default Actions'); + &Apache::loncommon::start_page('Parameter Setting Default Actions'); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults'); $r->print($start_page.$breadcrumbs); + &startSettingsScreen($r,'parmset',$crstype); $r->print(''); - my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; my @ids=(); my %typep=(); my %keyp=(); @@ -4912,11 +4764,11 @@ sub defaultsetter { } } } - foreach my $key (keys %allparms) { + foreach my $key (keys(%allparms)) { $newrules{$key.'_triggers'}=$triggers{$key}; } - &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs); - &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs); + &Apache::lonnet::put('parmdefactions',\%newrules,$cdom,$cnum); + &Apache::lonnet::del('parmdefactions',\@delrules,$cdom,$cnum); &resetrulescache(); } my %lt=&Apache::lonlocal::texthash('days' => 'Days', @@ -5004,6 +4856,7 @@ ENDYESNO $r->print(&Apache::loncommon::end_data_table(). "\n".''."\n"); + &endSettingsScreen($r); $r->print(&Apache::loncommon::end_page()); return; } @@ -5050,7 +4903,7 @@ my %standard_parms; my %standard_parms_types; sub load_parameter_names { - open(my $config,"<","$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab"); + open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab"); while (my $configline=<$config>) { if ($configline !~ /\S/ || $configline=~/^\#/) { next; } chomp($configline); @@ -5065,7 +4918,6 @@ sub load_parameter_names { close($config); $standard_parms{'int_pos'} = 'Positive Integer'; $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero'; - $standard_parms{'scoreformat'} = 'Format for display of score'; } sub standard_parameter_names { @@ -5092,7 +4944,10 @@ sub standard_parameter_types { } sub parm_change_log { - my ($r,$parm_permission)=@_; + my ($r)=@_; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'} &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', text=>"Parameter Change Log"}); my $js = ''."\n"; $r->print(&Apache::loncommon::start_page('Parameter Change Log',$js)); $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log')); - my %parmlog=&Apache::lonnet::dump('nohist_parameterlog', - $env{'course.'.$env{'request.course.id'}.'.domain'}, - $env{'course.'.$env{'request.course.id'}.'.num'}); + &startSettingsScreen($r,'parmset',$crstype); + my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',$cdom,$cnum); if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); } @@ -5121,19 +4975,12 @@ sub parm_change_log { $r->print(&Apache::loncommon::display_filter('parmslog').' '."\n". ''. '
'); - my $readonly = 1; - if ($parm_permission->{'edit'}) { - undef($readonly); - } - my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'}, - $env{'course.'.$env{'request.course.id'}.'.domain'}); + + my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row(). ''.&mt('Time').''.&mt('User').''.&mt('Extent').''.&mt('Users').''. - &mt('Parameter').''.&mt('Part').''.&mt('New Value').''); - unless ($readonly) { - $r->print(''.&mt('Announce').''); - } - $r->print(&Apache::loncommon::end_data_table_header_row()); + &mt('Parameter').''.&mt('Part').''.&mt('New Value').''.&mt('Announce').''. + &Apache::loncommon::end_data_table_header_row()); my $shown=0; my $folder=''; if ($env{'form.displayfilter'} eq 'currentfolder') { @@ -5145,12 +4992,6 @@ sub parm_change_log { } if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); } } - my $numgroups = 0; - my @groups; - if ($env{'request.course.groups'} ne '') { - @groups = split(/:/,$env{'request.course.groups'}); - $numgroups = scalar(@groups); - } foreach my $id (sort { if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) { @@ -5172,8 +5013,7 @@ sub parm_change_log { $parmlog{$id}{'exe_uname'}, $parmlog{$id}{'exe_udom'}); my $send_msg_link=''; - if ((!$readonly) && - (($parmlog{$id}{'exe_uname'} ne $env{'user.name'}) + if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'}) || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) { $send_msg_link ='
'. &Apache::loncommon::messagewrapper(&mt('Send message'), @@ -5191,11 +5031,10 @@ sub parm_change_log { my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)= &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag); if ($env{'request.course.sec'} ne '') { - next if (($issection ne '') && (!(($issection eq $env{'request.course.sec'}) || - ($numgroups && (grep(/^\Q$issection\E$/,@groups)))))); + next if (($issection ne '') && ($issection ne $env{'request.course.sec'})); if ($uname ne '') { my $stusection = &Apache::lonnet::getsection($uname,$udom,$env{'request.course.id'}); - next if (($stusection ne '-1') && ($stusection ne $env{'request.course.sec'})); + next if (($stusection ne '-1') && ($stusection ne $env{'request.course.sec'})); } } if ($env{'form.displayfilter'} eq 'currentfolder') { @@ -5251,31 +5090,27 @@ sub parm_change_log { } } } - $output .= ''; - - unless ($readonly) { - $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, - (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value)); - if (($uname) && ($udom)) { - $output .= - &Apache::loncommon::messagewrapper('Notify User', - $uname,$udom,$title, - $description); - } else { - $output .= - &Apache::lonrss::course_blog_link($id,$title, - $description); - } - } - $output .= ''; - } - $output .= &Apache::loncommon::end_data_table_row(); + $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, + (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value)); + if (($uname) && ($udom)) { + $output .= + &Apache::loncommon::messagewrapper('Notify User', + $uname,$udom,$title, + $description); + } else { + $output .= + &Apache::lonrss::course_blog_link($id,$title, + $description); + } + } + $output .= ''.&Apache::loncommon::end_data_table_row(); } if ($env{'form.displayfilter'} eq 'containing') { my $wholeentry=$about_me_link.':'. @@ -5295,6 +5130,7 @@ sub parm_change_log { || $shown<=$env{'form.show'})) { last; } } $r->print(&Apache::loncommon::end_data_table()); + &endSettingsScreen($r); $r->print(&Apache::loncommon::end_page()); } @@ -5343,10 +5179,10 @@ sub update_slots { context => 'parameter', ); &Apache::lonnet::write_log('course','slotreservationslog',\%storehash, - '',$uname,$udom,$cnum,$cdom); + '',$uname,$udom,$cnum,$cdom); &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash, - '',$uname,$udom,$uname,$udom); + '',$uname,$udom,$uname,$udom); } return $success; } @@ -5377,9 +5213,9 @@ sub delete_slots { context => 'parameter', ); &Apache::lonnet::write_log('course','slotreservationslog',\%storehash, - 1,$uname,$udom,$cnum,$cdom); + 1,$uname,$udom,$cnum,$cdom); &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash, - 1,$uname,$udom,$uname,$udom); + 1,$uname,$udom,$uname,$udom); } } } @@ -5402,58 +5238,20 @@ sub parameter_release_vars { } sub parameter_releasecheck { - my ($name,$value,$needsrelease,$cmajor,$cminor) = @_; + my ($name,$value,$valmatch,$needsrelease,$cmajor,$cminor) = @_; my $needsnewer; my ($needsmajor,$needsminor) = split(/\./,$needsrelease); if (($cmajor < $needsmajor) || ($cmajor == $needsmajor && $cminor < $needsminor)) { $needsnewer = 1; - } else { - &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.':'.$value}); + } elsif ($valmatch) { + &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.'::'.$valmatch}); + } elsif ($value) { + &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.':'.$value.':'}); } return $needsnewer; } -sub get_permission { - my %permission; - my $allowed = 0; - return (\%permission,$allowed) unless ($env{'request.course.id'}); - if ((&Apache::lonnet::allowed('opa',$env{'request.course.id'})) || - (&Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'. - $env{'request.course.sec'}))) { - %permission= ( - 'edit' => 1, - 'set' => 1, - 'setoverview' => 1, - 'addmetadata' => 1, - 'ordermetadata' => 1, - 'setrestrictmeta' => 1, - 'newoverview' => 1, - 'setdefaults' => 1, - 'settable' => 1, - 'parameterchangelog' => 1, - 'cleanparameters' => 1, - 'dateshift1' => 1, - 'dateshift2' => 1, - 'helper' => 1, - ); - } elsif ((&Apache::lonnet::allowed('vpa',$env{'request.course.id'})) || - (&Apache::lonnet::allowed('vpa',$env{'request.course.id'}.'/'. - $env{'request.course.sec'}))) { - %permission = ( - 'set' => 1, - 'settable' => 1, - 'newoverview' => 1, - 'setoverview' => 1, - 'parameterchangelog' => 1, - ); - } - foreach my $perm (values(%permission)) { - if ($perm) { $allowed=1; last; } - } - return (\%permission,$allowed); -} - sub handler { my $r=shift; @@ -5481,41 +5279,41 @@ sub handler { 'Parameter_Manager,Course_Environment,Parameter_Helper,Parameter_Overview,Table_Mode'}); # ----------------------------------------------------- Needs to be in a course - my ($parm_permission,$allowed) = &get_permission(); + my $parm_permission = + (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) || + &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'. + $env{'request.course.sec'})); my $exists = &check_for_course_info(); - if ($env{'request.course.id'} && $allowed && $exists) { + if ($env{'request.course.id'} && $parm_permission && $exists) { # # Main switch on form.action and form.state, as appropriate # # Check first if coming from someone else headed directly for # the table mode - if (($parm_permission->{'set'}) && - ((($env{'form.command'} eq 'set') && ($env{'form.url'}) - && (!$env{'form.dis'})) || ($env{'form.symb'}))) { - &assessparms($r,$parm_permission); + if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) + && (!$env{'form.dis'})) || ($env{'form.symb'})) { + &assessparms($r); } elsif (! exists($env{'form.action'})) { &print_main_menu($r,$parm_permission); - } elsif (!$parm_permission->{$env{'form.action'}}) { - &print_main_menu($r,$parm_permission); } elsif ($env{'form.action'} eq 'setoverview') { - &overview($r,$parm_permission); - } elsif ($env{'form.action'} eq 'addmetadata') { - &addmetafield($r); - } elsif ($env{'form.action'} eq 'ordermetadata') { - &order_meta_fields($r); + &overview($r); + } elsif ($env{'form.action'} eq 'addmetadata') { + &addmetafield($r); + } elsif ($env{'form.action'} eq 'ordermetadata') { + &order_meta_fields($r); } elsif ($env{'form.action'} eq 'setrestrictmeta') { - &setrestrictmeta($r); + &setrestrictmeta($r); } elsif ($env{'form.action'} eq 'newoverview') { - &newoverview($r,$parm_permission); + &newoverview($r); } elsif ($env{'form.action'} eq 'setdefaults') { - &defaultsetter($r); - } elsif ($env{'form.action'} eq 'settable') { - &assessparms($r,$parm_permission); + &defaultsetter($r); + } elsif ($env{'form.action'} eq 'settable') { + &assessparms($r); } elsif ($env{'form.action'} eq 'parameterchangelog') { - &parm_change_log($r,$parm_permission); + &parm_change_log($r); } elsif ($env{'form.action'} eq 'cleanparameters') { - &clean_parameters($r); + &clean_parameters($r); } elsif ($env{'form.action'} eq 'dateshift1') { &date_shift_one($r); } elsif ($env{'form.action'} eq 'dateshift2') {