--- loncom/interface/lonparmset.pm 2007/07/20 00:15:06 1.372
+++ loncom/interface/lonparmset.pm 2020/02/10 02:11:46 1.594
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.372 2007/07/20 00:15:06 raeburn Exp $
+# $Id: lonparmset.pm,v 1.594 2020/02/10 02:11:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,7 +36,12 @@ 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.
+
+It contains all the code for the "Content and Problem Settings" UI, except
+for the helpers parameter.helper and resettimes.helper, and lonhelper.pm,
+and lonblockingmenu.pm.
=head1 DESCRIPTION
@@ -44,8 +49,266 @@ This module sets coursewide and assessme
=head1 INTERNAL SUBROUTINES
+=over
+
+=item parmval()
+
+Figure out a cascading parameter.
+
+Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
+ $id - a bighash Id number
+ $def - the resource's default value 'stupid emacs
+
+Returns: A list, the first item is the index into the remaining list of items of parm values that is the active one, the list consists of parm values at the 18 possible levels
+
+18 - General Course
+17 - Map or Folder level in course (recursive)
+16 - Map or Folder level in course (non-recursive)
+15 - resource default
+14 - map default
+13 - resource level in course
+12 - General for section
+11 - Map or Folder level for section (recursive)
+10 - Map or Folder level for section (non-recursive)
+9 - resource level in section
+8 - General for group
+7 - Map or Folder level for group (recursive)
+6 - Map or Folder level for group (non-recursive)
+5 - resource level in group
+4 - General for specific student
+3 - Map or Folder level for specific student (recursive)
+2 - Map or Folder level for specific student (non-recursive)
+1 - resource level for specific student
+
+=item parmval_by_symb()
+
+=item reset_caches()
+
+=item cacheparmhash()
+
+=item parmhash()
+
+=item symbcache()
+
+=item preset_defaults()
+
+=item date_sanity_info()
+
+=item storeparm()
+
+Store a parameter by symb
+
+ Takes
+ - symb
+ - name of parameter
+ - level
+ - new value
+ - new type
+ - username
+ - userdomain
+
+=item log_parmset()
+
+=item storeparm_by_symb_inner()
+
+=item valout()
+
+Format a value for output.
+
+Inputs: $value, $type, $editable
+
+Returns: $value, formatted for output. If $type indicates it is a date,
+localtime($value) is returned.
+$editable will return an icon to click on
+
+=item plink()
+
+Produces a link anchor.
+
+Inputs: $type,$dis,$value,$marker,$return,$call
+
+Returns: scalar with html code for a link which will envoke the
+javascript function 'pjump'.
+
+=item page_js()
+
+=item startpage()
+
+=item print_row()
+
+=item print_td()
+
+=item check_other_groups()
+
+=item parm_control_group()
+
+=item extractResourceInformation() :
+
+ extractResourceInformation extracts lots of information about all of the the course's resources into a variety of hashes.
+
+Input: See list below
+
+=over 4
+
+=item * B : Current username
+
+=item * B : Domain of current user.
+
+=item * B : Course
+
+=back
+
+Outputs: See list below:
+
=over 4
+=item * B (out) : An array that will contain all of the ids in the course.
+
+=item * B(out) : hash, id->type, where "type" contains the extension of the file, thus, I.
+
+=item * B (out) : hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id
+
+=item * B (out) : hash, name of parameter->display value (what is the display value?)
+
+=item * B (out) : hash, part identification->text representation of part, where the text representation is "[Part $part]"
+
+=item * B (out) : hash, ???
+
+=item * B : ??
+
+=item * B : hash, id->full sym?
+
+=item * B
+
+=item * B
+
+=item * B
+
+=item * B
+
+=back
+
+=item isdateparm()
+
+=item parmmenu()
+
+=item partmenu()
+
+=item usermenu()
+
+=item displaymenu()
+
+=item mapmenu()
+
+=item levelmenu()
+
+=item sectionmenu()
+
+=item keysplit()
+
+=item keysinorder()
+
+=item keysinorder_bytype()
+
+=item keysindisplayorder()
+
+=item standardkeyorder()
+
+=item assessparms() :
+
+Show assessment data and parameters. This is a large routine that should
+be simplified and shortened... someday.
+
+Inputs: $r - the Apache request object.
+
+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?
+
+=item * B<@catmarker> contains list of all possible parameters including part #s
+
+=item * B<$fullkeyp> contains the full part/id # for the extraction of proper parameters
+
+=item * B<$tempkeyp> contains part 0 only (no ids - ie, subparts)
+ When storing information, store as part 0
+ When requesting information, request from full part
+
+=back
+
+=item tablestart()
+
+=item tableend()
+
+=item extractuser()
+
+=item parse_listdata_key()
+
+=item listdata()
+
+=item date_interval_selector()
+
+=item get_date_interval_from_form()
+
+=item default_selector()
+
+=item string_selector()
+
+=item dateshift()
+
+=item newoverview()
+
+=item secgroup_lister()
+
+=item overview()
+
+=item clean_parameters()
+
+=item date_shift_one()
+
+=item date_shift_two()
+
+=item parse_key()
+
+=item header()
+
+Output html header for page
+
+=item print_main_menu()
+
+=item output_row()
+
+Set portfolio metadata
+
+=item order_meta_fields()
+
+=item addmetafield()
+
+=item setrestrictmeta()
+
+=item get_added_meta_fieldnames()
+
+=item get_deleted_meta_fieldnames()
+
+=item defaultsetter()
+
+=item components()
+
+=item load_parameter_names()
+
+=item parm_change_log()
+
+=item handler() :
+
+Main handler. Calls &assessparms subroutine.
+
+=back
+
=cut
###################################################################
@@ -65,239 +328,360 @@ use Apache::lonlocal;
use Apache::lonnavmaps;
use Apache::longroup;
use Apache::lonrss;
+use HTML::Entities;
use LONCAPA qw(:DEFAULT :match);
-# --- Caches local to lonparmset
-
-my $parmhashid;
-my %parmhash;
-my $symbsid;
-my %symbs;
-my $rulesid;
-my %rules;
-
-# --- end local caches
##################################################
+# CONTENT AND PROBLEM SETTINGS HTML PAGE HEADER/FOOTER
##################################################
-=pod
-
-=item parmval
-
-Figure out a cascading parameter.
+# Page header
+#
+# @param {Apache2::RequestRec} $r - Apache request object
+# @param {string} $mode - selected tab, 'parmset' for course and problem settings, or 'coursepref' for course settings
+# @param {string} $crstype - course type ('Community' for community settings)
+sub startSettingsScreen {
+ my ($r,$mode,$crstype)=@_;
+
+ my $tabtext = &mt('Course Settings');
+ if ($crstype eq 'Community') {
+ $tabtext = &mt('Community Settings');
+ }
+ $r->print("\n".'
');
-Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
- $id - a bighash Id number
- $def - the resource's default value 'stupid emacs
+ $r->print("\n".'
');
+}
-Returns: A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 14 possible levels
+# Page footer
+sub endSettingsScreen {
+ my ($r)=@_;
+ $r->print('
');
+}
-14- General Course
-13- Map or Folder level in course
-12- resource default
-11- map default
-10- resource level in course
-9 - General for section
-8 - Map or Folder level for section
-7 - resource level in section
-6 - General for group
-5 - Map or Folder level for group
-4 - resource level in group
-3 - General for specific student
-2 - Map or Folder level for specific student
-1 - resource level for specific student
-=cut
##################################################
+# (mostly) TABLE MODE
+# (parmval is also used for the log of parameter changes)
+##################################################
+
+# 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 - 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
+# @param {string} $csec - section name
+# @param {string} $cgroup - group name
+# @param {hash reference} $courseopt - course parameters hash (result of lonnet::get_courseresdata, dump of course's resourcedata.db)
+# @returns {Array}
sub parmval {
my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,
$cgroup,$courseopt);
}
+# Returns an array containing
+# - the most specific level that is defined for that parameter (integer)
+# - an array with the level as index and the parameter value as value (when defined)
+# (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 or map src
+# @param {string} $def - the resource's default value for this parameter
+# @param {string} $uname - user name
+# @param {string} $udom - user domain
+# @param {string} $csec - section name
+# @param {string} $cgroup - group name
+# @param {hash reference} $courseopt - course parameters hash (result of lonnet::get_courseresdata, dump of course's resourcedata.db)
+# @returns {Array}
sub parmval_by_symb {
my ($what,$symb,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
-# load caches
- &cacheparmhash();
my $useropt;
if ($uname ne '' && $udom ne '') {
- $useropt = &Apache::lonnet::get_userresdata($uname,$udom);
+ $useropt = &Apache::lonnet::get_userresdata($uname,$udom);
}
my $result='';
my @outpar=();
# ----------------------------------------------------- Cascading lookup scheme
- my $map=(&Apache::lonnet::decode_symb($symb))[0];
+ my $map=(&Apache::lonnet::decode_symb($symb))[0];
$map = &Apache::lonnet::deversion($map);
-
+
+ # NOTE: some of that code looks redondant with code in lonnavmaps::parmval_real,
+ # any change should be reflected there.
+
my $symbparm=$symb.'.'.$what;
+ my $recurseparm=$map.'___(rec).'.$what;
my $mapparm=$map.'___(all).'.$what;
my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$what;
my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
+ my $grpleveli=$env{'request.course.id'}.'.['.$cgroup.'].'.$recurseparm;
my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
+ my $secleveli=$env{'request.course.id'}.'.['.$csec.'].'.$recurseparm;
my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
my $courselevel=$env{'request.course.id'}.'.'.$what;
my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
+ my $courseleveli=$env{'request.course.id'}.'.'.$recurseparm;
my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
# --------------------------------------------------------- first, check course
+# 18 - General Course
if (defined($$courseopt{$courselevel})) {
- $outpar[14]=$$courseopt{$courselevel};
- $result=14;
+ $outpar[18]=$$courseopt{$courselevel};
+ $result=18;
}
+# 17 - Map or Folder level in course (recursive)
+ if (defined($$courseopt{$courseleveli})) {
+ $outpar[17]=$$courseopt{$courseleveli};
+ $result=17;
+ }
+
+# 16 - Map or Folder level in course (non-recursive)
if (defined($$courseopt{$courselevelm})) {
- $outpar[13]=$$courseopt{$courselevelm};
- $result=13;
+ $outpar[16]=$$courseopt{$courselevelm};
+ $result=16;
}
# ------------------------------------------------------- second, check default
- if (defined($def)) { $outpar[12]=$def; $result=12; }
+# 15 - resource default
+ if (defined($def)) { $outpar[15]=$def; $result=15; }
# ------------------------------------------------------ third, check map parms
- my $thisparm=$parmhash{$symbparm};
- if (defined($thisparm)) { $outpar[11]=$thisparm; $result=11; }
+
+# 14 - map default
+ my $thisparm=&parmhash($symbparm);
+ if (defined($thisparm)) { $outpar[14]=$thisparm; $result=14; }
+# 13 - resource level in course
if (defined($$courseopt{$courselevelr})) {
- $outpar[10]=$$courseopt{$courselevelr};
- $result=10;
+ $outpar[13]=$$courseopt{$courselevelr};
+ $result=13;
}
# ------------------------------------------------------ fourth, back to course
if ($csec ne '') {
+# 12 - General for section
if (defined($$courseopt{$seclevel})) {
- $outpar[9]=$$courseopt{$seclevel};
- $result=9;
- }
+ $outpar[12]=$$courseopt{$seclevel};
+ $result=12;
+ }
+# 11 - Map or Folder level for section (recursive)
+ if (defined($$courseopt{$secleveli})) {
+ $outpar[11]=$$courseopt{$secleveli};
+ $result=11;
+ }
+# 10 - Map or Folder level for section (non-recursive)
if (defined($$courseopt{$seclevelm})) {
- $outpar[8]=$$courseopt{$seclevelm};
- $result=8;
- }
-
+ $outpar[10]=$$courseopt{$seclevelm};
+ $result=10;
+ }
+# 9 - resource level in section
if (defined($$courseopt{$seclevelr})) {
- $outpar[7]=$$courseopt{$seclevelr};
- $result=7;
- }
+ $outpar[9]=$$courseopt{$seclevelr};
+ $result=9;
+ }
}
# ------------------------------------------------------ fifth, check course group
if ($cgroup ne '') {
+# 8 - General for group
if (defined($$courseopt{$grplevel})) {
- $outpar[6]=$$courseopt{$grplevel};
- $result=6;
+ $outpar[8]=$$courseopt{$grplevel};
+ $result=8;
}
+# 7 - Map or Folder level for group (recursive)
+ if (defined($$courseopt{$grpleveli})) {
+ $outpar[7]=$$courseopt{$grpleveli};
+ $result=7;
+ }
+# 6 - Map or Folder level for group (non-recursive)
if (defined($$courseopt{$grplevelm})) {
- $outpar[5]=$$courseopt{$grplevelm};
- $result=5;
+ $outpar[6]=$$courseopt{$grplevelm};
+ $result=6;
}
+# 5 - resource level in group
if (defined($$courseopt{$grplevelr})) {
- $outpar[4]=$$courseopt{$grplevelr};
- $result=4;
+ $outpar[5]=$$courseopt{$grplevelr};
+ $result=5;
}
}
-# ---------------------------------------------------------- fifth, check user
+# ---------------------------------------------------------- sixth, check user
if ($uname ne '') {
- if (defined($$useropt{$courselevel})) {
- $outpar[3]=$$useropt{$courselevel};
- $result=3;
- }
-
- if (defined($$useropt{$courselevelm})) {
- $outpar[2]=$$useropt{$courselevelm};
- $result=2;
- }
-
- if (defined($$useropt{$courselevelr})) {
- $outpar[1]=$$useropt{$courselevelr};
- $result=1;
- }
+# 4 - General for specific student
+ if (defined($$useropt{$courselevel})) {
+ $outpar[4]=$$useropt{$courselevel};
+ $result=4;
+ }
+
+# 3 - Map or Folder level for specific student (recursive)
+ if (defined($$useropt{$courseleveli})) {
+ $outpar[3]=$$useropt{$courseleveli};
+ $result=3;
+ }
+
+# 2 - Map or Folder level for specific student (non-recursive)
+ if (defined($$useropt{$courselevelm})) {
+ $outpar[2]=$$useropt{$courselevelm};
+ $result=2;
+ }
+
+# 1 - resource level for specific student
+ if (defined($$useropt{$courselevelr})) {
+ $outpar[1]=$$useropt{$courselevelr};
+ $result=1;
+ }
}
return ($result,@outpar);
}
-sub resetparmhash {
- $parmhashid='';
-}
-sub cacheparmhash {
- if ($parmhashid eq $env{'request.course.fn'}) { return; }
- my %parmhashfile;
- if (tie(%parmhashfile,'GDBM_File',
- $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
- %parmhash=%parmhashfile;
- untie %parmhashfile;
- $parmhashid=$env{'request.course.fn'};
- }
-}
-sub resetsymbcache {
- $symbsid='';
-}
+# --- Caches local to lonparmset
+
-sub symbcache {
- my $id=shift;
- if ($symbsid ne $env{'request.course.id'}) {
- %symbs=();
+# Reset lonparmset caches (called at the beginning and end of the handler).
+sub reset_caches {
+ &resetparmhash();
+ &resetsymbcache();
+ &resetrulescache();
+}
+
+# cache for map parameters, stored temporarily in $env{'request.course.fn'}_parms.db
+# (these parameters come from param elements in .sequence files created with the advanced RAT)
+{
+ my $parmhashid; # course identifier, to initialize the cache only once for a course
+ my %parmhash; # the parameter cache
+ # reset map parameter hash
+ sub resetparmhash {
+ undef($parmhashid);
+ undef(%parmhash);
+ }
+
+ # dump the _parms.db database into %parmhash
+ sub cacheparmhash {
+ if ($parmhashid eq $env{'request.course.fn'}) { return; }
+ my %parmhashfile;
+ if (tie(%parmhashfile,'GDBM_File',
+ $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
+ %parmhash=%parmhashfile;
+ untie(%parmhashfile);
+ $parmhashid=$env{'request.course.fn'};
+ }
}
- unless ($symbs{$id}) {
- my $navmap = Apache::lonnavmaps::navmap->new();
- if ($id=~/\./) {
- my $resource=$navmap->getById($id);
- $symbs{$id}=$resource->symb();
- } else {
- my $resource=$navmap->getByMapPc($id);
- $symbs{$id}=&Apache::lonnet::declutter($resource->src());
- }
- $symbsid=$env{'request.course.id'};
+
+ # returns a parameter value for an identifier symb.parts.parameter, using the map parameter cache
+ sub parmhash {
+ my ($id) = @_;
+ &cacheparmhash();
+ return $parmhash{$id};
}
- return $symbs{$id};
}
-sub resetrulescache {
- $rulesid='';
+# 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
+ # reset the id->symb cache
+ sub resetsymbcache {
+ undef($symbsid);
+ undef(%symbs);
+ }
+
+ # 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'}) {
+ undef(%symbs);
+ }
+ if (!$symbs{$id}) {
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if ($id=~/\./) {
+ my $resource=$navmap->getById($id);
+ $symbs{$id}=$resource->symb();
+ } else {
+ my $resource=$navmap->getByMapPc($id);
+ $symbs{$id}=&Apache::lonnet::declutter($resource->src());
+ }
+ $symbsid=$env{'request.course.id'};
+ }
+ return $symbs{$id};
+ }
}
-sub rulescache {
- my $id=shift;
- if ($rulesid ne $env{'request.course.id'}
- && !defined($rules{$id})) {
- my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
- %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
- $rulesid=$env{'request.course.id'};
+# cache for parameter default actions (stored in parmdefactions.db)
+{
+ my $rulesid; # course identifier, to initialize the cache only once for a course
+ my %rules; # parameter default actions hash
+ sub resetrulescache {
+ undef($rulesid);
+ undef(%rules);
+ }
+
+ # returns the value for a given key in the parameter default action hash
+ sub rulescache {
+ my $id=shift;
+ if ($rulesid ne $env{'request.course.id'}
+ && !defined($rules{$id})) {
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
+ $rulesid=$env{'request.course.id'};
+ }
+ return $rules{$id};
}
- return $rules{$id};
}
+
+# Returns the values of the parameter type default action
+# "default value when manually setting".
+# If none is defined, ('','','','','') is returned.
+#
+# @param {string} $type - parameter type
+# @returns {Array} - (hours, min, sec, value)
sub preset_defaults {
my $type=shift;
if (&rulescache($type.'_action') eq 'default') {
-# yes, there is something
- return (&rulescache($type.'_hours'),
- &rulescache($type.'_min'),
- &rulescache($type.'_sec'),
- &rulescache($type.'_value'));
+ # yes, there is something
+ return (&rulescache($type.'_hours'),
+ &rulescache($type.'_min'),
+ &rulescache($type.'_sec'),
+ &rulescache($type.'_value'));
} else {
-# nothing there or something else
- return ('','','','','');
+ # nothing there or something else
+ return ('','','','','');
}
}
-##################################################
+# Checks that a date is after enrollment start date and before
+# enrollment end date.
+# Returns HTML with a warning if it is not, or the empty string otherwise.
+# This is used by both overview and table modes.
+#
+# @param {integer} $checkdate - the date to check.
+# @returns {string} - HTML possibly containing a localized warning message.
sub date_sanity_info {
my $checkdate=shift;
unless ($checkdate) { return ''; }
@@ -305,288 +689,393 @@ sub date_sanity_info {
my $crsprefix='course.'.$env{'request.course.id'}.'.';
if ($env{$crsprefix.'default_enrollment_end_date'}) {
if ($checkdate>$env{$crsprefix.'default_enrollment_end_date'}) {
- $result.=' '.&mt('After course enrollment end!');
+ $result.='
'
+ .&mt('After course enrollment end!')
+ .'
';
}
}
if ($env{$crsprefix.'default_enrollment_start_date'}) {
if ($checkdate<$env{$crsprefix.'default_enrollment_start_date'}) {
- $result.=' '.&mt('Before course enrollment start!');
+ $result.='
'
+ .&mt('Before course enrollment start!')
+ .'
';
}
}
+# Preparation for additional warnings about dates in the past/future.
+# An improved, more context sensitive version is recommended,
+# e.g. warn for due and answer dates which are defined before the corresponding open date, etc.
+# if ($checkdate
'
+ .''
+ );
} # end of $parmlev eq general
}
- $r->print(''.&Apache::loncommon::end_page());
+ $r->print('');
+ if ($numreclinks) {
+ $r->print(<<"END");
+
+
+END
+ }
+ &endSettingsScreen($r);
+ $r->print(&Apache::loncommon::end_page());
} # end sub assessparms
-##################################################
-##################################################
-
-=pod
-
-=item crsenv
-
-Show and set course data and parameters. This is a large routine that should
-be simplified and shortened... someday.
-
-Inputs: $r
-
-Returns: nothing
-
-=cut
##################################################
+# OVERVIEW MODE
##################################################
-sub crsenv {
- my $r=shift;
- my $setoutput='';
- my $breadcrumbs =
- &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment');
- my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
-
- #
- # Go through list of changes
- foreach (keys %env) {
- next if ($_!~/^form\.(.+)\_setparmval$/);
- my $name = $1;
- my $value = $env{'form.'.$name.'_value'};
- if ($name eq 'newp') {
- $name = $env{'form.newp_name'};
- }
- if ($name eq 'url') {
- $value=~s/^\/res\///;
- my $bkuptime=time;
- my @tmp = &Apache::lonnet::get
- ('environment',['url'],$dom,$crs);
- $setoutput.=&mt('Backing up previous URL').': '.
- &Apache::lonnet::put
- ('environment',
- {'top level map backup '.$bkuptime => $tmp[1] },
- $dom,$crs).
- ' ';
- }
- #
- # Deal with modified default spreadsheets
- if ($name =~ /^spreadsheet_default_(classcalc|
- studentcalc|
- assesscalc)$/x) {
- my $sheettype = $1;
- if ($sheettype eq 'classcalc') {
- # no need to do anything since viewing the sheet will
- # cause it to be updated.
- } elsif ($sheettype eq 'studentcalc') {
- # expire all the student spreadsheets
- &Apache::lonnet::expirespread('','','studentcalc');
- } else {
- # expire all the assessment spreadsheets
- # this includes non-default spreadsheets, but better to
- # be safe than sorry.
- &Apache::lonnet::expirespread('','','assesscalc');
- # expire all the student spreadsheets
- &Apache::lonnet::expirespread('','','studentcalc');
- }
- }
- #
- # Deal with the enrollment dates
- if ($name =~ /^default_enrollment_(start|end)_date$/) {
- $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
- }
- #
- # Deal with the emails
- if ($name =~ /\.email$/) {
- foreach my $specifier (split(',',$value)) {
- my ($user,$sections_or_groups)=
- ($specifier=~/^([^\(]+)\(([^\)]+)\)/);
- if (!$sections_or_groups) {
- $user = $specifier;
- }
- my ($name,$domain) = split(':',$user);
- if (!defined($user) || !defined($domain)) {
- $setoutput.= ' '.
- &mt("Invalid email address specified, address must be of the form username:domain what was specified was ([_1])",$user).
- '';
- undef($value);
- } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') {
- $setoutput.= ' '.
- &mt("Invalid email address specified, user [_1] is unknown.",$name).
- '';
- undef($value);
- }
- }
- }
- # Get existing cloners
- my @oldcloner = ();
- if ($name eq 'cloners') {
- my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
- if ($clonenames{'cloners'} =~ /,/) {
- @oldcloner = split/,/,$clonenames{'cloners'};
- } else {
- $oldcloner[0] = $clonenames{'cloners'};
- }
- }
- #
- # Let the user know we made the changes
- if ($name && defined($value)) {
- my $failed_cloners;
- if ($name eq 'cloners') {
- $value =~ s/\s//g;
- $value =~ s/^,//;
- $value =~ s/,$//;
- # check requested clones are valid users.
- $failed_cloners = &check_cloners(\$value,\@oldcloner);
- }
- my $put_result = &Apache::lonnet::put('environment',
- {$name=>$value},$dom,$crs);
- if ($put_result eq 'ok') {
- $setoutput.=&mt('Set').' '.$name.' '.&mt('to').' '.$value.'. ';
- if ($name eq 'cloners') {
- &change_clone($value,\@oldcloner);
- }
- # Flush the course logs so course description is immediately updated
- if ($name eq 'description' && defined($value)) {
- &Apache::lonnet::flushcourselogs();
- }
- } else {
- $setoutput.=&mt('Unable to set').' '.$name.' '.&mt('to').
- ' '.$value.' '.&mt('due to').' '.$put_result.'. ';
- }
- if (($name eq 'cloners') && ($failed_cloners)) {
- $setoutput.= &mt('Unable to include').' - '.$failed_cloners.', '.
- &mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist').
- '. '.&mt('Please ').
- ' '.
- &mt('add the user(s)').', '.
- &mt('and then return to the ').
- ''.
- &mt('Course Parameters page').' '.
- &mt('to add the new user(s) to the list of possible cloners').
- '. ';
- }
- }
- }
-
- my $start_table =&Apache::loncommon::start_data_table();
- my $start_header_row=&Apache::loncommon::start_data_table_header_row();
- my $end_header_row =&Apache::loncommon::end_data_table_header_row();
-# ------------------------- Re-init course environment entries for this session
-
- &Apache::lonnet::coursedescription($env{'request.course.id'},
- {'freshen_cache' => 1});
-
-# -------------------------------------------------------- Get parameters again
-
- my %values=&Apache::lonnet::dump('environment',$dom,$crs);
- my $SelectStyleFile=&mt('Select Style File');
- my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
- my $output='';
- if (! exists($values{'con_lost'})) {
- my %descriptions=
- ('url' => ''.&mt('Top Level Map').' '.
- '".
- &mt('Select Map').' '.
- &mt('Modification may make assessment data inaccessible').
- '',
- 'description' => ''.&mt('Course Description').'',
- 'courseid' => ''.&mt('Course ID or number').
- ' '.
- '('.&mt('internal').', '.&mt('optional').')',
- 'cloners' => ''.&mt('Users allowed to clone course').' (user:domain,user:domain) '.&mt('Users with active Course Coordinator role in the course automatically have the right to clone it, and can be omitted from list.'),
- 'grading' => ''.&mt('Grading').' '.
- '"standard", "external", or "spreadsheet" '.&Apache::loncommon::help_open_topic('GradingOptions'),
- 'default_xml_style' => ''.&mt('Default XML Style File').' '.
- '$SelectStyleFile ",
- 'question.email' => ''.&mt('Feedback Addresses for Resource Content Question').
- ' (user:domain,'.
- 'user:domain(section;section;...;*;...),...)',
- 'question.email.text' => ''.&mt('Custom Text for Resource Content Question Option in Feedback').
- '',
- 'comment.email' => ''.&mt('Feedback Addresses for Course Content Comments').' '.
- '(user:domain,user:domain(section;section;...;*;...),...)',
- 'comment.email.text' => ''.&mt('Custom Text for Course Content Option in Feedback').
- '',
- 'policy.email' => ''.&mt('Feedback Addresses for Course Policy').''.
- ' (user:domain,user:domain(section;section;...;*;...),...)',
- 'policy.email.text' => ''.&mt('Custom Text for Course Policy Option in Feedback').
- '',
- 'hideemptyrows' => ''.&mt('Hide Empty Rows in Spreadsheets').' '.
- '('.&mt('"[_1]" for default hiding','yes').')',
- 'pageseparators' => ''.&mt('Visibly Separate Items on Pages').' '.
- '('.&mt('"[_1]" for visible separation','yes').', '.
- &mt('changes will not show until next login').')',
- 'student_classlist_view' => ''.&mt('Allow students to view classlist.').''.&mt('("all":students can view all sections,"section":students can only view their own section.blank or "disabled" prevents student view.'),
- 'student_classlist_portfiles' => ''.&mt('Include link to accessible portfolio files').' '.&mt('"[_1]" for link to each a listing of each student\'s files.','yes'),
- 'student_classlist_opt_in' => ''.&mt("Student's agreement needed for listing in student-viewable roster").' '.&mt('"[_1]" to require students to opt-in to listing in the roster (on the roster page).','yes'),
- 'plc.roles.denied'=> ''.&mt('Disallow live chatroom use for Roles').
- ' "st": '.
- &mt('student').', "ta": '.
- 'TA, "in": '.
- &mt('instructor').'; '.&mt('role,role,...').') '.
- Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
- 'plc.users.denied' =>
- ''.&mt('Disallow live chatroom use for Users').' '.
- '(user:domain,user:domain,...)',
-
- 'pch.roles.denied'=> ''.&mt('Disallow Resource Discussion for Roles').
- ' "st": '.
- 'student, "ta": '.
- 'TA, "in": '.
- 'instructor; role,role,...) '.
- Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
- 'pch.users.denied' =>
- ''.&mt('Disallow Resource Discussion for Users').' '.
- '(user:domain,user:domain,...)',
- 'spreadsheet_default_classcalc'
- => ''.&mt('Default Course Spreadsheet').' '.
- '$SelectSpreadsheetFile ",
- 'spreadsheet_default_studentcalc'
- => ''.&mt('Default Student Spreadsheet').' '.
- '$SelectSpreadsheetFile ",
- 'spreadsheet_default_assesscalc'
- => ''.&mt('Default Assessment Spreadsheet').' '.
- '$SelectSpreadsheetFile ",
- 'allow_limited_html_in_feedback'
- => ''.&mt('Allow limited HTML in discussion posts').' '.
- '('.&mt('Set value to "[_1]" to allow',"yes").')',
- 'allow_discussion_post_editing'
- => ''.&mt('Allow users with specified roles to edit/delete their own discussion posts').' "st": '.
- &mt('student').', "ta": '.
- 'TA, "in": '.
- &mt('instructor').'; ('.&mt('role:section,role:section,..., e.g., st:001,st:002,in,cc would permit students in sections 001 and 002 and instructors in any section, and course coordinators to edit their own posts.').') '.
- '('.&mt('or set value to "[_1]" to allow all roles',"yes").')',
- 'rndseed'
- => ''.&mt('Randomization algorithm used').' '.
- ''.&mt('Modifying this will make problems').' '.
- &mt('have different numbers and answers').'',
- 'receiptalg'
- => ''.&mt('Receipt algorithm used').' '.
- &mt('This controls how receipt numbers are generated.'),
- 'suppress_tries'
- => ''.&mt('Suppress number of tries in printing').' '.
- ' ('.&mt('"[_1]" to suppress, anything else to not suppress','yes').')',
- 'problem_stream_switch'
- => ''.&mt('Allow problems to be split over pages').' '.
- ' ('.&mt('"[_1]" if allowed, anything else if not','yes').')',
- 'default_paper_size'
- => ''.&mt('Default paper type').' '.
- ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
- ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
- ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
- 'print_header_format'
- => &mtn(' Print header format; substitutions : %n student name %c course id %a assignment note, numbers after the % limit the field size.').'',
- 'default_enrollment_start_date' => ''.&mt('Default beginning date for student access.').'',
- 'default_enrollment_end_date' => ''.&mt('Default ending date for student access.').'',
- 'nothideprivileged' => ''.&mt('Privileged users that should not be hidden on staff listings').''.
- ' (user:domain,user:domain,...)',
- 'languages' => ''.&mt('Languages used').'',
- 'disable_receipt_display'
- => ''.&mt('Disable display of problem receipts').' '.
- ' ('.&mt('"[_1]" to disable, anything else if not','yes').')',
- 'task_messages'
- => ''.&mt('Send message to student when clicking Done on Tasks').' ('.&mt('[_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','only_student','student_and_user_notes_screen').')',
- 'disablesigfigs'
- => ''.&mt('Disable checking of Significant Figures').' '.
- ' ('.&mt('"[_1]" to disable, anything else if not','yes').')',
- 'disableexampointprint'
- => ''.&mt('Disable automatically printing point values onto exams.').' '.
- ' ('.&mt('"[_1]" to disable, anything else if not','yes').')',
- 'externalsyllabus'
- => ''.&mt('URL of Syllabus (not using internal handler)').'',
- 'tthoptions'
- => ''.&mt('Default set of options to pass to tth/m when converting tex').'',
-
- 'texengine'
- => ''.&mt('Force all students in the course to use a specific math rendering engine.').' '.&mt('(Valid options are [_1].)','"tth", "jsMath", "mimetex"').'',
- );
- my @Display_Order = ('url','description','courseid','cloners','grading',
- 'externalsyllabus',
- 'default_xml_style','pageseparators',
- 'question.email','question.email.text','comment.email','comment.email.text','policy.email','policy.email.text',
- 'student_classlist_view',
- 'student_classlist_opt_in',
- 'student_classlist_portfiles',
- 'plc.roles.denied','plc.users.denied',
- 'pch.roles.denied','pch.users.denied',
- 'allow_limited_html_in_feedback',
- 'allow_discussion_post_editing',
- 'languages',
- 'nothideprivileged',
- 'rndseed',
- 'receiptalg',
- 'problem_stream_switch',
- 'suppress_tries',
- 'default_paper_size',
- 'print_header_format',
- 'disable_receipt_display',
- 'spreadsheet_default_classcalc',
- 'spreadsheet_default_studentcalc',
- 'spreadsheet_default_assesscalc',
- 'hideemptyrows',
- 'default_enrollment_start_date',
- 'default_enrollment_end_date',
- 'tthoptions',
- 'texengine',
- 'disablesigfigs',
- 'disableexampointprint',
- 'task_messages'
- );
- foreach my $parameter (sort(keys(%values))) {
- unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) {
- if (! $descriptions{$parameter}) {
- $descriptions{$parameter}=$parameter;
- push(@Display_Order,$parameter);
- }
- }
- }
-
- foreach my $parameter (@Display_Order) {
- my $description = $descriptions{$parameter};
- # onchange is javascript to automatically check the 'Set' button.
- my $onchange = 'onFocus="javascript:window.document.forms'.
- "['envform'].elements['".$parameter."_setparmval']".
- '.checked=true;"';
- $output .= &Apache::loncommon::start_data_table_row().
- '
'.
- &Apache::loncommon::end_data_table_row()."\n";
- }
- my %lt=&Apache::lonlocal::texthash(
- 'par' => 'Parameter',
- 'val' => 'Value',
- 'set' => 'Set',
- 'sce' => 'Set Course Environment'
- );
-
- my $Parameter=&mt('Parameter');
- my $Value=&mt('Value');
- my $Set=&mt('Set');
- my $browse_js=
- '';
-
- my $start_page =
- &Apache::loncommon::start_page('Set Course Environment',
- $browse_js);
- my $end_page =
- &Apache::loncommon::end_page();
- my $end_table=&Apache::loncommon::end_data_table();
- $r->print(<
-$setoutput
-$start_table
-$start_header_row
-
$lt{'par'}
$lt{'val'}
$lt{'set'}?
-$end_header_row
-$output
-$end_table
-
-
-$end_page
-ENDENV
-}
-##################################################
-# Overview mode
-##################################################
-my $tableopen;
+my $tableopen; # boolean, true if HTML table is already opened
+# Returns HTML with the HTML table start tag and header, unless the table is already opened.
+# @param {boolean} $readonly - true if values cannot be edited (otherwise more columns are added)
+# @returns {string}
sub tablestart {
+ my ($readonly,$is_map) = @_;
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 ...').'
';
+ if ($is_map) {
+ $output .= '
'.&mt('Recursive?').'
';
+ }
+ }
+ $output .= '
';
+ return $output;
}
}
+# Returns HTML with the HTML table end tag, unless the table is not opened.
+# @returns {string}
sub tableend {
if ($tableopen) {
- $tableopen=0;
- return &Apache::loncommon::end_data_table();
+ $tableopen=0;
+ return &Apache::loncommon::end_data_table();
} else {
- return'';
+ return'';
}
}
+# Reads course and user information.
+# If the context is looking for a scalar, returns the course parameters hash (result of lonnet::get_courseresdata, dump of course's resourcedata.db) with added student data from lonnet::get_userresdata (which reads the user's resourcedata.db).
+# The key for student data is modified with '[useropt:'.username.':'.userdomain.'].'.
+# If the context is looking for a list, returns a list with the scalar data and the class list.
+# @param {string} $crs - course number
+# @param {string} $dom - course domain
+# @returns {hash reference|Array}
sub readdata {
my ($crs,$dom)=@_;
# Read coursedata
@@ -2406,25 +3934,45 @@ sub readdata {
# Read userdata
my $classlist=&Apache::loncoursedata::get_classlist();
- foreach (keys %$classlist) {
- if ($_=~/^($match_username)\:($match_domain)$/) {
- my ($tuname,$tudom)=($1,$2);
- my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
- foreach my $userkey (keys %{$useropt}) {
- if ($userkey=~/^$env{'request.course.id'}/) {
+ foreach my $user (keys(%$classlist)) {
+ if ($user=~/^($match_username)\:($match_domain)$/) {
+ my ($tuname,$tudom)=($1,$2);
+ my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
+ foreach my $userkey (keys(%{$useropt})) {
+ if ($userkey=~/^\Q$env{'request.course.id'}\E/) {
my $newkey=$userkey;
- $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
- $$resourcedata{$newkey}=$$useropt{$userkey};
- }
- }
- }
+ $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
+ $$resourcedata{$newkey}=$$useropt{$userkey};
+ }
+ }
+ }
+ }
+ if (wantarray) {
+ return ($resourcedata,$classlist);
+ } else {
+ return $resourcedata;
}
- return $resourcedata;
}
-# Setting
-
+# Stores parameter data, using form parameters directly.
+#
+# Uses the following form parameters. The variable part in the names is a resourcedata key (except for a modification for user data).
+# set_* (except settext, setipallow, setipdeny, setdeeplink) - set a parameter value
+# del_* - remove a parameter
+# datepointer_* - set a date parameter (value is key_* refering to a set of other form parameters)
+# dateinterval_* - set a date interval parameter (value refers to more form parameters)
+# key_* - date values
+# days_* - for date intervals
+# hours_* - for date intervals
+# minutes_* - for date intervals
+# seconds_* - for date intervals
+# done_* - for date intervals
+# typeof_* - parameter type
+#
+# @param {Apache2::RequestRec} $r - the Apache request
+# @param {string} $crs - course number
+# @param {string} $dom - course domain
sub storedata {
my ($r,$crs,$dom)=@_;
# Set userlevel immediately
@@ -2433,107 +3981,418 @@ sub storedata {
my %newdata=();
undef %newdata;
my @deldata=();
+ my @delrec=();
+ my @delnonrec=();
undef @deldata;
- foreach (keys %env) {
- if ($_=~/^form\.([a-z]+)\_(.+)$/) {
- my $cmd=$1;
- my $thiskey=$2;
- my ($tuname,$tudom)=&extractuser($thiskey);
- my $tkey=$thiskey;
+ 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;
+ my ($altkey,$recursive,$tkey,$tkeyrec,$tkeynonrec);
+ next if ($cmd eq 'rec' || $cmd eq 'settext' || $cmd eq 'setipallow' || $cmd eq 'setipdeny' || $cmd eq 'setdeeplink');
+ if ((($cmd eq 'set') || ($cmd eq 'datepointer') || ($cmd eq 'dateinterval') || ($cmd eq 'del')) &&
+ ($thiskey =~ /(?:sequence|page)\Q___(all)\E/)) {
+ unless ($thiskey =~ /(encrypturl|hiddenresource)$/) {
+ $altkey = $thiskey;
+ $altkey =~ s/\Q___(all)\E/___(rec)/;
+ if ($env{'form.rec_'.$thiskey}) {
+ $recursive = 1;
+ }
+ }
+ }
+ my ($tuname,$tudom)=&extractuser($thiskey);
if ($tuname) {
- $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
- }
- if ($cmd eq 'set') {
- my $data=$env{$_};
- my $typeof=$env{'form.typeof_'.$thiskey};
- if ($$olddata{$thiskey} ne $data) {
- if ($tuname) {
- if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
- $tkey.'.type' => $typeof},
- $tudom,$tuname) eq 'ok') {
- &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
- $r->print(' '.&mt('Saved modified parameter for').' '.
- &Apache::loncommon::plainname($tuname,$tudom));
- } else {
- $r->print('
';
+ }
+ return $result;
+}
+
+my %intervals =
+ (
+ 'date_interval'
+ => [[ 'done', 'Yes' ],
+ [ 'done_proctor', 'Yes, with proctor key'],
+ [ '', 'No' ]],
+ );
+
+my %intervalmatches = (
+ 'date_interval'
+ => [['done','\d+_done(|\:[^\:]+\:)$'],
+ ['done_proctor','\d+_done(|\:[^\:]+\:)_proctor_']],
+ );
+
+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') {
+ return $intervalmatches{$interval_type};
+ }
+ 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})) {
+ return $intervaltypes{$name};
+ }
+ 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') {
+ return $intervals{$interval_type};
+ }
+ 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);
+ if ($name eq 'interval') {
+ my $intervaltype = &get_intervaltype($name);
+ my ($got_chostname,$chostname,$cmajor,$cminor);
+ foreach my $possibilities (@{ $intervals{$intervaltype} }) {
+ next unless (ref($possibilities) eq 'ARRAY');
+ my ($parmval, $description) = @{ $possibilities };
+ my $parmmatch;
+ if (ref($intervalmatches{$intervaltype}) eq 'ARRAY') {
+ foreach my $item (@{$intervalmatches{$intervaltype}}) {
+ if (ref($item) eq 'ARRAY') {
+ if ($parmval eq $item->[0]) {
+ $parmmatch = $parmval;
+ $parmval = '';
+ last;
+ }
+ }
+ }
+ }
+ my $needsrelease=$Apache::lonnet::needsrelease{"parameter:$name:$parmval:$parmmatch"};
+ if ($needsrelease) {
+ unless ($got_chostname) {
+ ($chostname,$cmajor,$cminor)=¶meter_release_vars();
+ $got_chostname = 1;
+ }
+ my $needsnewer=¶meter_releasecheck($name,$parmval,$parmmatch,undef,
+ $needsrelease,$cmajor,$cminor);
+ if ($needsnewer) {
+ if ($parmmatch ne '') {
+ $skipval{$parmmatch} = 1;
+ } elsif ($parmval ne '') {
+ $skipval{$parmval} = 1;
+ }
+ }
+ }
+ }
+ }
+
+ my $currval = $showval;
+ foreach my $which (['days', 86400, 31],
+ ['hours', 3600, 23],
+ ['minutes', 60, 59],
+ ['seconds', 1, 59]) {
+ my ($name, $factor, $max) = @{ $which };
+ my $amount = int($showval/$factor);
+ $showval %= $factor;
+ my %select = ((map {$_ => $_} (0..$max)),
+ 'select_form_order' => [0..$max]);
+ $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
+ \%select,'',$readonly);
+ $result .= ' '.&mt($name);
+ }
+ if ($name eq 'interval') {
+ unless ($skipval{'done'}) {
+ my $checkedon = '';
+ my $checkedproc = '';
+ my $currproctorkey = '';
+ my $currprocdisplay = 'hidden';
+ my $currdonetext = &mt('Done');
+ my $checkedoff = ' checked="checked"';
+ if ($currval =~ /^(?:\d+)_done$/) {
+ $checkedon = ' checked="checked"';
+ $checkedoff = '';
+ } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:$/) {
+ $currdonetext = $1;
+ $checkedon = ' checked="checked"';
+ $checkedoff = '';
+ } elsif ($currval =~ /^(?:\d+)_done_proctor_(.+)$/) {
+ $currproctorkey = $1;
+ $checkedproc = ' checked="checked"';
+ $checkedoff = '';
+ $currprocdisplay = 'text';
+ } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:_proctor_(.+)$/) {
+ $currdonetext = $1;
+ $currproctorkey = $2;
+ $checkedproc = ' checked="checked"';
+ $checkedoff = '';
+ $currprocdisplay = 'text';
+ }
+ my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"';
+ my $disabled;
+ if ($readonly) {
+ $disabled = ' disabled="disabled"';
+ }
+ $result .= ' '.&mt('Include "done" button').
+ ''.(' 'x2).
+ ''.(' 'x2).
+ ''.
+ '&').'"'.$disabled.' /> '.
+ ''.&mt('Button text').': '.
+ '&').'"'.$disabled.' />';
+ }
+ }
+ unless ($readonly) {
+ $result .= '';
+ }
+ 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);
+ if ($namematch) {
+ my $level = &standard_parameter_levels($namematch);
+ my $msg = '';
+ if ($level) {
+ $msg = &mt('[_1] was [_2]not[_3] set at the level of: [_4].',
+ $standard_name,'','','"'.$level.'"');
+ } else {
+ $msg = &mt('[_1] was [_2]not[_3] set.',
+ $standard_name,'','');
+ }
+ return '
'.$msg.' '.
+ &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
+ $cmajor.'.'.$cminor,$chostname,
+ $needsrelease).
+ '
';
+ }
+ my $desc;
+ my $stringtype = &get_stringtype($name);
+ if ($stringtype ne '') {
+ if ($name eq 'examcode') {
+ $desc = $value;
+ } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
+ foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) {
+ next unless (ref($possibilities) eq 'ARRAY');
+ my ($parmval, $description) = @{ $possibilities };
+ my $parmmatch;
+ if (ref($stringmatches{$stringtypes{$name}}) eq 'ARRAY') {
+ foreach my $item (@{$stringmatches{$stringtypes{$name}}}) {
+ if (ref($item) eq 'ARRAY') {
+ my ($regexpname,$pattern) = @{$item};
+ if ($parmval eq $regexpname) {
+ if ($value =~ /$pattern/) {
+ $desc = $description;
+ $parmmatch = 1;
+ last;
+ }
+ }
+ }
+ }
+ last if ($parmmatch);
+ } elsif ($parmval eq $value) {
+ $desc = $description;
+ last;
+ }
+ }
+ }
+ } 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);
+ }
+ }
+ }
+ }
+ 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).
+ '
';
+}
+
+} # end of block using some constants related to parameter types
+
+
+
+# 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,$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 %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
+# ugly retro fix for broken version of types
+ foreach my $key (keys(%data)) {
+ if ($key=~/\wtype$/) {
+ my $newkey=$key;
+ $newkey=~s/type$/\.type/;
+ $data{$newkey}=$data{$key};
+ delete $data{$key};
+ }
+ }
+ my %storecontent=();
+# 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'}\.\[$sec\]\./);
+ }
+ my $newdate=$data{$key}+$shift;
+ $$numchanges ++;
+ $storecontent{$key}=$newdate;
+ }
+ }
+ my $reply=&Apache::lonnet::cput
+ ('resourcedata',\%storecontent,$dom,$crs);
+ if ($reply eq 'ok') {
+ &log_parmset(\%storecontent);
+ }
+ &Apache::lonnet::devalidatecourseresdata($crs,$dom);
+ 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 $start_page = &Apache::loncommon::start_page('Set Parameters');
+ 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"});
+
+ my %loaditems = (
+ 'onload' => "showHide_courseContent(); resize_scrollbox('mapmenuscroll','1','1'); showHideLenient();",
+ );
+ my $js = '
+
+';
+
+ my $start_page = &Apache::loncommon::start_page('Set Parameters',$js,
+ {'add_entries' => \%loaditems,});
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
+ $r->print($start_page.$breadcrumbs);
+ &startSettingsScreen($r,'parmset',$crstype);
$r->print(<
+'.&Apache::loncommon::end_page());
+ $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}) {
@@ -2821,7 +5648,7 @@ sub secgroup_lister {
$$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
} elsif ($parmlev eq 'map') {
# map-level parameter
- foreach my $mapid (keys %{$allmaps}) {
+ foreach my $mapid (keys(%{$allmaps})) {
if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
$$listdata{$newparmkey}=1;
@@ -2841,45 +5668,85 @@ sub secgroup_lister {
}
}
+# 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 = ''."\n";
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
+ text=>"Overview Mode"});
+ my %loaditems = (
+ 'onload' => "showHideLenient();",
+ );
- my $start_page=&Apache::loncommon::start_page('Modify Parameters');
+ my $start_page=&Apache::loncommon::start_page('Modify Parameters',$js,{'add_entries' => \%loaditems,});
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
- $r->print(<
-ENDOVER
+ $r->print($start_page.$breadcrumbs);
+ &startSettingsScreen($r,'parmset',$crstype);
+ $r->print(''.
- &Apache::loncommon::end_page());
+# List data
+
+ my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder,'overview',$classlist,$readonly);
+ $r->print(&tableend().'
'.
- &Apache::loncommon::end_page());
+ ''.
+ '');
+ &endSettingsScreen($r);
+ $r->print(&Apache::loncommon::end_page());
+}
+
+# UI to shift all dates (called by dateshift1 action).
+# Used by overview mode.
+#
+# @param {Apache2::RequestRec} $r - the Apache request
+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 $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
+ 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 '') {
+ $submit_text = &mt("Shift all dates set explicitly for section '[_1]', accordingly",$sec);
+ }
+ my $start_page=&Apache::loncommon::start_page('Shift Dates');
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
+ $r->print($start_page.$breadcrumbs);
+ &startSettingsScreen($r,'parmset',$crstype);
+ $r->print('');
+ &endSettingsScreen($r);
+ $r->print(&Apache::loncommon::end_page());
+}
+
+# UI to shift all dates (second form).
+#
+# @param {Apache2::RequestRec} $r - the Apache request
+sub date_shift_two {
+ my ($r) = @_;
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $sec = $env{'request.course.sec'};
+ my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
+ text=>"Shifting Dates"});
+ my $start_page=&Apache::loncommon::start_page('Shift Dates');
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
+ $r->print($start_page.$breadcrumbs);
+ &startSettingsScreen($r,'parmset',$crstype);
+ my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
+ $r->print('
'.&mt('Shift Dates').'
');
+ if ($sec ne '') {
+ $r->print('
'.
+ &mt("Shift all dates set explicitly for section '[_1]', such that [_2] becomes [_3]",
+ $sec,&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'};
+ 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').'']));
+ &endSettingsScreen($r);
+ $r->print(&Apache::loncommon::end_page());
}
+# Returns the different components of a resourcedata key.
+# Keys: scope_type, scope, realm_type, realm, realm_title,
+# realm_exists, parameter_part, parameter_name.
+# Was used by clean_parameters (which is unused).
+#
+# @param {string} $key - the parameter key
+# @returns {hash}
sub parse_key {
my ($key) = @_;
my %data;
my ($middle,$part,$name)=
- ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
+ ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s\-]+)\.(\w+)$/);
$data{'scope_type'} = 'all';
if ($middle=~/^\[(.*)\]/) {
- $data{'scope'} = $1;
- if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
- $data{'scope_type'} = 'user';
- $data{'scope'} = [$1,$2];
- } else {
- #FIXME check for group scope
- $data{'scope_type'} = 'section';
- }
- $middle=~s/^\[(.*)\]//;
+ $data{'scope'} = $1;
+ if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
+ $data{'scope_type'} = 'user';
+ $data{'scope'} = [$1,$2];
+ } else {
+ $data{'scope_type'} = 'secgroup';
+ }
+ $middle=~s/^\[(.*)\]//;
}
$middle=~s/\.+$//;
$middle=~s/^\.+//;
$data{'realm_type'}='all';
if ($middle=~/^(.+)\_\_\_\(all\)$/) {
- $data{'realm'} = $1;
- $data{'realm_type'} = 'folder';
- $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
- ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
- &Apache::lonnet::logthis($1." siad ". $data{'realm_exists'} );
+ $data{'realm'} = $1;
+ $data{'realm_type'} = 'folder';
+ $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
+ ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
} elsif ($middle) {
- $data{'realm'} = $middle;
- $data{'realm_type'} = 'symb';
- $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
- my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
- $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
+ $data{'realm'} = $middle;
+ $data{'realm_type'} = 'symb';
+ $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
+ my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
+ $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
}
-
+
$data{'parameter_part'} = $part;
$data{'parameter_name'} = $name;
return %data;
}
-##################################################
-##################################################
-
-=pod
-
-=item check_cloners
-Checks if new users included in list of allowed cloners
-are valid users. Replaces supplied list with
-cleaned list containing only users with valid usernames
-and domains.
-
-Inputs: $clonelist, $oldcloner
-where $clonelist is ref to array of requested cloners,
-and $oldcloner is ref to array of currently allowed
-cloners.
-
-Returns: string - comma separated list of requested
-cloners (username:domain) who do not exist in system.
-
-=item change_clone
-
-Modifies the list of courses a user can clone (stored
-in the user's environment.db file), called when a
-change is made to the list of users allowed to clone
-a course.
-
-Inputs: $action,$cloner
-where $action is add or drop, and $cloner is identity of
-user for whom cloning ability is to be changed in course.
-
-=cut
-
-##################################################
-##################################################
-
-sub extract_cloners {
- my ($clonelist,$allowclone) = @_;
- if ($clonelist =~ /,/) {
- @{$allowclone} = split/,/,$clonelist;
- } else {
- $$allowclone[0] = $clonelist;
- }
+# Calls loncommon::start_page with the "Settings" title.
+sub header {
+ return &Apache::loncommon::start_page('Settings');
}
-sub check_cloners {
- my ($clonelist,$oldcloner) = @_;
- my ($clean_clonelist,$disallowed);
- my @allowclone = ();
- &extract_cloners($$clonelist,\@allowclone);
- foreach my $currclone (@allowclone) {
- if (!grep/^$currclone$/,@$oldcloner) {
- my ($uname,$udom) = split/:/,$currclone;
- if ($uname && $udom) {
- if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
- $disallowed .= $currclone.',';
- } else {
- $clean_clonelist .= $currclone.',';
- }
- }
- } else {
- $clean_clonelist .= $currclone.',';
- }
- }
- if ($disallowed) {
- $disallowed =~ s/,$//;
- }
- if ($clean_clonelist) {
- $clean_clonelist =~ s/,$//;
- }
- $$clonelist = $clean_clonelist;
- return $disallowed;
-}
-
-sub change_clone {
- my ($clonelist,$oldcloner) = @_;
- my ($uname,$udom);
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $clone_crs = $cnum.':'.$cdom;
-
- if ($cnum && $cdom) {
- my @allowclone;
- &extract_cloners($clonelist,\@allowclone);
- foreach my $currclone (@allowclone) {
- if (!grep/^$currclone$/,@$oldcloner) {
- ($uname,$udom) = split/:/,$currclone;
- if ($uname && $udom) {
- unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
- my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
- if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
- if ($currclonecrs{'cloneable'} eq '') {
- $currclonecrs{'cloneable'} = $clone_crs;
- } else {
- $currclonecrs{'cloneable'} .= ','.$clone_crs;
- }
- &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
- }
- }
- }
- }
- }
- foreach my $oldclone (@$oldcloner) {
- if (!grep/^$oldclone$/,@allowclone) {
- ($uname,$udom) = split/:/,$oldclone;
- if ($uname && $udom) {
- unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
- my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
- my %newclonecrs = ();
- if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
- if ($currclonecrs{'cloneable'} =~ /,/) {
- my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
- foreach (@currclonecrs) {
- unless ($_ eq $clone_crs) {
- $newclonecrs{'cloneable'} .= $_.',';
- }
- }
- $newclonecrs{'cloneable'} =~ s/,$//;
- } else {
- $newclonecrs{'cloneable'} = '';
- }
- &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
- }
- }
- }
- }
- }
- }
-}
-
##################################################
+# MAIN MENU
##################################################
-=pod
-
-=item * header
-
-Output html header for page
-
-=cut
-
-##################################################
-##################################################
-sub header {
- return &Apache::loncommon::start_page('Parameter Manager');
-}
-##################################################
-##################################################
+# Content and problem settings main menu.
+#
+# @param {Apache2::RequestRec} $r - the Apache request
+# @param {boolean} $parm_permission - true if the user has permission to edit the current course or section
sub print_main_menu {
my ($r,$parm_permission)=@_;
#
+ $r->print(&header());
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content and Problem Settings'));
+ my $crstype = &Apache::loncommon::course_type();
+ my $lc_crstype = lc($crstype);
+
+ &startSettingsScreen($r,'parmset',$crstype);
$r->print(<
@@ -3160,87 +5993,136 @@ 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 $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 =
- ( { divider=>'Settings for Your Course',
- },
- { text => 'Set Course Environment',
- action => 'crsenv',
- permission => $parm_permission,
- help => 'Course_Environment',
- },
- { text => 'Set Portfolio Metadata',
- action => 'setrestrictmeta',
- permission => $parm_permission,
+ ( { categorytitle=>"Content Settings for this $crstype",
+ items => [
+ { linktext => 'Portfolio Metadata',
+ url => '/adm/parmset?action=setrestrictmeta',
+ permission => $parm_permission->{'setrestrictmeta'},
+ linktitle => "Restrict metadata for this $lc_crstype." ,
+ icon =>'contact-new.png' ,
},
- { text => 'Manage Course Slots',
- url => '/adm/slotrequest?command=showslots',
- permission => $vgr,
+ { linktext => $linktext{'resettimes'},
+ url => $url{'resettimes'},
+ permission => ($vgr || $mgr),
+ linktitle => $linktitle{'resettimes'},
+ icon => 'start-here.png',
},
- { text => 'Reset Student Access Times',
- url => '/adm/helper/resettimes.helper',
- permission => $mgr,
+ { 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',
},
-
- { text => 'Set Parameter Setting Default Actions',
- action => 'setdefaults',
- permission => $parm_permission,
- },
- { divider => 'New and Existing Parameter Settings for Your Resources',
- },
- { text => 'Set/Modify Resource Parameters - Helper Mode',
+ { linktext => 'Set Parameter Setting Default Actions',
+ url => '/adm/parmset?action=setdefaults',
+ permission => $parm_permission->{'setdefaults'},
+ linktitle =>'Set default actions for parameters.' ,
+ icon => 'folder-new.png' ,
+ }]},
+ { categorytitle => 'New and Existing Parameter Settings for Resources',
+ items => [
+ { linktext => 'Edit Resource Parameters - Helper Mode',
url => '/adm/helper/parameter.helper',
- permission => $parm_permission,
- help => 'Parameter_Helper',
+ permission => $parm_permission->{'helper'},
+ linktitle =>'Set/Modify resource parameters in helper mode.' ,
+ icon => 'dialog-information.png' ,
+ #help => 'Parameter_Helper',
},
- { text => 'Set/Modify Resource Parameters - Overview Mode',
- action => 'newoverview',
- permission => $parm_permission,
- help => 'Parameter_Overview',
+ { linktext => $linktext{'newoverview'},
+ url => '/adm/parmset?action=newoverview',
+ permission => $parm_permission->{'newoverview'},
+ linktitle => $linktitle{'newoverview'},
+ icon => 'edit-find.png',
+ #help => 'Parameter_Overview',
},
- { text => 'Set/Modify Resource Parameters - Table Mode',
- action => 'settable',
- permission => $parm_permission,
- help => 'Table_Mode',
- },
- { divider => 'Existing Parameter Settings for Your Resources',
- },
- { text => 'Modify Resource Parameters - Overview Mode',
- action => 'setoverview',
- permission => $parm_permission,
- help => 'Parameter_Overview',
- },
- { text => 'Parameter Change Log and Course Blog Posting/User Notification',
- action => 'parameterchangelog',
- permission => $parm_permission,
+ { linktext => $linktext{'settable'},
+ url => '/adm/parmset?action=settable',
+ permission => $parm_permission->{'settable'},
+ linktitle => $linktitle{'settable'},
+ icon => 'edit-copy.png',
+ #help => 'Table_Mode',
+ }]},
+ { categorytitle => 'Existing Parameter Settings for Resources',
+ items => [
+ { linktext => $linktext{'setoverview'},
+ url => '/adm/parmset?action=setoverview',
+ 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->{'parameterchangelog'},
+ linktitle =>"View parameter and $lc_crstype blog posting/user notification change log." ,
+ icon => 'document-properties.png',
+ }]}
);
- my $menu_html = '';
- foreach my $menu_item (@menu) {
- if ($menu_item->{'divider'}) {
- $menu_html .= '
'.&mt($menu_item->{'divider'}).'
';
- next;
- }
- next if (! $menu_item->{'permission'});
- $menu_html.='
'.$/;
- }
- $r->print($menu_html);
+ $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
+ $r->print('');
+ &endSettingsScreen($r);
+ $r->print(&Apache::loncommon::end_page());
return;
}
-### Set portfolio metadata
+
+
+
+##################################################
+# PORTFOLIO METADATA
+##################################################
+
+# Prints HTML to edit an item of portfolio metadata. The HTML contains several td elements (no tr).
+# It looks like field titles are not localized.
+#
+# @param {Apache2::RequestRec} $r - the Apache request
+# @param {string} $field_name - metadata field name
+# @param {string} $field_text - metadata field title, in English unless manually added
+# @param {boolean} $added_flag - true if the field was manually added
sub output_row {
my ($r, $field_name, $field_text, $added_flag) = @_;
my $output;
@@ -3252,114 +6134,125 @@ sub output_row {
}
if (!($options =~ /deleted/)) {
my @options= ( ['active', 'Show to student'],
- ['stuadd', 'Provide text area for students to type catalog information'],
+ ['stuadd', 'Provide text area for students to type metadata'],
['choices','Provide choices for students to select from']);
-# ['onlyone','Student may select only one choice']);
+# ['onlyone','Student may select only one choice']);
if ($added_flag) {
push @options,['deleted', 'Delete Metadata Field'];
}
$output = &Apache::loncommon::start_data_table_row();
- $output .= '