--- loncom/interface/lonparmset.pm 2006/09/27 23:30:12 1.337
+++ loncom/interface/lonparmset.pm 2021/01/18 23:11:15 1.522.2.28
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.337 2006/09/27 23:30:12 banghart Exp $
+# $Id: lonparmset.pm,v 1.522.2.28 2021/01/18 23:11:15 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,7 +36,8 @@ lonparmset - Handler to set parameters f
=head1 SYNOPSIS
-lonparmset provides an interface to setting course parameters.
+lonparmset provides an interface to setting content parameters in a
+course.
=head1 DESCRIPTION
@@ -44,46 +45,9 @@ This module sets coursewide and assessme
=head1 INTERNAL SUBROUTINES
-=over 4
-
-=cut
-
-###################################################################
-###################################################################
-
-package Apache::lonparmset;
-
-use strict;
-use Apache::lonnet;
-use Apache::Constants qw(:common :http REDIRECT);
-use Apache::lonhtmlcommon();
-use Apache::loncommon;
-use GDBM_File;
-use Apache::lonhomework;
-use Apache::lonxml;
-use Apache::lonlocal;
-use Apache::lonnavmaps;
-use Apache::longroup;
-use Apache::lonrss;
-use LONCAPA;
-
-# --- Caches local to lonparmset
-
-my $parmhashid;
-my %parmhash;
-my $symbsid;
-my %symbs;
-my $rulesid;
-my %rules;
-
-# --- end local caches
-
-##################################################
-##################################################
-
-=pod
+=over
-=item parmval
+=item parmval()
Figure out a cascading parameter.
@@ -108,9 +72,258 @@ Returns: A list, the first item is the
2 - Map or Folder level for specific student
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
-##################################################
+###################################################################
+###################################################################
+
+package Apache::lonparmset;
+
+use strict;
+use Apache::lonnet;
+use Apache::Constants qw(:common :http REDIRECT);
+use Apache::lonhtmlcommon();
+use Apache::loncommon;
+use GDBM_File;
+use Apache::lonhomework;
+use Apache::lonxml;
+use Apache::lonlocal;
+use Apache::lonnavmaps;
+use Apache::longroup;
+use Apache::lonrss;
+use HTML::Entities;
+use LONCAPA qw(:DEFAULT :match);
+
+
sub parmval {
my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,
@@ -119,15 +332,16 @@ sub parmval {
sub parmval_by_symb {
my ($what,$symb,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
-# load caches
- &cacheparmhash();
- my $useropt=&Apache::lonnet::get_userresdata($uname,$udom);
+ my $useropt;
+ if ($uname ne '' && $udom ne '') {
+ $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);
my $symbparm=$symb.'.'.$what;
@@ -149,13 +363,13 @@ sub parmval_by_symb {
# --------------------------------------------------------- first, check course
if (defined($$courseopt{$courselevel})) {
- $outpar[14]=$$courseopt{$courselevel};
- $result=14;
+ $outpar[14]=$$courseopt{$courselevel};
+ $result=14;
}
if (defined($$courseopt{$courselevelm})) {
- $outpar[13]=$$courseopt{$courselevelm};
- $result=13;
+ $outpar[13]=$$courseopt{$courselevelm};
+ $result=13;
}
# ------------------------------------------------------- second, check default
@@ -164,32 +378,32 @@ sub parmval_by_symb {
# ------------------------------------------------------ third, check map parms
- my $thisparm=$parmhash{$symbparm};
+ my $thisparm=&parmhash($symbparm);
if (defined($thisparm)) { $outpar[11]=$thisparm; $result=11; }
if (defined($$courseopt{$courselevelr})) {
- $outpar[10]=$$courseopt{$courselevelr};
- $result=10;
+ $outpar[10]=$$courseopt{$courselevelr};
+ $result=10;
}
# ------------------------------------------------------ fourth, back to course
- if (defined($csec)) {
+ if ($csec ne '') {
if (defined($$courseopt{$seclevel})) {
- $outpar[9]=$$courseopt{$seclevel};
- $result=9;
- }
+ $outpar[9]=$$courseopt{$seclevel};
+ $result=9;
+ }
if (defined($$courseopt{$seclevelm})) {
- $outpar[8]=$$courseopt{$seclevelm};
- $result=8;
- }
+ $outpar[8]=$$courseopt{$seclevelm};
+ $result=8;
+ }
if (defined($$courseopt{$seclevelr})) {
- $outpar[7]=$$courseopt{$seclevelr};
- $result=7;
- }
+ $outpar[7]=$$courseopt{$seclevelr};
+ $result=7;
+ }
}
# ------------------------------------------------------ fifth, check course group
- if (defined($cgroup)) {
+ if ($cgroup ne '') {
if (defined($$courseopt{$grplevel})) {
$outpar[6]=$$courseopt{$grplevel};
$result=6;
@@ -206,96 +420,129 @@ sub parmval_by_symb {
# ---------------------------------------------------------- fifth, check user
- if (defined($uname)) {
- 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;
- }
+ 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;
+ }
}
return ($result,@outpar);
}
-sub resetparmhash {
- $parmhashid='';
+
+
+# --- Caches local to lonparmset
+
+
+sub reset_caches {
+ &resetparmhash();
+ &resetsymbcache();
+ &resetrulescache();
}
-sub cacheparmhash {
+{
+ my $parmhashid;
+ my %parmhash;
+ sub resetparmhash {
+ undef($parmhashid);
+ undef(%parmhash);
+ }
+
+ sub cacheparmhash {
if ($parmhashid eq $env{'request.course.fn'}) { return; }
my %parmhashfile;
if (tie(%parmhashfile,'GDBM_File',
- $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
- %parmhash=%parmhashfile;
- untie %parmhashfile;
- $parmhashid=$env{'request.course.fn'};
+ $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
+ %parmhash=%parmhashfile;
+ untie(%parmhashfile);
+ $parmhashid=$env{'request.course.fn'};
+ }
}
-}
-sub resetsymbcache {
- $symbsid='';
-}
+ sub parmhash {
+ my ($id) = @_;
+ &cacheparmhash();
+ return $parmhash{$id};
+ }
+ }
-sub symbcache {
+{
+ my $symbsid;
+ my %symbs;
+ sub resetsymbcache {
+ undef($symbsid);
+ undef(%symbs);
+ }
+
+ sub symbcache {
my $id=shift;
if ($symbsid ne $env{'request.course.id'}) {
- %symbs=();
+ undef(%symbs);
}
- unless ($symbs{$id}) {
- my $navmap = Apache::lonnavmaps::navmap->new();
- if ($id=~/\./) {
- my $resource=$navmap->getById($id);
- $symbs{$id}=$resource->symb();
- } else {
- my $resource=$navmap->getByMapPc($id);
- $symbs{$id}=&Apache::lonnet::declutter($resource->src());
- }
- $symbsid=$env{'request.course.id'};
+ 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 resetrulescache {
- $rulesid='';
-}
+{
+ my $rulesid;
+ my %rules;
+ sub resetrulescache {
+ undef($rulesid);
+ undef(%rules);
+ }
-sub rulescache {
+ sub rulescache {
my $id=shift;
- if ($rulesid ne $env{'request.course.id'}) {
- %rules=();
- }
- unless (defined($rules{$id})) {
- my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
- %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
- $rulesid=$env{'request.course.id'};
+ 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};
+ }
}
+
+
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'));
+ return (&rulescache($type.'_hours'),
+ &rulescache($type.'_min'),
+ &rulescache($type.'_sec'),
+ &rulescache($type.'_value'));
} else {
# nothing there or something else
- return ('','','','','');
+ return ('','','','','');
}
}
-##################################################
+
+
sub date_sanity_info {
my $checkdate=shift;
@@ -304,14 +551,31 @@ 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('');
+ $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
-
-##################################################
-##################################################
-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');
- }
- # 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;...;*;...),...)',
- 'comment.email' => ''.&mt('Feedback Addresses for Course Content Comments').' '.
- '(user:domain,user:domain(section;section;...;*;...),...)',
- 'policy.email' => ''.&mt('Feedback Addresses for Course Policy').''.
- ' (user:domain,user:domain(section;section;...;*;...),...)',
- '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.'),
-
- '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'
- => 'Print header format; substitutions: %n student name %c course id %a assignment',
- 'anonymous_quiz'
- => ''.&mt('Anonymous quiz/exam').' '.
- ' ('.&mt('yes').' '.&mt('to avoid print students names').' )',
- '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. [_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').''
- );
- my @Display_Order = ('url','description','courseid','cloners','grading',
- 'externalsyllabus',
- 'default_xml_style','pageseparators',
- 'question.email','comment.email','policy.email',
- 'student_classlist_view',
- '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',
- '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_page());
+ ''.
+ '');
+ $r->print(&Apache::loncommon::end_page());
+}
+
+sub date_shift_one {
+ my ($r) = @_;
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $sec = $env{'request.course.sec'};
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
+ text=>"Shifting Dates"});
+ my $submit_text = &mt('Shift all dates accordingly');
+ if ($sec ne '') {
+ my @groups;
+ if ($env{'request.course.groups'} ne '') {
+ @groups = split(/:/,$env{'request.course.groups'});
+ }
+ if (@groups) {
+ $submit_text = &mt("Shift dates set just for your section/group(s), accordingly");
+ } else {
+ $submit_text = &mt("Shift dates set just for your section, accordingly");
+ }
+ }
+ my $start_page=&Apache::loncommon::start_page('Shift Dates');
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
+ $r->print($start_page.$breadcrumbs);
+ $r->print('');
+ $r->print(&Apache::loncommon::end_page());
+}
+
+sub date_shift_two {
+ my ($r) = @_;
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $sec = $env{'request.course.sec'};
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
+ text=>"Shifting Dates"});
+ my $start_page=&Apache::loncommon::start_page('Shift Dates');
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
+ $r->print($start_page.$breadcrumbs);
+ my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
+ $r->print('
'.&mt('Shift Dates').'
');
+ if ($sec ne '') {
+ my @groups;
+ if ($env{'request.course.groups'} ne '') {
+ @groups = split(/:/,$env{'request.course.groups'});
+ }
+ if (@groups) {
+ $r->print('
'.
+ &mt("Shift dates set just for your section/group(s), such that [_1] becomes [_2]",
+ &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+ &Apache::lonlocal::locallocaltime($timeshifted)).
+ '
');
+ } else {
+ $r->print('
'.
+ &mt("Shift dates set just for your section, such that [_1] becomes [_2]",
+ &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+ &Apache::lonlocal::locallocaltime($timeshifted)).
+ '
');
+ }
+ } else {
+ $r->print('
'.&mt('Shifting all dates such that [_1] becomes [_2]',
+ &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+ &Apache::lonlocal::locallocaltime($timeshifted)).
+ '
');
+ }
+ my $delta=$timeshifted-$env{'form.timebase'};
+ my $numchanges = 0;
+ my $result = &dateshift($delta,\$numchanges);
+ if ($result eq 'ok') {
+ $r->print(
+ &Apache::lonhtmlcommon::confirm_success(&mt('Completed shifting of [quant,_1,date setting]',
+ $numchanges)));
+ } elsif ($result eq 'con_delayed') {
+ $r->print(
+ &Apache::lonhtmlcommon::confirm_success(&mt('Queued shifting of [quant,_1,date setting]',
+ $numchanges)));
+ } else {
+ $r->print(
+ &Apache::lonhtmlcommon::confirm_success(&mt('An error occurred attempting to shift dates'),1));
+ }
+ $r->print(
+ '
'.
+ &Apache::lonhtmlcommon::actionbox(
+ [''.&mt('Content and Problem Settings').'']));
+ $r->print(&Apache::loncommon::end_page());
}
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\:(\w+)\:(\w+)/) {
- $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;
- }
-}
-
-
-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);
- }
- }
- }
- }
- }
- }
+sub header {
+ return &Apache::loncommon::start_page('Content and Problem Settings');
}
-##################################################
-##################################################
-
-=pod
-
-=item * header
-
-Output html header for page
-
-=cut
-##################################################
-##################################################
-sub header {
- return &Apache::loncommon::start_page('Parameter Manager');
-}
-##################################################
-##################################################
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);
+
$r->print(<
@@ -3111,82 +4101,124 @@ ENDMAINFORMHEAD
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
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',
+ ( { 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 => 'Set Portfolio Metadata',
- action => 'setrestrictmeta',
- permission => $parm_permission,
+ { linktext => $linktext{'resettimes'},
+ url => $url{'resettimes'},
+ permission => ($vgr || $mgr),
+ linktitle => $linktitle{'resettimes'},
+ icon => 'start-here.png',
},
- { text => 'Manage Course Slots',
- url => '/adm/slotrequest?command=showslots',
- permission => $vgr,
+ { 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',
- },
- { text => 'Set/Modify Resource Parameters - Overview Mode',
- action => 'newoverview',
- permission => $parm_permission,
- help => 'Parameter_Overview',
+ permission => $parm_permission->{'helper'},
+ linktitle =>'Set/Modify resource parameters in helper mode.' ,
+ icon => 'dialog-information.png' ,
+ #help => 'Parameter_Helper',
},
- { text => 'Set/Modify Resource Parameters - Table Mode',
- action => 'settable',
- permission => $parm_permission,
- help => 'Table_Mode',
+ { linktext => $linktext{'newoverview'},
+ url => '/adm/parmset?action=newoverview',
+ permission => $parm_permission->{'newoverview'},
+ linktitle => $linktitle{'newoverview'},
+ icon => 'edit-find.png',
+ #help => 'Parameter_Overview',
},
- { 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(''.&Apache::loncommon::end_page());
return;
}
-### Set portfolio metadata
+
+
+
sub output_row {
my ($r, $field_name, $field_text, $added_flag) = @_;
my $output;
@@ -3197,58 +4229,229 @@ sub output_row {
$values = '';
}
if (!($options =~ /deleted/)) {
- $output.=''.$field_text.':';
- $output.=' ';
-
my @options= ( ['active', 'Show to student'],
- ['onlyone','Student may select only one choice'],
- ['stuadd', 'Student may type choices']);
+ ['stuadd', 'Provide text area for students to type metadata'],
+ ['choices','Provide choices for students to select from']);
+# ['onlyone','Student may select only one choice']);
if ($added_flag) {
push @options,['deleted', 'Delete Metadata Field'];
}
+ $output = &Apache::loncommon::start_data_table_row();
+ $output .= '