[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm
damieng
damieng at source.lon-capa.org
Tue Jul 12 16:30:20 EDT 2016
damieng Tue Jul 12 20:30:20 2016 EDT
Modified files:
/loncom/interface lonparmset.pm
Log:
fixed indentations and started adding comments
-------------- next part --------------
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.559 loncom/interface/lonparmset.pm:1.560
--- loncom/interface/lonparmset.pm:1.559 Fri May 13 22:48:05 2016
+++ loncom/interface/lonparmset.pm Tue Jul 12 20:30:20 2016
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.559 2016/05/13 22:48:05 raeburn Exp $
+# $Id: lonparmset.pm,v 1.560 2016/07/12 20:30:20 damieng Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,7 +36,11 @@
=head1 SYNOPSIS
-lonparmset provides an interface to setting course parameters.
+lonparmset provides an interface to setting course parameters.
+
+It contains all the code for the "Content and Problem Settings" UI, except
+for the helpers parameter.helper and resettimes.helper, and lonhelper.pm,
+and lonblockingmenu.pm.
=head1 DESCRIPTION
@@ -327,6 +331,11 @@
use LONCAPA qw(:DEFAULT :match);
+##################################################
+# CONTENT AND PROBLEM SETTINGS HTML PAGE HEADER/FOOTER
+##################################################
+
+# Page header
sub startSettingsScreen {
my ($r,$mode,$crstype)=@_;
@@ -345,6 +354,7 @@
$r->print('<div class="LC_Box" style="clear:both;margin:0;" id="parameditor"><div id="maincoursedoc" style="margin:0 0;padding:0 0;"><div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">');
}
+# Page footer
sub endSettingsScreen {
my ($r)=@_;
$r->print('</div></div></div>');
@@ -352,6 +362,11 @@
+##################################################
+# TABLE MODE
+# (parmval is also used for the log of parameter changes)
+##################################################
+
sub parmval {
my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,
@@ -504,74 +519,74 @@
my $parmhashid;
my %parmhash;
sub resetparmhash {
- undef($parmhashid);
- undef(%parmhash);
+ undef($parmhashid);
+ undef(%parmhash);
}
sub cacheparmhash {
- if ($parmhashid eq $env{'request.course.fn'}) { return; }
- my %parmhashfile;
- if (tie(%parmhashfile,'GDBM_File',
- $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
- %parmhash=%parmhashfile;
- untie(%parmhashfile);
- $parmhashid=$env{'request.course.fn'};
- }
+ if ($parmhashid eq $env{'request.course.fn'}) { return; }
+ my %parmhashfile;
+ if (tie(%parmhashfile,'GDBM_File',
+ $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
+ %parmhash=%parmhashfile;
+ untie(%parmhashfile);
+ $parmhashid=$env{'request.course.fn'};
+ }
}
sub parmhash {
- my ($id) = @_;
- &cacheparmhash();
- return $parmhash{$id};
+ my ($id) = @_;
+ &cacheparmhash();
+ return $parmhash{$id};
}
- }
+}
{
my $symbsid;
my %symbs;
sub resetsymbcache {
- undef($symbsid);
- undef(%symbs);
+ undef($symbsid);
+ undef(%symbs);
}
sub symbcache {
- my $id=shift;
- if ($symbsid ne $env{'request.course.id'}) {
- undef(%symbs);
- }
- if (!$symbs{$id}) {
- my $navmap = Apache::lonnavmaps::navmap->new();
- if ($id=~/\./) {
- my $resource=$navmap->getById($id);
- $symbs{$id}=$resource->symb();
- } else {
- my $resource=$navmap->getByMapPc($id);
- $symbs{$id}=&Apache::lonnet::declutter($resource->src());
+ my $id=shift;
+ if ($symbsid ne $env{'request.course.id'}) {
+ undef(%symbs);
+ }
+ if (!$symbs{$id}) {
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if ($id=~/\./) {
+ my $resource=$navmap->getById($id);
+ $symbs{$id}=$resource->symb();
+ } else {
+ my $resource=$navmap->getByMapPc($id);
+ $symbs{$id}=&Apache::lonnet::declutter($resource->src());
+ }
+ $symbsid=$env{'request.course.id'};
}
- $symbsid=$env{'request.course.id'};
- }
- return $symbs{$id};
+ return $symbs{$id};
}
- }
+}
{
my $rulesid;
my %rules;
sub resetrulescache {
- undef($rulesid);
- undef(%rules);
+ undef($rulesid);
+ undef(%rules);
}
sub rulescache {
- my $id=shift;
- if ($rulesid ne $env{'request.course.id'}
- && !defined($rules{$id})) {
- my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
- %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
- $rulesid=$env{'request.course.id'};
- }
- return $rules{$id};
+ my $id=shift;
+ if ($rulesid ne $env{'request.course.id'}
+ && !defined($rules{$id})) {
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
+ $rulesid=$env{'request.course.id'};
+ }
+ return $rules{$id};
}
}
@@ -580,14 +595,14 @@
sub preset_defaults {
my $type=shift;
if (&rulescache($type.'_action') eq 'default') {
-# yes, there is something
- return (&rulescache($type.'_hours'),
- &rulescache($type.'_min'),
- &rulescache($type.'_sec'),
- &rulescache($type.'_value'));
+ # yes, there is something
+ return (&rulescache($type.'_hours'),
+ &rulescache($type.'_min'),
+ &rulescache($type.'_sec'),
+ &rulescache($type.'_value'));
} else {
-# nothing there or something else
- return ('','','','','');
+ # nothing there or something else
+ return ('','','','','');
}
}
@@ -651,50 +666,51 @@
sub storeparm_by_symb {
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_;
unless ($recflag) {
-# first time call
- %recstack=();
- $recflag=1;
+ # first time call
+ %recstack=();
+ $recflag=1;
}
-# store parameter
+ # store parameter
&storeparm_by_symb_inner
($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup);
-# don't do anything if parameter was reset
+ # don't do anything if parameter was reset
unless ($nval) { return; }
my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/);
-# remember that this was set
+ # remember that this was set
$recstack{$parm}=1;
-# what does this trigger?
+ # what does this trigger?
foreach my $triggered (split(/\:/,&rulescache($parm.'_triggers'))) {
-# don't backfire
- unless ((!$triggered) || ($recstack{$triggered})) {
- my $action=&rulescache($triggered.'_action');
- my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
-# set triggered parameter on same level
- my $newspnam=$prefix.$triggered;
- my $newvalue='';
- my $active=1;
- if ($action=~/^when\_setting/) {
-# are there restrictions?
- if (&rulescache($triggered.'_triggervalue')=~/\w/) {
- $active=0;
- foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) {
- if (lc($possiblevalue) eq lc($nval)) { $active=1; }
- }
- }
- $newvalue=&rulescache($triggered.'_value');
- } else {
- my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec');
- if ($action=~/^later\_than/) {
- $newvalue=$nval+$totalsecs;
- } else {
- $newvalue=$nval-$totalsecs;
- }
- }
- if ($active) {
- &storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'),
- $uname,$udom,$csec,$recflag,$cgroup);
- }
- }
+ # don't backfire
+ unless ((!$triggered) || ($recstack{$triggered})) {
+ my $action=&rulescache($triggered.'_action');
+ my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
+ # set triggered parameter on same level
+ my $newspnam=$prefix.$triggered;
+ my $newvalue='';
+ my $active=1;
+ if ($action=~/^when\_setting/) {
+ # are there restrictions?
+ if (&rulescache($triggered.'_triggervalue')=~/\w/) {
+ $active=0;
+ foreach my $possiblevalue (split(/\s*\,
+ \s*/,&rulescache($triggered.'_triggervalue'))) {
+ if (lc($possiblevalue) eq lc($nval)) { $active=1; }
+ }
+ }
+ $newvalue=&rulescache($triggered.'_value');
+ } else {
+ my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec');
+ if ($action=~/^later\_than/) {
+ $newvalue=$nval+$totalsecs;
+ } else {
+ $newvalue=$nval-$totalsecs;
+ }
+ }
+ if ($active) {
+ &storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'),
+ $uname,$udom,$csec,$recflag,$cgroup);
+ }
+ }
}
return '';
}
@@ -750,60 +766,61 @@
my %storecontent = ($storeunder => $nval,
$storeunder.'.type' => $ntype);
my $reply='';
+
if ($snum>4) {
# ---------------------------------------------------------------- Store Course
#
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-# Expire sheets
- &Apache::lonnet::expirespread('','','studentcalc');
- if (($snum==13) || ($snum==9) || ($snum==5)) {
- &Apache::lonnet::expirespread('','','assesscalc',$symb);
- } elsif (($snum==14) || ($snum==10) || ($snum==6)) {
- &Apache::lonnet::expirespread('','','assesscalc',$map);
- } else {
- &Apache::lonnet::expirespread('','','assesscalc');
- }
-# Store parameter
- if ($delete) {
- $reply=&Apache::lonnet::del
- ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
- &log_parmset(\%storecontent,1);
- } else {
- $reply=&Apache::lonnet::cput
- ('resourcedata',\%storecontent,$cdom,$cnum);
- &log_parmset(\%storecontent);
- }
- &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ # Expire sheets
+ &Apache::lonnet::expirespread('','','studentcalc');
+ if (($snum==13) || ($snum==9) || ($snum==5)) {
+ &Apache::lonnet::expirespread('','','assesscalc',$symb);
+ } elsif (($snum==14) || ($snum==10) || ($snum==6)) {
+ &Apache::lonnet::expirespread('','','assesscalc',$map);
+ } else {
+ &Apache::lonnet::expirespread('','','assesscalc');
+ }
+ # Store parameter
+ if ($delete) {
+ $reply=&Apache::lonnet::del
+ ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
+ &log_parmset(\%storecontent,1);
+ } else {
+ $reply=&Apache::lonnet::cput
+ ('resourcedata',\%storecontent,$cdom,$cnum);
+ &log_parmset(\%storecontent);
+ }
+ &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
} else {
# ------------------------------------------------------------------ Store User
#
-# Expire sheets
- &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
- if ($snum==1) {
- &Apache::lonnet::expirespread
- ($uname,$udom,'assesscalc',$symb);
- } elsif ($snum==2) {
- &Apache::lonnet::expirespread
- ($uname,$udom,'assesscalc',$map);
- } else {
- &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
- }
-# Store parameter
- if ($delete) {
- $reply=&Apache::lonnet::del
- ('resourcedata',[keys(%storecontent)],$udom,$uname);
- &log_parmset(\%storecontent,1,$uname,$udom);
- } else {
- $reply=&Apache::lonnet::cput
- ('resourcedata',\%storecontent,$udom,$uname);
- &log_parmset(\%storecontent,0,$uname,$udom);
- }
- &Apache::lonnet::devalidateuserresdata($uname,$udom);
+ # Expire sheets
+ &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
+ if ($snum==1) {
+ &Apache::lonnet::expirespread
+ ($uname,$udom,'assesscalc',$symb);
+ } elsif ($snum==2) {
+ &Apache::lonnet::expirespread
+ ($uname,$udom,'assesscalc',$map);
+ } else {
+ &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
+ }
+ # Store parameter
+ if ($delete) {
+ $reply=&Apache::lonnet::del
+ ('resourcedata',[keys(%storecontent)],$udom,$uname);
+ &log_parmset(\%storecontent,1,$uname,$udom);
+ } else {
+ $reply=&Apache::lonnet::cput
+ ('resourcedata',\%storecontent,$udom,$uname);
+ &log_parmset(\%storecontent,0,$uname,$udom);
+ }
+ &Apache::lonnet::devalidateuserresdata($uname,$udom);
}
if ($reply=~/^error\:(.*)/) {
- return "<span class=\"LC_error\">Write Error: $1</span>";
+ return "<span class=\"LC_error\">Write Error: $1</span>";
}
return '';
}
@@ -876,11 +893,11 @@
}
} elsif (&isdateparm($type)) {
$result = &Apache::lonlocal::locallocaltime($value).
- &date_sanity_info($value);
+ &date_sanity_info($value);
} else {
$result = $value;
$result=~s/\,/\, /gs;
- $result = &HTML::Entities::encode($result,'"<>&');
+ $result = &HTML::Entities::encode($result,'"<>&');
}
}
return $result;
@@ -891,7 +908,7 @@
my ($type,$dis,$value,$marker,$return,$call)=@_;
my $winvalue=$value;
unless ($winvalue) {
- if (&isdateparm($type)) {
+ if (&isdateparm($type)) {
$winvalue=$env{'form.recent_'.$type};
} else {
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
@@ -904,8 +921,8 @@
my $unencmarker = $marker;
foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call,
\$hour, \$min, \$sec) {
- $$item = &HTML::Entities::encode($$item,'"<>&');
- $$item =~ s/\'/\\\'/g;
+ $$item = &HTML::Entities::encode($$item,'"<>&');
+ $$item =~ s/\'/\\\'/g;
}
return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$unencmarker.'" /></td></tr><tr><td align="center">'.
'<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
@@ -1173,14 +1190,14 @@
$loaditems{'onload'} = "showHide_courseContent(); group_or_section('cgroup'); resize_scrollbox('mapmenuscroll','1','1');";
}
- 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"});
+ 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'});
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
+ text=>"Table Mode",
+ help => 'Course_Setting_Parameters'});
}
my $js = &page_js().'
<script type="text/javascript">
@@ -1218,21 +1235,21 @@
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
-# get the values for the parameter in cascading order
-# empty levels will remain empty
+ # get the values for the parameter in cascading order
+ # empty levels will remain empty
my ($result, at outpar)=&parmval($$part{$which}.'.'.$$name{$which},
$rid,$$default{$which},$uname,$udom,$csec,$cgroup,$courseopt);
-# get the type for the parameters
-# problem: these may not be set for all levels
+ # get the type for the parameters
+ # problem: these may not be set for all levels
my ($typeresult, at typeoutpar)=&parmval($$part{$which}.'.'.
$$name{$which}.'.type',$rid,
$$defaulttype{$which},$uname,$udom,$csec,$cgroup,$courseopt);
-# cascade down manually
+ # cascade down manually
my $cascadetype=$$defaulttype{$which};
for (my $i=18;$i>0;$i--) {
- if ($typeoutpar[$i]) {
+ if ($typeoutpar[$i]) {
$cascadetype=$typeoutpar[$i];
- } else {
+ } else {
$typeoutpar[$i]=$cascadetype;
}
}
@@ -1246,7 +1263,7 @@
}
my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers');
if ($automatic) {
- $parm.='<span class="LC_warning"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</span>';
+ $parm.='<span class="LC_warning"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</span>';
}
$r->print('<td>'.$parm.'</td>');
@@ -1336,7 +1353,9 @@
my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
'.'.$$name{$which},$$symbp{$rid});
my $sessionvaltype=$typeoutpar[$result];
- if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
+ if (!defined($sessionvaltype)) {
+ $sessionvaltype=$$defaulttype{$which};
+ }
$r->print('<td style="background-color:#999999;" align="center"><font color="#FFFFFF">'.
&valout($sessionval,$sessionvaltype,$$name{$which}).' '.
'</font></td>');
@@ -1656,8 +1675,8 @@
'contentopen' => 'time_settings',
'contentclose' => 'time_settings',
'discussend' => 'time_settings',
- 'printstartdate' => 'time_settings',
- 'printenddate' => 'time_settings',
+ 'printstartdate' => 'time_settings',
+ 'printenddate' => 'time_settings',
'weight' => 'grading',
'handgrade' => 'grading',
'maxtries' => 'tries',
@@ -1832,15 +1851,15 @@
my %temphash=();
foreach (@{$psprt}) { $temphash{$_}=1; }
foreach my $tempkey (sort {
- if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); }
- } keys(%{$allparts})) {
- unless ($tempkey =~ /\./) {
- $r->print('<option value="'.$tempkey.'"');
- if ($$psprt[0] eq "all" || $temphash{$tempkey}) {
- $r->print(' selected="selected"');
+ if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); }
+ } keys(%{$allparts})) {
+ unless ($tempkey =~ /\./) {
+ $r->print('<option value="'.$tempkey.'"');
+ if ($$psprt[0] eq "all" || $temphash{$tempkey}) {
+ $r->print(' selected="selected"');
+ }
+ $r->print('>'.$$allparts{$tempkey}.'</option>');
}
- $r->print('>'.$$allparts{$tempkey}.'</option>');
- }
}
$r->print('</select>');
}
@@ -2199,26 +2218,26 @@
sub keysinorder {
my ($name,$keyorder)=@_;
return sort {
- $$keyorder{$a} <=> $$keyorder{$b};
+ $$keyorder{$a} <=> $$keyorder{$b};
} (keys(%{$name}));
}
sub keysinorder_bytype {
my ($name,$keyorder)=@_;
return sort {
- my $ta=(split('_',$a))[-1];
- my $tb=(split('_',$b))[-1];
- if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) {
- return ($a cmp $b);
- }
- $$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb};
+ my $ta=(split('_',$a))[-1];
+ my $tb=(split('_',$b))[-1];
+ if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) {
+ return ($a cmp $b);
+ }
+ $$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb};
} (keys(%{$name}));
}
sub keysindisplayorder {
my ($name,$keyorder)=@_;
return sort {
- $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
+ $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
} (keys(%{$name}));
}
@@ -2259,17 +2278,17 @@
'parameter_0_discussend' => 19,
'parameter_0_discusshide' => 20,
'parameter_0_discussvote' => 21,
- 'parameter_0_printstartdate' => 22,
- 'parameter_0_printenddate' => 23);
+ 'parameter_0_printstartdate' => 22,
+ 'parameter_0_printenddate' => 23);
}
+# Table mode UI.
sub assessparms {
my $r=shift;
-
# -------------------------------------------------------- Variable declaration
my @ids=();
my %symbp=();
@@ -2353,8 +2372,8 @@
# ----------------------------------------------- Was this started from grades?
- if (($env{'form.command'} eq 'set') && ($env{'form.url'})
- && (!$env{'form.dis'})) {
+ if (($env{'form.command'} eq 'set') && ($env{'form.url'}) &&
+ (!$env{'form.dis'})) {
my $url=$env{'form.url'};
$url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
$pssymb=&Apache::lonnet::symbread($url);
@@ -2729,26 +2748,26 @@
#
# This produces the cascading table output of parameters
#
- my $coursespan=$csec?10:6;
- my $userspan=4;
- if ($cgroup ne '') {
- $coursespan += 4;
- }
+ my $coursespan=$csec?10:6;
+ my $userspan=4;
+ if ($cgroup ne '') {
+ $coursespan += 4;
+ }
- $r->print(&Apache::loncommon::start_data_table());
-#
-# This produces the headers
-#
- $r->print('<tr><td colspan="5"></td>');
- $r->print('<th colspan="'.($coursespan).'">'.&mt('Any User').'</th>');
- if ($uname) {
+ $r->print(&Apache::loncommon::start_data_table());
+ #
+ # This produces the headers
+ #
+ $r->print('<tr><td colspan="5"></td>');
+ $r->print('<th colspan="'.($coursespan).'">'.&mt('Any User').'</th>');
+ if ($uname) {
if (@usersgroups > 1) {
- $userspan ++;
- }
- $r->print('<th colspan="'.$userspan.'" rowspan="2">');
- $r->print(&mt('User [_1] at Domain [_2]',"'".$uname."'","'".$udom."'").'</th>');
- }
- my %lt=&Apache::lonlocal::texthash(
+ $userspan ++;
+ }
+ $r->print('<th colspan="'.$userspan.'" rowspan="2">');
+ $r->print(&mt('User [_1] at Domain [_2]',"'".$uname."'","'".$udom."'").'</th>');
+ }
+ my %lt=&Apache::lonlocal::texthash(
'pie' => "Parameter in Effect",
'csv' => "Current Session Value",
'rl' => "Resource Level",
@@ -2765,59 +2784,59 @@
'formfr' => 'for Map or Folder (recursive)',
'fr' => 'for Resource'
);
- $r->print(<<ENDTABLETWO);
+ $r->print(<<ENDTABLETWO);
<th rowspan="3">$lt{'pie'}</th>
<th rowspan="3">$lt{'csv'}<br />($csuname:$csudom)</th>
</tr><tr><td colspan="5"></td><th colspan="3">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th>
<th colspan="1">$lt{'ic'}</th>
ENDTABLETWO
- if ($csec) {
- $r->print('<th colspan="4">'.
- &mt("in Section")." $csec</th>");
- }
- if ($cgroup) {
+ if ($csec) {
+ $r->print('<th colspan="4">'.
+ &mt("in Section")." $csec</th>");
+ }
+ if ($cgroup) {
$r->print('<th colspan="4">'.
&mt("in Group")." $cgroup</th>");
- }
- $r->print(<<ENDTABLEHEADFOUR);
+ }
+ $r->print(<<ENDTABLEHEADFOUR);
</tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
<th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
<th>$lt{'gen'}</th><th>$lt{'formfr'}</th><th>$lt{'foremf'}</th>
<th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
ENDTABLEHEADFOUR
- if ($csec) {
- $r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'formfr'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>');
- }
-
- if ($cgroup) {
- $r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'formfr'}.'</th><th>'.&mt('foremf').'</th><th>'.$lt{'fr'}.'</th>');
- }
-
- if ($uname) {
- if (@usersgroups > 1) {
- $r->print('<th>'.&mt('Control by other group?').'</th>');
- }
- $r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'formfr'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>');
- }
+ if ($csec) {
+ $r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'formfr'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>');
+ }
- $r->print('</tr>');
+ if ($cgroup) {
+ $r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'formfr'}.'</th><th>'.&mt('foremf').'</th><th>'.$lt{'fr'}.'</th>');
+ }
+
+ if ($uname) {
+ if (@usersgroups > 1) {
+ $r->print('<th>'.&mt('Control by other group?').'</th>');
+ }
+ $r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'formfr'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>');
+ }
+
+ $r->print('</tr>');
#
# Done with the headers
#
- my $defbgone='';
- my $defbgtwo='';
- my $defbgthree = '';
+ my $defbgone='';
+ my $defbgtwo='';
+ my $defbgthree = '';
- foreach my $rid (@ids) {
+ foreach my $rid (@ids) {
my ($inmapid)=($rid=~/\.(\d+)$/);
if ((!$pssymb &&
- (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
- ||
- ($pssymb && $pssymb eq $symbp{$rid})) {
+ (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
+ ||
+ ($pssymb && $pssymb eq $symbp{$rid})) {
# ------------------------------------------------------ Entry for one resource
if ($defbgone eq '#E0E099') {
$defbgone='#E0E0DD';
@@ -2847,34 +2866,34 @@
my $filter=$env{'form.filter'};
foreach my $tempkeyp (&keysplit($keyp{$rid})) {
if (grep $_ eq $tempkeyp, @catmarker) {
- my $parmname=&Apache::lonnet::metadata($uri,$tempkeyp.'.name');
-# We may only want certain parameters listed
- if ($filter) {
- unless ($filter=~/\Q$parmname\E/) { next; }
- }
- $name{$tempkeyp}=$parmname;
- $part{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp.'.part');
-
- my $parmdis=&Apache::lonnet::metadata($uri,$tempkeyp.'.display');
- if ($allparms{$name{$tempkeyp}} ne '') {
- my $identifier;
- if ($parmdis =~ /(\s*\[Part.*)$/) {
- $identifier = $1;
- }
- $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
- } else {
- $display{$tempkeyp} = $parmdis;
- }
- 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 $parmname=&Apache::lonnet::metadata($uri,$tempkeyp.'.name');
+ # We may only want certain parameters listed
+ if ($filter) {
+ unless ($filter=~/\Q$parmname\E/) { next; }
+ }
+ $name{$tempkeyp}=$parmname;
+ $part{$tempkeyp}=&Apache::lonnet::metadata($uri,$tempkeyp.'.part');
+
+ my $parmdis=&Apache::lonnet::metadata($uri,$tempkeyp.'.display');
+ if ($allparms{$name{$tempkeyp}} ne '') {
+ my $identifier;
+ if ($parmdis =~ /(\s*\[Part.*)$/) {
+ $identifier = $1;
+ }
+ $display{$tempkeyp} = $allparms{$name{$tempkeyp}}.$identifier;
+ } else {
+ $display{$tempkeyp} = $parmdis;
+ }
+ 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));
if ($totalparms>0) {
- my $firstrow=1;
+ my $firstrow=1;
my $title=&Apache::lonnet::gettitle($symbp{$rid});
$r->print('<tr><td style="background-color:'.$defbgone.';"'.
' rowspan='.$totalparms.
@@ -2931,7 +2950,7 @@
#-------------------------------------------- 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
@@ -2951,7 +2970,7 @@
# $r->print("$mapid:$map: $rid <br /> \n");
- if ($map eq $mapid) {
+ if ($map eq $mapid) {
my $uri=&Apache::lonnet::declutter($uris{$rid});
# $r->print("Keys: $keyp{$rid} <br />\n");
@@ -2986,7 +3005,7 @@
$type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
}
} # end loop through keys
- }
+ }
} # end loop through ids
#---------------------------------------------------- print header information
@@ -3086,7 +3105,7 @@
$display{$tempkeyp} =~ s/_\w+_/_0_/;
$default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
$type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
- }
+ }
} # end loop through keys
} # end loop through ids
@@ -3133,8 +3152,10 @@
$r->print(&Apache::loncommon::end_page());
} # end sub assessparms
+
+
##################################################
-# Overview mode
+# OVERVIEW MODE
##################################################
my $tableopen;
@@ -3157,10 +3178,10 @@
sub tableend {
if ($tableopen) {
- $tableopen=0;
- return &Apache::loncommon::end_data_table();
+ $tableopen=0;
+ return &Apache::loncommon::end_data_table();
} else {
- return'';
+ return'';
}
}
@@ -3205,202 +3226,202 @@
undef @deldata;
my ($got_chostname,$chostname,$cmajor,$cminor);
my $now = time;
- foreach my $key (keys(%env)) {
- if ($key =~ /^form\.([a-z]+)\_(.+)$/) {
- my $cmd=$1;
- my $thiskey=$2;
- next if ($cmd eq 'settext' || $cmd eq 'setipallow' || $cmd eq 'setipdeny');
- my ($tuname,$tudom)=&extractuser($thiskey);
- my $tkey=$thiskey;
+ foreach my $key (keys(%env)) {
+ if ($key =~ /^form\.([a-z]+)\_(.+)$/) {
+ my $cmd=$1;
+ my $thiskey=$2;
+ 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, $valmatch, $namematch);
- if ($cmd eq 'set') {
- $data=$env{$key};
- $valmatch = '';
- $valchk = $data;
- $typeof=$env{'form.typeof_'.$thiskey};
- $text = &mt('Saved modified parameter for');
- if ($typeof eq 'string_questiontype') {
- $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;
+ $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
+ }
+ if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
+ my ($data, $typeof, $text, $name, $valchk, $valmatch, $namematch);
+ if ($cmd eq 'set') {
+ $data=$env{$key};
+ $valmatch = '';
+ $valchk = $data;
+ $typeof=$env{'form.typeof_'.$thiskey};
+ $text = &mt('Saved modified parameter for');
+ if ($typeof eq 'string_questiontype') {
+ $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') {
- $name = 'examcode';
- if (&Apache::lonnet::validCODE($data)) {
- $valchk = 'valid';
- }
- } elsif ($typeof eq 'string_yesno') {
- if ($thiskey =~ /\.retrypartial$/) {
- $name = 'retrypartial';
- }
- }
- } elsif ($cmd eq 'datepointer') {
- $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key});
- $typeof=$env{'form.typeof_'.$thiskey};
- $text = &mt('Saved modified date for');
- if ($typeof eq 'date_start') {
- if ($thiskey =~ /\.printstartdate$/) {
- $name = 'printstartdate';
- if (($data) && ($data > $now)) {
- $valchk = 'future';
- }
- }
- } elsif ($typeof eq 'date_end') {
- if ($thiskey =~ /\.printenddate$/) {
- $name = 'printenddate';
- if (($data) && ($data < $now)) {
- $valchk = 'past';
+ } elsif ($typeof eq 'string_discussvote') {
+ $name = 'discussvote';
+ } elsif ($typeof eq 'string_examcode') {
+ $name = 'examcode';
+ if (&Apache::lonnet::validCODE($data)) {
+ $valchk = 'valid';
+ }
+ } elsif ($typeof eq 'string_yesno') {
+ if ($thiskey =~ /\.retrypartial$/) {
+ $name = 'retrypartial';
+ }
+ }
+ } elsif ($cmd eq 'datepointer') {
+ $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key});
+ $typeof=$env{'form.typeof_'.$thiskey};
+ $text = &mt('Saved modified date for');
+ if ($typeof eq 'date_start') {
+ if ($thiskey =~ /\.printstartdate$/) {
+ $name = 'printstartdate';
+ if (($data) && ($data > $now)) {
+ $valchk = 'future';
+ }
+ }
+ } elsif ($typeof eq 'date_end') {
+ if ($thiskey =~ /\.printenddate$/) {
+ $name = 'printenddate';
+ if (($data) && ($data < $now)) {
+ $valchk = 'past';
+ }
}
}
- }
- } elsif ($cmd eq 'dateinterval') {
- $data=&get_date_interval_from_form($thiskey);
- if ($thiskey =~ /\.interval$/) {
- $name = 'interval';
- my $intervaltype = &get_intervaltype($name);
- my $intervalmatch = &standard_interval_matches($intervaltype);
- if (ref($intervalmatch) eq 'ARRAY') {
- foreach my $item (@{$intervalmatch}) {
- if (ref($item) eq 'ARRAY') {
- my ($regexpname,$pattern) = @{$item};
- if ($pattern ne '') {
- if ($data =~ /$pattern/) {
- $valmatch = $regexpname;
- $valchk = '';
- last;
+ } elsif ($cmd eq 'dateinterval') {
+ $data=&get_date_interval_from_form($thiskey);
+ if ($thiskey =~ /\.interval$/) {
+ $name = 'interval';
+ my $intervaltype = &get_intervaltype($name);
+ my $intervalmatch = &standard_interval_matches($intervaltype);
+ if (ref($intervalmatch) eq 'ARRAY') {
+ foreach my $item (@{$intervalmatch}) {
+ if (ref($item) eq 'ARRAY') {
+ my ($regexpname,$pattern) = @{$item};
+ if ($pattern ne '') {
+ if ($data =~ /$pattern/) {
+ $valmatch = $regexpname;
+ $valchk = '';
+ last;
+ }
}
}
}
}
}
+ $typeof=$env{'form.typeof_'.$thiskey};
+ $text = &mt('Saved modified date for');
}
- $typeof=$env{'form.typeof_'.$thiskey};
- $text = &mt('Saved modified date for');
- }
- if ($thiskey =~ m{\.(?:sequence|page)___\(rec\)}) {
- $namematch = 'maplevelrecurse';
- }
- if (($name ne '') || ($namematch ne '')) {
- my ($needsrelease,$needsnewer);
- if ($name ne '') {
- $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,$valmatch,undef,
- $needsrelease,
- $cmajor,$cminor);
- }
+ if ($thiskey =~ m{\.(?:sequence|page)___\(rec\)}) {
+ $namematch = 'maplevelrecurse';
}
- if ($namematch ne '') {
- if ($needsnewer) {
- undef($namematch);
- } else {
- my $currneeded;
+ if (($name ne '') || ($namematch ne '')) {
+ my ($needsrelease,$needsnewer);
+ if ($name ne '') {
+ $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$valchk:$valmatch:"};
if ($needsrelease) {
- $currneeded = $needsrelease;
- }
- $needsrelease =
- $Apache::lonnet::needsrelease{"parameter::::$namematch"};
- if (($needsrelease) && (($currneeded eq '') || ($needsrelease < $currneeded))) {
unless ($got_chostname) {
- ($chostname,$cmajor,$cminor) = ¶meter_release_vars();
+ ($chostname,$cmajor,$cminor)=¶meter_release_vars();
$got_chostname = 1;
}
- $needsnewer = ¶meter_releasecheck(undef,$valchk,$valmatch,$namematch,
- $needsrelease,$cmajor,$cminor);
- } else {
+ $needsnewer = ¶meter_releasecheck($name,$valchk,$valmatch,undef,
+ $needsrelease,
+ $cmajor,$cminor);
+ }
+ }
+ if ($namematch ne '') {
+ if ($needsnewer) {
undef($namematch);
+ } else {
+ my $currneeded;
+ if ($needsrelease) {
+ $currneeded = $needsrelease;
+ }
+ $needsrelease =
+ $Apache::lonnet::needsrelease{"parameter::::$namematch"};
+ if (($needsrelease) && (($currneeded eq '') || ($needsrelease < $currneeded))) {
+ unless ($got_chostname) {
+ ($chostname,$cmajor,$cminor) = ¶meter_release_vars();
+ $got_chostname = 1;
+ }
+ $needsnewer = ¶meter_releasecheck(undef,$valchk,$valmatch,$namematch,
+ $needsrelease,$cmajor,$cminor);
+ } else {
+ undef($namematch);
+ }
}
}
+ if ($needsnewer) {
+ $r->print('<br />'.&oldversion_warning($name,$namematch,$data,
+ $chostname,$cmajor,
+ $cminor,$needsrelease));
+ next;
+ }
}
- if ($needsnewer) {
- $r->print('<br />'.&oldversion_warning($name,$namematch,$data,
- $chostname,$cmajor,
- $cminor,$needsrelease));
- next;
- }
- }
- if (defined($data) and $$olddata{$thiskey} ne $data) {
- if ($tuname) {
- if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
- $tkey.'.type' => $typeof},
- $tudom,$tuname) eq 'ok') {
- &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
- $r->print('<br />'.$text.' '.
- &Apache::loncommon::plainname($tuname,$tudom));
- } else {
- $r->print('<div class="LC_error">'.
- &mt('Error saving parameters').'</div>');
+ if (defined($data) and $$olddata{$thiskey} ne $data) {
+ if ($tuname) {
+ if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
+ $tkey.'.type' => $typeof},
+ $tudom,$tuname) eq 'ok') {
+ &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
+ $r->print('<br />'.$text.' '.
+ &Apache::loncommon::plainname($tuname,$tudom));
+ } else {
+ $r->print('<div class="LC_error">'.
+ &mt('Error saving parameters').'</div>');
+ }
+ &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
+ } else {
+ $newdata{$thiskey}=$data;
+ $newdata{$thiskey.'.type'}=$typeof;
+ }
}
- &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
- } else {
- $newdata{$thiskey}=$data;
- $newdata{$thiskey.'.type'}=$typeof;
- }
- }
- } elsif ($cmd eq 'del') {
- if ($tuname) {
- if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
- &log_parmset({$tkey=>''},1,$tuname,$tudom);
- $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
- } else {
- $r->print('<div class="LC_error">'.
- &mt('Error deleting parameters').'</div>');
+ } elsif ($cmd eq 'del') {
+ if ($tuname) {
+ if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
+ &log_parmset({$tkey=>''},1,$tuname,$tudom);
+ $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
+ } else {
+ $r->print('<div class="LC_error">'.
+ &mt('Error deleting parameters').'</div>');
+ }
+ &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
+ } else {
+ push (@deldata,$thiskey,$thiskey.'.type');
+ }
}
- &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
- } else {
- push (@deldata,$thiskey,$thiskey.'.type');
- }
}
}
- }
# Store all course level
my $delentries=$#deldata+1;
my @newdatakeys=keys(%newdata);
my $putentries=$#newdatakeys+1;
if ($delentries) {
- if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
- my %loghash=map { $_ => '' } @deldata;
- &log_parmset(\%loghash,1);
- $r->print('<h2>'.&mt('Deleted [quant,_1,parameter]',$delentries/2).'</h2>');
- } else {
- $r->print('<div class="LC_error">'.
- &mt('Error deleting parameters').'</div>');
- }
- &Apache::lonnet::devalidatecourseresdata($crs,$dom);
+ if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
+ my %loghash=map { $_ => '' } @deldata;
+ &log_parmset(\%loghash,1);
+ $r->print('<h2>'.&mt('Deleted [quant,_1,parameter]',$delentries/2).'</h2>');
+ } else {
+ $r->print('<div class="LC_error">'.
+ &mt('Error deleting parameters').'</div>');
+ }
+ &Apache::lonnet::devalidatecourseresdata($crs,$dom);
}
if ($putentries) {
- if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
- &log_parmset(\%newdata,0);
- $r->print('<h3>'.&mt('Saved [quant,_1,parameter]',$putentries/2).'</h3>');
- } else {
- $r->print('<div class="LC_error">'.
- &mt('Error saving parameters').'</div>');
- }
- &Apache::lonnet::devalidatecourseresdata($crs,$dom);
+ if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
+ &log_parmset(\%newdata,0);
+ $r->print('<h3>'.&mt('Saved [quant,_1,parameter]',$putentries/2).'</h3>');
+ } else {
+ $r->print('<div class="LC_error">'.
+ &mt('Error saving parameters').'</div>');
+ }
+ &Apache::lonnet::devalidatecourseresdata($crs,$dom);
}
}
@@ -3417,11 +3438,11 @@
($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
# if course wide student would be undefined
if (!defined($student)) {
- ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
+ ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
}
# strip off the .type if it's not the Question type parameter
if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
- $realm=~s/\.type//;
+ $realm=~s/\.type//;
}
# split into resource+part and parameter name
my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
@@ -3429,6 +3450,7 @@
return ($student,$res,$part,$parm);
}
+# Displays forms for the given data in overview mode (newoverview or overview).
sub listdata {
my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist)=@_;
@@ -3453,176 +3475,180 @@
}
foreach my $thiskey (sort {
- my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
- my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
+ my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
+ my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
- # get the numerical order for the param
- $aparm=$keyorder{'parameter_0_'.$aparm};
- $bparm=$keyorder{'parameter_0_'.$bparm};
+ # get the numerical order for the param
+ $aparm=$keyorder{'parameter_0_'.$aparm};
+ $bparm=$keyorder{'parameter_0_'.$bparm};
- my $result=0;
+ my $result=0;
- if ($sortorder eq 'realmstudent') {
+ if ($sortorder eq 'realmstudent') {
if ($ares ne $bres ) {
- $result = ($ares cmp $bres);
+ $result = ($ares cmp $bres);
} elsif ($astudent ne $bstudent) {
- $result = ($astudent cmp $bstudent);
- } elsif ($apart ne $bpart ) {
- $result = ($apart cmp $bpart);
- }
- } else {
- if ($astudent ne $bstudent) {
- $result = ($astudent cmp $bstudent);
- } elsif ($ares ne $bres ) {
- $result = ($ares cmp $bres);
- } elsif ($apart ne $bpart ) {
- $result = ($apart cmp $bpart);
+ $result = ($astudent cmp $bstudent);
+ } elsif ($apart ne $bpart ) {
+ $result = ($apart cmp $bpart);
+ }
+ } else {
+ if ($astudent ne $bstudent) {
+ $result = ($astudent cmp $bstudent);
+ } elsif ($ares ne $bres ) {
+ $result = ($ares cmp $bres);
+ } elsif ($apart ne $bpart ) {
+ $result = ($apart cmp $bpart);
+ }
}
- }
- if (!$result) {
+ if (!$result) {
if (defined($aparm) && defined($bparm)) {
- $result = ($aparm <=> $bparm);
+ $result = ($aparm <=> $bparm);
} elsif (defined($aparm)) {
- $result = -1;
+ $result = -1;
} elsif (defined($bparm)) {
- $result = 1;
+ $result = 1;
+ }
}
- }
- $result;
- } keys(%{$listdata})) {
+ $result;
+
+ } keys(%{$listdata})) { # foreach my $thiskey
- my $readonly;
- if ($$listdata{$thiskey.'.type'}) {
- my $thistype=$$listdata{$thiskey.'.type'};
- if ($$resourcedata{$thiskey.'.type'}) {
- $thistype=$$resourcedata{$thiskey.'.type'};
- }
- my ($middle,$part,$name)=
- ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
- my $section=&mt('All Students');
- if ($middle=~/^\[(.*)\]/) {
- my $issection=$1;
- if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
- my ($stuname,$studom) = ($1,$2);
- 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'});
+ my $readonly;
+ if ($$listdata{$thiskey.'.type'}) {
+ my $thistype=$$listdata{$thiskey.'.type'};
+ if ($$resourcedata{$thiskey.'.type'}) {
+ $thistype=$$resourcedata{$thiskey.'.type'};
+ }
+ my ($middle,$part,$name)=
+ ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
+ my $section=&mt('All Students');
+ if ($middle=~/^\[(.*)\]/) {
+ my $issection=$1;
+ if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
+ my ($stuname,$studom) = ($1,$2);
+ 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'});
+ }
}
}
- }
- $section=&mt('User').": ".&Apache::loncommon::plainname($stuname,$studom);
- } else {
- if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
- if (exists($grouphash{$issection})) {
- $section=&mt('Group').': '.$issection;
- } elsif ($issection eq $env{'request.course.sec'}) {
- $section = &mt('Section').': '.$issection;
+ $section=&mt('User').": ".&Apache::loncommon::plainname($stuname,$studom);
+ } else {
+ if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
+ if (exists($grouphash{$issection})) {
+ $section=&mt('Group').': '.$issection;
+ } elsif ($issection eq $env{'request.course.sec'}) {
+ $section = &mt('Section').': '.$issection;
+ } else {
+ next;
+ }
} else {
- next;
+ $section=&mt('Group/Section').': '.$issection;
}
- } else {
- $section=&mt('Group/Section').': '.$issection;
+ }
+ $middle=~s/^\[(.*)\]//;
+ } elsif (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
+ $readonly = 1;
+ }
+ $middle=~s/\.+$//;
+ $middle=~s/^\.+//;
+ my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
+ if ($middle=~/^(.+)\_\_\_\((all|rec)\)$/) {
+ my $mapurl = $1;
+ my $maplevel = $2;
+ my $leveltitle = &mt('Folder/Map');
+ if ($maplevel eq 'rec') {
+ $leveltitle = &mt('Recursive');
+ }
+ $realm='<span class="LC_parm_scope_folder">'.$leveltitle.': '.&Apache::lonnet::gettitle($mapurl).' <br /><span class="LC_parm_folder">('.$mapurl.')</span></span>';
+ } elsif ($middle) {
+ my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
+ $realm='<span class="LC_parm_scope_resource">'.&mt('Resource').
+ ': '.&Apache::lonnet::gettitle($middle).
+ ' <br /><span class="LC_parm_symb">('.$url.' in '.$map.' id: '.
+ $id.')</span></span>';
+ }
+ if ($sortorder eq 'realmstudent') {
+ if ($realm ne $oldrealm) {
+ $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
+ $oldrealm=$realm;
+ $oldsection='';
+ }
+ if ($section ne $oldsection) {
+ $r->print(&tableend()."\n<h2>$section</h2>");
+ $oldsection=$section;
+ $oldpart='';
+ }
+ } else {
+ if ($section ne $oldsection) {
+ $r->print(&tableend()."\n<hr /><h1>$section</h1>");
+ $oldsection=$section;
+ $oldrealm='';
+ }
+ if ($realm ne $oldrealm) {
+ $r->print(&tableend()."\n<h2>$realm</h2>");
+ $oldrealm=$realm;
+ $oldpart='';
}
}
- $middle=~s/^\[(.*)\]//;
- } elsif (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
- $readonly = 1;
- }
- $middle=~s/\.+$//;
- $middle=~s/^\.+//;
- my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
- if ($middle=~/^(.+)\_\_\_\((all|rec)\)$/) {
- my $mapurl = $1;
- my $maplevel = $2;
- my $leveltitle = &mt('Folder/Map');
- if ($maplevel eq 'rec') {
- $leveltitle = &mt('Recursive');
+ if ($part ne $oldpart) {
+ $r->print(&tableend().
+ "\n".'<span class="LC_parm_part">'.&mt('Part').": $part</span>");
+ $oldpart=$part;
}
- $realm='<span class="LC_parm_scope_folder">'.$leveltitle.': '.&Apache::lonnet::gettitle($mapurl).' <br /><span class="LC_parm_folder">('.$mapurl.')</span></span>';
- } elsif ($middle) {
- my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
- $realm='<span class="LC_parm_scope_resource">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><span class="LC_parm_symb">('.$url.' in '.$map.' id: '.$id.')</span></span>';
- }
- if ($sortorder eq 'realmstudent') {
- if ($realm ne $oldrealm) {
- $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
- $oldrealm=$realm;
- $oldsection='';
- }
- if ($section ne $oldsection) {
- $r->print(&tableend()."\n<h2>$section</h2>");
- $oldsection=$section;
- $oldpart='';
- }
- } else {
- if ($section ne $oldsection) {
- $r->print(&tableend()."\n<hr /><h1>$section</h1>");
- $oldsection=$section;
- $oldrealm='';
- }
- if ($realm ne $oldrealm) {
- $r->print(&tableend()."\n<h2>$realm</h2>");
- $oldrealm=$realm;
- $oldpart='';
- }
- }
- if ($part ne $oldpart) {
- $r->print(&tableend().
- "\n".'<span class="LC_parm_part">'.&mt('Part').": $part</span>");
- $oldpart=$part;
- }
-#
-# Ready to print
-#
+ #
+ # Ready to print
+ #
my $parmitem = &standard_parameter_names($name);
- $r->print(&tablestart($readonly).
- &Apache::loncommon::start_data_table_row().
- '<td><b>'.&mt($parmitem).
- '</b></td>');
- unless ($readonly) {
- $r->print('<td><input type="checkbox" name="del_'.
- $thiskey.'" /></td>');
- }
- $r->print('<td>');
- $foundkeys++;
- if (&isdateparm($thistype)) {
- my $jskey='key_'.$pointer;
- my $state;
- $pointer++;
- if ($readonly) {
- $state = 'disabled';
- }
- $r->print(
- &Apache::lonhtmlcommon::date_setter('parmform',
- $jskey,
- $$resourcedata{$thiskey},
- '',1,$state));
- unless ($readonly) {
+ $r->print(&tablestart($readonly).
+ &Apache::loncommon::start_data_table_row().
+ '<td><b>'.&mt($parmitem).
+ '</b></td>');
+ unless ($readonly) {
+ $r->print('<td><input type="checkbox" name="del_'.
+ $thiskey.'" /></td>');
+ }
+ $r->print('<td>');
+ $foundkeys++;
+ if (&isdateparm($thistype)) {
+ my $jskey='key_'.$pointer;
+ my $state;
+ $pointer++;
+ if ($readonly) {
+ $state = 'disabled';
+ }
$r->print(
-'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
-(($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
-&mt('Shift all dates based on this date').'</a></span>':'').
-&date_sanity_info($$resourcedata{$thiskey})
- );
+ &Apache::lonhtmlcommon::date_setter('parmform',
+ $jskey,
+ $$resourcedata{$thiskey},
+ '',1,$state));
+ unless ($readonly) {
+ $r->print(
+ '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
+ (($$resourcedata{$thiskey}!=0)?'<span class="LC_nobreak"><a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
+ &mt('Shift all dates based on this date').'</a></span>':'').
+ &date_sanity_info($$resourcedata{$thiskey})
+ );
+ }
+ } elsif ($thistype eq 'date_interval') {
+ $r->print(&date_interval_selector($thiskey,$name,
+ $$resourcedata{$thiskey},$readonly));
+ } elsif ($thistype =~ m/^string/) {
+ $r->print(&string_selector($thistype,$thiskey,
+ $$resourcedata{$thiskey},$name,$readonly));
+ } else {
+ $r->print(&default_selector($thiskey,$$resourcedata{$thiskey},$readonly));
}
- } elsif ($thistype eq 'date_interval') {
- $r->print(&date_interval_selector($thiskey,$name,
- $$resourcedata{$thiskey},$readonly));
- } elsif ($thistype =~ m/^string/) {
- $r->print(&string_selector($thistype,$thiskey,
- $$resourcedata{$thiskey},$name,$readonly));
- } else {
- $r->print(&default_selector($thiskey,$$resourcedata{$thiskey},$readonly));
- }
- unless ($readonly) {
- $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
- $thistype.'" />');
+ unless ($readonly) {
+ $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
+ $thistype.'" />');
+ }
+ $r->print('</td>'.&Apache::loncommon::end_data_table_row());
}
- $r->print('</td>'.&Apache::loncommon::end_data_table_row());
- }
}
return $foundkeys;
}
@@ -3634,12 +3660,13 @@
['hours', 3600],
['minutes', 60],
['seconds', 1]) {
- my ($name, $factor) = @{ $which };
- if (defined($env{'form.'.$name.'_'.$key})) {
- $seconds += $env{'form.'.$name.'_'.$key} * $factor;
- }
+ my ($name, $factor) = @{ $which };
+ if (defined($env{'form.'.$name.'_'.$key})) {
+ $seconds += $env{'form.'.$name.'_'.$key} * $factor;
+ }
}
- if (($key =~ /\.interval$/) && (($env{'form.done_'.$key} eq '_done') || ($env{'form.done_'.$key} eq '_done_proctor'))) {
+ if (($key =~ /\.interval$/) &&
+ (($env{'form.done_'.$key} eq '_done') || ($env{'form.done_'.$key} eq '_done_proctor'))) {
if ($env{'form.done_'.$key.'_buttontext'}) {
$env{'form.done_'.$key.'_buttontext'} =~ s/\://g;
$seconds .= '_done:'.$env{'form.done_'.$key.'_buttontext'}.':';
@@ -3650,7 +3677,7 @@
$seconds .= $env{'form.done_'.$key};
}
if (($env{'form.done_'.$key} eq '_done_proctor') &&
- ($env{'form.done_'.$key.'_proctorkey'})) {
+ ($env{'form.done_'.$key.'_proctorkey'})) {
$seconds .= '_'.$env{'form.done_'.$key.'_proctorkey'};
}
}
@@ -3727,12 +3754,14 @@
return $output;
}
-{
+
+{ # block using some constants related to parameter types (overview mode)
+
my %strings =
(
'string_yesno'
=> [[ 'yes', 'Yes' ],
- [ 'no', 'No' ]],
+ [ 'no', 'No' ]],
'string_problemstatus'
=> [[ 'yes', 'Yes' ],
[ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
@@ -3811,10 +3840,10 @@
my %skiptype;
if (($thistype eq 'string_questiontype') ||
- ($thistype eq 'string_lenient') ||
- ($thistype eq 'string_discussvote') ||
- ($thistype eq 'string_ip') ||
- ($name eq 'retrypartial')) {
+ ($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');
@@ -4036,14 +4065,14 @@
['hours', 3600, 23],
['minutes', 60, 59],
['seconds', 1, 59]) {
- my ($name, $factor, $max) = @{ $which };
- my $amount = int($showval/$factor);
- $showval %= $factor;
- my %select = ((map {$_ => $_} (0..$max)),
- 'select_form_order' => [0..$max]);
- $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
- \%select,'',$readonly);
- $result .= ' '.&mt($name);
+ my ($name, $factor, $max) = @{ $which };
+ my $amount = int($showval/$factor);
+ $showval %= $factor;
+ my %select = ((map {$_ => $_} (0..$max)),
+ 'select_form_order' => [0..$max]);
+ $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
+ \%select,'',$readonly);
+ $result .= ' '.&mt($name);
}
if ($name eq 'interval') {
unless ($skipval{'done'}) {
@@ -4164,7 +4193,8 @@
'</p>';
}
-}
+} # end of block using some constants related to parameter types
+
#
# Shift all start and end dates by $shift
@@ -4412,6 +4442,7 @@
}
}
+# Display all existing parameter settings.
sub overview {
my ($r) = @_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -4458,6 +4489,7 @@
&Apache::loncommon::end_page());
}
+# Unused sub.
sub clean_parameters {
my ($r) = @_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -4493,51 +4525,51 @@
'<th>'.&mt('Parameter').'</th>'.
'</tr>');
foreach my $thiskey (sort(keys(%{$resourcedata}))) {
- next if (!exists($resourcedata->{$thiskey.'.type'})
- && $thiskey=~/\.type$/);
- my %data = &parse_key($thiskey);
- if (1) { #exists($data{'realm_exists'})
- #&& !$data{'realm_exists'}) {
- $r->print(&Apache::loncommon::start_data_table_row().
- '<tr>'.
- '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
-
- $r->print('<td>');
- my $display_value = $resourcedata->{$thiskey};
- if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
- $display_value =
- &Apache::lonlocal::locallocaltime($display_value);
- }
+ next if (!exists($resourcedata->{$thiskey.'.type'})
+ && $thiskey=~/\.type$/);
+ my %data = &parse_key($thiskey);
+ if (1) { #exists($data{'realm_exists'})
+ #&& !$data{'realm_exists'}) {
+ $r->print(&Apache::loncommon::start_data_table_row().
+ '<tr>'.
+ '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
+
+ $r->print('<td>');
+ my $display_value = $resourcedata->{$thiskey};
+ if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
+ $display_value =
+ &Apache::lonlocal::locallocaltime($display_value);
+ }
my $parmitem = &standard_parameter_names($data{'parameter_name'});
$parmitem = &mt($parmitem);
- $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
- $parmitem,$resourcedata->{$thiskey}));
- $r->print('<br />');
- if ($data{'scope_type'} eq 'all') {
- $r->print(&mt('All users'));
- } elsif ($data{'scope_type'} eq 'user') {
- $r->print(&mt('User: [_1]',join(':',@{$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('<br />');
- if ($data{'realm_type'} eq 'all') {
- $r->print(&mt('All Resources'));
- } elsif ($data{'realm_type'} eq 'folder') {
- $r->print(&mt('Folder: [_1]'),$data{'realm'});
- } elsif ($data{'realm_type'} eq 'symb') {
- my ($map,$resid,$url) =
- &Apache::lonnet::decode_symb($data{'realm'});
- $r->print(&mt('Resource: [_1]with ID: [_2]in folder [_3]',
- $url.' <br /> ',
- $resid.' <br /> ',$map));
- }
- $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
- $r->print('</td></tr>');
+ $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
+ $parmitem,$resourcedata->{$thiskey}));
+ $r->print('<br />');
+ if ($data{'scope_type'} eq 'all') {
+ $r->print(&mt('All users'));
+ } elsif ($data{'scope_type'} eq 'user') {
+ $r->print(&mt('User: [_1]',join(':',@{$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('<br />');
+ if ($data{'realm_type'} eq 'all') {
+ $r->print(&mt('All Resources'));
+ } elsif ($data{'realm_type'} eq 'folder') {
+ $r->print(&mt('Folder: [_1]'),$data{'realm'});
+ } elsif ($data{'realm_type'} eq 'symb') {
+ my ($map,$resid,$url) =
+ &Apache::lonnet::decode_symb($data{'realm'});
+ $r->print(&mt('Resource: [_1]with ID: [_2]in folder [_3]',
+ $url.' <br /> ',
+ $resid.' <br /> ',$map));
+ }
+ $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
+ $r->print('</td></tr>');
- }
+ }
}
$r->print(&Apache::loncommon::end_data_table().'<p>'.
'<input type="submit" value="'.&mt('Delete Selected').'" />'.
@@ -4546,6 +4578,7 @@
$r->print(&Apache::loncommon::end_page());
}
+# Overview mode, UI to shift all dates.
sub date_shift_one {
my ($r) = @_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -4574,6 +4607,7 @@
$r->print(&Apache::loncommon::end_page());
}
+# Overview mode, UI to shift all dates (second form).
sub date_shift_two {
my ($r) = @_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -4608,30 +4642,30 @@
($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
$data{'scope_type'} = 'all';
if ($middle=~/^\[(.*)\]/) {
- $data{'scope'} = $1;
- if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
- $data{'scope_type'} = 'user';
- $data{'scope'} = [$1,$2];
- } else {
- #FIXME check for group scope
- $data{'scope_type'} = 'section';
- }
- $middle=~s/^\[(.*)\]//;
+ $data{'scope'} = $1;
+ if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
+ $data{'scope_type'} = 'user';
+ $data{'scope'} = [$1,$2];
+ } else {
+ #FIXME check for group scope
+ $data{'scope_type'} = 'section';
+ }
+ $middle=~s/^\[(.*)\]//;
}
$middle=~s/\.+$//;
$middle=~s/^\.+//;
$data{'realm_type'}='all';
if ($middle=~/^(.+)\_\_\_\(all\)$/) {
- $data{'realm'} = $1;
- $data{'realm_type'} = 'folder';
- $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
- ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
+ $data{'realm'} = $1;
+ $data{'realm_type'} = 'folder';
+ $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
+ ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
} elsif ($middle) {
- $data{'realm'} = $middle;
- $data{'realm_type'} = 'symb';
- $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
- my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
- $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
+ $data{'realm'} = $middle;
+ $data{'realm_type'} = 'symb';
+ $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
+ my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
+ $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
}
$data{'parameter_part'} = $part;
@@ -4647,6 +4681,10 @@
+##################################################
+# MAIN MENU
+##################################################
+
sub print_main_menu {
my ($r,$parm_permission)=@_;
#
@@ -4746,6 +4784,10 @@
+##################################################
+# PORTFOLIO METADATA
+##################################################
+
sub output_row {
my ($r, $field_name, $field_text, $added_flag) = @_;
my $output;
@@ -4767,14 +4809,14 @@
$output .= '<td><strong>'.$field_text.':</strong></td>';
$output .= &Apache::loncommon::end_data_table_row();
foreach my $opt (@options) {
- my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
- $output .= &Apache::loncommon::continue_data_table_row();
- $output .= '<td>'.(' ' x 5).'<label>
- <input type="checkbox" name="'.
- $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
- &mt($opt->[1]).'</label></td>';
- $output .= &Apache::loncommon::end_data_table_row();
- }
+ my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
+ $output .= &Apache::loncommon::continue_data_table_row();
+ $output .= '<td>'.(' ' x 5).'<label>
+ <input type="checkbox" name="'.
+ $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
+ &mt($opt->[1]).'</label></td>';
+ $output .= &Apache::loncommon::end_data_table_row();
+ }
$output .= &Apache::loncommon::continue_data_table_row();
$output .= '<td>'.(' ' x 10).'<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></td>';
$output .= &Apache::loncommon::end_data_table_row();
@@ -4787,22 +4829,22 @@
$multiple_checked = ' checked="checked"';
$single_checked = '';
}
- $output .= &Apache::loncommon::continue_data_table_row();
- $output .= '<td>'.(' ' x 10).'
- <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
- '.&mt('Student may select multiple choices from list').'</td>';
- $output .= &Apache::loncommon::end_data_table_row();
- $output .= &Apache::loncommon::continue_data_table_row();
- $output .= '<td>'.(' ' x 10).'
- <input type="radio" name="'.$field_name.'_onlyone" value="single"'.$single_checked.' />
- '.&mt('Student may select only one choice from list').'</td>';
- $output .= &Apache::loncommon::end_data_table_row();
+ $output .= &Apache::loncommon::continue_data_table_row();
+ $output .= '<td>'.(' ' x 10).'
+ <input type="radio" name="'.$field_name.'_onlyone" value="multiple"'.$multiple_checked .' />
+ '.&mt('Student may select multiple choices from list').'</td>';
+ $output .= &Apache::loncommon::end_data_table_row();
+ $output .= &Apache::loncommon::continue_data_table_row();
+ $output .= '<td>'.(' ' x 10).'
+ <input type="radio" name="'.$field_name.'_onlyone" value="single"'.$single_checked.' />
+ '.&mt('Student may select only one choice from list').'</td>';
+ $output .= &Apache::loncommon::end_data_table_row();
}
return ($output);
}
-
+# UI to order portfolio metadata fields.
sub order_meta_fields {
my ($r)=@_;
my $idx = 1;
@@ -4810,12 +4852,13 @@
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',
+ &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"},
- {text=>"Order Metadata"});
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ {href=>"/adm/parmset?action=setrestrictmeta",
+ text=>"Restrict Metadata"},
+ {text=>"Order Metadata"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
&startSettingsScreen($r,'parmset',$crstype);
if ($env{'form.storeorder'}) {
@@ -4827,14 +4870,14 @@
if ($newpos > $currentpos) {
# moving stuff up
for ($i=0;$i<$currentpos;$i++) {
- $neworder[$i]=$oldorder[$i];
+ $neworder[$i]=$oldorder[$i];
}
for ($i=$currentpos;$i<$newpos;$i++) {
- $neworder[$i]=$oldorder[$i+1];
+ $neworder[$i]=$oldorder[$i+1];
}
$neworder[$newpos]=$oldorder[$currentpos];
for ($i=$newpos+1;$i<=$#oldorder;$i++) {
- $neworder[$i]=$oldorder[$i];
+ $neworder[$i]=$oldorder[$i];
}
} else {
# moving stuff down
@@ -4849,10 +4892,10 @@
$neworder[$i]=$oldorder[$i];
}
}
- my $ordered_fields = join ",", @neworder;
+ my $ordered_fields = join ",", @neworder;
my $put_result = &Apache::lonnet::put('environment',
- {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
- &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
+ {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
+ &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
}
my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
my $ordered_fields;
@@ -4955,6 +4998,7 @@
+# Display or save portfolio metadata.
sub setrestrictmeta {
my ($r)=@_;
my $next_meta;
@@ -4995,10 +5039,10 @@
$options.='deleted,';
}
my $name = $save_field;
- $put_result = &Apache::lonnet::put('environment',
- {'metadata.'.$meta_field.'.options'=>$options,
- 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
- },$dom,$crs);
+ $put_result = &Apache::lonnet::put('environment',
+ {'metadata.'.$meta_field.'.options'=>$options,
+ 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
+ },$dom,$crs);
}
}
}
@@ -5014,8 +5058,8 @@
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});
- }
+ $output.= &output_row($r, $field, $metadata_fields{$field});
+ }
}
my $buttons = (<<ENDButtons);
<input type="submit" name="restrictmeta" value="Save" />
@@ -5045,7 +5089,6 @@
}
-
sub get_added_meta_fieldnames {
my ($cid) = @_;
my %fields;
@@ -5060,7 +5103,6 @@
}
-
sub get_deleted_meta_fieldnames {
my ($cid) = @_;
my %fields;
@@ -5075,6 +5117,13 @@
}
return \%fields;
}
+
+
+##################################################
+# PARAMETER SETTINGS DEFAULT ACTIONS
+##################################################
+
+# UI to change parameter setting default actions
sub defaultsetter {
my ($r) = @_;
@@ -5107,45 +5156,45 @@
\%mapp, \%symbp,\%maptitles,\%uris,
\%keyorder,\%defkeytype);
if ($env{'form.storerules'}) {
- my %newrules=();
- my @delrules=();
- my %triggers=();
- foreach my $key (keys(%env)) {
+ my %newrules=();
+ my @delrules=();
+ my %triggers=();
+ foreach my $key (keys(%env)) {
if ($key=~/^form\.(\w+)\_action$/) {
- my $tempkey=$1;
- my $action=$env{$key};
+ my $tempkey=$1;
+ my $action=$env{$key};
if ($action) {
- $newrules{$tempkey.'_action'}=$action;
- if ($action ne 'default') {
- my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
- $triggers{$whichparm}.=$tempkey.':';
- }
- $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
- if (&isdateparm($defkeytype{$tempkey})) {
- $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
- $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
- $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
- $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
- } else {
- $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
- $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
+ $newrules{$tempkey.'_action'}=$action;
+ if ($action ne 'default') {
+ my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
+ $triggers{$whichparm}.=$tempkey.':';
+ }
+ $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
+ if (&isdateparm($defkeytype{$tempkey})) {
+ $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
+ $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
+ $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
+ $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
+ } else {
+ $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
+ $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
+ }
+ } else {
+ push(@delrules,$tempkey.'_action');
+ push(@delrules,$tempkey.'_type');
+ push(@delrules,$tempkey.'_hours');
+ push(@delrules,$tempkey.'_min');
+ push(@delrules,$tempkey.'_sec');
+ push(@delrules,$tempkey.'_value');
+ }
}
- } else {
- push(@delrules,$tempkey.'_action');
- push(@delrules,$tempkey.'_type');
- push(@delrules,$tempkey.'_hours');
- push(@delrules,$tempkey.'_min');
- push(@delrules,$tempkey.'_sec');
- push(@delrules,$tempkey.'_value');
}
+ foreach my $key (keys(%allparms)) {
+ $newrules{$key.'_triggers'}=$triggers{$key};
}
- }
- foreach my $key (keys(%allparms)) {
- $newrules{$key.'_triggers'}=$triggers{$key};
- }
- &Apache::lonnet::put('parmdefactions',\%newrules,$cdom,$cnum);
- &Apache::lonnet::del('parmdefactions',\@delrules,$cdom,$cnum);
- &resetrulescache();
+ &Apache::lonnet::put('parmdefactions',\%newrules,$cdom,$cnum);
+ &Apache::lonnet::del('parmdefactions',\@delrules,$cdom,$cnum);
+ &resetrulescache();
}
my %lt=&Apache::lonlocal::texthash('days' => 'Days',
'hours' => 'Hours',
@@ -5158,15 +5207,15 @@
my @dateoptions=('','default');
my @datedisplay=('',&mt('Default value when manually setting'));
foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
- unless ($tempkey) { next; }
- push @standardoptions,'when_setting_'.$tempkey;
- push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
- if (&isdateparm($defkeytype{$tempkey})) {
- push @dateoptions,'later_than_'.$tempkey;
- push @datedisplay,&mt('Automatically set later than ').$tempkey;
- push @dateoptions,'earlier_than_'.$tempkey;
- push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
- }
+ unless ($tempkey) { next; }
+ push @standardoptions,'when_setting_'.$tempkey;
+ push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
+ if (&isdateparm($defkeytype{$tempkey})) {
+ push @dateoptions,'later_than_'.$tempkey;
+ push @datedisplay,&mt('Automatically set later than ').$tempkey;
+ push @dateoptions,'earlier_than_'.$tempkey;
+ push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
+ }
}
$r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
&mt('Automatic setting rules apply to table mode interfaces only.'));
@@ -5176,57 +5225,57 @@
&mt('Action').'</th><th>'.&mt('Value').'</th>'.
&Apache::loncommon::end_data_table_header_row());
foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
- unless ($tempkey) { next; }
- $r->print("\n".&Apache::loncommon::start_data_table_row().
- "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
- my $action=&rulescache($tempkey.'_action');
- $r->print('<select name="'.$tempkey.'_action">');
- if (&isdateparm($defkeytype{$tempkey})) {
- for (my $i=0;$i<=$#dateoptions;$i++) {
- if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
- $r->print("\n<option value='$dateoptions[$i]'".
- ($dateoptions[$i] eq $action?' selected="selected"':'').
- ">$datedisplay[$i]</option>");
+ unless ($tempkey) { next; }
+ $r->print("\n".&Apache::loncommon::start_data_table_row().
+ "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
+ my $action=&rulescache($tempkey.'_action');
+ $r->print('<select name="'.$tempkey.'_action">');
+ if (&isdateparm($defkeytype{$tempkey})) {
+ for (my $i=0;$i<=$#dateoptions;$i++) {
+ if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
+ $r->print("\n<option value='$dateoptions[$i]'".
+ ($dateoptions[$i] eq $action?' selected="selected"':'').
+ ">$datedisplay[$i]</option>");
+ }
+ } else {
+ for (my $i=0;$i<=$#standardoptions;$i++) {
+ if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
+ $r->print("\n<option value='$standardoptions[$i]'".
+ ($standardoptions[$i] eq $action?' selected="selected"':'').
+ ">$standarddisplay[$i]</option>");
+ }
}
- } else {
- for (my $i=0;$i<=$#standardoptions;$i++) {
- if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
- $r->print("\n<option value='$standardoptions[$i]'".
- ($standardoptions[$i] eq $action?' selected="selected"':'').
- ">$standarddisplay[$i]</option>");
+ $r->print('</select>');
+ unless (&isdateparm($defkeytype{$tempkey})) {
+ $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
+ '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
}
- }
- $r->print('</select>');
- unless (&isdateparm($defkeytype{$tempkey})) {
- $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
- '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
- }
- $r->print("\n</td><td>\n");
+ $r->print("\n</td><td>\n");
if (&isdateparm($defkeytype{$tempkey})) {
- my $days=&rulescache($tempkey.'_days');
- my $hours=&rulescache($tempkey.'_hours');
- my $min=&rulescache($tempkey.'_min');
- my $sec=&rulescache($tempkey.'_sec');
- $r->print(<<ENDINPUTDATE);
-<input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
-<input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
-<input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
-<input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
-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"'; }
-
- $r->print(<<ENDYESNO);
-<label><input type="radio" name="$tempkey\_value" value="yes"$yeschecked /> $lt{'yes'}</label><br />
-<label><input type="radio" name="$tempkey\_value" value="no"$nochecked /> $lt{'no'}</label>
-ENDYESNO
+ my $days=&rulescache($tempkey.'_days');
+ my $hours=&rulescache($tempkey.'_hours');
+ my $min=&rulescache($tempkey.'_min');
+ my $sec=&rulescache($tempkey.'_sec');
+ $r->print(<<ENDINPUTDATE);
+ <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
+ <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
+ <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
+ <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
+ 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"'; }
+
+ $r->print(<<ENDYESNO);
+ <label><input type="radio" name="$tempkey\_value" value="yes"$yeschecked /> $lt{'yes'}</label><br />
+ <label><input type="radio" name="$tempkey\_value" value="no"$nochecked /> $lt{'no'}</label>
+ ENDYESNO
} else {
- $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
- }
+ $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
+ }
$r->print('</td>'.&Apache::loncommon::end_data_table_row());
}
$r->print(&Apache::loncommon::end_data_table().
@@ -5237,28 +5286,32 @@
return;
}
+##################################################
+# PARAMETER CHANGES LOG
+##################################################
+
sub components {
my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
if ($typeflag) {
- $key=~s/\.type$//;
+ $key=~s/\.type$//;
}
my ($middle,$part,$name)=
- ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
+ ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
my $issection;
my $section=&mt('All Students');
if ($middle=~/^\[(.*)\]/) {
- $issection=$1;
- $section=&mt('Group/Section').': '.$issection;
- $middle=~s/^\[(.*)\]//;
+ $issection=$1;
+ $section=&mt('Group/Section').': '.$issection;
+ $middle=~s/^\[(.*)\]//;
}
$middle=~s/\.+$//;
$middle=~s/^\.+//;
if ($uname) {
- $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
- $issection='';
+ $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
+ $issection='';
}
my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
my $realmdescription=&mt('all resources');
@@ -5269,12 +5322,16 @@
if ($maplevel eq 'rec') {
$leveltitle = &mt('Recursive');
}
- $realm='<span class="LC_parm_scope_folder">'.$leveltitle.': '.&Apache::lonnet::gettitle($mapurl).' <span class="LC_parm_folder"><br />('.$mapurl.')</span></span>';
- $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($mapurl);
- } elsif ($middle) {
- my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
- $realm='<span class="LC_parm_scope_resource">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><span class="LC_parm_symb">('.$url.' in '.$map.' id: '.$id.')</span></span>';
- $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
+ $realm='<span class="LC_parm_scope_folder">'.$leveltitle.
+ ': '.&Apache::lonnet::gettitle($mapurl).' <span class="LC_parm_folder"><br />('.
+ $mapurl.')</span></span>';
+ $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($mapurl);
+ } elsif ($middle) {
+ my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
+ $realm='<span class="LC_parm_scope_resource">'.&mt('Resource').
+ ': '.&Apache::lonnet::gettitle($middle).' <br /><span class="LC_parm_symb">('.$url.
+ ' in '.$map.' id: '.$id.')</span></span>';
+ $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
}
my $what=$part.'.'.$name;
return ($realm,$section,$name,$part,
@@ -5287,14 +5344,14 @@
sub load_parameter_names {
open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
while (my $configline=<$config>) {
- if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
- chomp($configline);
- my ($short,$plain)=split(/:/,$configline);
- my (undef,$name,$type)=split(/\&/,$short,3);
- if ($type eq 'display') {
- $standard_parms{$name} = $plain;
+ if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
+ chomp($configline);
+ my ($short,$plain)=split(/:/,$configline);
+ my (undef,$name,$type)=split(/\&/,$short,3);
+ if ($type eq 'display') {
+ $standard_parms{$name} = $plain;
} elsif ($type eq 'type') {
- $standard_parms_types{$name} = $plain;
+ $standard_parms_types{$name} = $plain;
}
}
close($config);
@@ -5305,12 +5362,12 @@
sub standard_parameter_names {
my ($name)=@_;
if (!%standard_parms) {
- &load_parameter_names();
+ &load_parameter_names();
}
if ($standard_parms{$name}) {
- return $standard_parms{$name};
+ return $standard_parms{$name};
} else {
- return $name;
+ return $name;
}
}
@@ -5339,6 +5396,7 @@
return;
}
+# Display log for parameter changes, blog postings, user notification changes.
sub parm_change_log {
my ($r)=@_;
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -5380,89 +5438,89 @@
my $shown=0;
my $folder='';
if ($env{'form.displayfilter'} eq 'currentfolder') {
- my $last='';
- if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
- &GDBM_READER(),0640)) {
- $last=$hash{'last_known'};
- untie(%hash);
- }
- if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
- }
- foreach my $id (sort
- {
- if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
- return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
- }
- my $aid = (split('00000',$a))[-1];
- my $bid = (split('00000',$b))[-1];
- return $bid<=>$aid;
+ my $last='';
+ if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
+ &GDBM_READER(),0640)) {
+ $last=$hash{'last_known'};
+ untie(%hash);
+ }
+ if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
+ }
+ foreach my $id (sort {
+ if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
+ return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
+ }
+ my $aid = (split('00000',$a))[-1];
+ my $bid = (split('00000',$b))[-1];
+ return $bid<=>$aid;
} (keys(%parmlog))) {
my @changes=keys(%{$parmlog{$id}{'logentry'}});
- my $count = 0;
- my $time =
- &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
- my $plainname =
- &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
- $parmlog{$id}{'exe_udom'});
- my $about_me_link =
- &Apache::loncommon::aboutmewrapper($plainname,
- $parmlog{$id}{'exe_uname'},
- $parmlog{$id}{'exe_udom'});
- my $send_msg_link='';
- if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
- || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
- $send_msg_link ='<br />'.
- &Apache::loncommon::messagewrapper(&mt('Send message'),
- $parmlog{$id}{'exe_uname'},
- $parmlog{$id}{'exe_udom'});
- }
- my $row_start=&Apache::loncommon::start_data_table_row();
- my $makenewrow=0;
- my %istype=();
- my $output;
- foreach my $changed (reverse(sort(@changes))) {
- my $value=$parmlog{$id}{'logentry'}{$changed};
- my $typeflag = ($changed =~/\.type$/ &&
- !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
+ my $count = 0;
+ my $time =
+ &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
+ my $plainname =
+ &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
+ $parmlog{$id}{'exe_udom'});
+ my $about_me_link =
+ &Apache::loncommon::aboutmewrapper($plainname,
+ $parmlog{$id}{'exe_uname'},
+ $parmlog{$id}{'exe_udom'});
+ my $send_msg_link='';
+ if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
+ || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
+ $send_msg_link ='<br />'.
+ &Apache::loncommon::messagewrapper(&mt('Send message'),
+ $parmlog{$id}{'exe_uname'},
+ $parmlog{$id}{'exe_udom'});
+ }
+ my $row_start=&Apache::loncommon::start_data_table_row();
+ my $makenewrow=0;
+ my %istype=();
+ my $output;
+ foreach my $changed (reverse(sort(@changes))) {
+ my $value=$parmlog{$id}{'logentry'}{$changed};
+ my $typeflag = ($changed =~/\.type$/ &&
+ !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
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 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'}));
- }
- }
- if ($env{'form.displayfilter'} eq 'currentfolder') {
- if ($folder) {
- if ($middle!~/^\Q$folder\E/) { next; }
- }
- }
- if ($typeflag) {
- $istype{$parmname}=$value;
- if (!$env{'form.includetypes'}) { next; }
- }
- $count++;
- if ($makenewrow) {
- $output .= $row_start;
- } else {
- $makenewrow=1;
- }
+ &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
+ if ($env{'request.course.sec'} ne '') {
+ 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'}));
+ }
+ }
+ if ($env{'form.displayfilter'} eq 'currentfolder') {
+ if ($folder) {
+ if ($middle!~/^\Q$folder\E/) { next; }
+ }
+ }
+ if ($typeflag) {
+ $istype{$parmname}=$value;
+ if (!$env{'form.includetypes'}) { next; }
+ }
+ $count++;
+ if ($makenewrow) {
+ $output .= $row_start;
+ } else {
+ $makenewrow=1;
+ }
my $parmitem = &standard_parameter_names($parmname);
- $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
- &mt($parmitem).'</td><td>'.
- ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
- my $stillactive=0;
- if ($parmlog{$id}{'delflag'}) {
- $output .= &mt('Deleted');
- } else {
- if ($typeflag) {
+ $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
+ &mt($parmitem).'</td><td>'.
+ ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
+ 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);
- } else {
- my ($level, at all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
- $uname,$udom,$issection,$issection,$courseopt);
+ $output .= &mt('Type: [_1]',$parmitem);
+ } else {
+ my ($level, at all)=&parmval_by_symb($what,$middle,
+ &Apache::lonnet::metadata($middle,$what),
+ $uname,$udom,$issection,$issection,$courseopt);
my $showvalue = $value;
if ($istype{$parmname} eq '') {
my $type = &standard_parameter_types($parmname);
@@ -5473,63 +5531,67 @@
}
}
} else {
- if (&isdateparm($istype{$parmname})) {
- $showvalue =
- &Apache::lonlocal::locallocaltime($value);
- }
+ if (&isdateparm($istype{$parmname})) {
+ $showvalue = &Apache::lonlocal::locallocaltime($value);
+ }
}
$output .= $showvalue;
- if ($value ne $all[$level]) {
- $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
- } else {
- $stillactive=1;
+ if ($value ne $all[$level]) {
+ $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
+ } else {
+ $stillactive=1;
+ }
+ }
}
- }
- }
- $output .= '</td><td>';
-
- if ($stillactive) {
+ $output .= '</td><td>';
+
+ if ($stillactive) {
my $parmitem = &standard_parameter_names($parmname);
$parmitem = &mt($parmitem);
- my $title=&mt('Changed [_1]',$parmitem);
+ my $title=&mt('Changed [_1]',$parmitem);
my $description=&mt('Changed [_1] for [_2] to [_3]',
- $parmitem,$realmdescription,
+ $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);
- }
+ if (($uname) && ($udom)) {
+ $output .=
+ &Apache::loncommon::messagewrapper('Notify User',
+ $uname,$udom,$title,
+ $description);
+ } else {
+ $output .=
+ &Apache::lonrss::course_blog_link($id,$title,
+ $description);
+ }
+ }
+ $output .= '</td>'.&Apache::loncommon::end_data_table_row();
}
- $output .= '</td>'.&Apache::loncommon::end_data_table_row();
- }
if ($env{'form.displayfilter'} eq 'containing') {
- my $wholeentry=$about_me_link.':'.
- $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
- $output;
- if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
- }
+ my $wholeentry=$about_me_link.':'.
+ $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
+ $output;
+ if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
+ }
if ($count) {
- $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
- <td rowspan="'.$count.'">'.$about_me_link.
- '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
- ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
- $send_msg_link.'</td>'.$output);
- $shown++;
- }
- if (!($env{'form.show'} eq &mt('all')
- || $shown<=$env{'form.show'})) { last; }
+ $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
+ <td rowspan="'.$count.'">'.$about_me_link.
+ '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
+ ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
+ $send_msg_link.'</td>'.$output);
+ $shown++;
+ }
+ if (!($env{'form.show'} eq &mt('all')
+ || $shown<=$env{'form.show'})) { last; }
}
$r->print(&Apache::loncommon::end_data_table());
&endSettingsScreen($r);
$r->print(&Apache::loncommon::end_page());
}
+##################################################
+# MISC !
+##################################################
+
+# Used by table UI
sub update_slots {
my ($slot_name,$cdom,$cnum,$symb,$uname,$udom) = @_;
my %slot=&Apache::lonnet::get_slot($slot_name);
@@ -5583,6 +5645,7 @@
return $success;
}
+# Used by table UI
sub delete_slots {
my ($slot_name,$cdom,$cnum,$uname,$udom,$symb) = @_;
my $delresult;
@@ -5618,6 +5681,7 @@
return $delresult;
}
+# Used by handler
sub check_for_course_info {
my $navmap = Apache::lonnavmaps::navmap->new();
return 1 if ($navmap);
@@ -5652,6 +5716,27 @@
return $needsnewer;
}
+##################################################
+# HANDLER
+##################################################
+
+# Main handler for lonparmset.
+# Sub called based on request parameters action and command:
+# no command or action: print_main_menu
+# command 'set': assessparms (direct access to table mode for a resource)
+# (this can also be accessed simply with the symb parameter)
+# action 'setoverview': overview (display all existing parameter settings)
+# action 'addmetadata': addmetafield (called to add a portfolio metadata field)
+# action 'ordermetadata': order_meta_fields (called to order portfolio metadata fields)
+# action 'setrestrictmeta': setrestrictmeta (display or save portfolio metadata)
+# action 'newoverview': newoverview (overview mode)
+# action 'setdefaults': defaultsetter (UI to change parameter setting default actions)
+# action 'settable': assessparms (table mode)
+# action 'parameterchangelog': parm_change_log (display log for parameter changes,
+# blog postings, user notification changes)
+# action 'cleanparameters': clean_parameters (unused)
+# action 'dateshift1': date_shift_one (overview mode, shift all dates)
+# action 'dateshift2': date_shift_two (overview mode, shift all dates)
sub handler {
my $r=shift;
@@ -5692,28 +5777,28 @@
# Check first if coming from someone else headed directly for
# the table mode
if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
- && (!$env{'form.dis'})) || ($env{'form.symb'})) {
- &assessparms($r);
+ && (!$env{'form.dis'})) || ($env{'form.symb'})) {
+ &assessparms($r);
} elsif (! exists($env{'form.action'})) {
&print_main_menu($r,$parm_permission);
} elsif ($env{'form.action'} eq 'setoverview') {
- &overview($r);
- } 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);
+ &newoverview($r);
} elsif ($env{'form.action'} eq 'setdefaults') {
- &defaultsetter($r);
- } elsif ($env{'form.action'} eq 'settable') {
- &assessparms($r);
+ &defaultsetter($r);
+ } elsif ($env{'form.action'} eq 'settable') {
+ &assessparms($r);
} elsif ($env{'form.action'} eq 'parameterchangelog') {
- &parm_change_log($r);
+ &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') {
@@ -5721,14 +5806,14 @@
}
} else {
# ----------------------------- Not in a course, or not allowed to modify parms
- if ($exists) {
- $env{'user.error.msg'}=
- "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
- } else {
- $env{'user.error.msg'}=
- "/adm/parmset::0:1:Course environment gone, reinitialize the course";
- }
- return HTTP_NOT_ACCEPTABLE;
+ if ($exists) {
+ $env{'user.error.msg'}=
+ "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
+ } else {
+ $env{'user.error.msg'}=
+ "/adm/parmset::0:1:Course environment gone, reinitialize the course";
+ }
+ return HTTP_NOT_ACCEPTABLE;
}
&reset_caches();
More information about the LON-CAPA-cvs
mailing list