--- loncom/interface/lonparmset.pm 2005/06/02 16:35:32 1.200
+++ loncom/interface/lonparmset.pm 2005/11/22 19:02:40 1.268.2.1
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.200 2005/06/02 16:35:32 www Exp $
+# $Id: lonparmset.pm,v 1.268.2.1 2005/11/22 19:02:40 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -68,20 +68,13 @@ use Apache::lonnavmaps;
my $parmhashid;
my %parmhash;
+my $symbsid;
+my %symbs;
+my $rulesid;
+my %rules;
# --- end local caches
-#
-# FIXME: get rid of items below
-#
-my @ids;
-my %symbp;
-my %mapp;
-my %typep;
-my %keyp;
-my %uris;
-my %maptitles;
-
##################################################
##################################################
@@ -112,9 +105,13 @@ Returns: A list, the first item is the
=cut
##################################################
-##################################################
sub parmval {
my ($what,$id,$def,$uname,$udom,$csec)=@_;
+ return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec);
+}
+
+sub parmval_by_symb {
+ my ($what,$symb,$def,$uname,$udom,$csec)=@_;
# load caches
&cacheparmhash();
@@ -128,9 +125,10 @@ sub parmval {
my $result='';
my @outpar=();
# ----------------------------------------------------- Cascading lookup scheme
+ my $map=(&Apache::lonnet::decode_symb($symb))[0];
- my $symbparm=$symbp{$id}.'.'.$what;
- my $mapparm=$mapp{$id}.'___(all).'.$what;
+ my $symbparm=$symb.'.'.$what;
+ my $mapparm=$map.'___(all).'.$what;
my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
@@ -180,8 +178,7 @@ sub parmval {
}
if (defined($$courseopt{$seclevelr})) {
- $outpar[4]=$$courseopt
-{$seclevelr};
+ $outpar[4]=$$courseopt{$seclevelr};
$result=4;
}
}
@@ -222,6 +219,61 @@ sub cacheparmhash {
}
}
+sub resetsymbcache {
+ $symbsid='';
+}
+
+sub symbcache {
+ my $id=shift;
+ if ($symbsid ne $env{'request.course.id'}) {
+ %symbs=();
+ }
+ unless ($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'};
+ }
+ return $symbs{$id};
+}
+
+sub resetrulescache {
+ $rulesid='';
+}
+
+sub rulescache {
+ my $id=shift;
+ if ($rulesid ne $env{'request.course.id'}) {
+ %rules=();
+ }
+ unless (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};
+}
+
+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'));
+ } else {
+# nothing there or something else
+ return ('','','','','');
+ }
+}
+
##################################################
##################################################
#
@@ -238,14 +290,7 @@ sub cacheparmhash {
sub storeparm {
my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
- my $navmap = Apache::lonnavmaps::navmap->new();
- if ($sresid=~/\./) {
- my $resource=$navmap->getById($sresid);
- &storeparm_by_symb($resource->symb(),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
- } else {
- my $resource=$navmap->getByMapPc($sresid);
- &storeparm_by_symb(&Apache::lonnet::declutter($resource->src()),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
- }
+ &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
}
#
@@ -260,7 +305,59 @@ sub storeparm {
# - username
# - userdomain
+my %recstack;
sub storeparm_by_symb {
+ my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag)=@_;
+ unless ($recflag) {
+# first time call
+ %recstack=();
+ $recflag=1;
+ }
+# store parameter
+ &storeparm_by_symb_inner
+ ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
+# don't do anything if parameter was reset
+ unless ($nval) { return; }
+ my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/);
+# remember that this was set
+ $recstack{$parm}=1;
+# 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);
+ }
+ }
+ }
+ return '';
+}
+
+sub storeparm_by_symb_inner {
# ---------------------------------------------------------- Get symb, map, etc
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
# ---------------------------------------------------------- Construct prefixes
@@ -392,7 +489,7 @@ sub valout {
$result.=$sec.' secs ';
}
$result=~s/\s+$//;
- } elsif ($type=~/^date/) {
+ } elsif (&isdateparm($type)) {
$result = localtime($value);
} else {
$result = $value;
@@ -423,45 +520,29 @@ sub plink {
my ($type,$dis,$value,$marker,$return,$call)=@_;
my $winvalue=$value;
unless ($winvalue) {
- if ($type=~/^date/) {
+ if (&isdateparm($type)) {
$winvalue=$env{'form.recent_'.$type};
} else {
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
}
}
- return
+ my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/);
+ my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
+ unless (defined($winvalue)) { $winvalue=$val; }
+ return '
'.
''.
- &valout($value,$type).' ';
+ .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.
+ &valout($value,$type).'
';
}
-
sub startpage {
- my ($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader)=@_;
+ my $r=shift;
my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','',
'onUnload="pclose()"');
- my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table');
- my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
- &Apache::loncommon::selectstudent_link('parmform','uname','udom');
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table Mode Parameter Setting');
my $selscript=&Apache::loncommon::studentbrowser_javascript();
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
- my %lt=&Apache::lonlocal::texthash(
- 'cep' => "Course Environment Parameters",
- 'scep' => "Set Course Environment Parameters",
- 'smcap' => "Set/Modify Course Assessment Parameter",
- 'mcap' => "Modify Course Assessment Parameters",
- 'caphm' => "Course Assessment Parameter - Helper Mode",
- 'capom' => "Course Assessment Parameters - Overview Mode",
- 'captm' => "Course Assessments Parameters - Table Mode",
- 'sg' => "Section/Group",
- 'fu' => "For User",
- 'oi' => "or ID",
- 'ad' => "at Domain"
- );
- my $overallhelp=
- &Apache::loncommon::help_open_menu('','Setting Parameters','Course_Setting_Parameters','',10,'Instructor Interface');
- my $assessparmhelp=&Apache::loncommon::help_open_topic("Cascading_Parameters","Assessment Parameters");
my $html=&Apache::lonxml::xmlbegin();
$r->print(<
$bodytag
$breadcrumbs
-$overallhelp
-ENDHEAD
-
- unless ($trimheader) {$r->print(<
-$lt{'cep'}
-
-
-
-$assessparmhelp
-
-
-
-
-ENDHEAD2
- }
- my %sectionhash=();
- my $sections='';
- if (&Apache::loncommon::get_sections(
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'},
- \%sectionhash)) {
- $sections=$lt{'sg'}.': ';
- foreach ('',sort keys %sectionhash) {
- $sections.=''.$_.' ';
- }
- $sections.=' ';
- }
- $r->print(<
-$lt{'captm'}
-ENDHEAD3
-
- if (!$have_assesments) {
- $r->print(''.&mt('There are no assesment parameters in this course to set.').' ');
- } else {
- $r->print(<
-$sections
-
-$lt{'fu'}
-
-$lt{'oi'}
-
-$lt{'ad'}
-$chooseopt
-
+
ENDHEAD
- }
}
+
sub print_row {
- my ($r,$which,$part,$name,$rid,$default,$defaulttype,$display,$defbgone,
+ my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
$defbgtwo,$parmlev,$uname,$udom,$csec)=@_;
# get the values for the parameter in cascading order
# empty levels will remain empty
@@ -596,13 +625,16 @@ sub print_row {
}
my $parm=$$display{$which};
- if ($parmlev eq 'full' || $parmlev eq 'brief') {
+ if ($parmlev eq 'full') {
$r->print(''
.$$part{$which}.' ');
} else {
$parm=~s|\[.*\]\s||g;
}
-
+ my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers');
+ if ($automatic) {
+ $parm.=' '.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).' ';
+ }
$r->print(''.$parm.' ');
my $thismarker=$which;
@@ -631,47 +663,30 @@ sub print_row {
&print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- if ($parmlev eq 'brief') {
-
- &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
-
- if ($csec) {
- &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- }
- if ($uname) {
- &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- }
- } else {
-
- &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,8,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,8,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+
+ if ($csec) {
+ &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ }
+ if ($uname) {
+ &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ }
- if ($csec) {
- &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- }
- if ($uname) {
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- }
- } # end of $brief if/else
} # end of $parmlev if/else
$r->print(''.
&valout($outpar[$result],$typeoutpar[$result]).' ');
- if ($parmlev eq 'full' || $parmlev eq 'brief') {
+ if ($parmlev eq 'full') {
my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
- '.'.$$name{$which},$symbp{$rid});
-
-# this doesn't seem to work, and I don't think is correct
-# my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}.
-# '.'.$$name{$which}.'.type',$symbp{$rid});
-# this seems to work
+ '.'.$$name{$which},$$symbp{$rid});
my $sessionvaltype=$typeoutpar[$result];
if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
$r->print(''.
@@ -696,6 +711,7 @@ sub print_td {
$r->print(' '."\n");
}
+
=pod
=item B: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
@@ -736,15 +752,15 @@ sub extractResourceInformation {
my $keyp = shift;
my $allparms = shift;
my $allparts = shift;
- my $allkeys = shift;
my $allmaps = shift;
- my $fcat = shift;
- my $defp = shift;
my $mapp = shift;
my $symbp = shift;
my $maptitles=shift;
my $uris=shift;
+ my $keyorder=shift;
+ my $defkeytype=shift;
+ my $keyordercnt=100;
my $navmap = Apache::lonnavmaps::navmap->new();
my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
@@ -761,30 +777,40 @@ sub extractResourceInformation {
foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
if ($_=~/^parameter\_(.*)/) {
my $key=$_;
- my $allkey=$1;
- $allkey=~s/\_/\./g;
- if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq
- 'parm') {
- next; #hide hidden things
+# Hidden parameters
+ if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm') {
+ next;
}
my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
+#
+# allparms is a hash of parameter names
+#
my $parmdis = $display;
- $parmdis =~ s|(\[Part.*)$||g;
- my $partkey = $part;
- $partkey =~ tr|_|.|;
- $$allparms{$name} = $parmdis;
- $$allparts{$part} = "[Part $part]";
- $$allkeys{$allkey}=$display;
- if ($allkey eq $fcat) {
- $$defp{$id}= &Apache::lonnet::metadata($srcf,$key);
- }
+ $parmdis =~ s/\[Part.*$//g;
+ $$allparms{$name}=$parmdis;
+ $$defkeytype{$name}=&Apache::lonnet::metadata($srcf,$key.'.type');
+#
+# allparts is a hash of all parts
+#
+ $$allparts{$part} = "Part: $part";
+#
+# Remember all keys going with this resource
+#
if ($$keyp{$id}) {
$$keyp{$id}.=','.$key;
} else {
$$keyp{$id}=$key;
}
+#
+# Put in order
+#
+ unless ($$keyorder{$key}) {
+ $$keyorder{$key}=$keyordercnt;
+ $keyordercnt++;
+ }
+
}
}
$$mapp{$id}=
@@ -802,6 +828,304 @@ sub extractResourceInformation {
}
}
+
+##################################################
+##################################################
+
+sub isdateparm {
+ my $type=shift;
+ return (($type=~/^date/) && (!($type eq 'date_interval')));
+}
+
+sub parmmenu {
+ my ($r,$allparms,$pscat,$keyorder)=@_;
+ my $tempkey;
+ $r->print(<
+ function checkall(value, checkName) {
+ for (i=0; i
+ENDSCRIPT
+ $r->print();
+ $r->print("\n');
+}
+
+sub partmenu {
+ my ($r,$allparts,$psprt)=@_;
+ $r->print('');
+ $r->print('print(' selected') unless (@{$psprt});
+ $r->print('>'.&mt('All Parts').' ');
+ 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('print(' selected');
+ }
+ $r->print('>'.$$allparts{$tempkey}.' ');
+ }
+ }
+ $r->print(' ');
+}
+
+sub usermenu {
+ my ($r,$uname,$id,$udom,$csec)=@_;
+ my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
+ &Apache::loncommon::selectstudent_link('parmform','uname','udom');
+ my $selscript=&Apache::loncommon::studentbrowser_javascript();
+ my %lt=&Apache::lonlocal::texthash(
+ 'sg' => "Section/Group",
+ 'fu' => "For User",
+ 'oi' => "or ID",
+ 'ad' => "at Domain"
+ );
+ my %sectionhash=();
+ my $sections='';
+ if (&Apache::loncommon::get_sections(
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'},
+ \%sectionhash)) {
+ $sections=$lt{'sg'}.': ';
+ foreach ('',sort keys %sectionhash) {
+ $sections.=''.$_.' ';
+ }
+ $sections.=' ';
+ }
+ $r->print(<
+$sections
+
+$lt{'fu'}
+
+$lt{'oi'}
+
+$lt{'ad'}
+$chooseopt
+
+ENDMENU
+}
+
+sub displaymenu {
+ my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_;
+ $r->print(''.&mt('Select Parameters to View').' '.
+ &mt('Select Parts to View').' ');
+ &parmmenu($r,$allparms,$pscat,$keyorder);
+ $r->print(' ');
+ &partmenu($r,$allparts,$psprt);
+ $r->print('
');
+}
+
+sub mapmenu {
+ my ($r,$allmaps,$pschp,$maptitles)=@_;
+ $r->print(''.&mt('Select Enclosing Map or Folder').' ');
+ $r->print('');
+ $r->print(''.&mt('All Maps or Folders').' ');
+ foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) {
+ $r->print('print(' selected'); }
+ $r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').' ');
+ }
+ $r->print(" ");
+}
+
+sub levelmenu {
+ my ($r,$alllevs,$parmlev)=@_;
+ $r->print(''.&mt('Select Parameter Level').
+ &Apache::loncommon::help_open_topic('Course_Parameter_Levels').' ');
+ $r->print('');
+ foreach (reverse sort keys %{$alllevs}) {
+ $r->print('print(' selected');
+ }
+ $r->print('>'.$_.' ');
+ }
+ $r->print(" ");
+}
+
+
+sub sectionmenu {
+ my ($r,$selectedsections)=@_;
+ my %sectionhash=();
+
+ if (&Apache::loncommon::get_sections(
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'},
+ \%sectionhash)) {
+ $r->print('');
+ foreach my $s ('all',sort keys %sectionhash) {
+ $r->print(' print(' selected');
+ last;
+ }
+ }
+ $r->print('>'.$s." \n");
+ }
+ $r->print(" \n");
+ }
+}
+
+sub keysplit {
+ my $keyp=shift;
+ return (split(/\,/,$keyp));
+}
+
+sub keysinorder {
+ my ($name,$keyorder)=@_;
+ return sort {
+ $$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};
+ } (keys %{$name});
+}
+
+sub keysindisplayorder {
+ my ($name,$keyorder)=@_;
+ return sort {
+ $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
+ } (keys %{$name});
+}
+
+sub sortmenu {
+ my ($r,$sortorder)=@_;
+ $r->print(' print(' checked="on"');
+ }
+ $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
+ $r->print(' print(' checked="on"');
+ }
+ $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
+ ' ');
+}
+
+sub standardkeyorder {
+ return ('parameter_0_opendate' => 1,
+ 'parameter_0_duedate' => 2,
+ 'parameter_0_answerdate' => 3,
+ 'parameter_0_interval' => 4,
+ 'parameter_0_weight' => 5,
+ 'parameter_0_maxtries' => 6,
+ 'parameter_0_hinttries' => 7,
+ 'parameter_0_contentopen' => 8,
+ 'parameter_0_contentclose' => 9,
+ 'parameter_0_type' => 10,
+ 'parameter_0_problemstatus' => 11,
+ 'parameter_0_hiddenresource' => 12,
+ 'parameter_0_hiddenparts' => 13,
+ 'parameter_0_display' => 14,
+ 'parameter_0_ordered' => 15,
+ 'parameter_0_tol' => 16,
+ 'parameter_0_sig' => 17,
+ 'parameter_0_turnoffunit' => 18,
+ 'parameter_0_discussend' => 19,
+ 'parameter_0_discusshide' => 20);
+}
+
##################################################
##################################################
@@ -835,8 +1159,17 @@ Variables used (guessed by Jeremy):
sub assessparms {
my $r=shift;
+
+ my @ids=();
+ my %symbp=();
+ my %mapp=();
+ my %typep=();
+ my %keyp=();
+ my %uris=();
+ my %maptitles=();
+
# -------------------------------------------------------- Variable declaration
- my %allkeys=();
+
my %allmaps=();
my %alllevs=();
@@ -848,13 +1181,15 @@ sub assessparms {
my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
$alllevs{'Resource Level'}='full';
- $alllevs{'Map Level'}='map';
+ $alllevs{'Map/Folder Level'}='map';
$alllevs{'Course Level'}='general';
my %allparms;
my %allparts;
-
- my %defp;
+#
+# Order in which these parameters will be displayed
+#
+ my %keyorder=&standardkeyorder();
@ids=();
%symbp=();
@@ -875,12 +1210,9 @@ sub assessparms {
my $pschp=$env{'form.pschp'};
my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
if (!@psprt) { $psprt[0]='0'; }
- my $showoptions=$env{'form.showoptions'};
my $pssymb='';
my $parmlev='';
- my $trimheader='';
- my $prevvisit=$env{'form.prevvisit'};
unless ($env{'form.parmlev'}) {
$parmlev = 'map';
@@ -898,13 +1230,11 @@ sub assessparms {
if (!@pscat) { @pscat=('all'); }
$pschp='';
$parmlev = 'full';
- $trimheader='yes';
} elsif ($env{'form.symb'}) {
$pssymb=$env{'form.symb'};
if (!@pscat) { @pscat=('all'); }
$pschp='';
$parmlev = 'full';
- $trimheader='yes';
} else {
$env{'form.url'}='';
}
@@ -953,211 +1283,64 @@ sub assessparms {
unless ($csec) { $csec=''; }
- my $fcat=$env{'form.fcat'};
- unless ($fcat) { $fcat=''; }
-
# --------------------------------------------------------- Get all assessments
- &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles,\%uris);
+ &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
+ \%mapp, \%symbp,\%maptitles,\%uris,
+ \%keyorder);
$mapp{'0.0'} = '';
$symbp{'0.0'} = '';
# ---------------------------------------------------------- Anything to store?
if ($env{'form.pres_marker'}) {
- $message.=&storeparm(split(/\&/,$env{'form.pres_marker'}),
- $env{'form.pres_value'},
- $env{'form.pres_type'},
- $uname,$udom,$csec);
+ my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
+ my @values=split(/\&\&\&/,$env{'form.pres_value'});
+ my @types=split(/\&\&\&/,$env{'form.pres_type'});
+ for (my $i=0;$i<=$#markers;$i++) {
+ $message.=&storeparm(split(/\&/,$markers[$i]),
+ $values[$i],
+ $types[$i],
+ $uname,$udom,$csec);
+ }
# ---------------------------------------------------------------- Done storing
$message.=''.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').' ';
}
-# ------------------------------------------------------------------- Sort this
-
- @ids=sort {
- if ($fcat eq '') {
- $a<=>$b;
- } else {
- my ($result,@outpar)=&parmval($fcat,$a,$defp{$a},$uname,$udom,$csec);
- my $aparm=$outpar[$result];
- ($result,@outpar)=&parmval($fcat,$b,$defp{$b},$uname,$udom,$csec);
- my $bparm=$outpar[$result];
- 1*$aparm<=>1*$bparm;
- }
- } @ids;
#----------------------------------------------- if all selected, fill in array
- if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);}
+ if ($pscat[0] eq "all") {@pscat = (keys %allparms);}
+ if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') };
if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
# ------------------------------------------------------------------ Start page
- my $have_assesments=1;
- if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; }
-
- $trimheader = 'yes';
- &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader);
-
-# if ($env{'form.url'}) {
-# $r->print(' ');
-# }
- $r->print(' ');
+ &startpage($r);
foreach ('tolerance','date_default','date_start','date_end',
'date_interval','int','float','string') {
$r->print(' ');
}
-
- $r->print(''.$message.' ');
- my $submitmessage = &mt('Update Section or Specific User');
if (!$pssymb) {
- $r->print(''.&mt('Select Parameter Level').
- &Apache::loncommon::help_open_topic('Course_Parameter_Levels').
- ' ');
- $r->print('');
- foreach (reverse sort keys %alllevs) {
- $r->print('print(' selected');
- }
- $r->print('>'.$_.' ');
- }
- $r->print(" \n");
-
- $r->print(' ');
+ $r->print('');
+ &levelmenu($r,\%alllevs,$parmlev);
if ($parmlev ne 'general') {
- $r->print(' '.&mt('Select Enclosing Map or Folder').' ');
- $r->print('');
- $r->print(''.&mt('All Maps or Folders').' ');
- foreach (sort {$allmaps{$a} cmp $allmaps{$b}} keys %allmaps) {
- $r->print('print(' selected'); }
- $r->print('>'.$maptitles{$_}.($allmaps{$_}!~/^uploaded/?' ['.$allmaps{$_}.']':'').' ');
- }
- $r->print(" \n");
+ $r->print('');
+ &mapmenu($r,\%allmaps,$pschp,\%maptitles);
+ $r->print(' ');
}
+ $r->print('
');
+ &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);
} else {
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
- $r->print("".&mt('Specific Resource')." $resource ");
- $r->print(' ');
- $r->print(' ');
- $r->print(' ');
- }
-
- $r->print(' print(" checked ");}
- $r->print(' name="showoptions" value="show" />'.&mt('Show More Options').' ');
-# $r->print("Show: $showoptions ");
-# $r->print("pscat: @pscat ");
-# $r->print("psprt: @psprt ");
-# $r->print("fcat: $fcat ");
-
- if ($showoptions eq 'show') {
- my $tempkey;
-
- $r->print(''.&mt('Select Parameters to View').' ');
-
- $r->print('');
-
-# $r->print(' Select Parts ');
- $r->print(' ');
- $r->print('print(' selected') unless (@psprt);
- $r->print('>'.&mt('All Parts').' ');
- my %temphash=();
- foreach (@psprt) { $temphash{$_}=1; }
- foreach $tempkey (sort keys %allparts) {
- unless ($tempkey =~ /\./) {
- $r->print('print(' selected');
- }
- $r->print('>'.$allparts{$tempkey}.' ');
- }
- }
- $r->print(' ');
-
- $r->print(''.&mt('Sort list by').' ');
- $r->print('');
- $r->print(''.&mt('Enclosing Map or Folder').' ');
- foreach (sort keys %allkeys) {
- $r->print('print(' selected'); }
- $r->print('>'.$allkeys{$_}.' ');
- }
- $r->print(' ');
-
- $r->print(' ');
-
- } else { # hide options - include any necessary extras here
-
- $r->print(' '."\n");
-
- unless (@pscat) {
- foreach (keys %allparms ) {
- $r->print(' '."\n");
- }
- } else {
- foreach (@pscat) {
- $r->print(' '."\n");
- }
- }
-
- unless (@psprt) {
- foreach (keys %allparts ) {
- $r->print(' '."\n");
- }
- } else {
- foreach (@psprt) {
- $r->print(' '."\n");
- }
- }
-
- }
- $r->print('
');
- if (($prevvisit) || ($pschp) || ($pssymb)) {
- $submitmessage = &mt("Update Course Assessment Parameter Display");
- } else {
- $submitmessage = &mt("Set/Modify Course Assessment Parameters");
- }
- $r->print(' ');
+ &usermenu($r,$uname,$id,$udom,$csec);
-# my @temp_psprt;
-# foreach my $t (@psprt) {
-# push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts));
-# }
+ $r->print(''.$message.'
');
-# @psprt = @temp_psprt;
+ $r->print(' ');
my @temp_pscat;
map {
@@ -1167,13 +1350,13 @@ sub assessparms {
@pscat = @temp_pscat;
- if (($prevvisit) || ($pschp) || ($pssymb)) {
+ if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
# ----------------------------------------------------------------- Start Table
my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
my $csuname=$env{'user.name'};
my $csudom=$env{'user.domain'};
- if ($parmlev eq 'full' || $parmlev eq 'brief') {
+ if ($parmlev eq 'full') {
my $coursespan=$csec?8:5;
$r->print('
');
$r->print(' ');
@@ -1259,7 +1442,7 @@ ENDTABLEHEADFOUR
my %default=();
my $uri=&Apache::lonnet::declutter($uris{$rid});
- foreach (split(/\,/,$keyp{$rid})) {
+ foreach (&keysplit($keyp{$rid})) {
my $tempkeyp = $_;
if (grep $_ eq $tempkeyp, @catmarker) {
$part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
@@ -1296,21 +1479,16 @@ ENDTABLEHEADFOUR
$r->print('');
-
- $r->print(' / res / ');
- $r->print(join(' / ', split(/\//,$mapp{$rid})));
+ '>'.$maptitles{$mapp{$rid}}.' ');
- $r->print('');
-
- foreach (sort keys %name) {
+ foreach (&keysinorder_bytype(\%name,\%keyorder)) {
unless ($firstrow) {
$r->print('');
} else {
undef $firstrow;
}
- &print_row($r,$_,\%part,\%name,$rid,\%default,
+ &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
\%type,\%display,$defbgone,$defbgtwo,
$parmlev,$uname,$udom,$csec);
}
@@ -1319,7 +1497,7 @@ ENDTABLEHEADFOUR
} # end foreach ids
# -------------------------------------------------- End entry for one resource
$r->print('
');
- } # end of brief/full
+ } # end of full
#--------------------------------------------------- Entry for parm level map
if ($parmlev eq 'map') {
my $defbgone = '"E0E099"';
@@ -1366,7 +1544,7 @@ ENDTABLEHEADFOUR
# When storing information, store as part 0
# When requesting information, request from full part
#-------------------------------------------------------------------
- foreach (split(/\,/,$keyp{$rid})) {
+ foreach (&keysplit($keyp{$rid})) {
my $tempkeyp = $_;
my $fullkeyp = $tempkeyp;
$tempkeyp =~ s/_\w+_/_0_/;
@@ -1395,10 +1573,7 @@ Set Defaults for All Resources in $folde
Specifically for
ENDMAPONE
if ($uname) {
- my %name=&Apache::lonnet::userenvironment($udom,$uname,
- ('firstname','middlename','lastname','generation', 'id'));
- my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
- .$name{'lastname'}.' '.$name{'generation'};
+ my $person=&Apache::loncommon::plainname($uname,$udom);
$r->print(&mt("User")." $uname \($person\) ".
&mt('in')." \n");
} else {
@@ -1416,12 +1591,11 @@ ENDMAPONE
$r->print(''.&mt('Default Value').' ');
$r->print(''.&mt('Parameter in Effect').' ');
- foreach (sort keys %name) {
+ foreach (&keysinorder(\%name,\%keyorder)) {
$r->print('');
- &print_row($r,$_,\%part,\%name,$mapid,\%default,
+ &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
\%type,\%display,$defbgone,$defbgtwo,
$parmlev,$uname,$udom,$csec);
-# $r->print(" resource.$part{$_}.$name{$_},$symbp{$mapid} \n");
}
$r->print("");
} # end each map
@@ -1453,7 +1627,7 @@ ENDMAPONE
# When storing information, store as part 0
# When requesting information, request from full part
#-------------------------------------------------------------------
- foreach (split(/\,/,$keyp{$rid})) {
+ foreach (&keysplit($keyp{$rid})) {
my $tempkeyp = $_;
my $fullkeyp = $tempkeyp;
$tempkeyp =~ s/_\w+_/_0_/;
@@ -1477,10 +1651,7 @@ ENDMAPONE
$coursename
ENDMAPONE
if ($uname) {
- my %name=&Apache::lonnet::userenvironment($udom,$uname,
- ('firstname','middlename','lastname','generation', 'id'));
- my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
- .$name{'lastname'}.' '.$name{'generation'};
+ my $person=&Apache::loncommon::plainname($uname,$udom);
$r->print(" ".&mt("User")." $uname \($person\) \n");
} else {
$r->print(" ".&mt("ALL")." ".&mt("USERS")." \n");
@@ -1494,11 +1665,10 @@ ENDMAPONE
$r->print(''.&mt('Default Value').' ');
$r->print(''.&mt('Parameter in Effect').' ');
- foreach (sort keys %name) {
+ foreach (&keysinorder(\%name,\%keyorder)) {
$r->print('');
- &print_row($r,$_,\%part,\%name,$mapid,\%default,
+ &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
\%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec);
-# $r->print(" resource.$part{$_}.$name{$_},$symbp{$mapid} \n");
}
$r->print("");
} # end of $parmlev eq general
@@ -1595,9 +1765,13 @@ sub crsenv {
#
# Let the user know we made the changes
if ($name && defined($value)) {
+ my $failed_cloners;
if ($name eq 'cloners') {
+ $value =~ s/\s//g;
$value =~ s/^,//;
$value =~ s/,$//;
+ # check requested clones are valid users.
+ $failed_cloners = &check_cloners(\$value,\@oldcloner);
}
my $put_result = &Apache::lonnet::put('environment',
{$name=>$value},$dom,$crs);
@@ -1614,6 +1788,18 @@ sub crsenv {
$setoutput.=&mt('Unable to set').' '.$name.' '.&mt('to').
' '.$value.' '.&mt('due to').' '.$put_result.'. ';
}
+ if (($name eq 'cloners') && ($failed_cloners)) {
+ $setoutput.= &mt('Unable to include').' - '.$failed_cloners.' , '.
+ &mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist').
+ '. '.&mt('Please ').
+ ' '.
+ &mt('add the user(s)').' , '.
+ &mt('and then return to the ').
+ ''.
+ &mt('Course Parameters page').' '.
+ &mt('to add the new user(s) to the list of possible cloners').
+ '. ';
+ }
}
}
# ------------------------- Re-init course environment entries for this session
@@ -1720,8 +1906,8 @@ sub crsenv {
'anonymous_quiz'
=> ''.&mt('Anonymous quiz/exam').' '.
' ('.&mt('yes').' '.&mt('to avoid print students names').' )',
- 'default_enrollment_start_date' => ''.&mt('Default beginning date when enrolling students').' ',
- 'default_enrollment_end_date' => ''.&mt('Default ending date when enrolling students').' ',
+ 'default_enrollment_start_date' => ''.&mt('Default beginning date for student access.').' ',
+ 'default_enrollment_end_date' => ''.&mt('Default ending date for student access.').' ',
'nothideprivileged' => ''.&mt('Privileged users that should not be hidden on staff listings').' '.
' (user:domain,user:domain,... )',
'languages' => ''.&mt('Languages used').' ',
@@ -1731,6 +1917,9 @@ sub crsenv {
'disablesigfigs'
=> ''.&mt('Disable checking of Significant Figures').' '.
' ('.&mt('"[_1]" to disable, anything else if not','yes ').')',
+ 'disableexampointprint'
+ => ''.&mt('Disable automatically printing point values onto exams.').' '.
+ ' ('.&mt('"[_1]" to disable, anything else if not','yes ').')',
'tthoptions'
=> ''.&mt('Default set of options to pass to tth/m when converting tex').' '
);
@@ -1757,10 +1946,11 @@ sub crsenv {
'default_enrollment_start_date',
'default_enrollment_end_date',
'tthoptions',
- 'disablesigfigs'
+ 'disablesigfigs',
+ 'disableexampointprint'
);
foreach my $parameter (sort(keys(%values))) {
- unless ($parameter =~ m/^internal\./) {
+ unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) {
if (! $descriptions{$parameter}) {
$descriptions{$parameter}=$parameter;
push(@Display_Order,$parameter);
@@ -1838,7 +2028,8 @@ $output
ENDenv
}
##################################################
-
+# Overview mode
+##################################################
my $tableopen;
sub tablestart {
@@ -1860,26 +2051,38 @@ sub tableend {
}
}
-sub overview {
- my $r=shift;
- my $bodytag=&Apache::loncommon::bodytag(
- 'Set/Modify Course Assessment Parameters');
- my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
- my $html=&Apache::lonxml::xmlbegin();
- $r->print(<
-LON-CAPA Course Environment
-
-$bodytag
-$breadcrumbs
-