--- loncom/interface/lonparmset.pm 2016/07/15 18:03:52 1.561
+++ loncom/interface/lonparmset.pm 2017/07/10 13:55:36 1.576
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.561 2016/07/15 18:03:52 damieng Exp $
+# $Id: lonparmset.pm,v 1.576 2017/07/10 13:55:36 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -367,14 +367,14 @@ sub endSettingsScreen {
##################################################
-# TABLE MODE
+# (mostly) TABLE MODE
# (parmval is also used for the log of parameter changes)
##################################################
-# Calls parmval_by_symb, getting the symb from $id (the big hash resource id) with &symbcache.
+# Calls parmval_by_symb, getting the symb from $id with &symbcache.
#
# @param {string} $what - part info and parameter name separated by a dot, e.g. '0.weight'
-# @param {string} $id - big hash resource id
+# @param {string} $id - resource id or map pc
# @param {string} $def - the resource's default value for this parameter
# @param {string} $uname - user name
# @param {string} $udom - user domain
@@ -394,7 +394,7 @@ sub parmval {
# (level 1 is the most specific and will have precedence)
#
# @param {string} $what - part info and parameter name separated by a dot, e.g. '0.weight'
-# @param {string} $symb - resource symb
+# @param {string} $symb - resource symb or map src
# @param {string} $def - the resource's default value for this parameter
# @param {string} $uname - user name
# @param {string} $udom - user domain
@@ -597,7 +597,7 @@ sub reset_caches {
}
}
-# cache big hash id -> symb, using lonnavmaps to find association
+# cache resource id or map pc -> resource symb or map src, using lonnavmaps to find association
{
my $symbsid; # course identifier, to initialize the cache only once for a course
my %symbs; # hash id->symb
@@ -607,7 +607,8 @@ sub reset_caches {
undef(%symbs);
}
- # returns the symb corresponding to a big hash id (using lonnavmaps and a cache)
+ # returns the resource symb or map src corresponding to a resource id or map pc
+ # (using lonnavmaps and a cache)
sub symbcache {
my $id=shift;
if ($symbsid ne $env{'request.course.id'}) {
@@ -718,8 +719,8 @@ sub date_sanity_info {
# Store a parameter value and type by ID, also triggering more parameter changes based on parameter default actions.
#
-# @param {string} $sresid - resource big hash id
-# @param {string} $spnam - part info and parameter name separated by a dot, e.g. '0.weight'
+# @param {string} $sresid - resource id or map pc
+# @param {string} $spnam - part info and parameter name separated by a dot or underscore, e.g. '0.weight'
# @param {integer} $snum - level
# @param {string} $nval - new value
# @param {string} $ntype - new type
@@ -737,8 +738,8 @@ my %recstack; # hash parameter name -> 1
# Store a parameter value and type by symb, also triggering more parameter changes based on parameter default actions.
# Uses storeparm_by_symb_inner to actually store the parameter, ignoring any returned error.
#
-# @param {string} $symb - resource symb
-# @param {string} $spnam - part info and parameter name separated by a dot, e.g. '0.weight'
+# @param {string} $symb - resource symb or map src
+# @param {string} $spnam - part info and parameter name separated by a dot or underscore, e.g. '0.weight'
# @param {integer} $snum - level
# @param {string} $nval - new value
# @param {string} $ntype - new type
@@ -776,8 +777,7 @@ sub storeparm_by_symb {
# are there restrictions?
if (&rulescache($triggered.'_triggervalue')=~/\w/) {
$active=0;
- foreach my $possiblevalue (split(/\s*\,
- \s*/,&rulescache($triggered.'_triggervalue'))) {
+ foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) {
if (lc($possiblevalue) eq lc($nval)) { $active=1; }
}
}
@@ -808,7 +808,7 @@ sub log_parmset {
# Store a parameter value and type by symb, without using the parameter default actions.
# Expire related sheets.
#
-# @param {string} $symb - resource symb
+# @param {string} $symb - resource symb or map src
# @param {string} $spnam - part info and parameter name separated by a dot, e.g. '0.weight'
# @param {integer} $snum - level
# @param {string} $nval - new value
@@ -1065,16 +1065,16 @@ sub page_js {
document.parmform.action+='#'+document.parmform.pres_marker.value;
var typedef=new Array();
typedef=document.parmform.pres_type.value.split('_');
- if (document.parmform.pres_type.value!='') {
- if (typedef[0]=='date') {
- eval('document.parmform.recent_'+
- document.parmform.pres_type.value+
- '.value=document.parmform.pres_value.value;');
- } else {
- eval('document.parmform.recent_'+typedef[0]+
- '.value=document.parmform.pres_value.value;');
+ if (document.parmform.pres_type.value!='') {
+ if (typedef[0]=='date') {
+ eval('document.parmform.recent_'+
+ document.parmform.pres_type.value+
+ '.value=document.parmform.pres_value.value;');
+ } else {
+ eval('document.parmform.recent_'+typedef[0]+
+ '.value=document.parmform.pres_value.value;');
+ }
}
- }
document.parmform.submit();
} else {
document.parmform.pres_value.value='';
@@ -1365,7 +1365,7 @@ ENDHEAD
# @param {string} $which - parameter key ('parameter_'.part.'_'.name)
# @param {hash reference} $part - parameter key -> parameter part (can be problem part.'_'.response id for response parameters)
# @param {hash reference} $name - parameter key -> parameter name
-# @param {hash reference} $symbp - resource id -> symb
+# @param {hash reference} $symbp - map pc or resource/map id -> map src.'___(all)' or resource symb
# @param {string} $rid - resource id
# @param {hash reference} $default - parameter key -> resource parameter default value
# @param {hash reference} $defaulttype - parameter key -> resource parameter default type
@@ -1380,9 +1380,11 @@ ENDHEAD
# @param {string} $cgroup - group name
# @param {array reference} $usersgroups - list of groups the user belongs to, if any
# @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters
+# @param {boolean} $readonly - true if no editing allowed.
sub print_row {
my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
- $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp)=@_;
+ $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);
@@ -1427,27 +1429,27 @@ sub print_row {
if ($parmlev eq 'general') {
if ($uname) {
- &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
} elsif ($cgroup) {
- &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
+ &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
} elsif ($csec) {
- &print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
} else {
- &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
}
} elsif ($parmlev eq 'map') {
if ($uname) {
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
} elsif ($cgroup) {
- &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
- &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
+ &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
+ &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
} elsif ($csec) {
- &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
} else {
- &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
}
} else {
if ($uname) {
@@ -1467,35 +1469,35 @@ sub print_row {
}
}
- &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,15,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,14,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,15,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,14,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
if ($csec) {
- &print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
}
if ($cgroup) {
- &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
- &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
- &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
- &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp);
+ &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
+ &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
+ &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
+ &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp.$readonly);
}
if ($uname) {
if ($othergrp) {
$r->print($othergrp);
}
- &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
- &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display);
+ &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
+ &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
}
} # end of $parmlev if/else
@@ -1532,26 +1534,35 @@ sub print_row {
# @param {array reference} $typeoutpar - array level -> parameter type (when defined)
# @param {hash reference} $display - parameter key -> full title for the parameter
# @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters
+# @param {boolean} $readonly -true if editing not allowed.
sub print_td {
- my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp)=@_;
+ my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly)=@_;
$r->print('
');
my $nolink = 0;
- if ($which == 14 || $which == 15) {
- $nolink = 1;
- } elsif (($env{'request.course.sec'} ne '') && ($which > 12)) {
+ if ($readonly) {
$nolink = 1;
- } elsif ($which == 5 || $which == 6 || $which == 7 || $which == 8) {
- if ($noeditgrp) {
+ } else {
+ if ($which == 14 || $which == 15 || $mprefix =~ /mapalias\&/) {
$nolink = 1;
- }
- } elsif ($mprefix =~ /availablestudent\&$/) {
- if ($which > 4) {
- $nolink = 1;
- }
- } elsif ($mprefix =~ /examcode\&$/) {
- unless ($which == 2) {
+ } elsif (($env{'request.course.sec'} ne '') && ($which > 12)) {
$nolink = 1;
+ } elsif ($which == 5 || $which == 6 || $which == 7 || $which == 8) {
+ if ($noeditgrp) {
+ $nolink = 1;
+ }
+ } elsif ($mprefix =~ /availablestudent\&$/) {
+ if ($which > 4) {
+ $nolink = 1;
+ }
+ } elsif ($mprefix =~ /examcode\&$/) {
+ unless ($which == 2) {
+ $nolink = 1;
+ }
+ } elsif ($mprefix =~ /(encrypturl|hiddenresource)/) {
+ if ($which == 16 || $which == 10 || $which == 6 || $which == 2) {
+ $nolink = 1;
+ }
}
}
if ($nolink) {
@@ -1648,7 +1659,21 @@ sub parm_control_group {
-# extracts lots of information about all of the the course's resources into a variety of hashes.
+# Extracts lots of information about all of the the course's resources into a variety of hashes, using lonnavmaps and lonnet::metadata.
+# All the parameters are references and are filled by the sub.
+#
+# @param {array reference} $ids - resource and map ids
+# @param {hash reference} $typep - hash resource/map id -> resource type (file extension)
+# @param {hash reference} $keyp - hash resource/map id -> comma-separated list of parameter keys from lonnet::metadata
+# @param {hash reference} $allparms - hash parameter name -> parameter title
+# @param {hash reference} $allparts - hash parameter part -> part title (a parameter part can be problem part.'_'.response id for response parameters)
+# @param {hash reference} $allmaps - hash map pc -> map src
+# @param {hash reference} $mapp - hash map pc or resource/map id -> enclosing map src
+# @param {hash reference} $symbp - hash map pc or resource/map id -> map src.'___(all)' for a map or resource symb for a resource
+# @param {hash reference} $maptitles - hash map pc or src -> map title (this should really be two separate hashes)
+# @param {hash reference} $uris - hash resource/map id -> resource src
+# @param {hash reference} $keyorder - hash parameter key -> appearance rank for this parameter when looking through every resource and every parameter, starting at 100 (integer)
+# @param {hash reference} $defkeytype - hash parameter name -> parameter type
sub extractResourceInformation {
my $ids = shift;
my $typep = shift;
@@ -1749,17 +1774,22 @@ sub extractResourceInformation {
}
-
+# Tells if a parameter type is a date.
+#
+# @param {string} type - parameter type
+# @returns{boolean} - true if it is a date
sub isdateparm {
my $type=shift;
return (($type=~/^date/) && (!($type eq 'date_interval')));
}
+# Prints the HTML and Javascript to select parameters, with various shortcuts.
+# FIXME: remove unused parameters
#
-# 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.
-#
+# @param {Apache2::RequestRec} $r - the Apache request (unused)
+# @param {hash reference} $allparms - hash parameter name -> parameter title
+# @param {array reference} $pscat - list of selected parameter names (unused)
+# @param {hash reference} $keyorder - hash parameter key -> appearance rank (unused)
sub parmmenu {
my ($r,$allparms,$pscat,$keyorder)=@_;
my $tempkey;
@@ -1775,7 +1805,7 @@ sub parmmenu {
displayOverview = "none"
}
- for (i=0; i
@@ -1844,7 +1872,10 @@ ENDSCRIPT
&shortCuts($r,$allparms,$pscat,$keyorder);
$r->print('');
}
-# return a hash
+
+# Returns parameter categories.
+#
+# @returns {hash} - category name -> title in English
sub categories {
return ('time_settings' => 'Time Settings',
'grading' => 'Grading',
@@ -1858,7 +1889,9 @@ sub categories {
'misc' => 'Miscellaneous' );
}
-# return a hash. Like a look-up table
+# Returns the category for each parameter.
+#
+# @returns {hash} - parameter name -> category name
sub lookUpTableParameter {
return (
@@ -1906,9 +1939,13 @@ sub lookUpTableParameter {
'retrypartial' => 'tries',
'discussvote' => 'misc',
'examcode' => 'high_level_randomization',
- );
+ );
}
+# Adds the given parameter name to an array of arrays listing all parameters for each category.
+#
+# @param {string} $name - parameter name
+# @param {array reference} $catList - array reference category name -> array reference of parameter names
sub whatIsMyCategory {
my $name = shift;
my $catList = shift;
@@ -1932,6 +1969,11 @@ sub whatIsMyCategory {
}
}
+# Sorts parameter names based on appearance order.
+#
+# @param {array reference} name - array reference of parameter names
+# @param {hash reference} $keyorder - hash parameter key -> appearance rank
+# @returns {Array} - array of parameter names
sub keysindisplayorderCategory {
my ($name,$keyorder)=@_;
return sort {
@@ -1939,6 +1981,9 @@ sub keysindisplayorderCategory {
} ( @{$name});
}
+# Returns a hash category name -> order, starting at 1 (integer)
+#
+# @returns {hash}
sub category_order {
return (
'time_settings' => 1,
@@ -1955,6 +2000,12 @@ sub category_order {
}
+# Prints HTML to let the user select parameters, from a list of all parameters organized by category.
+#
+# @param {Apache2::RequestRec} $r - the Apache request
+# @param {hash reference} $allparms - hash parameter name -> parameter title
+# @param {array reference} $pscat - list of selected parameter names
+# @param {hash reference} $keyorder - hash parameter key -> appearance rank
sub parmboxes {
my ($r,$allparms,$pscat,$keyorder)=@_;
my %categories = &categories();
@@ -1982,6 +2033,7 @@ sub parmboxes {
$r->print('
'
.'
'.&mt($categories{$key}).'
'."\n");
foreach my $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) {
+ next if ($tempkey eq '');
$r->print(''
.'
'.&Apache::loncommon::end_data_table_row());
+ $r->print('');
+ if ($is_map) {
+ if (($name eq 'encrypturl') || ($name eq 'hiddenresource')) {
+ $r->print('
');
+ }
+ }
+ $r->print(&Apache::loncommon::end_data_table_row());
}
}
return $foundkeys;
}
+# Returns a string representing the interval, directly using form data matching the given key.
+# The returned string may also include information related to proctored exams.
+# Format: seconds['_done'[':'done button title':']['_proctor'['_'proctor key]]]
+#
+# @param {string} $key - suffix for form fields related to the interval
+# @returns {string}
sub get_date_interval_from_form {
my ($key) = @_;
my $seconds = 0;
@@ -3879,6 +4321,12 @@ sub get_date_interval_from_form {
}
+# Returns HTML to enter a text value for a parameter.
+#
+# @param {string} $thiskey - parameter key
+# @param {string} $showval - the current value
+# @param {boolean} $readonly - true if the field should not be made editable
+# @returns {string}
sub default_selector {
my ($thiskey, $showval, $readonly) = @_;
my $disabled;
@@ -3888,6 +4336,12 @@ sub default_selector {
return '';
}
+# Returns HTML to enter allow/deny rules related to IP addresses.
+#
+# @param {string} $thiskey - parameter key
+# @param {string} $showval - the current value
+# @param {boolean} $readonly - true if the fields should not be made editable
+# @returns {string}
sub string_ip_selector {
my ($thiskey, $showval, $readonly) = @_;
my %access = (
@@ -3916,7 +4370,7 @@ sub string_ip_selector {
@{$access{'deny'}} = ('');
}
my ($disabled,$addmore);
- if ($disabled) {
+ if ($readonly) {
$disabled=' disabled="disabled"';
} else {
$addmore = "\n".'';
@@ -4001,6 +4455,11 @@ my %stringtypes = (
acc => 'string_ip',
);
+# Returns the possible values and titles for a given string type, or undef if there are none.
+# Used by courseprefs.
+#
+# @param {string} $string_type - a parameter type for strings
+# @returns {array reference} - 2D array, containing values and English titles
sub standard_string_options {
my ($string_type) = @_;
if (ref($strings{$string_type}) eq 'ARRAY') {
@@ -4009,6 +4468,10 @@ sub standard_string_options {
return;
}
+# Returns regular expressions to match kinds of string types, or undef if there are none.
+#
+# @param {string} $string_type - a parameter type for strings
+# @returns {array reference} - 2D array, containing regular expression names and regular expressions
sub standard_string_matches {
my ($string_type) = @_;
if (ref($stringmatches{$string_type}) eq 'ARRAY') {
@@ -4017,6 +4480,10 @@ sub standard_string_matches {
return;
}
+# Returns a parameter type for a given parameter with a string type, or undef if not known.
+#
+# @param {string} $name - parameter name
+# @returns {string}
sub get_stringtype {
my ($name) = @_;
if (exists($stringtypes{$name})) {
@@ -4025,6 +4492,14 @@ sub get_stringtype {
return;
}
+# Returns HTML to edit a string parameter.
+#
+# @param {string} $thistype - parameter type
+# @param {string} $thiskey - parameter key
+# @param {string} $showval - parameter current value
+# @param {string} $name - parameter name
+# @param {boolean} $readonly - true if the values should not be made editable
+# @returns {string}
sub string_selector {
my ($thistype, $thiskey, $showval, $name, $readonly) = @_;
@@ -4190,6 +4665,10 @@ my %intervaltypes = (
interval => 'date_interval',
);
+# Returns regular expressions to match kinds of interval type, or undef if there are none.
+#
+# @param {string} $interval_type - a parameter type for intervals
+# @returns {array reference} - 2D array, containing regular expression names and regular expressions
sub standard_interval_matches {
my ($interval_type) = @_;
if (ref($intervalmatches{$interval_type}) eq 'ARRAY') {
@@ -4198,6 +4677,10 @@ sub standard_interval_matches {
return;
}
+# Returns a parameter type for a given parameter with an interval type, or undef if not known.
+#
+# @param {string} $name - parameter name
+# @returns {string}
sub get_intervaltype {
my ($name) = @_;
if (exists($intervaltypes{$name})) {
@@ -4206,6 +4689,11 @@ sub get_intervaltype {
return;
}
+# Returns the possible values and titles for a given interval type, or undef if there are none.
+# Used by courseprefs.
+#
+# @param {string} $interval_type - a parameter type for intervals
+# @returns {array reference} - 2D array, containing values and English titles
sub standard_interval_options {
my ($interval_type) = @_;
if (ref($intervals{$interval_type}) eq 'ARRAY') {
@@ -4214,6 +4702,13 @@ sub standard_interval_options {
return;
}
+# Returns HTML to edit a date interval parameter.
+#
+# @param {string} $thiskey - parameter key
+# @param {string} $name - parameter name
+# @param {string} $showval - parameter current value
+# @param {boolean} $readonly - true if the values should not be made editable
+# @returns {string}
sub date_interval_selector {
my ($thiskey, $name, $showval, $readonly) = @_;
my ($result,%skipval);
@@ -4296,17 +4791,21 @@ sub date_interval_selector {
$currprocdisplay = 'text';
}
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').''.
'&').'" /> '.
+ 'name="done_'.$thiskey.'_proctorkey" value="'.&HTML::Entities::encode($currproctorkey,'"<>&').'"'.$disabled.' /> '.
''.&mt('Button text').': '.
- '&').'" />';
+ '&').'"'.$disabled.' />';
}
}
unless ($readonly) {
@@ -4315,6 +4814,16 @@ sub date_interval_selector {
return $result;
}
+# Returns HTML with a warning if a parameter requires a more recent version of LON-CAPA.
+#
+# @param {string} $name - parameter name
+# @param {string} $namematch - parameter level name (recognized: resourcelevel|maplevel|maplevelrecurse|courselevel)
+# @param {string} $value - parameter value
+# @param {string} $chostname - course server name
+# @param {integer} $cmajor - major version number
+# @param {integer} $cminor - minor version number
+# @param {string} $needsrelease - release version needed (major.minor)
+# @returns {string}
sub oldversion_warning {
my ($name,$namematch,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_;
my $standard_name = &standard_parameter_names($name);
@@ -4390,10 +4899,11 @@ sub oldversion_warning {
} # end of block using some constants related to parameter types
-#
-# Shift all start and end dates by $shift
-#
+# Shifts all start and end dates in the current course by $shift.
+#
+# @param {integer} $shift - time to shift, in seconds
+# @returns {string} - error name or 'ok'
sub dateshift {
my ($shift)=@_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -4425,12 +4935,19 @@ sub dateshift {
return $reply;
}
+# Overview mode UI to edit course parameters.
+#
+# @param {Apache2::RequestRec} $r - the Apache request
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 $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
+ my $readonly = 1;
+ if ($parm_permission->{'edit'}) {
+ undef($readonly);
+ }
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
text=>"Overview Mode"});
@@ -4533,7 +5050,7 @@ ENDOVER
$r->print('
');
$r->print('
');
- &displaymenu($r,\%allparms,\@pscat,\%keyorder);
+ &displaymenu($r,\%allparms,\@pscat,\%keyorder); # FIXME: wrong parameters, could make keysindisplayorderCategory crash because $keyorder is undefined
$r->print(&Apache::lonhtmlcommon::start_pick_box());
$r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
my $sectionselector = §ionmenu(\@selected_sections);
@@ -4589,15 +5106,31 @@ ENDOVER
# List data
- &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview');
+ &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly);
}
- $r->print(&tableend().
- ((($env{'form.store'}) || ($env{'form.dis'}))?'':'').
- '');
+ $r->print(&tableend());
+ unless ($readonly) {
+ $r->print( ((($env{'form.store'}) || ($env{'form.dis'}))?'':'') );
+ }
+ $r->print('');
&endSettingsScreen($r);
$r->print(&Apache::loncommon::end_page());
}
+# Fills $listdata with parameter information.
+# Keys use the format course id.[section id].part.name and course id.[section id].part.name.type.
+# The non-type value is always 1.
+#
+# @param {string} $cat - parameter name
+# @param {string} $pschp - selected map pc, or 'all'
+# @param {string} $parmlev - selected level value (full|map|general), or ''
+# @param {hash reference} $listdata - the parameter data that will be modified
+# @param {array reference} $psprt - selected parts
+# @param {array reference} $selections - selected sections
+# @param {hash reference} $defkeytype - hash parameter name -> parameter type
+# @param {hash reference} $allmaps - hash map pc -> map src
+# @param {array reference} $ids - resource and map ids
+# @param {hash reference} $symbp - hash map pc or resource/map id -> map src.'___(all)' or resource symb
sub secgroup_lister {
my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
foreach my $item (@{$selections}) {
@@ -4618,9 +5151,6 @@ sub secgroup_lister {
my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
$$listdata{$newparmkey}=1;
$$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
- $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(rec).'.$part.'.'.$cat;
- $$listdata{$newparmkey}=1;
- $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
}
} else {
# resource-level parameter
@@ -4636,12 +5166,19 @@ sub secgroup_lister {
}
}
-# Display all existing parameter settings.
+# UI to edit parameter settings starting with a list of all existing parameters.
+# (called by setoverview action)
+#
+# @param {Apache2::RequestRec} $r - the Apache request
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 $readonly = 1;
+ if ($parm_permission->{'edit'}) {
+ undef($readonly);
+ }
my $js = '