--- loncom/interface/lonparmset.pm 2011/05/23 09:29:27 1.513
+++ loncom/interface/lonparmset.pm 2024/08/19 17:01:00 1.522.2.28.4.12
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.513 2011/05/23 09:29:27 foxr Exp $
+# $Id: lonparmset.pm,v 1.522.2.28.4.12 2024/08/19 17:01:00 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,7 +36,8 @@ lonparmset - Handler to set parameters f
=head1 SYNOPSIS
-lonparmset provides an interface to setting course parameters.
+lonparmset provides an interface to setting content parameters in a
+course.
=head1 DESCRIPTION
@@ -46,8 +47,6 @@ This module sets coursewide and assessme
=over
-=pod
-
=item parmval()
Figure out a cascading parameter.
@@ -131,7 +130,7 @@ javascript function 'pjump'.
=item print_td()
-=item print_usergroups()
+=item check_other_groups()
=item parm_control_group()
@@ -139,15 +138,21 @@ javascript function 'pjump'.
extractResourceInformation extracts lots of information about all of the the course's resources into a variety of hashes.
-Input: See list below:
+Input: See list below
+
+=over 4
=item * B : Current username
=item * B : Domain of current user.
-=item * b : Course
+
+=back
-Outputs: See list below:
+Outputs: See list below
+
+=over 4
=item * B (out) : An array that will contain all of the ids in the course.
@@ -173,6 +178,8 @@ Outputs: See list below:
=item * B
+=back
+
=item isdateparm()
=item parmmenu()
@@ -210,6 +217,8 @@ Returns: nothing
Variables used (guessed by Jeremy):
+=over
+
=item * B: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type.
=item * B: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
@@ -222,6 +231,8 @@ Variables used (guessed by Jeremy):
When storing information, store as part 0
When requesting information, request from full part
+=back
+
=item tablestart()
=item tableend()
@@ -288,7 +299,6 @@ Set portfolio metadata
Main handler. Calls &assessparms subroutine.
-
=back
=cut
@@ -311,30 +321,10 @@ use Apache::lonnavmaps;
use Apache::longroup;
use Apache::lonrss;
use HTML::Entities;
+use Text::Wrap();
use LONCAPA qw(:DEFAULT :match);
-sub startSettingsScreen {
- my ($r,$mode)=@_;
-
- $r->print("\n".''."\n");
- $r->print('');
-}
-
-sub endSettingsScreen {
- my ($r)=@_;
- $r->print('
');
-}
-
-
-
sub parmval {
my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,
@@ -661,7 +651,7 @@ sub storeparm_by_symb {
}
sub log_parmset {
- return &Apache::lonnet::instructor_log('parameterlog',@_);
+ return &Apache::lonnet::write_log('course','parameterlog',@_);
}
sub storeparm_by_symb_inner {
@@ -768,14 +758,27 @@ sub valout {
my $result = '';
# Values of zero are valid.
if (! $value && $value ne '0') {
- if ($editable) {
- $result = '* ';
- } else {
- $result=' ';
- }
+ if ($editable) {
+ $result =
+ ' ';
+ } else {
+ $result=' ';
+ }
} else {
if ($type eq 'date_interval') {
- my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
+ my ($totalsecs,$donesuffix) = split(/_/,$value,2);
+ my ($usesdone,$donebuttontext,$proctor,$secretkey);
+ if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) {
+ $donebuttontext = $1;
+ (undef,$proctor,$secretkey) = split(/_/,$2);
+ $usesdone = 'done';
+ } elsif ($donesuffix =~ /^done(|_.+)$/) {
+ $donebuttontext = &mt('Done');
+ ($usesdone,$proctor,$secretkey) = split(/_/,$donesuffix);
+ }
+ my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($totalsecs);
my @timer;
$year=$year-70;
$mday--;
@@ -808,11 +811,19 @@ sub valout {
push(@timer,&mt('[quant,_1,sec]',0));
}
$result.=join(", ",@timer);
+ if ($usesdone eq 'done') {
+ if ($secretkey) {
+ $result .= ' '.&mt('+ "[_1]" with proctor key: [_2]',$donebuttontext,$secretkey);
+ } else {
+ $result .= ' + "'.$donebuttontext.'"';
+ }
+ }
} elsif (&isdateparm($type)) {
$result = &Apache::lonlocal::locallocaltime($value).
&date_sanity_info($value);
} else {
$result = $value;
+ $result=~s/\,/\, /gs;
$result = &HTML::Entities::encode($result,'"<>&');
}
}
@@ -821,11 +832,15 @@ sub valout {
sub plink {
- my ($type,$dis,$value,$marker,$return,$call)=@_;
+ my ($type,$dis,$value,$marker,$return,$call,$extra)=@_;
my $winvalue=$value;
unless ($winvalue) {
- if (&isdateparm($type)) {
+ if ((&isdateparm($type)) || (&is_specialstring($type))) {
$winvalue=$env{'form.recent_'.$type};
+ } elsif ($type eq 'string_yesno') {
+ if ($env{'form.recent_string'} =~ /^(yes|no)$/i) {
+ $winvalue=$env{'form.recent_string'};
+ }
} else {
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
}
@@ -836,13 +851,13 @@ sub plink {
my $valout = &valout($value,$type,1);
my $unencmarker = $marker;
foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call,
- \$hour, \$min, \$sec) {
+ \$hour, \$min, \$sec, \$extra) {
$$item = &HTML::Entities::encode($$item,'"<>&');
$$item =~ s/\'/\\\'/g;
}
return '';
}
@@ -854,30 +869,26 @@ sub page_js {
return(<
// 0) {
+ var possdeeplink = document.parmform.elements[i].options[idx].value
+ possdeeplink = possdeeplink.replace(/^\s+|\s+$/g,'');
+ if (document.parmform.elements['set_'+identifier].value) {
+ possdeeplink = ','+possdeeplink;
+ }
+ document.parmform.elements['set_'+identifier].value += possdeeplink;
+ }
+ } else if (dlLinkProtectRegExp.test(name)) {
+ if (document.parmform.elements[i].checked) {
+ var identifier = name.replace(dlLinkProtectRegExp,'');
+ var posslinkurl = document.parmform.elements[i].value;
+ posslinkurl = posslinkurl.replace(/^\s+|\s+$/g,'');
+ if (document.parmform.elements['set_'+identifier].value) {
+ posslinkurl = ','+posslinkurl;
+ }
+ document.parmform.elements['set_'+identifier].value += posslinkurl;
+ }
+ } else if (dlLtidRegExp.test(name)) {
+ var identifier = name.replace(dlLtidRegExp,'');
+ if (isRadioSet('deeplink_protect_'+identifier,'ltid')) {
+ var possltid = document.parmform.elements[i].value;
+ possltid = possltid.replace(/\D+/g,'');
+ if (possltid.length) {
+ if (document.parmform.elements['set_'+identifier].value) {
+ possltid = ':'+possltid;
+ }
+ document.parmform.elements['set_'+identifier].value += possltid;
+ } else {
+ document.parmform.elements['set_'+identifier].value = '';
+ alert("A link type of 'domain LTI launch' was selected but no domain LTI launcher was selected.\nPlease select one, or choose a different supported link type.");
+ return false;
+ }
+ }
+ } else if (dlLticRegExp.test(name)) {
+ var identifier = name.replace(dlLticRegExp,'');
+ if (isRadioSet('deeplink_protect_'+identifier,'ltic')) {
+ var possltic = document.parmform.elements[i].value;
+ possltic = possltic.replace(/\D+/g,'');
+ if (possltic.length) {
+ if (document.parmform.elements['set_'+identifier].value) {
+ possltic = ':'+possltic;
+ }
+ document.parmform.elements['set_'+identifier].value += possltic;
+ } else {
+ document.parmform.elements['set_'+identifier].value = '';
+ alert("A link type of 'course LTI launch' was selected but no course LTI launcher was selected.\nPlease select one, or choose a different supported link type.");
+ return false;
+ }
+ }
+ } else if (dlKeyRegExp.test(name)) {
+ var identifier = name.replace(dlKeyRegExp,'');
+ if (isRadioSet('deeplink_protect_'+identifier,'key')) {
+ var posskey = document.parmform.elements[i].value;
+ posskey = posskey.replace(/^\s+|\s+$/g,'');
+ var origlength = posskey.length;
+ posskey = posskey.replace(/[^a-zA-Z\d_.!@#$%^&*()+=-]/g,'');
+ var newlength = posskey.length;
+ if (newlength > 0) {
+ var change = origlength - newlength;
+ if (change) {
+ alert(change+' disallowed character(s) removed from deeplink key');
+ }
+ if (document.parmform.elements['set_'+identifier].value) {
+ posskey = ':'+posskey;
+ }
+ document.parmform.elements['set_'+identifier].value += posskey;
+ } else {
+ document.parmform.elements['set_'+identifier].value = '';
+ if (newlength < origlength) {
+ alert("A link type of 'deep with key' was selected but the key value was blank, after removing disallowed characters.\nPlease enter a key using one or more of: a-zA-Z0-9_.!@#$%^&*()+=-");
+ } else {
+ alert("A link type of 'deep with key' was selected but the key value was blank.\nPlease enter a key.");
+ }
+ return false;
+ }
+ }
+ } else if (dlMenusRegExp.test(name)) {
+ if (document.parmform.elements[i].checked) {
+ var identifier = name.replace(dlMenusRegExp,'');
+ var posslinkmenu = document.parmform.elements[i].value;
+ posslinkmenu = posslinkmenu.replace(/^\s+|\s+$/g,'');
+ if (posslinkmenu == 'std') {
+ posslinkmenu = '0';
+ if (document.parmform.elements['set_'+identifier].value) {
+ posslinkmenu = ','+posslinkmenu;
+ }
+ document.parmform.elements['set_'+identifier].value += posslinkmenu;
+ }
+ }
+ } else if (dlCollsRegExp.test(name)) {
+ var identifier = name.replace(dlCollsRegExp,'');
+ if (isRadioSet('deeplink_menus_'+identifier,'colls')) {
+ var posslinkmenu = document.parmform.elements[i].value;
+ if (document.parmform.elements['set_'+identifier].value) {
+ posslinkmenu = ','+posslinkmenu;
+ }
+ document.parmform.elements['set_'+identifier].value += posslinkmenu;
+ }
+ } else if (dlTargetRegExp.test(name)) {
+ var identifier = name.replace(dlTargetRegExp,'');
+ var idx = document.parmform.elements[i].selectedIndex;
+ if (idx > 0) {
+ var linktarget = document.parmform.elements[i].options[idx].value
+ linktarget = linktarget.replace(/^\s+|\s+$/g,'');
+ if (document.parmform.elements['set_'+identifier].value) {
+ linktarget = ','+linktarget;
+ }
+ document.parmform.elements['set_'+identifier].value += linktarget;
+ }
+ } else if (dlExitRegExp.test(name)) {
+ if (document.parmform.elements[i].checked) {
+ var identifier = name.replace(dlExitRegExp,'');
+ var posslinkexit = document.parmform.elements[i].value;
+ posslinkexit = posslinkexit.replace(/^\s+|\s+$/g,'');
+ if (document.parmform.elements['set_'+identifier].value) {
+ posslinkexit = ','+posslinkexit;
+ }
+ document.parmform.elements['set_'+identifier].value += posslinkexit;
+ }
+ } else if (dlExitTextRegExp.test(name)) {
+ var identifier = name.replace(dlExitTextRegExp,'');
+ if ((isRadioSet('deeplink_exit_'+identifier,'yes')) ||
+ (isRadioSet('deeplink_exit_'+identifier,'url'))) {
+ var posstext = document.parmform.elements[i].value;
+ posstext = posstext.replace(/^\s+|\s+$/g,'');
+ var origlength = posstext.length;
+ posstext = posstext.replace(/[:;'",]/g,'');
+ var newlength = posstext.length;
+ if (newlength > 0) {
+ var change = origlength - newlength;
+ if (change) {
+ alert(change+' disallowed character(s) removed from Exit Button text');
+ }
+ if (posstext !== 'Exit Tool') {
+ posstext = ':'+posstext;
+ document.parmform.elements['set_'+identifier].value += posstext;
+ }
+ } else {
+ document.parmform.elements['set_'+identifier].value = '';
+ if (newlength < origlength) {
+ alert("An exit link type of 'In use' was selected but the button text value was blank, after removing disallowed characters.\nDisallowed characters are ,\":;'");
+ } else {
+ alert("An exit link type of 'In use' was selected but the button text value was blank.\nPlease enter the text to use.");
+ }
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return true;
+}
+
+function isRadioSet(name,expected) {
+ var menuitems = document.getElementsByName(name);
+ var radioLength = menuitems.length;
+ result = false;
+ if (radioLength > 1) {
+ for (var j=0; j$remove ');
+ });
+
+ \$(wrapper).delegate(".LC_remove_ipacc","click", function(e){
+ e.preventDefault(); \$(this).closest("div").remove();
+ })
+});
+
+
+END
+}
+
+sub done_proctor_js {
+ my $defaultdone = &mt('Done');
+ &js_escape(\$defaultdone);
+ return <<"END";
+function toggleSecret(form,radio,key) {
+ var radios = form[radio+key];
+ if (radios.length) {
+ for (var i=0; i "pclose()",
- 'onload' => "showHide_courseContent(); group_or_section('cgroup')",
- );
+ my %loaditems = (
+ 'onload' => "group_or_section('cgroup')",
+ );
+ if (!$psymb) {
+ $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'})) {
@@ -915,16 +1319,22 @@ sub startpage {
text=>"Table Mode",
help => 'Course_Setting_Parameters'});
}
+ my $js = &page_js().'
+
+';
my $start_page =
- &Apache::loncommon::start_page('Set/Modify Course Parameters',
- &page_js(),
+ &Apache::loncommon::start_page('Set/Modify Course Parameters',$js,
{'add_entries' => \%loaditems,});
my $breadcrumbs =
&Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode');
my $escfilter=&Apache::lonhtmlcommon::entity_encode($env{'form.filter'});
my $escpart=&Apache::lonhtmlcommon::entity_encode($env{'form.part'});
$r->print($start_page.$breadcrumbs);
- &startSettingsScreen($r,'parmset');
$r->print(<
@@ -939,7 +1349,8 @@ ENDHEAD
sub print_row {
my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
- $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups)=@_;
+ $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp,
+ $readonly)=@_;
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
@@ -978,37 +1389,85 @@ sub print_row {
my $thismarker=$which;
$thismarker=~s/^parameter\_//;
my $mprefix=$rid.'&'.$thismarker.'&';
+ my ($parmname)=($thismarker=~/\_([^\_]+)$/);
my $effective_parm = &valout($outpar[$result],$typeoutpar[$result]);
- my ($othergrp,$grp_parm,$controlgrp);
+ my ($othergrp,$grp_parm,$controlgrp,$extra);
+ if ($parmname eq 'deeplink') {
+ my ($domltistr,$crsltistr);
+ my %lti =
+ &Apache::lonnet::get_domain_lti($env{'course.'.$env{'request.course.id'}.'.domain'},
+ 'linkprot');
+ if (keys(%lti)) {
+ foreach my $item (sort { $a <=> $b } (keys(%lti))) {
+ if (($item =~ /^\d+$/) && (ref($lti{$item}) eq 'HASH')) {
+ $domltistr .= $item.':'.&escape(&escape($lti{$item}{'name'})).',';
+ }
+ }
+ $domltistr =~ s/,$//;
+ if ($domltistr) {
+ $extra = 'ltid_'.$domltistr;
+ }
+ }
+ my %courselti = &Apache::lonnet::get_course_lti($cnum,$cdom,'provider');
+ if (keys(%courselti)) {
+ foreach my $item (sort { $a <=> $b } keys(%courselti)) {
+ if (($item =~ /^\d+$/) && (ref($courselti{$item}) eq 'HASH')) {
+ $crsltistr .= $item.':'.&escape(&escape($courselti{$item}{'name'})).',';
+ }
+ }
+ $crsltistr =~ s/,$//;
+ if ($crsltistr) {
+ if ($extra) {
+ $extra .= '&';
+ }
+ $extra .= 'ltic_'.$crsltistr;
+ }
+ }
+ if ($env{'course.'.$env{'request.course.id'}.'.menucollections'}) {
+ my @colls;
+ foreach my $item (split(/;/,$env{'course.'.$env{'request.course.id'}.'.menucollections'})) {
+ my ($num,$value) = split(/\%/,$item);
+ if ($num =~ /^\d+$/) {
+ push(@colls,$num);
+ }
+ }
+ if (@colls) {
+ if ($extra) {
+ $extra .= '&';
+ }
+ $extra .= 'menus_'.join(',',@colls);
+ }
+ }
+ }
if ($parmlev eq 'general') {
if ($uname) {
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
} elsif ($cgroup) {
- &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
} elsif ($csec) {
- &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
} else {
- &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
}
} elsif ($parmlev eq 'map') {
if ($uname) {
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
} elsif ($cgroup) {
- &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
} elsif ($csec) {
- &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
} else {
- &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
}
} else {
if ($uname) {
if (@{$usersgroups} > 1) {
my ($coursereply,$grp_parm,$controlgrp);
($coursereply,$othergrp,$grp_parm,$controlgrp) =
- &print_usergroups($r,$$part{$which}.'.'.$$name{$which},
+ &check_other_groups($$part{$which}.'.'.$$name{$which},
$rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt);
if ($coursereply && $result > 3) {
if (defined($controlgrp)) {
@@ -1021,32 +1480,32 @@ sub print_row {
}
}
- &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
- &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
if ($csec) {
- &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
}
if ($cgroup) {
- &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
- &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
+ &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
+ &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
+ &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly,$extra);
}
if ($uname) {
if ($othergrp) {
$r->print($othergrp);
}
- &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);
+ &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
+ &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly,$extra);
}
} # end of $parmlev if/else
@@ -1066,15 +1525,27 @@ sub print_row {
}
sub print_td {
- my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
+ my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly,$extra)=@_;
$r->print('');
my $nolink = 0;
- if ($which == 11 || $which == 12) {
+ if ($readonly) {
$nolink = 1;
- } elsif ($mprefix =~ /availablestudent\&$/) {
- if ($which > 3) {
+ } else {
+ if ($which == 11 || $which == 12) {
$nolink = 1;
+ } elsif (($env{'request.course.sec'} ne '') && ($which > 9)) {
+ $nolink = 1;
+ } elsif ($which == 4 || $which == 5 || $which == 6) {
+ if ($noeditgrp) {
+ $nolink = 1;
+ }
+ } elsif ($mprefix =~ /availablestudent\&$/) {
+ $nolink = 1;
+ } elsif ($mprefix =~ /examcode\&$/) {
+ unless ($which == 2) {
+ $nolink = 1;
+ }
}
}
if ($nolink) {
@@ -1082,13 +1553,13 @@ sub print_td {
} else {
$r->print(&plink($$typeoutpar[$which],
$$display{$value},$$outpar[$which],
- $mprefix."$which",'parmform.pres','psub'));
+ $mprefix."$which",'parmform.pres','psub',$extra));
}
$r->print(' '."\n");
}
-sub print_usergroups {
- my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
+sub check_other_groups {
+ my ($what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
my $courseid = $env{'request.course.id'};
my $output;
my $symb = &symbcache($rid);
@@ -1103,7 +1574,6 @@ sub print_usergroups {
if (($coursereply) && ($cgroup ne $resultgroup)) {
if ($result > 3) {
$bgcolor = '#AAFFAA';
- $grp_parm = &valout($coursereply,$resulttype);
}
$grp_parm = &valout($coursereply,$resulttype);
$output = '';
@@ -1171,23 +1641,27 @@ sub extractResourceInformation {
my $srcf=$resource->src();
$srcf=~/\.(\w+)$/;
$$typep{$id}=$1;
+ my $toolsymb;
+ if ($srcf =~ /ext\.tool$/) {
+ $toolsymb = $resource->symb();
+ }
$$keyp{$id}='';
$$uris{$id}=$srcf;
- foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
+ foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys',$toolsymb))) {
next if ($key!~/^parameter_/);
# Hidden parameters
- next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm');
+ next if (&Apache::lonnet::metadata($srcf,$key.'.hidden',$toolsymb) eq 'parm');
#
# allparms is a hash of parameter names
#
- my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
+ my $name=&Apache::lonnet::metadata($srcf,$key.'.name',$toolsymb);
if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) {
my ($display,$parmdis);
$display = &standard_parameter_names($name);
if ($display eq '') {
- $display= &Apache::lonnet::metadata($srcf,$key.'.display');
+ $display= &Apache::lonnet::metadata($srcf,$key.'.display',$toolsymb);
$parmdis = $display;
$parmdis =~ s/\s*\[Part.*$//g;
} else {
@@ -1196,14 +1670,14 @@ sub extractResourceInformation {
$$allparms{$name}=$parmdis;
if (ref($defkeytype)) {
$$defkeytype{$name}=
- &Apache::lonnet::metadata($srcf,$key.'.type');
+ &Apache::lonnet::metadata($srcf,$key.'.type',$toolsymb);
}
}
#
# allparts is a hash of all parts
#
- my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
+ my $part= &Apache::lonnet::metadata($srcf,$key.'.part',$toolsymb);
$$allparts{$part} = &mt('Part: [_1]',$part);
#
# Remember all keys going with this resource
@@ -1229,7 +1703,7 @@ sub extractResourceInformation {
$$mapp{$mapid}=$$mapp{$id};
$$allmaps{$mapid}=$$mapp{$id};
if ($mapid eq '1') {
- $$maptitles{$mapid}=&mt('Main Course Documents');
+ $$maptitles{$mapid}=&mt('Main Content');
} else {
$$maptitles{$mapid}=&Apache::lonnet::gettitle($$mapp{$id});
}
@@ -1249,14 +1723,21 @@ sub isdateparm {
return (($type=~/^date/) && (!($type eq 'date_interval')));
}
+# Determine if parameter type is specialized string type (i.e.,
+# not just string or string_yesno.
+
+sub is_specialstring {
+ my $type=shift;
+ return (($type=~/^string_/) && ($type ne 'string_yesno'));
+}
+
#
# parmmenu displays a list of the selected parameters.
# It also offers a link to show/hide the complete parameter list
# from which you can select all desired parameters.
#
sub parmmenu {
- my ($r,$allparms,$pscat,$keyorder)=@_;
- my $tempkey;
+ my ($r)=@_;
$r->print(<
// print(' ');
- &shortCuts($r,$allparms,$pscat,$keyorder);
+ &shortCuts($r);
$r->print(' ');
}
# return a hash
@@ -1362,8 +1844,8 @@ sub lookUpTableParameter {
'contentopen' => 'time_settings',
'contentclose' => 'time_settings',
'discussend' => 'time_settings',
- 'printopendate' => 'time_settings',
- 'printclosedate' => 'time_settings',
+ 'printstartdate' => 'time_settings',
+ 'printenddate' => 'time_settings',
'weight' => 'grading',
'handgrade' => 'grading',
'maxtries' => 'tries',
@@ -1383,6 +1865,7 @@ sub lookUpTableParameter {
'buttonshide' => 'hiding',
'turnoffeditor' => 'hiding',
'encrypturl' => 'hiding',
+ 'deeplink' => 'hiding',
'randomorder' => 'high_level_randomization',
'randompick' => 'high_level_randomization',
'available' => 'slots',
@@ -1395,8 +1878,12 @@ sub lookUpTableParameter {
'acc' => 'misc',
'maxcollaborators' => 'misc',
'scoreformat' => 'misc',
-
- );
+ 'lenient' => 'grading',
+ 'retrypartial' => 'tries',
+ 'discussvote' => 'misc',
+ 'texdisplay' => 'misc',
+ 'examcode' => 'high_level_randomization',
+ );
}
sub whatIsMyCategory {
@@ -1468,30 +1955,31 @@ sub parmboxes {
&whatIsMyCategory($tempparameter, \%categoryList);
}
#part to print the parm-list
+ $Text::Wrap::columns=60;
+ $Text::Wrap::separator=' ';
$r->print('\n");
@@ -1500,7 +1988,7 @@ sub parmboxes {
# This function offers some links on the parameter section to get with one click a group a parameters
#
sub shortCuts {
- my ($r,$allparms,$pscat,$keyorder)=@_;
+ my ($r)=@_;
# Parameter Selection
$r->print(
@@ -1533,8 +2021,12 @@ sub shortCuts {
sub partmenu {
my ($r,$allparts,$psprt)=@_;
+ my $selsize = 1+scalar(keys(%{$allparts}));
+ if ($selsize > 8) {
+ $selsize = 8;
+ }
- $r->print('');
+ $r->print('');
$r->print('print(' selected="selected"') unless (@{$psprt});
$r->print('>'.&mt('All Parts').' ');
@@ -1555,21 +2047,60 @@ sub partmenu {
}
sub usermenu {
- my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_;
+ my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups,$pssymb)=@_;
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
- &Apache::loncommon::selectstudent_link('parmform','uname','udom');
- my $selscript=&Apache::loncommon::studentbrowser_javascript();
+ &Apache::loncommon::selectstudent_link('parmform','uname','udom','condition').
+ &Apache::lonhtmlcommon::scripttag(< '.
+ $stuonly.' '.
+ ' '.
+ &mt('any role').' ';
my $sections='';
my %sectionhash = &Apache::loncommon::get_sections();
my $groups;
- my %grouphash = &Apache::longroup::coursegroups();
+ my %grouphash;
+ if (($pssymb) || &Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
+ %grouphash = &Apache::longroup::coursegroups();
+ } elsif ($env{'request.course.groups'} ne '') {
+ map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'});
+ }
my $g_s_header='';
my $g_s_footer='';
- if (%sectionhash) {
+ my $currsec = $env{'request.course.sec'};
+ if ($currsec) {
+ $sections=&mt('Section:').' '.$currsec;
+ if (%grouphash) {
+ $sections .= ';'.(' ' x2);
+ }
+ } elsif (%sectionhash && $currsec eq '') {
$sections=&mt('Section:').' ';
}
- if (%sectionhash && %grouphash && $parmlev ne 'full') {
+ if (%sectionhash && %grouphash && $parmlev ne 'full' && $currsec eq '') {
$sections .= ' '.&mt('or').' ';
$sections .= qq|
|;
- } else {
+ } elsif ($currsec eq '') {
$sections .= qq|
@@ -2217,30 +2931,18 @@ ENDPARMSELSCRIPT
}
# Step 1
- $r->print(&Apache::lonhtmlcommon::topic_bar(1,&mt('Resource Specification')));
- $r->print(<print(&Apache::lonhtmlcommon::topic_bar(1,&mt('Resource Specification'),'parmstep1'));
+ $r->print('
-COURSECONTENTSCRIPT
-
- $r->print(&Apache::lonhtmlcommon::start_pick_box());
+');
+ $r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel'));
&levelmenu($r,\%alllevs,$parmlev);
$r->print(&Apache::lonhtmlcommon::row_closure());
- &mapmenu($r,\%allmaps,$pschp,\%maptitles, \%symbp);
+ &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp,$parmlev);
$r->print(&Apache::lonhtmlcommon::row_closure());
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
&partmenu($r,\%allparts,\@psprt);
@@ -2248,13 +2950,13 @@ COURSECONTENTSCRIPT
$r->print(&Apache::lonhtmlcommon::end_pick_box());
# Step 2
- $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification')));
- &displaymenu($r,\%allparms,\@pscat,\@psprt,\%keyorder);
+ $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2'));
+ &displaymenu($r,\%allparms,\@pscat,\%keyorder,'parmmenuscroll');
# Step 3
- $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)')));
+ $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));
$r->print(&Apache::lonhtmlcommon::start_pick_box());
- &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
+ &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb);
$r->print(&Apache::lonhtmlcommon::row_closure(1));
$r->print(&Apache::lonhtmlcommon::end_pick_box());
@@ -2277,6 +2979,7 @@ COURSECONTENTSCRIPT
.''
.'');
} else {
+ $r->print();
# parameter screen for a single resource.
my ($map,$iid,$resource)=&Apache::lonnet::decode_symb($pssymb);
my $title = &Apache::lonnet::gettitle($pssymb);
@@ -2292,7 +2995,7 @@ COURSECONTENTSCRIPT
($env{'form.psprt'}?' checked="checked"':'').' />'.
&mt('Show all parts').
' ');
- &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
+ &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups,$pssymb);
$r->print(&Apache::lonhtmlcommon::row_closure(1));
$r->print(&Apache::lonhtmlcommon::end_pick_box());
$r->print(''
@@ -2321,6 +3024,11 @@ COURSECONTENTSCRIPT
my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
my $csuname=$env{'user.name'};
my $csudom=$env{'user.domain'};
+ my $readonly = 1;
+ if ($parm_permission->{'edit'}) {
+ undef($readonly);
+ }
+ $r->print('
');
if ($parmlev eq 'full') {
#
@@ -2332,7 +3040,7 @@ COURSECONTENTSCRIPT
$coursespan += 3;
}
- $r->print('
');
+ $r->print(&Apache::loncommon::start_data_table());
#
# This produces the headers
#
@@ -2440,20 +3148,24 @@ ENDTABLEHEADFOUR
my %type= ();
my %default=();
my $uri=&Apache::lonnet::declutter($uris{$rid});
+ my $toolsymb;
+ if ($uri =~ /ext\.tool$/) {
+ $toolsymb = $symbp{$rid};
+ }
my $filter=$env{'form.filter'};
foreach (&keysplit($keyp{$rid})) {
my $tempkeyp = $_;
if (grep $_ eq $tempkeyp, @catmarker) {
- my $parmname=&Apache::lonnet::metadata($uri,$_.'.name');
+ my $parmname=&Apache::lonnet::metadata($uri,$_.'.name',$toolsymb);
# We may only want certain parameters listed
if ($filter) {
unless ($filter=~/\Q$parmname\E/) { next; }
}
$name{$_}=$parmname;
- $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
+ $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part',$toolsymb);
- my $parmdis=&Apache::lonnet::metadata($uri,$_.'.display');
+ my $parmdis=&Apache::lonnet::metadata($uri,$_.'.display',$toolsymb);
if ($allparms{$name{$_}} ne '') {
my $identifier;
if ($parmdis =~ /(\s*\[Part.*)$/) {
@@ -2465,9 +3177,9 @@ ENDTABLEHEADFOUR
}
unless ($display{$_}) { $display{$_}=''; }
$display{$_}.=' ('.$name{$_}.')';
- $default{$_}=&Apache::lonnet::metadata($uri,$_);
- $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
- $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
+ $default{$_}=&Apache::lonnet::metadata($uri,$_,$toolsymb);
+ $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type',$toolsymb);
+ $thistitle=&Apache::lonnet::metadata($uri,$_.'.title',$toolsymb);
}
}
my $totalparms=scalar keys %name;
@@ -2506,13 +3218,13 @@ ENDTABLEHEADFOUR
&print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
\%type,\%display,$defbgone,$defbgtwo,
$defbgthree,$parmlev,$uname,$udom,$csec,
- $cgroup,\@usersgroups);
+ $cgroup,\@usersgroups,$noeditgrp,$readonly);
}
}
}
} # end foreach ids
# -------------------------------------------------- End entry for one resource
- $r->print('
');
+ $r->print(&Apache::loncommon::end_data_table);
} # end of full
#--------------------------------------------------- Entry for parm level map
if ($parmlev eq 'map') {
@@ -2530,7 +3242,7 @@ ENDTABLEHEADFOUR
#-------------------------------------------- for each map, gather information
my $mapid;
- foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
+ foreach $mapid (sort { $a <=> $b } keys(%maplist)) {
my $maptitle = $maplist{$mapid};
#----------------------- loop through ids and get all parameter types for map
@@ -2552,6 +3264,10 @@ ENDTABLEHEADFOUR
if ($map eq $mapid) {
my $uri=&Apache::lonnet::declutter($uris{$rid});
+ my $toolsymb;
+ if ($uri =~ /ext\.tool$/) {
+ $toolsymb = $symbp{$rid};
+ }
# $r->print("Keys: $keyp{$rid}
\n");
#--------------------------------------------------------------------
@@ -2568,8 +3284,8 @@ ENDTABLEHEADFOUR
if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
$part{$tempkeyp}="0";
- $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
- my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
+ $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name',$toolsymb);
+ my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display',$toolsymb);
if ($allparms{$name{$tempkeyp}} ne '') {
my $identifier;
if ($parmdis =~ /(\s*\[Part.*)$/) {
@@ -2582,8 +3298,8 @@ ENDTABLEHEADFOUR
unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
$display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
$display{$tempkeyp} =~ s/_\w+_/_0_/;
- $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
- $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
+ $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp,$toolsymb);
+ $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type',$toolsymb);
}
} # end loop through keys
}
@@ -2629,7 +3345,8 @@ ENDTABLEHEADFOUR
$r->print(&Apache::loncommon::start_data_table_row());
&print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
\%type,\%display,$defbgone,$defbgtwo,$defbgthree,
- $parmlev,$uname,$udom,$csec,$cgroup);
+ $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp,
+ $readonly);
}
$r->print(&Apache::loncommon::end_data_table().''
.'
'
@@ -2656,6 +3373,10 @@ ENDTABLEHEADFOUR
my $rid = $_;
my $uri=&Apache::lonnet::declutter($uris{$rid});
+ my $toolsymb;
+ if ($uri =~ /ext\.tool$/) {
+ $toolsymb = $symbp{$rid};
+ }
#--------------------------------------------------------------------
# @catmarker contains list of all possible parameters including part #s
@@ -2670,8 +3391,8 @@ ENDTABLEHEADFOUR
$tempkeyp =~ s/_\w+_/_0_/;
if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
$part{$tempkeyp}="0";
- $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
- my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
+ $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name',$toolsymb);
+ my $parmdis=&Apache::lonnet::metadata($uri,$fullkeyp.'.display',$toolsymb);
if ($allparms{$name{$tempkeyp}} ne '') {
my $identifier;
if ($parmdis =~ /(\s*\[Part.*)$/) {
@@ -2684,8 +3405,8 @@ ENDTABLEHEADFOUR
unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
$display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
$display{$tempkeyp} =~ s/_\w+_/_0_/;
- $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
- $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
+ $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp,$toolsymb);
+ $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type',$toolsymb);
}
} # end loop through keys
} # end loop through ids
@@ -2719,17 +3440,18 @@ ENDMAPONE
foreach (&keysinorder(\%name,\%keyorder)) {
$r->print(&Apache::loncommon::start_data_table_row());
&print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
- \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
- $parmlev,$uname,$udom,$csec,$cgroup);
+ \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
+ $parmlev,$uname,$udom,$csec,$cgroup,'',$noeditgrp,
+ $readonly);
}
$r->print(&Apache::loncommon::end_data_table()
.'
'
.''
);
} # end of $parmlev eq general
+ $r->print('');
}
$r->print('');
- &endSettingsScreen($r);
$r->print(&Apache::loncommon::end_page());
} # end sub assessparms
@@ -2739,12 +3461,19 @@ ENDMAPONE
my $tableopen;
sub tablestart {
+ my ($readonly) = @_;
if ($tableopen) {
- return '';
+ return '';
} else {
- $tableopen=1;
- return &Apache::loncommon::start_data_table().''.&mt('Parameter').' '.
- &mt('Delete').' '.&mt('Set to ...').' ';
+ $tableopen=1;
+ my $output = &Apache::loncommon::start_data_table().''.&mt('Parameter').' ';
+ if ($readonly) {
+ $output .= ''.&mt('Current value').' ';
+ } else {
+ $output .= ''.&mt('Delete').' '.&mt('Set to ...').' ';
+ }
+ $output .= ' ';
+ return $output;
}
}
@@ -2777,7 +3506,11 @@ sub readdata {
}
}
}
- return $resourcedata;
+ if (wantarray) {
+ return ($resourcedata,$classlist);
+ } else {
+ return $resourcedata;
+ }
}
@@ -2793,48 +3526,103 @@ sub storedata {
my @deldata=();
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 'setipallow' || $cmd eq 'setipdeny' || $cmd eq 'setdeeplink');
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);
+ 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') {
- my ($needsrelease,$needsnewer);
- $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$data};
- if ($needsrelease) {
- unless ($got_chostname) {
- ($chostname,$cmajor,$cminor)=&questiontype_release_vars();
- $got_chostname = 1;
+ $name = 'type';
+ } elsif ($typeof eq 'string_deeplink') {
+ ($name) = ($typeof =~ /^string_(deeplink)$/);
+ 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;
+ }
+ }
+ }
}
- $needsnewer = &questiontype_releasecheck($data,$needsrelease,
- $chostname,$cmajor,
- $cminor);
}
- if ($needsnewer) {
- $r->print(' '.&oldversion_warning($data,$chostname,$cmajor,
- $cminor,$needsrelease));
- next;
+ } elsif ($typeof eq 'string_lenient') {
+ $name = 'lenient';
+ } 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 ($typeof eq 'string_tex') {
+ $name = 'texdisplay';
}
} 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);
$typeof=$env{'form.typeof_'.$thiskey};
$text = &mt('Saved modified date for');
}
+ if ($name ne '') {
+ my ($needsrelease,$needsnewer);
+ $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$valchk"};
+ if ($needsrelease) {
+ unless ($got_chostname) {
+ ($chostname,$cmajor,$cminor)=¶meter_release_vars();
+ $got_chostname = 1;
+ }
+ $needsnewer = ¶meter_releasecheck($name,$valchk,
+ $needsrelease,
+ $cmajor,$cminor);
+ if ($needsnewer) {
+ $r->print(' '.&oldversion_warning($name,$data,
+ $chostname,$cmajor,
+ $cminor,$needsrelease));
+ next;
+ }
+ }
+ }
if (defined($data) and $$olddata{$thiskey} ne $data) {
if ($tuname) {
if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
@@ -2877,7 +3665,7 @@ sub storedata {
if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
my %loghash=map { $_ => '' } @deldata;
&log_parmset(\%loghash,1);
- $r->print(''.&mt('Deleted [_1] parameter(s) ',$delentries));
+ $r->print(''.&mt('Deleted [quant,_1,parameter]',$delentries/2).' ');
} else {
$r->print(''.
&mt('Error deleting parameters').'
');
@@ -2887,7 +3675,7 @@ sub storedata {
if ($putentries) {
if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
&log_parmset(\%newdata,0);
- $r->print(''.&mt('Saved [_1] parameter(s)',$putentries/2).' ');
+ $r->print(''.&mt('Saved [quant,_1,parameter]',$putentries/2).' ');
} else {
$r->print(''.
&mt('Error saving parameters').'
');
@@ -2922,7 +3710,7 @@ sub parse_listdata_key {
}
sub listdata {
- my ($r,$resourcedata,$listdata,$sortorder)=@_;
+ my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist,$readonly,$parmlev)=@_;
# Start list output
my $oldsection='';
@@ -2932,6 +3720,17 @@ sub listdata {
$tableopen=0;
my $foundkeys=0;
my %keyorder=&standardkeyorder();
+ my $readonlyall = $readonly;
+
+ my ($secidx,%grouphash);
+ if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
+ $secidx = &Apache::loncoursedata::CL_SECTION();
+ if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
+ %grouphash = &Apache::longroup::coursegroups();
+ } elsif ($env{'request.course.groups'} ne '') {
+ map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'});
+ }
+ }
foreach my $thiskey (sort {
my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
@@ -2975,29 +3774,55 @@ sub listdata {
} keys %{$listdata}) {
if ($$listdata{$thiskey.'.type'}) {
- my $thistype=$$listdata{$thiskey.'.type'};
- if ($$resourcedata{$thiskey.'.type'}) {
- $thistype=$$resourcedata{$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');
+ $readonly = $readonlyall;
+ my $userscope;
+ my $showval = $$resourcedata{$thiskey};
if ($middle=~/^\[(.*)\]/) {
- my $issection=$1;
- if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
- $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
- } else {
- $section=&mt('Group/Section').': '.$issection;
- }
- $middle=~s/^\[(.*)\]//;
+ 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($1,$2);
+ $userscope = 1;
+ } 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 {
+ $section=&mt('Group/Section').': '.$issection;
+ }
+ }
+ $middle=~s/^\[(.*)\]//;
+ } elsif (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) {
+ $readonly = 1;
}
$middle=~s/\.+$//;
$middle=~s/^\.+//;
my $realm=''.&mt('All Resources').' ';
+
if ($middle=~/^(.+)\_\_\_\(all\)$/) {
$realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' ('.$1.') ';
} elsif ($middle) {
my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
+ next if (($url =~ /\.(page|sequence)$/) && ($parmlev eq 'full') && ($caller eq 'newoverview'));
$realm=''.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' ('.$url.' in '.$map.' id: '.$id.') ';
}
if ($sortorder eq 'realmstudent') {
@@ -3032,36 +3857,57 @@ sub listdata {
# Ready to print
#
my $parmitem = &standard_parameter_names($name);
- $r->print(&tablestart().
+ $r->print(&tablestart($readonly).
&Apache::loncommon::start_data_table_row().
''.&mt($parmitem).
- ' ');
+ ' ');
+ unless ($readonly) {
+ my $disabled;
+ if (($name eq 'availablestudent') &&
+ (($showval eq '') || ($userscope))) {
+ $disabled = ' disabled="disabled"';
+ }
+ $r->print(' ');
+ }
+ $r->print('');
$foundkeys++;
if (&isdateparm($thistype)) {
- my $jskey='key_'.$pointer;
- $pointer++;
- $r->print(
- &Apache::lonhtmlcommon::date_setter('parmform',
- $jskey,
- $$resourcedata{$thiskey},
- '',1,'','').
+ 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(
' '.
(($$resourcedata{$thiskey}!=0)?''.
&mt('Shift all dates based on this date').' ':'').
&date_sanity_info($$resourcedata{$thiskey})
);
+ }
} elsif ($thistype eq 'date_interval') {
- $r->print(&date_interval_selector($thiskey,
- $$resourcedata{$thiskey}));
+ $r->print(&date_interval_selector($thiskey,$name,
+ $$resourcedata{$thiskey},$readonly));
} elsif ($thistype =~ m/^string/) {
- $r->print(&string_selector($thistype,$thiskey,
- $$resourcedata{$thiskey}));
+ if ($name eq 'availablestudent') {
+ $readonly = 1;
+ }
+ $r->print(&string_selector($thistype,$thiskey,
+ $$resourcedata{$thiskey},$name,$readonly));
} else {
- $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
+ $r->print(&default_selector($thiskey,$$resourcedata{$thiskey},$readonly));
+ }
+ unless ($readonly) {
+ $r->print(' ');
}
- $r->print(' ');
$r->print(' '.&Apache::loncommon::end_data_table_row());
}
}
@@ -3070,8 +3916,9 @@ sub listdata {
sub date_interval_selector {
- my ($thiskey, $showval) = @_;
- my $result;
+ my ($thiskey, $pname, $showval, $readonly) = @_;
+ my ($result,%skipval);
+ my $currval = $showval;
foreach my $which (['days', 86400, 31],
['hours', 3600, 23],
['minutes', 60, 59],
@@ -3081,11 +3928,65 @@ sub date_interval_selector {
$showval %= $factor;
my %select = ((map {$_ => $_} (0..$max)),
'select_form_order' => [0..$max]);
+ if ($currval eq '') {
+ unshift(@{$select{'select_form_order'}},'');
+ $select{''} = '';
+ $amount = '';
+ }
$result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
- \%select);
+ \%select,'',$readonly);
$result .= ' '.&mt($name);
}
- $result .= ' ';
+ if ($pname eq 'interval') {
+ unless ($skipval{'done'}) {
+ my $checkedon = '';
+ my $checkedoff = '';
+ my $checkedproc = '';
+ my $currproctorkey = '';
+ my $currprocdisplay = 'hidden';
+ my $currdonetext = &mt('Done');
+ my $checkedoff = ' checked="checked"';
+ if ($currval =~ /^(?:\d+)_done$/) {
+ $checkedon = ' checked="checked"';
+ } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:$/) {
+ $currdonetext = $1;
+ $checkedon = ' checked="checked"';
+ } elsif ($currval =~ /^(?:\d+)_done_proctor_(.+)$/) {
+ $currproctorkey = $1;
+ $checkedproc = ' checked="checked"';
+ $currprocdisplay = 'text';
+ } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:_proctor_(.+)$/) {
+ $currdonetext = $1;
+ $currproctorkey = $2;
+ $checkedproc = ' checked="checked"';
+ $currprocdisplay = 'text';
+ } elsif ($currval ne '') {
+ $checkedoff = ' checked="checked"';
+ } else {
+ $currdonetext = '';
+ }
+ my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"';
+ my $disabled;
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ }
+ $result .= ''.&mt('Include "done" button').
+ ' '.
+ &mt('No').' '.(' 'x2).
+ ' '.
+ &mt('Yes').' '.(' 'x2).
+ ' '.
+ &mt('Yes, with proctor key').' '.
+ ' &').'"'.$disabled.' /> '.
+ ''.&mt('Button text').': '.
+ ' &').'"'.$disabled.' /> ';
+ }
+ }
+ unless ($readonly) {
+ $result .= ' ';
+ }
return $result;
}
@@ -3093,24 +3994,363 @@ sub date_interval_selector {
sub get_date_interval_from_form {
my ($key) = @_;
my $seconds = 0;
+ my $numnotnull = 0;
foreach my $which (['days', 86400],
['hours', 3600],
['minutes', 60],
['seconds', 1]) {
my ($name, $factor) = @{ $which };
if (defined($env{'form.'.$name.'_'.$key})) {
- $seconds += $env{'form.'.$name.'_'.$key} * $factor;
+ unless ($env{'form.'.$name.'_'.$key} eq '') {
+ $numnotnull ++;
+ $seconds += $env{'form.'.$name.'_'.$key} * $factor;
+ }
}
}
+ 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'}.':';
+ if ($env{'form.done_'.$key} eq '_done_proctor') {
+ $seconds .= '_proctor';
+ }
+ } else {
+ $seconds .= $env{'form.done_'.$key};
+ }
+ if (($env{'form.done_'.$key} eq '_done_proctor') &&
+ ($env{'form.done_'.$key.'_proctorkey'})) {
+ $seconds .= '_'.$env{'form.done_'.$key.'_proctorkey'};
+ }
+ }
+ return if (!$numnotnull);
return $seconds;
}
sub default_selector {
- my ($thiskey, $showval) = @_;
- return ' ';
+ my ($thiskey, $showval, $readonly) = @_;
+ my $disabled;
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ }
+ return ' ';
+}
+
+sub string_ip_selector {
+ my ($thiskey, $showval, $readonly) = @_;
+ my %access = (
+ allow => [],
+ deny => [],
+ );
+ if ($showval ne '') {
+ my @current;
+ if ($showval =~ /,/) {
+ @current = split(/,/,$showval);
+ } else {
+ @current = ($showval);
+ }
+ foreach my $item (@current) {
+ if ($item =~ /^\!([\[\]a-zA-Z\.\d\*\-]+)$/) {
+ push(@{$access{'deny'}},$1);
+ } elsif ($item =~ /^([\[\]a-zA-Z\.\d\*\-]+)$/) {
+ push(@{$access{'allow'}},$item);
+ }
+ }
+ }
+ if (!@{$access{'allow'}}) {
+ @{$access{'allow'}} = ('');
+ }
+ if (!@{$access{'deny'}}) {
+ @{$access{'deny'}} = ('');
+ }
+ my ($disabled,$addmore);
+ if ($readonly) {
+ $disabled=' disabled="disabled"';
+ } else {
+ $addmore = "\n".''.&mt('Add more').' ';
+ }
+ my $output = '
+'.&mt('Allow from').' '.&mt('Deny from').' ';
+ foreach my $acctype ('allow','deny') {
+ $output .= '
+
+
+
'."\n";
+ my $num = 0;
+ foreach my $curr (@{$access{$acctype}}) {
+ $output .= '
'."\n";
+ $num ++;
+ }
+ $output .= '
+
'.$addmore.'
+
+ ';
+ }
+ $output .= '
+
+
'."\n";
+ return $output;
+}
+
+sub string_deeplink_selector {
+ my ($thiskey, $showval, $readonly) = @_;
+ my (@tables,%values,@current,%titles,%options,%optiontext,%defaults,
+ %selectnull,%domlti,%crslti,@possmenus,%components);
+ @tables = ('upper','lower');
+ %components = (
+ upper => ['state','others','listing','scope'],
+ lower => ['protect','menus','target','exit'],
+ );
+ %titles = &Apache::lonlocal::texthash (
+ state => 'Access status',
+ others => 'Hide other resources',
+ listing => 'In Contents and/or Gradebook',
+ scope => 'Access scope for link',
+ protect => 'Link protection',
+ menus => 'Menu Items Displayed',
+ target => 'Embedded?',
+ exit => 'Exit Tool Button?',
+ );
+ %options = (
+ state => ['only','off','both'],
+ others => ['hide','unhide'],
+ listing => ['full','absent','grades','details','datestatus'],
+ scope => ['res','map','rec'],
+ protect => ['none','key','ltid','ltic'],
+ menus => ['std','colls'],
+ target => ['_self','_top'],
+ exit => ['no','yes','url'],
+ );
+ %optiontext = &Apache::lonlocal::texthash (
+ only => 'deep only',
+ off => 'deeplink off',
+ both => 'regular + deep',
+ hide => 'Hidden',
+ unhide => 'Unhidden',
+ full => 'Listed (linked) in both',
+ absent => 'Not listed',
+ grades => 'Listed in grades only',
+ details => 'Listed (unlinked) in both',
+ datestatus => 'Listed (unlinked) inc. status in both',
+ res => 'resource only',
+ map => 'enclosing map/folder',
+ rec => 'recursive map/folder',
+ none => 'not in use',
+ key => 'key access',
+ ltic => 'LTI access (course)',
+ ltid => 'LTI access (domain)' ,
+ std => 'Standard (all menus)',
+ colls => 'Numbered collection',
+ _self => 'Embedded',
+ _top => 'Not embedded',
+ no => 'Not in use',
+ yes => 'In use, no URL redirect',
+ url => 'In use, redirect to URL',
+ );
+ %selectnull = &Apache::lonlocal::texthash (
+ ltic => 'Select Launcher',
+ ltid => 'Select Launcher',
+ colls => 'Select',
+ );
+ if ($showval =~ /,/) {
+ %values=();
+ @current = split(/,/,$showval);
+ ($values{'state'}) = ($current[0] =~ /^(only|off|both)$/);
+ ($values{'others'}) = ($current[1] =~ /^(hide|unhide)$/);
+ ($values{'listing'}) = ($current[2] =~ /^(full|absent|grades|details|datestatus)$/);
+ ($values{'scope'}) = ($current[3] =~ /^(res|map|rec)$/);
+ ($values{'protect'}) = ($current[4] =~ /^(key:[a-zA-Z\d_.!\@#\$%^&*()+=-]+|ltic:\d+|ltid:\d+)$/);
+ ($values{'menus'}) = ($current[5] =~ /^(\d+)$/);
+ ($values{'target'}) = ($current[6] =~ /^(_self|_top)$/);
+ ($values{'exit'}) = ($current[7] =~ /^((?:(?:yes|url)(?:|\:[^:;"',]+))|no)$/);
+ } else {
+ $defaults{'state'} = 'off',
+ $defaults{'others'} = 'unhide',
+ $defaults{'listing'} = 'full';
+ $defaults{'scope'} = 'res';
+ $defaults{'protect'} = 'none';
+ $defaults{'menus'} = '0';
+ $defaults{'target'} = '_top';
+ $defaults{'exit'} = 'yes';
+ }
+ my $disabled;
+ if ($readonly) {
+ $disabled=' disabled="disabled"';
+ }
+ my %courselti =
+ &Apache::lonnet::get_course_lti($env{'course.'.$env{'request.course.id'}.'.num'},
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ 'provider');
+ foreach my $item (keys(%courselti)) {
+ if (ref($courselti{$item}) eq 'HASH') {
+ $crslti{$item} = $courselti{$item}{'name'};
+ }
+ }
+ my %lti =
+ &Apache::lonnet::get_domain_lti($env{'course.'.$env{'request.course.id'}.'.domain'},
+ 'linkprot');
+ foreach my $item (keys(%lti)) {
+ if (($item =~ /^\d+$/) && (ref($lti{$item}) eq 'HASH')) {
+ $domlti{$item} = $lti{$item}{'name'};
+ }
+ }
+ if ($env{'course.'.$env{'request.course.id'}.'.menucollections'}) {
+ foreach my $item (split(/;/,$env{'course.'.$env{'request.course.id'}.'.menucollections'})) {
+ my ($num,$value) = split(/\%/,$item);
+ if ($num =~ /^\d+$/) {
+ push(@possmenus,$num);
+ }
+ }
+ }
+
+ my $output = ' ';
+ foreach my $table ('upper','lower') {
+ next unless (ref($components{$table}) eq 'ARRAY');
+ $output .= ''."\n";
+ if ($table eq 'upper') {
+ $output .= ' ';
+ }
+ }
+ return $output;
}
+{
+
my %strings =
(
'string_yesno'
@@ -3130,8 +4370,43 @@ my %strings =
[ 'randomizetry', 'New Randomization Each N Tries (default N=1)'],
[ 'practice', 'Practice'],
[ 'surveycred', 'Survey (credit for submission)']],
+ 'string_lenient'
+ => [['yes', 'Yes' ],
+ [ 'no', 'No' ],
+ [ 'default', 'Default - only bubblesheet grading is lenient' ]],
+ 'string_discussvote'
+ => [['yes','Yes'],
+ ['notended','Yes, unless discussion ended'],
+ ['no','No']],
+ 'string_ip'
+ => [['_allowfrom_','Hostname(s), or IP(s) from which access is allowed'],
+ ['_denyfrom_','Hostname(s) or IP(s) from which access is disallowed']],
+ 'string_deeplink'
+ => [['on','Set choices for link protection, resource listing, access scope, shown menu items, embedding, and exit link']],
+ 'string_tex'
+ => [['tth', 'tth (TeX to HTML)'],
+ ['mathjax', 'MathJax']],
);
+my %stringmatches = (
+ 'string_ip'
+ => [['_allowfrom_','[^\!]+'],
+ ['_denyfrom_','\!']],
+ 'string_deeplink'
+ => [['on','^(only|off|both)\,(hide|unhide)\,(full|absent|grades|details|datestatus)\,(res|map|rec)\,(none|key\:\w+|ltic\:\d+|ltid\:\d+)\,(\d+|)\,_(self|top),(yes|url|no)(|:[^:;\'",]+)$']],
+ );
+
+my %stringtypes = (
+ type => 'string_questiontype',
+ lenient => 'string_lenient',
+ retrypartial => 'string_yesno',
+ discussvote => 'string_discussvote',
+ examcode => 'string_examcode',
+ acc => 'string_ip',
+ deeplink => 'string_deeplink',
+ texdisplay => 'string_tex',
+ );
+
sub standard_string_options {
my ($string_type) = @_;
if (ref($strings{$string_type}) eq 'ARRAY') {
@@ -3140,36 +4415,56 @@ sub standard_string_options {
return;
}
+sub standard_string_matches {
+ my ($string_type) = @_;
+ if (ref($stringmatches{$string_type}) eq 'ARRAY') {
+ return $stringmatches{$string_type};
+ }
+ return;
+}
+
sub string_selector {
- my ($thistype, $thiskey, $showval) = @_;
+ my ($thistype, $thiskey, $showval, $name, $readonly) = @_;
if (!exists($strings{$thistype})) {
- return &default_selector($thiskey,$showval);
+ return &default_selector($thiskey,$showval,$readonly);
}
my %skiptype;
- if ($thistype eq 'string_questiontype') {
+ if (($thistype eq 'string_questiontype') ||
+ ($thistype eq 'string_lenient') ||
+ ($thistype eq 'string_discussvote') ||
+ ($name eq 'retrypartial')) {
my ($got_chostname,$chostname,$cmajor,$cminor);
foreach my $possibilities (@{ $strings{$thistype} }) {
next unless (ref($possibilities) eq 'ARRAY');
- my ($name, $description) = @{ $possibilities };
- my $needsrelease=$Apache::lonnet::needsrelease{'parameter:type:'.$name};
+ my ($parmval, $description) = @{ $possibilities };
+ my $needsrelease=$Apache::lonnet::needsrelease{"parameter:$name:$parmval"};
if ($needsrelease) {
unless ($got_chostname) {
- ($chostname,$cmajor,$cminor)=&questiontype_release_vars();
+ ($chostname,$cmajor,$cminor)=¶meter_release_vars();
$got_chostname = 1;
}
- my $needsnewer=&questiontype_releasecheck($name,$needsrelease,
- $chostname,$cmajor,
- $cminor);
+ my $needsnewer=¶meter_releasecheck($name,$parmval,$needsrelease,
+ $cmajor,$cminor);
if ($needsnewer) {
- $skiptype{$name} = 1;
+ $skiptype{$parmval} = 1;
}
}
}
}
- my $result;
+ if ($thistype eq 'string_ip') {
+ return &string_ip_selector($thiskey,$showval,$readonly);
+ } elsif ($thistype eq 'string_deeplink') {
+ return &string_deeplink_selector($thiskey,$showval,$readonly);
+ }
+
+ my ($result,$disabled);
+
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ }
my $numinrow = 3;
if ($thistype eq 'string_problemstatus') {
$numinrow = 2;
@@ -3195,7 +4490,7 @@ sub string_selector {
$result .= ''.
''.
' 'string_questiontype',
+ lenient => 'string_lenient',
+ retrypartial => 'string_yesno',
+ discussvote => 'string_discussvote',
+ examcode => 'string_examcode',
+ );
+ if (exists($stringtypes{$name})) {
+ if ($name eq 'examcode') {
+ $desc = $value;
+ } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
+ foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) {
+ next unless (ref($possibilities) eq 'ARRAY');
+ my ($parmval, $description) = @{ $possibilities };
+ if ($parmval eq $value) {
+ $desc = $description;
+ last;
+ }
+ }
+ }
+ } elsif (($name eq 'printstartdate') || ($name eq 'printenddate')) {
+ my $now = time;
+ if ($value =~ /^\d+$/) {
+ if ($name eq 'printstartdate') {
+ if ($value > $now) {
+ $desc = &Apache::lonlocal::locallocaltime($value);
+ }
+ } elsif ($name eq 'printenddate') {
+ if ($value < $now) {
+ $desc = &Apache::lonlocal::locallocaltime($value);
+ }
+ }
+ }
+ }
+ my $standard_name = &standard_parameter_names($name);
+ return ''.
+ &mt('[_1] was [_2]not[_3] set to [_4].',
+ $standard_name,'',' ','"'.$desc.'"').' '.
+ &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
+ $cmajor.'.'.$cminor,$chostname,
+ $needsrelease).
+ '
';
+}
+
+}
+
#
# Shift all start and end dates by $shift
#
sub dateshift {
- my ($shift)=@_;
+ my ($shift,$numchanges)=@_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $sec = $env{'request.course.sec'};
+ my $secgrpregex;
+ if ($sec ne '') {
+ my @groups;
+ if ($env{'request.course.groups'} ne '') {
+ @groups = split(/:/,$env{'request.course.groups'});
+ }
+ if (@groups) {
+ $secgrpregex = '(?:'.join('|',($sec,@groups)).')';
+ } else {
+ $secgrpregex = $sec;
+ }
+ }
my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
# ugly retro fix for broken version of types
foreach my $key (keys %data) {
@@ -3240,7 +4597,11 @@ sub dateshift {
# go through all parameters and look for dates
foreach my $key (keys %data) {
if ($data{$key.'.type'}=~/^date_(start|end)$/) {
+ if ($sec ne '') {
+ next unless ($key =~ /^$env{'request.course.id'}\.\[$secgrpregex\]\./);
+ }
my $newdate=$data{$key}+$shift;
+ $$numchanges ++;
$storecontent{$key}=$newdate;
}
}
@@ -3254,18 +4615,39 @@ sub dateshift {
}
sub newoverview {
- my ($r) = @_;
+ my ($r,$parm_permission) = @_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $readonly = 1;
+ if ($parm_permission->{'edit'}) {
+ undef($readonly);
+ }
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
text=>"Overview Mode"});
- my $start_page = &Apache::loncommon::start_page('Set Parameters');
+
+ my %loaditems = (
+ 'onload' => "showHide_courseContent(); resize_scrollbox('mapmenuscroll','1','1');",
+ );
+ my $js = '
+
+';
+ my $start_page = &Apache::loncommon::start_page('Set Parameters',$js,
+ {'add_entries' => \%loaditems,});
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
$r->print($start_page.$breadcrumbs);
- &startSettingsScreen($r,'parmset');
$r->print(<
+ ');
+ $r->print('');
+ if ($sectionselector) {
+ $r->print(''.$sectionselector.' ');
+ }
+ if ($groupselector) {
+ $r->print(''.$groupselector.' ');
+ }
+ $r->print('');
$r->print(&Apache::lonhtmlcommon::row_closure(1));
$r->print(&Apache::lonhtmlcommon::end_pick_box());
$r->print('');
@@ -3384,12 +4777,13 @@ ENDOVER
# List data
- &listdata($r,$resourcedata,$listdata,$sortorder);
+ &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly,$parmlev);
+ }
+ $r->print(&tableend());
+ unless ($readonly) {
+ $r->print(((($env{'form.store'}) || ($env{'form.dis'}))?'
':''));
}
- $r->print(&tableend().
- ((($env{'form.store'}) || ($env{'form.dis'}))?'
':'').
- '');
- &endSettingsScreen($r);
+ $r->print('');
$r->print(&Apache::loncommon::end_page());
}
@@ -3429,38 +4823,63 @@ sub secgroup_lister {
}
sub overview {
- my ($r) = @_;
+ my ($r,$parm_permission) = @_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
-
+ my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
+ my $js = ''."\n";
+ my $readonly = 1;
+ if ($parm_permission->{'edit'}) {
+ undef($readonly);
+ }
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
text=>"Overview Mode"});
- my $start_page=&Apache::loncommon::start_page('Modify Parameters');
+ my $start_page=&Apache::loncommon::start_page('Modify Parameters',$js);
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
$r->print($start_page.$breadcrumbs);
- &startSettingsScreen($r,'parmset');
- $r->print(''.
- &Apache::loncommon::end_page());
+ $r->print(&tableend().'');
+ if ($foundkeys) {
+ unless ($readonly) {
+ $r->print('
'.$submitbutton.'
');
+ }
+ } else {
+ $r->print(''.&mt('There are no parameters.').'
');
+ }
+ $r->print(''.&Apache::loncommon::end_page());
}
sub clean_parameters {
@@ -3522,10 +4941,8 @@ ENDOVER
$r->print(&mt('All users'));
} elsif ($data{'scope_type'} eq 'user') {
$r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
- } elsif ($data{'scope_type'} eq 'section') {
- $r->print(&mt('Section: [_1]',$data{'scope'}));
- } elsif ($data{'scope_type'} eq 'group') {
- $r->print(&mt('Group: [_1]',$data{'scope'}));
+ } elsif ($data{'scope_type'} eq 'secgroup') {
+ $r->print(&mt('Group/Section: [_1]',$data{'scope'}));
}
$r->print(' ');
if ($data{'realm_type'} eq 'all') {
@@ -3535,8 +4952,9 @@ ENDOVER
} 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,$resid,$map));
+ $r->print(&mt('Resource: [_1]with ID: [_2]in folder [_3]',
+ $url.' ',
+ $resid.' ',$map));
}
$r->print(' '.&mt('Part: [_1]',$data{'parameter_part'}));
$r->print('');
@@ -3546,7 +4964,6 @@ ENDOVER
$r->print(&Apache::loncommon::end_data_table().''.
' '.
'
');
- &endSettingsScreen($r);
$r->print(&Apache::loncommon::end_page());
}
@@ -3554,27 +4971,36 @@ sub date_shift_one {
my ($r) = @_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
-
+ my $sec = $env{'request.course.sec'};
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
text=>"Shifting Dates"});
+ my $submit_text = &mt('Shift all dates accordingly');
+ if ($sec ne '') {
+ my @groups;
+ if ($env{'request.course.groups'} ne '') {
+ @groups = split(/:/,$env{'request.course.groups'});
+ }
+ if (@groups) {
+ $submit_text = &mt("Shift dates set just for your section/group(s), accordingly");
+ } else {
+ $submit_text = &mt("Shift dates set just for your section, accordingly");
+ }
+ }
my $start_page=&Apache::loncommon::start_page('Shift Dates');
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
$r->print($start_page.$breadcrumbs);
- &startSettingsScreen($r,'parmset');
- $r->print('');
- &endSettingsScreen($r);
+ ' ');
$r->print(&Apache::loncommon::end_page());
}
@@ -3582,19 +5008,57 @@ sub date_shift_two {
my ($r) = @_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $sec = $env{'request.course.sec'};
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
text=>"Shifting Dates"});
my $start_page=&Apache::loncommon::start_page('Shift Dates');
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
$r->print($start_page.$breadcrumbs);
- &startSettingsScreen($r,'parmset');
my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
- $r->print(&mt('Shifting all dates such that [_1] becomes [_2]',
- &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
- &Apache::lonlocal::locallocaltime($timeshifted)));
+ $r->print(''.&mt('Shift Dates').' ');
+ if ($sec ne '') {
+ my @groups;
+ if ($env{'request.course.groups'} ne '') {
+ @groups = split(/:/,$env{'request.course.groups'});
+ }
+ if (@groups) {
+ $r->print(''.
+ &mt("Shift dates set just for your section/group(s), such that [_1] becomes [_2]",
+ &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+ &Apache::lonlocal::locallocaltime($timeshifted)).
+ '
');
+ } else {
+ $r->print(''.
+ &mt("Shift dates set just for your section, such that [_1] becomes [_2]",
+ &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+ &Apache::lonlocal::locallocaltime($timeshifted)).
+ '
');
+ }
+ } else {
+ $r->print(''.&mt('Shifting all dates such that [_1] becomes [_2]',
+ &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+ &Apache::lonlocal::locallocaltime($timeshifted)).
+ '
');
+ }
my $delta=$timeshifted-$env{'form.timebase'};
- &dateshift($delta);
- &endSettingsScreen($r);
+ my $numchanges = 0;
+ my $result = &dateshift($delta,\$numchanges);
+ if ($result eq 'ok') {
+ $r->print(
+ &Apache::lonhtmlcommon::confirm_success(&mt('Completed shifting of [quant,_1,date setting]',
+ $numchanges)));
+ } elsif ($result eq 'con_delayed') {
+ $r->print(
+ &Apache::lonhtmlcommon::confirm_success(&mt('Queued shifting of [quant,_1,date setting]',
+ $numchanges)));
+ } else {
+ $r->print(
+ &Apache::lonhtmlcommon::confirm_success(&mt('An error occurred attempting to shift dates'),1));
+ }
+ $r->print(
+ ' '.
+ &Apache::lonhtmlcommon::actionbox(
+ [''.&mt('Content and Problem Settings').' ']));
$r->print(&Apache::loncommon::end_page());
}
@@ -3610,8 +5074,7 @@ sub parse_key {
$data{'scope_type'} = 'user';
$data{'scope'} = [$1,$2];
} else {
- #FIXME check for group scope
- $data{'scope_type'} = 'section';
+ $data{'scope_type'} = 'secgroup';
}
$middle=~s/^\[(.*)\]//;
}
@@ -3639,7 +5102,7 @@ sub parse_key {
sub header {
- return &Apache::loncommon::start_page('Settings');
+ return &Apache::loncommon::start_page('Content and Problem Settings');
}
@@ -3649,7 +5112,9 @@ sub print_main_menu {
#
$r->print(&header());
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Content and Problem Settings'));
- &startSettingsScreen($r,'parmset');
+ my $crstype = &Apache::loncommon::course_type();
+ my $lc_crstype = lc($crstype);
+
$r->print(<
@@ -3659,29 +5124,74 @@ ENDMAINFORMHEAD
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
-
- my $crstype = &Apache::loncommon::course_type();
- my $lc_crstype = lc($crstype);
-
+ my $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'});
+ my $vcb = &Apache::lonnet::allowed('vcb',$env{'request.course.id'});
+ my $vpa = &Apache::lonnet::allowed('vpa',$env{'request.course.id'});
+ if ((!$dcm) && ($env{'request.course.sec'} ne '')) {
+ $dcm = &Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'});
+ }
+ if ((!$vcb) && ($env{'request.course.sec'} ne '')) {
+ $vcb = &Apache::lonnet::allowed('vcb',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'});
+ }
+ my (%linktext,%linktitle,%url);
+ if ($parm_permission->{'edit'}) {
+ %linktext = (
+ newoverview => 'Edit Resource Parameters - Overview Mode',
+ settable => 'Edit Resource Parameters - Table Mode',
+ setoverview => 'Modify Resource Parameters - Overview Mode',
+ );
+ %linktitle = (
+ newoverview => 'Set/Modify resource parameters in overview mode.',
+ settable => 'Set/Modify resource parameters in table mode.',
+ setoverview => 'Set/Modify existing resource parameters in overview mode.',
+ );
+ } else {
+ %linktext = (
+ newoverview => 'View Resource Parameters - Overview Mode',
+ settable => 'View Resource Parameters - Table Mode',
+ setoverview => 'View Resource Parameters - Overview Mode',
+ );
+ %linktitle = (
+ newoverview => 'Display resource parameters in overview mode.',
+ settable => 'Display resource parameters in table mode.',
+ setoverview => 'Display existing resource parameters in overview mode.',
+ );
+ }
+ if ($mgr) {
+ $linktext{'resettimes'} = 'Reset Student Access Times';
+ $linktitle{'resettimes'} = "Reset access times for folders/maps, resources or the $lc_crstype.";
+ $url{'resettimes'} = '/adm/helper/resettimes.helper';
+ } elsif ($vgr) {
+ $linktext{'resettimes'} = 'Display Student Access Times',
+ $linktitle{'resettimes'} = "Display access times for folders/maps, resources or the $lc_crstype.",
+ $url{'resettimes'} = '/adm/accesstimes';
+ }
my @menu =
( { categorytitle=>"Content Settings for this $crstype",
items => [
{ linktext => 'Portfolio Metadata',
url => '/adm/parmset?action=setrestrictmeta',
- permission => $parm_permission,
+ permission => $parm_permission->{'setrestrictmeta'},
linktitle => "Restrict metadata for this $lc_crstype." ,
icon =>'contact-new.png' ,
},
- { linktext => 'Reset Student Access Times',
- url => '/adm/helper/resettimes.helper',
- permission => $mgr,
- linktitle => "Reset access times for folders/maps, resources or the $lc_crstype." ,
- icon => 'start-here.png' ,
+ { linktext => $linktext{'resettimes'},
+ url => $url{'resettimes'},
+ permission => ($vgr || $mgr),
+ linktitle => $linktitle{'resettimes'},
+ icon => 'start-here.png',
+ },
+ { linktext => 'Blocking Communication/Resource Access',
+ url => '/adm/setblock',
+ permission => ($vcb || $dcm),
+ linktitle => 'Configure blocking of communication/collaboration and access to resources during an exam',
+ icon => 'comblock.png',
},
-
{ linktext => 'Set Parameter Setting Default Actions',
url => '/adm/parmset?action=setdefaults',
- permission => $parm_permission,
+ permission => $parm_permission->{'setdefaults'},
linktitle =>'Set default actions for parameters.' ,
icon => 'folder-new.png' ,
}]},
@@ -3689,43 +5199,43 @@ ENDMAINFORMHEAD
items => [
{ linktext => 'Edit Resource Parameters - Helper Mode',
url => '/adm/helper/parameter.helper',
- permission => $parm_permission,
+ permission => $parm_permission->{'helper'},
linktitle =>'Set/Modify resource parameters in helper mode.' ,
icon => 'dialog-information.png' ,
#help => 'Parameter_Helper',
},
- { linktext => 'Edit Resource Parameters - Overview Mode',
+ { linktext => $linktext{'newoverview'},
url => '/adm/parmset?action=newoverview',
- permission => $parm_permission,
- linktitle =>'Set/Modify resource parameters in overview mode.' ,
- icon => 'edit-find.png' ,
+ permission => $parm_permission->{'newoverview'},
+ linktitle => $linktitle{'newoverview'},
+ icon => 'edit-find.png',
#help => 'Parameter_Overview',
},
- { linktext => 'Edit Resource Parameters - Table Mode',
+ { linktext => $linktext{'settable'},
url => '/adm/parmset?action=settable',
- permission => $parm_permission,
- linktitle =>'Set/Modify resource parameters in table mode.' ,
- icon => 'edit-copy.png' ,
+ permission => $parm_permission->{'settable'},
+ linktitle => $linktitle{'settable'},
+ icon => 'edit-copy.png',
#help => 'Table_Mode',
}]},
{ categorytitle => 'Existing Parameter Settings for Resources',
items => [
- { linktext => 'Modify Resource Parameters - Overview Mode',
+ { linktext => $linktext{'setoverview'},
url => '/adm/parmset?action=setoverview',
- permission => $parm_permission,
- linktitle =>'Set/Modify existing resource parameters in overview mode.' ,
- icon => 'preferences-desktop-wallpaper.png' ,
+ permission => $parm_permission->{'setoverview'},
+ linktitle => $linktitle{'setoverview'},
+ icon => 'preferences-desktop-wallpaper.png',
#help => 'Parameter_Overview',
},
{ linktext => 'Change Log',
url => '/adm/parmset?action=parameterchangelog',
- permission => $parm_permission,
+ permission => $parm_permission->{'parameterchangelog'},
linktitle =>"View parameter and $lc_crstype blog posting/user notification change log." ,
icon => 'document-properties.png',
}]}
);
$r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
- &endSettingsScreen($r);
+ $r->print(''.&Apache::loncommon::end_page());
return;
}
@@ -3801,7 +5311,6 @@ sub order_meta_fields {
text=>"Restrict Metadata"},
{text=>"Order Metadata"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
- &startSettingsScreen($r,'parmset');
if ($env{'form.storeorder'}) {
my $newpos = $env{'form.newpos'} - 1;
my $currentpos = $env{'form.currentpos'} - 1;
@@ -3855,7 +5364,7 @@ sub order_meta_fields {
foreach my $key (@fields_in_order) {
$r->print('');
$r->print('
-
+
-
+
ENDButtons
my $added_flag = 1;
foreach my $field (sort(keys(%$added_metadata_fields))) {
- $row_alt = $row_alt ? 0 : 1;
- $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt);
+ $output.= &output_row($r,$field,$$added_metadata_fields{$field},$added_flag);
}
$output .= &Apache::loncommon::end_data_table();
$r->print(<
ENDenv
- &endSettingsScreen($r);
$r->print(&Apache::loncommon::end_page());
return 'ok';
}
@@ -4066,7 +5583,6 @@ sub defaultsetter {
&Apache::loncommon::start_page('Parameter Setting Default Actions');
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
$r->print($start_page.$breadcrumbs);
- &startSettingsScreen($r,'parmset');
$r->print('');
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -4213,7 +5729,6 @@ ENDYESNO
$r->print(&Apache::loncommon::end_data_table().
"\n".' '."\n");
- &endSettingsScreen($r);
$r->print(&Apache::loncommon::end_page());
return;
}
@@ -4260,7 +5775,7 @@ my %standard_parms;
my %standard_parms_types;
sub load_parameter_names {
- open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
+ open(my $config,"<","$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
while (my $configline=<$config>) {
if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
chomp($configline);
@@ -4275,6 +5790,7 @@ sub load_parameter_names {
close($config);
$standard_parms{'int_pos'} = 'Positive Integer';
$standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
+ $standard_parms{'scoreformat'} = 'Format for display of score';
}
sub standard_parameter_names {
@@ -4301,19 +5817,25 @@ sub standard_parameter_types {
}
sub parm_change_log {
- my ($r)=@_;
+ my ($r,$parm_permission)=@_;
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
text=>"Parameter Change Log"});
- $r->print(&Apache::loncommon::start_page('Parameter Change Log'));
+ my $js = ''."\n";
+ $r->print(&Apache::loncommon::start_page('Parameter Change Log',$js));
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
- &startSettingsScreen($r,'parmset');
my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'});
if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
- $r->print('print(''.
+ '
'.&mt('Display of Changes').' '.
+ '');
my %saveable_parameters = ('show' => 'scalar',);
@@ -4321,17 +5843,22 @@ sub parm_change_log {
\%saveable_parameters);
&Apache::loncommon::restore_course_settings('parameter_log',
\%saveable_parameters);
- $r->print(&Apache::loncommon::display_filter().
- ''.&Apache::lonhtmlcommon::checkbox('includetypes',$env{'form.includetypes'},'1').
- ' '.&mt('Include parameter types').' '.
- ' ');
-
+ $r->print(&Apache::loncommon::display_filter('parmslog').' '."\n".
+ ' '.
+ ' ');
+ my $readonly = 1;
+ if ($parm_permission->{'edit'}) {
+ undef($readonly);
+ }
my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
$env{'course.'.$env{'request.course.id'}.'.domain'});
$r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
''.&mt('Time').' '.&mt('User').' '.&mt('Extent').' '.&mt('Users').' '.
- &mt('Parameter').' '.&mt('Part').' '.&mt('New Value').' '.&mt('Announce').' '.
- &Apache::loncommon::end_data_table_header_row());
+ &mt('Parameter').''.&mt('Part').' '.&mt('New Value').' ');
+ unless ($readonly) {
+ $r->print(''.&mt('Announce').' ');
+ }
+ $r->print(&Apache::loncommon::end_data_table_header_row());
my $shown=0;
my $folder='';
if ($env{'form.displayfilter'} eq 'currentfolder') {
@@ -4343,6 +5870,12 @@ sub parm_change_log {
}
if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
}
+ my $numgroups = 0;
+ my @groups;
+ if ($env{'request.course.groups'} ne '') {
+ @groups = split(/:/,$env{'request.course.groups'});
+ $numgroups = scalar(@groups);
+ }
foreach my $id (sort
{
if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
@@ -4364,7 +5897,8 @@ sub parm_change_log {
$parmlog{$id}{'exe_uname'},
$parmlog{$id}{'exe_udom'});
my $send_msg_link='';
- if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
+ if ((!$readonly) &&
+ (($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
|| ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
$send_msg_link =' '.
&Apache::loncommon::messagewrapper(&mt('Send message'),
@@ -4381,6 +5915,14 @@ sub parm_change_log {
!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 eq $env{'request.course.sec'}) ||
+ ($numgroups && (grep(/^\Q$issection\E$/,@groups))))));
+ 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; }
@@ -4409,7 +5951,11 @@ sub parm_change_log {
$parmitem = &mt($parmitem);
$output .= &mt('Type: [_1]',$parmitem);
} else {
- my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
+ my $toolsymb;
+ if ($middle =~ /ext\.tool$/) {
+ $toolsymb = $middle;
+ }
+ my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what,$toolsymb),
$uname,$udom,$issection,$issection,$courseopt);
my $showvalue = $value;
if ($istype{$parmname} eq '') {
@@ -4434,27 +5980,31 @@ sub parm_change_log {
}
}
}
- $output .= ' ';
-
- if ($stillactive) {
- my $parmitem = &standard_parameter_names($parmname);
- $parmitem = &mt($parmitem);
- my $title=&mt('Changed [_1]',$parmitem);
- my $description=&mt('Changed [_1] for [_2] to [_3]',
- $parmitem,$realmdescription,
- (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
- if (($uname) && ($udom)) {
- $output .=
- &Apache::loncommon::messagewrapper('Notify User',
- $uname,$udom,$title,
- $description);
- } else {
- $output .=
- &Apache::lonrss::course_blog_link($id,$title,
- $description);
- }
- }
- $output .= ' '.&Apache::loncommon::end_data_table_row();
+ $output .= '';
+
+ unless ($readonly) {
+ $output .= '';
+ if ($stillactive) {
+ my $parmitem = &standard_parameter_names($parmname);
+ $parmitem = &mt($parmitem);
+ my $title=&mt('Changed [_1]',$parmitem);
+ my $description=&mt('Changed [_1] for [_2] to [_3]',
+ $parmitem,$realmdescription,
+ (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
+ if (($uname) && ($udom)) {
+ $output .=
+ &Apache::loncommon::messagewrapper('Notify User',
+ $uname,$udom,$title,
+ $description);
+ } else {
+ $output .=
+ &Apache::lonrss::course_blog_link($id,$title,
+ $description);
+ }
+ }
+ $output .= ' ';
+ }
+ $output .= &Apache::loncommon::end_data_table_row();
}
if ($env{'form.displayfilter'} eq 'containing') {
my $wholeentry=$about_me_link.':'.
@@ -4474,7 +6024,6 @@ sub parm_change_log {
|| $shown<=$env{'form.show'})) { last; }
}
$r->print(&Apache::loncommon::end_data_table());
- &endSettingsScreen($r);
$r->print(&Apache::loncommon::end_page());
}
@@ -4522,10 +6071,10 @@ sub update_slots {
action => 'reserve',
context => 'parameter',
);
- &Apache::lonnet::instructor_log('slotreservationslog',\%storehash,
+ &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
'',$uname,$udom,$cnum,$cdom);
- &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash,
+ &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
'',$uname,$udom,$uname,$udom);
}
return $success;
@@ -4556,9 +6105,9 @@ sub delete_slots {
action => 'release',
context => 'parameter',
);
- &Apache::lonnet::instructor_log('slotreservationslog',\%storehash,
+ &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
1,$uname,$udom,$cnum,$cdom);
- &Apache::lonnet::instructor_log($cdom.'_'.$cnum.'_slotlog',\%storehash,
+ &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
1,$uname,$udom,$uname,$udom);
}
}
@@ -4572,7 +6121,7 @@ sub check_for_course_info {
return 0;
}
-sub questiontype_release_vars {
+sub parameter_release_vars {
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
my $chostname = &Apache::lonnet::hostname($chome);
@@ -4581,39 +6130,57 @@ sub questiontype_release_vars {
return ($chostname,$cmajor,$cminor);
}
-sub questiontype_releasecheck {
- my ($questiontype,$needsrelease,$chostname,$cmajor,$cminor) = @_;
+sub parameter_releasecheck {
+ my ($name,$value,$needsrelease,$cmajor,$cminor) = @_;
my $needsnewer;
my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
if (($cmajor < $needsmajor) ||
($cmajor == $needsmajor && $cminor < $needsminor)) {
$needsnewer = 1;
} else {
- &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:type:'.$questiontype});
+ &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.':'.$value});
}
return $needsnewer;
}
-sub oldversion_warning {
- my ($questiontype,$chostname,$cmajor,$cminor,$needsrelease) = @_;
- my $desc;
- if (ref($strings{'string_questiontype'}) eq 'ARRAY') {
- foreach my $possibilities (@{ $strings{'string_questiontype'} }) {
- next unless (ref($possibilities) eq 'ARRAY');
- my ($name, $description) = @{ $possibilities };
- if ($name eq $questiontype) {
- $desc = $description;
- last;
- }
- }
+sub get_permission {
+ my %permission;
+ my $allowed = 0;
+ return (\%permission,$allowed) unless ($env{'request.course.id'});
+ if ((&Apache::lonnet::allowed('opa',$env{'request.course.id'})) ||
+ (&Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
+ $env{'request.course.sec'}))) {
+ %permission= (
+ 'edit' => 1,
+ 'set' => 1,
+ 'setoverview' => 1,
+ 'addmetadata' => 1,
+ 'ordermetadata' => 1,
+ 'setrestrictmeta' => 1,
+ 'newoverview' => 1,
+ 'setdefaults' => 1,
+ 'settable' => 1,
+ 'parameterchangelog' => 1,
+ 'cleanparameters' => 1,
+ 'dateshift1' => 1,
+ 'dateshift2' => 1,
+ 'helper' => 1,
+ );
+ } elsif ((&Apache::lonnet::allowed('vpa',$env{'request.course.id'})) ||
+ (&Apache::lonnet::allowed('vpa',$env{'request.course.id'}.'/'.
+ $env{'request.course.sec'}))) {
+ %permission = (
+ 'set' => 1,
+ 'settable' => 1,
+ 'newoverview' => 1,
+ 'setoverview' => 1,
+ 'parameterchangelog' => 1,
+ );
}
- return ''.
- &mt('Question Type was [_1]not[_2] set to [_3].',
- '',' ','"'.$desc.'"').' '.
- &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
- $cmajor.'.'.$cminor,$chostname,
- $needsrelease).
- '
';
+ foreach my $perm (values(%permission)) {
+ if ($perm) { $allowed=1; last; }
+ }
+ return (\%permission,$allowed);
}
sub handler {
@@ -4643,41 +6210,41 @@ sub handler {
'Parameter_Manager,Course_Environment,Parameter_Helper,Parameter_Overview,Table_Mode'});
# ----------------------------------------------------- Needs to be in a course
- my $parm_permission =
- (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
- &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
- $env{'request.course.sec'}));
+ my ($parm_permission,$allowed) = &get_permission();
my $exists = &check_for_course_info();
- if ($env{'request.course.id'} && $parm_permission && $exists) {
+ if ($env{'request.course.id'} && $allowed && $exists) {
#
# Main switch on form.action and form.state, as appropriate
#
# Check first if coming from someone else headed directly for
# the table mode
- if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
- && (!$env{'form.dis'})) || ($env{'form.symb'})) {
- &assessparms($r);
+ if (($parm_permission->{'set'}) &&
+ ((($env{'form.command'} eq 'set') && ($env{'form.url'})
+ && (!$env{'form.dis'})) || ($env{'form.symb'}))) {
+ &assessparms($r,$parm_permission);
} elsif (! exists($env{'form.action'})) {
&print_main_menu($r,$parm_permission);
+ } elsif (!$parm_permission->{$env{'form.action'}}) {
+ &print_main_menu($r,$parm_permission);
} elsif ($env{'form.action'} eq 'setoverview') {
- &overview($r);
- } elsif ($env{'form.action'} eq 'addmetadata') {
- &addmetafield($r);
- } elsif ($env{'form.action'} eq 'ordermetadata') {
- &order_meta_fields($r);
+ &overview($r,$parm_permission);
+ } 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,$parm_permission);
} 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,$parm_permission);
} elsif ($env{'form.action'} eq 'parameterchangelog') {
- &parm_change_log($r);
+ &parm_change_log($r,$parm_permission);
} 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') {