--- loncom/interface/lonparmset.pm 2006/06/23 05:56:35 1.317
+++ loncom/interface/lonparmset.pm 2015/03/12 02:44:51 1.522.2.17
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.317 2006/06/23 05:56:35 albertel Exp $
+# $Id: lonparmset.pm,v 1.522.2.17 2015/03/12 02:44:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -44,46 +44,9 @@ This module sets coursewide and assessme
=head1 INTERNAL SUBROUTINES
-=over 4
-
-=cut
+=over
-###################################################################
-###################################################################
-
-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
-
-=item parmval
+=item parmval()
Figure out a cascading parameter.
@@ -108,9 +71,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 print_usergroups()
+
+=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 +331,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 +362,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 +377,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 +419,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};
+ }
+ }
+
+{
+ my $symbsid;
+ my %symbs;
+ sub resetsymbcache {
+ undef($symbsid);
+ undef(%symbs);
+ }
-sub symbcache {
+ 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 +550,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])',
- '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',
- '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().
- '
');
$r->print('');
@@ -2753,19 +3466,20 @@ ENDOVER
if (($env{'form.store'}) || ($env{'form.dis'})) {
- if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
+ if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
# Read modified data
- my $resourcedata=&readdata($crs,$dom);
+ my $resourcedata=&readdata($crs,$dom);
# List data
- &listdata($r,$resourcedata,$listdata,$sortorder);
+ &listdata($r,$resourcedata,$listdata,$sortorder);
}
$r->print(&tableend().
- ((($env{'form.store'}) || ($env{'form.dis'}))?'':'').
- ''.&Apache::loncommon::end_page());
+ ((($env{'form.store'}) || ($env{'form.dis'}))?'':'').
+ '');
+ $r->print(&Apache::loncommon::end_page());
}
sub secgroup_lister {
@@ -2808,13 +3522,13 @@ sub overview {
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
+ text=>"Overview Mode"});
my $start_page=&Apache::loncommon::start_page('Modify Parameters');
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
- $r->print(<
-ENDOVER
+ $r->print($start_page.$breadcrumbs);
+ $r->print(''.
- &Apache::loncommon::end_page());
+ ($foundkeys?'':''.&mt('There are no parameters.').'').''.
+ &Apache::loncommon::end_page());
}
-##################################################
-##################################################
-
-=pod
+sub clean_parameters {
+ my ($r) = @_;
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
-=item check_cloners
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
+ text=>"Clean Parameters"});
+ my $start_page=&Apache::loncommon::start_page('Clean Parameters');
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean');
+ $r->print(<
+ENDOVER
+# Store modified
-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.
+ &storedata($r,$crs,$dom);
-=cut
-
-##################################################
-##################################################
+# Read modified data
-sub extract_cloners {
- my ($clonelist,$allowclone) = @_;
- if ($clonelist =~ /,/) {
- @{$allowclone} = split/,/,$clonelist;
- } else {
- $$allowclone[0] = $clonelist;
- }
-}
+ my $resourcedata=&readdata($crs,$dom);
+# List data
-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.',';
+ $r->print('
'.
+ &mt('These parameters refer to resources that do not exist.').
+ '
');
+ $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'};
-##################################################
-##################################################
+ &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);
+ $r->print('');
+ $r->print(&Apache::loncommon::end_page());
+}
-=pod
+sub date_shift_two {
+ my ($r) = @_;
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ &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').'
'.
+ '
'.&mt('Shifting all dates such that [_1] becomes [_2]',
+ &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+ &Apache::lonlocal::locallocaltime($timeshifted)).'
');
+ return 'ok';
+}
+
+
+sub continue {
+ my $output;
+ $output .= '');
+ }
+ $r->print('Or you may enter a new metadata field name.');
+}
+
+
+
sub setrestrictmeta {
my ($r)=@_;
my $next_meta;
my $output;
my $item_num;
my $put_result;
-
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
+ text=>"Restrict Metadata"});
$r->print(&Apache::loncommon::start_page('Restrict Metadata'));
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -3112,15 +4054,21 @@ sub setrestrictmeta {
my $meta_key = $2;
if ($save_field ne $meta_field) {
$save_field = $meta_field;
- if ($env{'form.'.$meta_field.'_stuadd'}) {
- $options.='stuadd,';
- }
- if ($env{'form.'.$meta_field.'_onlyone'}) {
- $options.='onlyone,';
- }
- if ($env{'form.'.$meta_field.'_active'}) {
- $options.='active,';
- }
+ if ($env{'form.'.$meta_field.'_stuadd'}) {
+ $options.='stuadd,';
+ }
+ if ($env{'form.'.$meta_field.'_choices'}) {
+ $options.='choices,';
+ }
+ if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
+ $options.='onlyone,';
+ }
+ if ($env{'form.'.$meta_field.'_active'}) {
+ $options.='active,';
+ }
+ if ($env{'form.'.$meta_field.'_deleted'}) {
+ $options.='deleted,';
+ }
my $name = $save_field;
$put_result = &Apache::lonnet::put('environment',
{'metadata.'.$meta_field.'.options'=>$options,
@@ -3131,37 +4079,86 @@ sub setrestrictmeta {
}
}
&Apache::lonnet::coursedescription($env{'request.course.id'},
- {'freshen_cache' => 1});
+ {'freshen_cache' => 1});
+ # Get the default metadata fields
my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
+ # Now get possible added metadata fields
+ my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
+ my $row_alt = 1;
+ $output .= &Apache::loncommon::start_data_table();
foreach my $field (sort(keys(%metadata_fields))) {
- &Apache::lonnet::logthis ($field);
if ($field ne 'courserestricted') {
- $output.= &output_row($r, $field, $metadata_fields{$field});
- }
+ $row_alt = $row_alt ? 0 : 1;
+ $output.= &output_row($r, $field, $metadata_fields{$field});
+ }
}
- $r->print(<
+
+
+
+
ENDenv
$r->print(&Apache::loncommon::end_page());
return 'ok';
}
-##################################################
+
+
+sub get_added_meta_fieldnames {
+ my ($cid) = @_;
+ my %fields;
+ foreach my $key(%env) {
+ if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
+ my $field_name = $1;
+ my ($display_field_name) = $env{$key};
+ $fields{$field_name} = $display_field_name;
+ }
+ }
+ return \%fields;
+}
+
+
+
+sub get_deleted_meta_fieldnames {
+ my ($cid) = @_;
+ my %fields;
+ foreach my $key(%env) {
+ if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
+ my $field_name = $1;
+ if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
+ my ($display_field_name) = $env{$key};
+ $fields{$field_name} = $display_field_name;
+ }
+ }
+ }
+ return \%fields;
+}
sub defaultsetter {
my ($r) = @_;
- my $start_page =
- &Apache::loncommon::start_page('Parameter Setting Default Actions');
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
+ text=>"Set Defaults"});
+ my $start_page =
+ &Apache::loncommon::start_page('Parameter Setting Default Actions');
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
- $r->print(<
-ENDDEFHEAD
+ $r->print($start_page.$breadcrumbs);
+ $r->print('\n".
- &Apache::loncommon::end_page());
+ $r->print(''.&Apache::loncommon::end_data_table_row());
+ }
+ $r->print(&Apache::loncommon::end_data_table().
+ "\n".''."\n");
+ $r->print(&Apache::loncommon::end_page());
return;
}
sub components {
- my ($key,$uname,$udom,$exeuser,$exedomain)=@_;
- my $typeflag=0;
- if ($key=~/\.type$/) {
- $key=~s/\.type$//;
- $typeflag=1;
+ my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
+
+ if ($typeflag) {
+ $key=~s/\.type$//;
}
+
+ my ($middle,$part,$name)=
+ ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
my $issection;
- my ($middle,$part,$name)=($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
+
my $section=&mt('All Students');
if ($middle=~/^\[(.*)\]/) {
- $issection=$1;
- $section=&mt('Group/Section').': '.$issection;
- $middle=~s/^\[(.*)\]//;
+ $issection=$1;
+ $section=&mt('Group/Section').': '.$issection;
+ $middle=~s/^\[(.*)\]//;
}
$middle=~s/\.+$//;
$middle=~s/^\.+//;
if ($uname) {
- $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
- $issection='';
+ $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
+ $issection='';
}
my $realm=''.&mt('All Resources').'';
- my $realmdescription=&mt('all resources');
+ my $realmdescription=&mt('all resources');
if ($middle=~/^(.+)\_\_\_\(all\)$/) {
- $realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' ('.$1.')';
- $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
+ $realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' ('.$1.')';
+ $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
} elsif ($middle) {
- my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
- $realm=''.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' ('.$url.' in '.$map.' id: '.$id.')';
- $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
+ my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
+ $realm=''.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' ('.$url.' in '.$map.' id: '.$id.')';
+ $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
}
my $what=$part.'.'.$name;
- return ($realm,$section,$name,$part,$typeflag,
- $what,$middle,$uname,$udom,$issection,$realmdescription);
+ return ($realm,$section,$name,$part,
+ $what,$middle,$uname,$udom,$issection,$realmdescription);
+}
+
+my %standard_parms;
+my %standard_parms_types;
+
+sub load_parameter_names {
+ open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
+ while (my $configline=<$config>) {
+ if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
+ chomp($configline);
+ my ($short,$plain)=split(/:/,$configline);
+ my (undef,$name,$type)=split(/\&/,$short,3);
+ if ($type eq 'display') {
+ $standard_parms{$name} = $plain;
+ } elsif ($type eq 'type') {
+ $standard_parms_types{$name} = $plain;
+ }
+ }
+ close($config);
+ $standard_parms{'int_pos'} = 'Positive Integer';
+ $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
}
sub standard_parameter_names {
my ($name)=@_;
- my %standard_parms=&Apache::lonlocal::texthash('duedate' => 'Due Date',
- 'answerdate' => 'Answer Date',
- 'opendate' => 'Open Date',
- 'maxtries' => 'Max. Number of Tries',
- 'weight' => 'Weight',
- 'date_start' => 'Starting Date',
- 'date_end' => 'Ending Date',
- 'interval' => 'Time Interval Length',
- 'tol' => 'Numerical Tolerance',
- 'sig' => 'Significant Digits',
- 'contentopen' => 'Content Opening Date',
- 'contentclose' => 'Content Closing Date',
- 'discussend' => 'End of Discussion Time',
- 'discusshide' => 'Discussion Hidden',
- 'problemstatus' => 'Problem Status Visible',
- 'int_pos' => 'Positive Integer',
- 'int_zero_pos' => 'Positive Integer or Zero',
- 'hinttries' => 'Number of Tries till Hints appear',
- 'numbubbles' => 'Number of Bubbles in Exam Mode');
+ if (!%standard_parms) {
+ &load_parameter_names();
+ }
if ($standard_parms{$name}) {
- return $standard_parms{$name};
- } else {
- return $name;
+ return $standard_parms{$name};
+ } else {
+ return $name;
}
}
-#
-# Parameter Change Log
-#
-
+sub standard_parameter_types {
+ my ($name)=@_;
+ if (!%standard_parms_types) {
+ &load_parameter_names();
+ }
+ if ($standard_parms_types{$name}) {
+ return $standard_parms_types{$name};
+ }
+ return;
+}
sub parm_change_log {
my ($r)=@_;
- &startpage($r);
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
+ text=>"Parameter Change Log"});
+ my $js = ''."\n";
+ $r->print(&Apache::loncommon::start_page('Parameter Change Log',$js));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'});
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
- $r->print('');
$r->print(&Apache::loncommon::end_page());
}
-##################################################
-##################################################
+sub update_slots {
+ my ($slot_name,$cdom,$cnum,$symb,$uname,$udom) = @_;
+ my %slot=&Apache::lonnet::get_slot($slot_name);
+ if (!keys(%slot)) {
+ return 'error: slot does not exist';
+ }
+ my $max=$slot{'maxspace'};
+ if (!defined($max)) { $max=99999; }
+
+ my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum,
+ "^$slot_name\0");
+ my ($tmp)=%consumed;
+ if ($tmp=~/^error: 2 / ) {
+ return 'error: unable to determine current slot status';
+ }
+ my $last=0;
+ foreach my $key (keys(%consumed)) {
+ my $num=(split('\0',$key))[1];
+ if ($num > $last) { $last=$num; }
+ if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
+ return 'ok';
+ }
+ }
-=pod
+ if (scalar(keys(%consumed)) >= $max) {
+ return 'error: no space left in slot';
+ }
+ my $wanted=$last+1;
-=item * handler
+ my %reservation=('name' => $uname.':'.$udom,
+ 'timestamp' => time,
+ 'symb' => $symb);
+
+ my $success=&Apache::lonnet::newput('slot_reservations',
+ {"$slot_name\0$wanted" =>
+ \%reservation},
+ $cdom, $cnum);
+ if ($success eq 'ok') {
+ my %storehash = (
+ symb => $symb,
+ slot => $slot_name,
+ action => 'reserve',
+ context => 'parameter',
+ );
+ &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
+ '',$uname,$udom,$cnum,$cdom);
+
+ &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
+ '',$uname,$udom,$uname,$udom);
+ }
+ return $success;
+}
+
+sub delete_slots {
+ my ($slot_name,$cdom,$cnum,$uname,$udom,$symb) = @_;
+ my $delresult;
+ my %consumed = &Apache::lonnet::dump('slot_reservations',$cdom,
+ $cnum, "^$slot_name\0");
+ if (&Apache::lonnet::error(%consumed)) {
+ return 'error: unable to determine current slot status';
+ }
+ my ($tmp)=%consumed;
+ if ($tmp=~/^error: 2 /) {
+ return 'error: unable to determine current slot status';
+ }
+ foreach my $key (keys(%consumed)) {
+ if ($consumed{$key}->{'name'} eq $uname.':'.$udom) {
+ my $num=(split('\0',$key))[1];
+ my $entry = $slot_name.'\0'.$num;
+ $delresult = &Apache::lonnet::del('slot_reservations',[$entry],
+ $cdom,$cnum);
+ if ($delresult eq 'ok') {
+ my %storehash = (
+ symb => $symb,
+ slot => $slot_name,
+ action => 'release',
+ context => 'parameter',
+ );
+ &Apache::lonnet::write_log('course','slotreservationslog',\%storehash,
+ 1,$uname,$udom,$cnum,$cdom);
+ &Apache::lonnet::write_log('course',$cdom.'_'.$cnum.'_slotlog',\%storehash,
+ 1,$uname,$udom,$uname,$udom);
+ }
+ }
+ }
+ return $delresult;
+}
-Main handler. Calls &assessparms and &crsenv subroutines.
+sub check_for_course_info {
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ return 1 if ($navmap);
+ return 0;
+}
-=cut
-##################################################
-##################################################
-# use Data::Dumper;
+sub parameter_release_vars {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
+ my $chostname = &Apache::lonnet::hostname($chome);
+ my ($cmajor,$cminor) =
+ split(/\./,&Apache::lonnet::get_server_loncaparev($cdom,$chome));
+ return ($chostname,$cmajor,$cminor);
+}
+
+sub parameter_releasecheck {
+ my ($name,$value,$needsrelease,$cmajor,$cminor) = @_;
+ my $needsnewer;
+ my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
+ if (($cmajor < $needsmajor) ||
+ ($cmajor == $needsmajor && $cminor < $needsminor)) {
+ $needsnewer = 1;
+ } else {
+ &Apache::lonnet::update_released_required($Apache::lonnet::needsrelease{'parameter:'.$name.':'.$value});
+ }
+ return $needsnewer;
+}
+sub oldversion_warning {
+ my ($name,$value,$chostname,$cmajor,$cminor,$needsrelease) = @_;
+ my $desc;
+ my %stringtypes = (
+ type => 'string_questiontype',
+ lenient => 'string_lenient',
+ retrypartial => 'string_yesno',
+ discussvote => 'string_discussvote',
+ examcode => 'string_examcode',
+ );
+ if (exists($stringtypes{$name})) {
+ if ($name eq 'examcode') {
+ $desc = $value;
+ } elsif (ref($strings{$stringtypes{$name}}) eq 'ARRAY') {
+ foreach my $possibilities (@{ $strings{$stringtypes{$name}} }) {
+ next unless (ref($possibilities) eq 'ARRAY');
+ my ($parmval, $description) = @{ $possibilities };
+ if ($parmval eq $value) {
+ $desc = $description;
+ last;
+ }
+ }
+ }
+ } elsif (($name eq 'printstartdate') || ($name eq 'printenddate')) {
+ my $now = time;
+ if ($value =~ /^\d+$/) {
+ if ($name eq 'printstartdate') {
+ if ($value > $now) {
+ $desc = &Apache::lonlocal::locallocaltime($value);
+ }
+ } elsif ($name eq 'printenddate') {
+ if ($value < $now) {
+ $desc = &Apache::lonlocal::locallocaltime($value);
+ }
+ }
+ }
+ }
+ my $standard_name = &standard_parameter_names($name);
+ return '
'.
+ &mt('[_1] was [_2]not[_3] set to [_4].',
+ $standard_name,'','','"'.$desc.'"').' '.
+ &mt('LON-CAPA version ([_1]) installed on home server ([_2]) does not meet version requirements ([_3] or newer).',
+ $cmajor.'.'.$cminor,$chostname,
+ $needsrelease).
+ '