--- loncom/interface/lonparmset.pm 2018/09/03 16:43:47 1.585
+++ loncom/interface/lonparmset.pm 2020/10/29 23:24:13 1.597
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.585 2018/09/03 16:43:47 raeburn Exp $
+# $Id: lonparmset.pm,v 1.597 2020/10/29 23:24:13 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -976,7 +976,6 @@ sub storeparm_by_symb_inner {
#
# @param {string} $value - the parameter value
# @param {string} $type - the parameter type
-# @param {string} $name - the parameter name (unused)
# @param {boolean} $editable - Set to true to get an icon when no value is defined.
sub valout {
my ($value,$type,$name,$editable)=@_;
@@ -1065,13 +1064,18 @@ sub valout {
# @param {string} $marker - identifier for the parameter, "resource id&part_parameter name&level", will be passed as pres_marker when the user submits a change.
# @param {string} $return - prefix for the name of the form and field names that will be used to submit the form ('parmform.pres')
# @param {string} $call - javascript function to call to submit the form ('psub')
-# @param {boolean} $recursive - true if link is for a map/folder where parameter is currently set to be recursive.
+# @param {boolean} $recursive - true if link is for a map/folder where parameter is currently set to be recursive.
+# @param {string} $extra - optional additional information to send as tenth arg in call to javascript pjump function.
sub plink {
- my ($type,$dis,$value,$marker,$return,$call,$recursive)=@_;
+ my ($type,$dis,$value,$marker,$return,$call,$recursive,$extra)=@_;
my $winvalue=$value;
unless ($winvalue) {
- if (&isdateparm($type)) {
+ if (&isdateparm($type) || (&is_specialstring($type))) {
$winvalue=$env{'form.recent_'.$type};
+ } elsif ($type eq 'string_yesno') {
+ if ($env{'form.recent_string'} =~ /^(yes|no)$/i) {
+ $winvalue=$env{'form.recent_string'};
+ }
} else {
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
}
@@ -1079,16 +1083,16 @@ sub plink {
my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/);
my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
unless (defined($winvalue)) { $winvalue=$val; }
- my $valout = &valout($value,$type,$parmname,1);
+ my $valout = &valout($value,$type,1);
my $unencmarker = $marker;
foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call,
- \$hour, \$min, \$sec) {
+ \$hour, \$min, \$sec, \$extra) {
$$item = &HTML::Entities::encode($$item,'"<>&');
$$item =~ s/\'/\\\'/g;
}
return '
');
}
$r->print('');
@@ -1666,10 +1869,11 @@ sub print_row {
# @param {hash reference} $display - parameter key -> full title for the parameter
# @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters
# @param {boolean} $readonly -true if editing not allowed.
-# @param {boolean} $ismaplevel - true if level is for a map.
+# @param {boolean} $ismaplevel - true if level is for a map.
+# @param {string} $extra - extra information to pass to plink.
sub print_td {
my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,
- $noeditgrp,$readonly,$ismaplevel)=@_;
+ $noeditgrp,$readonly,$ismaplevel,$extra)=@_;
my ($ineffect,$recursive,$currval,$currtype,$currlevel);
$ineffect = 0;
$currval = $$outpar[$which];
@@ -1719,11 +1923,12 @@ sub print_td {
}
if ($nolink) {
my ($parmname)=((split(/\&/,$mprefix))[1]=~/\_([^\_]+)$/);
- $r->print(&valout($currval,$currtype,$parmname));
+ $r->print(&valout($currval,$currtype));
} else {
$r->print(&plink($currtype,
$$display{$value},$currval,
- $mprefix.$currlevel,'parmform.pres','psub',$recursive));
+ $mprefix.$currlevel,'parmform.pres','psub',$recursive,
+ $extra));
}
$r->print(''."\n");
}
@@ -1758,7 +1963,7 @@ sub check_other_groups {
if ($result > 3) {
$bgcolor = '#AAFFAA';
}
- $grp_parm = &valout($coursereply,$resulttype,$parmname);
+ $grp_parm = &valout($coursereply,$resulttype);
$output = '
';
if ($resultgroup && $resultlevel) {
if ($resultlevel eq 'recursive') {
@@ -1966,6 +2171,14 @@ sub isdateparm {
return (($type=~/^date/) && (!($type eq 'date_interval')));
}
+# Determine if parameter type is specialized string type (i.e.,
+# not just string or string_yesno.
+
+sub is_specialstring {
+ my $type=shift;
+ return (($type=~/^string_/) && (($type ne 'string_yesno')));
+}
+
# Prints the HTML and Javascript to select parameters, with various shortcuts.
#
# @param {Apache2::RequestRec} $r - the Apache request
@@ -2101,6 +2314,7 @@ sub lookUpTableParameter {
'buttonshide' => 'hiding',
'turnoffeditor' => 'hiding',
'encrypturl' => 'hiding',
+ 'deeplink' => 'hiding',
'randomorder' => 'high_level_randomization',
'randompick' => 'high_level_randomization',
'available' => 'slots',
@@ -2310,9 +2524,37 @@ sub partmenu {
sub usermenu {
my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups,$pssymb)=@_;
my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
- &Apache::loncommon::selectstudent_link('parmform','uname','udom');
- my $selscript=&Apache::loncommon::studentbrowser_javascript();
+ &Apache::loncommon::selectstudent_link('parmform','uname','udom','condition').
+ &Apache::lonhtmlcommon::scripttag(<'.
+ $stuonly.' '.
+ '';
my $sections='';
my %sectionhash = &Apache::loncommon::get_sections();
@@ -2379,7 +2621,7 @@ function group_or_section(caller) {
}
if (%grouphash) {
- $groups=&mt('Group:').'
'.
''.
''.
- '');
+ '');
&endSettingsScreen($r);
$r->print(&Apache::loncommon::end_page());
}
@@ -5587,6 +6152,7 @@ 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"});
@@ -5595,14 +6161,47 @@ sub date_shift_two {
$r->print($start_page.$breadcrumbs);
&startSettingsScreen($r,'parmset',$crstype);
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)).'
');
+ $r->print('
'.&mt('Shift Dates').'
');
+ if ($sec ne '') {
+ my @groups;
+ if ($env{'request.course.groups'} ne '') {
+ @groups = split(/:/,$env{'request.course.groups'});
+ }
+ if (@groups) {
+ $r->print('
'.
+ &mt("Shift dates set just for your section/group(s), such that [_1] becomes [_2]",
+ &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+ &Apache::lonlocal::locallocaltime($timeshifted)).
+ '
');
+ } else {
+ $r->print('
'.
+ &mt("Shift dates set just for your section, such that [_1] becomes [_2]",
+ &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+ &Apache::lonlocal::locallocaltime($timeshifted)).
+ '
');
+ }
+ } else {
+ $r->print('
'.&mt('Shifting all dates such that [_1] becomes [_2]',
+ &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
+ &Apache::lonlocal::locallocaltime($timeshifted)).
+ '
');
+ }
my $delta=$timeshifted-$env{'form.timebase'};
- &dateshift($delta);
+ 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::confirm_success(&mt('Done')).
'
'.
&Apache::lonhtmlcommon::actionbox(
[''.&mt('Content and Problem Settings').'']));
@@ -5975,7 +6574,7 @@ sub continue {
my $output;
$output .= '');
}
- $r->print('Or you may enter a new metadata field name.'.
+ $r->print(''.
+ &mt('[_1]Or[_2] you may enter a new metadata field name.',
+ '','').
'');
}
&endSettingsScreen($r);
@@ -6058,6 +6667,11 @@ sub setrestrictmeta {
&startSettingsScreen($r,'parmset',$crstype);
my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
my $save_field = '';
+ my %lt = &Apache::lonlocal::texthash(
+ addm => 'Add Metadata Field',
+ ordm => 'Order Metadata Fields',
+ save => 'Save',
+ );
if ($env{'form.restrictmeta'}) {
foreach my $field (sort(keys(%env))) {
if ($field=~m/^form.(.+)_(.+)$/) {
@@ -6096,28 +6710,25 @@ sub setrestrictmeta {
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))) {
if ($field ne 'courserestricted') {
- $row_alt = $row_alt ? 0 : 1;
- $output.= &output_row($r, $field, $metadata_fields{$field});
+ $output.= &output_row($r,$field,$metadata_fields{$field});
}
}
my $buttons = (<
+