'."\n");
}
-sub print_usergroups {
- my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
+sub check_other_groups {
+ my ($what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
my $courseid = $env{'request.course.id'};
my $output;
my $symb = &symbcache($rid);
@@ -1127,7 +1574,6 @@ sub print_usergroups {
if (($coursereply) && ($cgroup ne $resultgroup)) {
if ($result > 3) {
$bgcolor = '#AAFFAA';
- $grp_parm = &valout($coursereply,$resulttype);
}
$grp_parm = &valout($coursereply,$resulttype);
$output = '
';
@@ -1195,23 +1641,27 @@ sub extractResourceInformation {
my $srcf=$resource->src();
$srcf=~/\.(\w+)$/;
$$typep{$id}=$1;
+ my $toolsymb;
+ if ($srcf =~ /ext\.tool$/) {
+ $toolsymb = $resource->symb();
+ }
$$keyp{$id}='';
$$uris{$id}=$srcf;
- foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
+ foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys',$toolsymb))) {
next if ($key!~/^parameter_/);
# Hidden parameters
- next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm');
+ next if (&Apache::lonnet::metadata($srcf,$key.'.hidden',$toolsymb) eq 'parm');
#
# allparms is a hash of parameter names
#
- my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
+ my $name=&Apache::lonnet::metadata($srcf,$key.'.name',$toolsymb);
if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) {
my ($display,$parmdis);
$display = &standard_parameter_names($name);
if ($display eq '') {
- $display= &Apache::lonnet::metadata($srcf,$key.'.display');
+ $display= &Apache::lonnet::metadata($srcf,$key.'.display',$toolsymb);
$parmdis = $display;
$parmdis =~ s/\s*\[Part.*$//g;
} else {
@@ -1220,14 +1670,14 @@ sub extractResourceInformation {
$$allparms{$name}=$parmdis;
if (ref($defkeytype)) {
$$defkeytype{$name}=
- &Apache::lonnet::metadata($srcf,$key.'.type');
+ &Apache::lonnet::metadata($srcf,$key.'.type',$toolsymb);
}
}
#
# allparts is a hash of all parts
#
- my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
+ my $part= &Apache::lonnet::metadata($srcf,$key.'.part',$toolsymb);
$$allparts{$part} = &mt('Part: [_1]',$part);
#
# Remember all keys going with this resource
@@ -1273,14 +1723,21 @@ 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'));
+}
+
#
# parmmenu displays a list of the selected parameters.
# It also offers a link to show/hide the complete parameter list
# from which you can select all desired parameters.
#
sub parmmenu {
- my ($r,$allparms,$pscat,$keyorder)=@_;
- my $tempkey;
+ my ($r)=@_;
$r->print(<
// print('');
- &shortCuts($r,$allparms,$pscat,$keyorder);
+ &shortCuts($r);
$r->print('');
}
# return a hash
@@ -1408,6 +1865,7 @@ sub lookUpTableParameter {
'buttonshide' => 'hiding',
'turnoffeditor' => 'hiding',
'encrypturl' => 'hiding',
+ 'deeplink' => 'hiding',
'randomorder' => 'high_level_randomization',
'randompick' => 'high_level_randomization',
'available' => 'slots',
@@ -1423,8 +1881,9 @@ sub lookUpTableParameter {
'lenient' => 'grading',
'retrypartial' => 'tries',
'discussvote' => 'misc',
+ 'texdisplay' => 'misc',
'examcode' => 'high_level_randomization',
- );
+ );
}
sub whatIsMyCategory {
@@ -1496,6 +1955,8 @@ sub parmboxes {
&whatIsMyCategory($tempparameter, \%categoryList);
}
#part to print the parm-list
+ $Text::Wrap::columns=60;
+ $Text::Wrap::separator=' ';
$r->print('
'."\n");
#Print parameters
@@ -1506,14 +1967,16 @@ sub parmboxes {
.&mt($categories{$key})
.''."\n");
foreach $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) {
+ next if ($tempkey eq '');
$r->print(''
.' '."\n");
}
$r->print("
\n");
@@ -1525,7 +1988,7 @@ sub parmboxes {
# This function offers some links on the parameter section to get with one click a group a parameters
#
sub shortCuts {
- my ($r,$allparms,$pscat,$keyorder)=@_;
+ my ($r)=@_;
# Parameter Selection
$r->print(
@@ -1584,21 +2047,60 @@ sub partmenu {
}
sub usermenu {
- my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_;
+ 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();
my $groups;
- my %grouphash = &Apache::longroup::coursegroups();
+ my %grouphash;
+ if (($pssymb) || &Apache::lonnet::allowed('mdg',$env{'request.course.id'})) {
+ %grouphash = &Apache::longroup::coursegroups();
+ } elsif ($env{'request.course.groups'} ne '') {
+ map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'});
+ }
my $g_s_header='';
my $g_s_footer='';
- if (%sectionhash) {
+ my $currsec = $env{'request.course.sec'};
+ if ($currsec) {
+ $sections=&mt('Section:').' '.$currsec;
+ if (%grouphash) {
+ $sections .= ';'.(' ' x2);
+ }
+ } elsif (%sectionhash && $currsec eq '') {
$sections=&mt('Section:').'
'."\n";
+ if ($table eq 'upper') {
+ $output .= ' ';
+ }
+ }
+ return $output;
+}
+
+{
+
my %strings =
(
'string_yesno'
@@ -3253,8 +4378,35 @@ my %strings =
=> [['yes','Yes'],
['notended','Yes, unless discussion ended'],
['no','No']],
+ 'string_ip'
+ => [['_allowfrom_','Hostname(s), or IP(s) from which access is allowed'],
+ ['_denyfrom_','Hostname(s) or IP(s) from which access is disallowed']],
+ 'string_deeplink'
+ => [['on','Set choices for link protection, resource listing, access scope, shown menu items, embedding, and exit link']],
+ 'string_tex'
+ => [['tth', 'tth (TeX to HTML)'],
+ ['mathjax', 'MathJax']],
);
+my %stringmatches = (
+ 'string_ip'
+ => [['_allowfrom_','[^\!]+'],
+ ['_denyfrom_','\!']],
+ 'string_deeplink'
+ => [['on','^(only|off|both)\,(hide|unhide)\,(full|absent|grades|details|datestatus)\,(res|map|rec)\,(none|key\:\w+|ltic\:\d+|ltid\:\d+)\,(\d+|)\,_(self|top),(yes|url|no)(|:[^:;\'",]+)$']],
+ );
+
+my %stringtypes = (
+ type => 'string_questiontype',
+ lenient => 'string_lenient',
+ retrypartial => 'string_yesno',
+ discussvote => 'string_discussvote',
+ examcode => 'string_examcode',
+ acc => 'string_ip',
+ deeplink => 'string_deeplink',
+ texdisplay => 'string_tex',
+ );
+
sub standard_string_options {
my ($string_type) = @_;
if (ref($strings{$string_type}) eq 'ARRAY') {
@@ -3263,6 +4415,14 @@ sub standard_string_options {
return;
}
+sub standard_string_matches {
+ my ($string_type) = @_;
+ if (ref($stringmatches{$string_type}) eq 'ARRAY') {
+ return $stringmatches{$string_type};
+ }
+ return;
+}
+
sub string_selector {
my ($thistype, $thiskey, $showval, $name, $readonly) = @_;
@@ -3293,6 +4453,12 @@ sub string_selector {
}
}
}
+
+ if ($thistype eq 'string_ip') {
+ return &string_ip_selector($thiskey,$showval,$readonly);
+ } elsif ($thistype eq 'string_deeplink') {
+ return &string_deeplink_selector($thiskey,$showval,$readonly);
+ }
my ($result,$disabled);
@@ -3347,14 +4513,76 @@ sub string_selector {
return $result;
}
+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).
+ '
';
+}
+
+}
+
#
# Shift all start and end dates by $shift
#
sub dateshift {
- my ($shift)=@_;
+ my ($shift,$numchanges)=@_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $sec = $env{'request.course.sec'};
+ my $secgrpregex;
+ if ($sec ne '') {
+ my @groups;
+ if ($env{'request.course.groups'} ne '') {
+ @groups = split(/:/,$env{'request.course.groups'});
+ }
+ if (@groups) {
+ $secgrpregex = '(?:'.join('|',($sec,@groups)).')';
+ } else {
+ $secgrpregex = $sec;
+ }
+ }
my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
# ugly retro fix for broken version of types
foreach my $key (keys %data) {
@@ -3369,7 +4597,11 @@ sub dateshift {
# go through all parameters and look for dates
foreach my $key (keys %data) {
if ($data{$key.'.type'}=~/^date_(start|end)$/) {
+ if ($sec ne '') {
+ next unless ($key =~ /^$env{'request.course.id'}\.\[$secgrpregex\]\./);
+ }
my $newdate=$data{$key}+$shift;
+ $$numchanges ++;
$storecontent{$key}=$newdate;
}
}
@@ -3403,6 +4635,10 @@ sub newoverview {
'.
&Apache::lonhtmlcommon::resize_scrollbox_js('params')."\n".
&showhide_js()."\n".
+ &validateparms_js()."\n".
+ &ipacc_boxes_js()."\n".
+ &done_proctor_js()."\n".
+ &deeplink_js()."\n".
'// ]]>
';
@@ -3411,7 +4647,7 @@ sub newoverview {
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
$r->print($start_page.$breadcrumbs);
$r->print(<
+
');
+ $r->print('');
+ if ($sectionselector) {
+ $r->print('
'.$sectionselector.'
');
+ }
+ if ($groupselector) {
+ $r->print('
'.$groupselector.'
');
+ }
+ $r->print('');
$r->print(&Apache::lonhtmlcommon::row_closure(1));
$r->print(&Apache::lonhtmlcommon::end_pick_box());
$r->print('');
@@ -3530,7 +4777,7 @@ ENDOVER
# List data
- &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly);
+ &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly,$parmlev);
}
$r->print(&tableend());
unless ($readonly) {
@@ -3579,16 +4826,25 @@ sub overview {
my ($r,$parm_permission) = @_;
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
+ my $js = ''."\n";
my $readonly = 1;
if ($parm_permission->{'edit'}) {
undef($readonly);
}
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
text=>"Overview Mode"});
- my $start_page=&Apache::loncommon::start_page('Modify Parameters');
+ my $start_page=&Apache::loncommon::start_page('Modify Parameters',$js);
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
$r->print($start_page.$breadcrumbs);
- $r->print('');
+ '');
$r->print(&Apache::loncommon::end_page());
}
@@ -3742,20 +5008,54 @@ 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').'
'.
- '
'.&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').'']));
@@ -3774,8 +5074,7 @@ sub parse_key {
$data{'scope_type'} = 'user';
$data{'scope'} = [$1,$2];
} else {
- #FIXME check for group scope
- $data{'scope_type'} = 'section';
+ $data{'scope_type'} = 'secgroup';
}
$middle=~s/^\[(.*)\]//;
}
@@ -4089,7 +5388,7 @@ sub continue {
my $output;
$output .= '');
}
- $r->print('Or you may enter a new metadata field name.');
}
@@ -4159,6 +5469,11 @@ sub setrestrictmeta {
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
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.(.+)_(.+)$/) {
@@ -4197,28 +5512,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});
}
}
my $buttons = (<
+