');
&parmmenu($r,\%allparms,\@pscat,\%keyorder);
- $r->print(' '.
- ''.&mt('Parts').' '.&mt('Section(s)').
- ' '.&mt('Group(s)').' ');
+ $r->print('
+ '.
+ ''.&mt('Parts').' '.&mt('Section(s)').
+ ' '.&mt('Group(s)').' ');
&partmenu($r,\%allparts,\@psprt);
- $r->print(' ');
+ $r->print(' ');
§ionmenu($r,\@selected_sections);
- $r->print(' ');
+ $r->print(' ');
&groupmenu($r,\@selected_groups);
$r->print('
');
$r->print('
');
@@ -2748,7 +3244,7 @@ ENDOVER
&listdata($r,$resourcedata,$listdata,$sortorder);
}
$r->print(&tableend().
- ((($env{'form.store'}) || ($env{'form.dis'}))?'
':'').
+ ((($env{'form.store'}) || ($env{'form.dis'}))?'
':'').
''.&Apache::loncommon::end_page());
}
@@ -2792,8 +3288,10 @@ 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(undef,'Overview');
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
$r->print(<'/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
+
+ &storedata($r,$crs,$dom);
+
+# Read modified data
+
+ my $resourcedata=&readdata($crs,$dom);
+
+# List data
+
+ $r->print(''.
+ &mt('These parameters refer to resources that do not exist.').
+ ' '.
+ ' '.' '.
+ ' ');
+ $r->print(&Apache::loncommon::start_data_table().
+ ''.
+ ''.&mt('Delete').' '.
+ ''.&mt('Parameter').' '.
+ ' ');
+ foreach my $thiskey (sort(keys(%{$resourcedata}))) {
+ next if (!exists($resourcedata->{$thiskey.'.type'})
+ && $thiskey=~/\.type$/);
+ my %data = &parse_key($thiskey);
+ if (1) { #exists($data{'realm_exists'})
+ #&& !$data{'realm_exists'}) {
+ $r->print(&Apache::loncommon::start_data_table_row().
+ ''.
+ ' ' );
+
+ $r->print('');
+ my $display_value = $resourcedata->{$thiskey};
+ if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
+ $display_value =
+ &Apache::lonlocal::locallocaltime($display_value);
+ }
+ $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
+ &standard_parameter_names($data{'parameter_name'}),
+ $resourcedata->{$thiskey}));
+ $r->print(' ');
+ if ($data{'scope_type'} eq 'all') {
+ $r->print(&mt('All users'));
+ } elsif ($data{'scope_type'} eq 'user') {
+ $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
+ } elsif ($data{'scope_type'} eq 'section') {
+ $r->print(&mt('Section: [_1]',$data{'scope'}));
+ } elsif ($data{'scope_type'} eq 'group') {
+ $r->print(&mt('Group: [_1]',$data{'scope'}));
+ }
+ $r->print(' ');
+ if ($data{'realm_type'} eq 'all') {
+ $r->print(&mt('All Resources'));
+ } elsif ($data{'realm_type'} eq 'folder') {
+ $r->print(&mt('Folder: [_1]'),$data{'realm'});
+ } elsif ($data{'realm_type'} eq 'symb') {
+ my ($map,$resid,$url) =
+ &Apache::lonnet::decode_symb($data{'realm'});
+ $r->print(&mt('Resource: [_1] with ID: [_2] in folder [_3]',
+ $url,$resid,$map));
+ }
+ $r->print(' '.&mt('Part: [_1]',$data{'parameter_part'}));
+ $r->print(' ');
+
+ }
+ }
+ $r->print(&Apache::loncommon::end_data_table().''.
+ ' '.
+ '
'.
+ &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(<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'};
+ &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(<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);
+ $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+)$/);
+ $data{'scope_type'} = 'all';
+ if ($middle=~/^\[(.*)\]/) {
+ $data{'scope'} = $1;
+ if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
+ $data{'scope_type'} = 'user';
+ $data{'scope'} = [$1,$2];
+ } else {
+ #FIXME check for group scope
+ $data{'scope_type'} = 'section';
+ }
+ $middle=~s/^\[(.*)\]//;
+ }
+ $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'});
+ } 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{'parameter_part'} = $part;
+ $data{'parameter_name'} = $name;
+
+ return %data;
+}
+
##################################################
##################################################
-
+
=pod
=item check_cloners
@@ -2853,48 +3524,63 @@ where $action is add or drop, and $clone
user for whom cloning ability is to be changed in course.
=cut
-
+
##################################################
##################################################
sub extract_cloners {
my ($clonelist,$allowclone) = @_;
if ($clonelist =~ /,/) {
- @{$allowclone} = split/,/,$clonelist;
+ @{$allowclone} = split(/,/,$clonelist);
} else {
$$allowclone[0] = $clonelist;
}
}
-
sub check_cloners {
my ($clonelist,$oldcloner) = @_;
- my ($clean_clonelist,$disallowed);
+ 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.',';
+ if (!grep(/^\Q$currclone\E$/,@$oldcloner)) {
+ if ($currclone eq '*') {
+ $clean_clonelist .= $currclone.',';
+ } else {
+ my ($uname,$udom) = split(/:/,$currclone);
+ if ($uname eq '*') {
+ if ($udom =~ /^$match_domain$/) {
+ if (!&Apache::lonnet::domain($udom)) {
+ $disallowed{'domain'} .= $currclone.',';
+ } else {
+ $clean_clonelist .= $currclone.',';
+ }
+ } else {
+ $disallowed{'format'} .= $currclone.',';
+ }
+ } elsif ($currclone !~/^($match_username)\:($match_domain)$/) {
+ $disallowed{'format'} .= $currclone.',';
} else {
- $clean_clonelist .= $currclone.',';
+ if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
+ $disallowed{'newuser'} .= $currclone.',';
+ } else {
+ $clean_clonelist .= $currclone.',';
+ }
}
}
} else {
$clean_clonelist .= $currclone.',';
}
}
- if ($disallowed) {
- $disallowed =~ s/,$//;
+ foreach my $key (keys(%disallowed)) {
+ $disallowed{$key} =~ s/,$//;
}
if ($clean_clonelist) {
$clean_clonelist =~ s/,$//;
}
$$clonelist = $clean_clonelist;
- return $disallowed;
-}
+ return %disallowed;
+}
sub change_clone {
my ($clonelist,$oldcloner) = @_;
@@ -2907,43 +3593,47 @@ sub change_clone {
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;
+ if (!grep(/^$currclone$/,@$oldcloner)) {
+ if ($currclone ne '*') {
+ ($uname,$udom) = split(/:/,$currclone);
+ if ($uname && $udom && $uname ne '*') {
+ if (&Apache::lonnet::homeserver($uname,$udom) ne '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);
}
- &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'} .= $_.',';
+ if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
+ if ($oldclone ne '*') {
+ ($uname,$udom) = split(/:/,$oldclone);
+ if ($uname && $udom && $uname ne '*' ) {
+ if (&Apache::lonnet::homeserver($uname,$udom) ne '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 my $crs (@currclonecrs) {
+ if ($crs ne $clone_crs) {
+ $newclonecrs{'cloneable'} .= $crs.',';
+ }
}
+ $newclonecrs{'cloneable'} =~ s/,$//;
+ } else {
+ $newclonecrs{'cloneable'} = '';
}
- $newclonecrs{'cloneable'} =~ s/,$//;
- } else {
- $newclonecrs{'cloneable'} = '';
+ &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
}
- &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
}
}
}
@@ -2974,6 +3664,8 @@ sub header {
sub print_main_menu {
my ($r,$parm_permission)=@_;
#
+ $r->print(&header());
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager'));
$r->print(<
@@ -2982,105 +3674,295 @@ 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 @menu =
- (
- { text => 'Set Course Environment Parameters',
- action => 'crsenv',
- permission => $parm_permission,
- },
- { text => 'Set Portfolio Metadata',
- action => 'setrestrictmeta',
- permission => $parm_permission,
- },
- { text => 'Manage Course Slots',
- url => '/adm/slotrequest?command=showslots',
- permission => $vgr,
- },
- { divider => 1,
- },
- { text => 'Set/Modify Resource Parameters - Helper Mode',
- url => '/adm/helper/parameter.helper',
- permission => $parm_permission,
- },
- { text => 'Modify Resource Parameters - Overview Mode',
- action => 'setoverview',
- permission => $parm_permission,
- },
- { text => 'Set Resource Parameters - Overview Mode',
- action => 'newoverview',
- permission => $parm_permission,
- },
- { text => 'Set/Modify Resource Parameters - Table Mode',
- action => 'settable',
- permission => $parm_permission,
- help => 'Cascading_Parameters',
- },
- { text => 'Set Parameter Setting Default Actions',
- action => 'setdefaults',
- permission => $parm_permission,
- },
+ ( { categorytitle=>'Settings for Your Course',
+ items => [
+ { linktext => 'Set Course Environment',
+ url => '/adm/parmset?action=crsenv',
+ permission => $parm_permission,
+ help => 'Course_Environment',
+ },
+ { linktext => 'Set Portfolio Metadata',
+ url => '/adm/parmset?action=setrestrictmeta',
+ permission => $parm_permission,
+ },
+ { linktext => 'Manage Course Slots',
+ url => '/adm/slotrequest?command=showslots',
+ permission => $vgr,
+ },
+ { linktext => 'Reset Student Access Times',
+ url => '/adm/helper/resettimes.helper',
+ permission => $mgr,
+ },
+
+ { linktext => 'Set Parameter Setting Default Actions',
+ url => '/adm/parmset?action=setdefaults',
+ permission => $parm_permission,
+ }]},
+ { categorytitle => 'New and Existing Parameter Settings for Your Resources',
+ items => [
+ { linktext => 'Set/Modify Resource Parameters - Helper Mode',
+ url => '/adm/helper/parameter.helper',
+ permission => $parm_permission,
+ help => 'Parameter_Helper',
+ },
+ { linktext => 'Set/Modify Resource Parameters - Overview Mode',
+ url => '/adm/parmset?action=newoverview',
+ permission => $parm_permission,
+ help => 'Parameter_Overview',
+ },
+ { linktext => 'Set/Modify Resource Parameters - Table Mode',
+ url => '/adm/parmset?action=settable',
+ permission => $parm_permission,
+ help => 'Table_Mode',
+ }]},
+ { categorytitle => 'Existing Parameter Settings for Your Resources',
+ items => [
+ { linktext => 'Modify Resource Parameters - Overview Mode',
+ url => '/adm/parmset?action=setoverview',
+ permission => $parm_permission,
+ help => 'Parameter_Overview',
+ },
+ { linktext => 'Parameter Change Log and Course Blog Posting/User Notification',
+ url => '/adm/parmset?action=parameterchangelog',
+ permission => $parm_permission,
+ }]}
);
- my $menu_html = '';
- foreach my $menu_item (@menu) {
- if ($menu_item->{'divider'}) {
- $menu_html .= ' ';
- next;
- }
- next if (! $menu_item->{'permission'});
- $menu_html.='';
- $menu_html.='';
- if (exists($menu_item->{'url'})) {
- $menu_html.=qq{};
- } else {
- $menu_html.=
- qq{ };
- }
- $menu_html.= &mt($menu_item->{'text'}).' ';
- if (exists($menu_item->{'help'})) {
- $menu_html.=
- &Apache::loncommon::help_open_topic($menu_item->{'help'});
- }
- $menu_html.='
'.$/;
- }
- $r->print($menu_html);
+#---- Remove when done ----
+# my $menu_html = '';
+# foreach my $menu_item (@menu) {
+# if ($menu_item->{'categorytitle'}) {
+# $menu_html .= ''.&mt($menu_item->{'categorytitle'}).' ';
+# next;
+# }
+# next if (! $menu_item->{'permission'});
+# $menu_html.='';
+# $menu_html.='';
+# if (exists($menu_item->{'help'})) {
+# $menu_html.=
+# &Apache::loncommon::help_open_topic($menu_item->{'help'});
+# }
+# $menu_html.='
'.$/;
+# }
+# --------------------------
+
+ $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
return;
}
+
### Set portfolio metadata
sub output_row {
- my ($r, $field_name, $field_text) = @_;
+ my ($r, $field_name, $field_text, $added_flag) = @_;
my $output;
my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
- unless (defined($options)) {
+ if (!defined($options)) {
$options = 'active,stuadd';
$values = '';
}
- $output.=''.$field_text.': ';
- $output.=' ';
-
- my @options= ( ['active', 'Show to student'],
- ['onlyone','Student may select only one choice'],
- ['stuadd', 'Student may type choices']);
- foreach my $opt (@options) {
- my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
- $output.=(' 'x5).' '.
- &mt($opt->[1]).' ';
+ if (!($options =~ /deleted/)) {
+ my @options= ( ['active', 'Show to student'],
+ ['stuadd', 'Provide text area for students to type catalog information'],
+ ['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 .= ''.$field_text.': ';
+ $output .= &Apache::loncommon::end_data_table_row();
+ foreach my $opt (@options) {
+ my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
+ $output .= &Apache::loncommon::continue_data_table_row();
+ $output .= ''.(' ' x 5).'
+ '.
+ &mt($opt->[1]).' ';
+ $output .= &Apache::loncommon::end_data_table_row();
+ }
+ $output .= &Apache::loncommon::continue_data_table_row();
+ $output .= ''.(' ' x 10).' ';
+ $output .= &Apache::loncommon::end_data_table_row();
+ my $multiple_checked;
+ my $single_checked;
+ if ($options =~ m/onlyone/) {
+ $multiple_checked = "";
+ $single_checked = " CHECKED ";
+ } else {
+ $multiple_checked = " CHECKED ";
+ $single_checked = "";
+ }
+ $output .= &Apache::loncommon::continue_data_table_row();
+ $output .= ''.(' ' x 10).'
+
+ Student may select multiple choices from list ';
+ $output .= &Apache::loncommon::end_data_table_row();
+ $output .= &Apache::loncommon::continue_data_table_row();
+ $output .= ''.(' ' x 10).'
+
+ Student may select only one choice from list ';
+ $output .= &Apache::loncommon::end_data_table_row();
}
return ($output);
}
-
+sub order_meta_fields {
+ my ($r)=@_;
+ my $idx = 1;
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
+ text=>"Add Metadata Field"});
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/parmset?action=setrestrictmeta",
+ text=>"Restrict Metadata"},
+ {text=>"Order Metadata"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
+ if ($env{'form.storeorder'}) {
+ my $newpos = $env{'form.newpos'} - 1;
+ my $currentpos = $env{'form.currentpos'} - 1;
+ my @neworder = ();
+ my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
+ my $i;
+ if ($newpos > $currentpos) {
+ # moving stuff up
+ for ($i=0;$i<$currentpos;$i++) {
+ $neworder[$i]=$oldorder[$i];
+ }
+ for ($i=$currentpos;$i<$newpos;$i++) {
+ $neworder[$i]=$oldorder[$i+1];
+ }
+ $neworder[$newpos]=$oldorder[$currentpos];
+ for ($i=$newpos+1;$i<=$#oldorder;$i++) {
+ $neworder[$i]=$oldorder[$i];
+ }
+ } else {
+ # moving stuff down
+ for ($i=0;$i<$newpos;$i++) {
+ $neworder[$i]=$oldorder[$i];
+ }
+ $neworder[$newpos]=$oldorder[$currentpos];
+ for ($i=$newpos+1;$i<$currentpos+1;$i++) {
+ $neworder[$i]=$oldorder[$i-1];
+ }
+ for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
+ $neworder[$i]=$oldorder[$i];
+ }
+ }
+ my $ordered_fields = join ",", @neworder;
+ my $put_result = &Apache::lonnet::put('environment',
+ {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
+ &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
+ }
+ my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
+ my $ordered_fields;
+ my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
+ if (!@fields_in_order) {
+ # no order found, pick sorted order then create metadata.addedorder key.
+ foreach my $key (sort keys %$fields) {
+ push @fields_in_order, $key;
+ $ordered_fields = join ",", @fields_in_order;
+ }
+ my $put_result = &Apache::lonnet::put('environment',
+ {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
+ }
+ $r->print('');
+ my $num_fields = scalar(@fields_in_order);
+ foreach my $key (@fields_in_order) {
+ $r->print('');
+ $r->print(' ');
+ $r->print(' ');
+ $r->print(' ');
+ $r->print('');
+ $r->print($$fields{$key}.' ');
+ $idx ++;
+ }
+ $r->print('
');
+ 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(undef,
- 'Restrict Metadata'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
@@ -3096,12 +3978,18 @@ sub setrestrictmeta {
if ($env{'form.'.$meta_field.'_stuadd'}) {
$options.='stuadd,';
}
- if ($env{'form.'.$meta_field.'_onlyone'}) {
+ 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,
@@ -3111,32 +3999,80 @@ sub setrestrictmeta {
}
}
}
- &Apache::lonnet::coursedescription($env{'request.course.id'});
+ &Apache::lonnet::coursedescription($env{'request.course.id'},
+ {'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') {
+ $row_alt = $row_alt ? 0 : 1;
$output.= &output_row($r, $field, $metadata_fields{$field});
}
}
+ my $buttons = (<
+
+
+
+
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) = @_;
+ &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(undef,'Defaults');
+ my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
$r->print(<print(&mt('Manual setting rules apply to all interfaces.').' '.
&mt('Automatic setting rules apply to table mode interfaces only.'));
- $r->print("\n\n \n".
+ $r->print(&Apache::loncommon::end_data_table().
+ "\n \n".
&Apache::loncommon::end_page());
return;
}
+sub components {
+ 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 $section=&mt('All Students');
+ if ($middle=~/^\[(.*)\]/) {
+ $issection=$1;
+ $section=&mt('Group/Section').': '.$issection;
+ $middle=~s/^\[(.*)\]//;
+ }
+ $middle=~s/\.+$//;
+ $middle=~s/^\.+//;
+ if ($uname) {
+ $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
+ $issection='';
+ }
+ my $realm=''.&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);
+ } 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 $what=$part.'.'.$name;
+ return ($realm,$section,$name,$part,
+ $what,$middle,$uname,$udom,$issection,$realmdescription);
+}
+
+my %standard_parms;
+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;
+ }
+ }
+ close($config);
+ $standard_parms{'int_pos'} = 'Positive Integer';
+ $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
+ %standard_parms=&Apache::lonlocal::texthash(%standard_parms);
+}
+
+sub standard_parameter_names {
+ my ($name)=@_;
+ if (!%standard_parms) {
+ &load_parameter_names();
+ }
+ if ($standard_parms{$name}) {
+ return $standard_parms{$name};
+ } else {
+ return $name;
+ }
+}
+
+#
+# Parameter Change Log
+#
+
+
+sub parm_change_log {
+ my ($r)=@_;
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
+ text=>"Parameter Change Log"});
+ $r->print(&Apache::loncommon::start_page('Parameter Change Log'));
+ $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'});
+
+ if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
+
+ $r->print('');
+
+ my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
+ $env{'course.'.$env{'request.course.id'}.'.domain'});
+ $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
+ ''.&mt('Time').' '.&mt('User').' '.&mt('Extent').' '.&mt('Users').' '.
+ &mt('Parameter').' '.&mt('Part').' '.&mt('New Value').' '.&mt('Announce').' '.
+ &Apache::loncommon::end_data_table_header_row());
+ my $shown=0;
+ my $folder='';
+ if ($env{'form.displayfilter'} eq 'currentfolder') {
+ my $last='';
+ if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
+ &GDBM_READER(),0640)) {
+ $last=$hash{'last_known'};
+ untie(%hash);
+ }
+ if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
+ }
+ foreach my $id (sort
+ {
+ if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
+ return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
+ }
+ my $aid = (split('00000',$a))[-1];
+ my $bid = (split('00000',$b))[-1];
+ return $bid<=>$aid;
+ } (keys(%parmlog))) {
+ my @changes=keys(%{$parmlog{$id}{'logentry'}});
+ my $count = 0;
+ my $time =
+ &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
+ my $plainname =
+ &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
+ $parmlog{$id}{'exe_udom'});
+ my $about_me_link =
+ &Apache::loncommon::aboutmewrapper($plainname,
+ $parmlog{$id}{'exe_uname'},
+ $parmlog{$id}{'exe_udom'});
+ my $send_msg_link='';
+ if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
+ || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
+ $send_msg_link =' '.
+ &Apache::loncommon::messagewrapper(&mt('Send message'),
+ $parmlog{$id}{'exe_uname'},
+ $parmlog{$id}{'exe_udom'});
+ }
+ my $row_start=&Apache::loncommon::start_data_table_row();
+ my $makenewrow=0;
+ my %istype=();
+ my $output;
+ foreach my $changed (reverse(sort(@changes))) {
+ my $value=$parmlog{$id}{'logentry'}{$changed};
+ my $typeflag = ($changed =~/\.type$/ &&
+ !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
+ my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
+ &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
+ if ($env{'form.displayfilter'} eq 'currentfolder') {
+ if ($folder) {
+ if ($middle!~/^\Q$folder\E/) { next; }
+ }
+ }
+ if ($typeflag) {
+ $istype{$parmname}=$value;
+ if (!$env{'form.includetypes'}) { next; }
+ }
+ $count++;
+ if ($makenewrow) {
+ $output .= $row_start;
+ } else {
+ $makenewrow=1;
+ }
+ $output .=''.$realm.' '.$section.' '.
+ &standard_parameter_names($parmname).' '.
+ ($part?&mt('Part: [_1]',$part):&mt('All Parts')).' ';
+ my $stillactive=0;
+ if ($parmlog{$id}{'delflag'}) {
+ $output .= &mt('Deleted');
+ } else {
+ if ($typeflag) {
+ $output .= &mt('Type: [_1]',&standard_parameter_names($value));
+ } else {
+ my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
+ $uname,$udom,$issection,$issection,$courseopt);
+ if (&isdateparm($istype{$parmname})) {
+ $output .= &Apache::lonlocal::locallocaltime($value);
+ } else {
+ $output .= $value;
+ }
+ if ($value ne $all[$level]) {
+ $output .= ''.&mt('Not active anymore').' ';
+ } else {
+ $stillactive=1;
+ }
+ }
+ }
+ $output .= ' ';
+ if ($stillactive) {
+ my $title=&mt('Changed [_1]',&standard_parameter_names($parmname));
+ my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription,
+ (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
+ if (($uname) && ($udom)) {
+ $output .=
+ &Apache::loncommon::messagewrapper('Notify User',
+ $uname,$udom,$title,
+ $description);
+ } else {
+ $output .=
+ &Apache::lonrss::course_blog_link($id,$title,
+ $description);
+ }
+ }
+ $output .= ' '.&Apache::loncommon::end_data_table_row();
+ }
+ if ($env{'form.displayfilter'} eq 'containing') {
+ my $wholeentry=$about_me_link.':'.
+ $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
+ $output;
+ if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
+ }
+ if ($count) {
+ $r->print($row_start.''.$time.'
+ '.$about_me_link.
+ ''.$parmlog{$id}{'exe_uname'}.
+ ':'.$parmlog{$id}{'exe_udom'}.' '.
+ $send_msg_link.' '.$output);
+ $shown++;
+ }
+ if (!($env{'form.show'} eq &mt('all')
+ || $shown<=$env{'form.show'})) { last; }
+ }
+ $r->print(&Apache::loncommon::end_data_table());
+ $r->print(&Apache::loncommon::end_page());
+}
+
+sub check_for_course_info {
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ return 1 if ($navmap);
+ return 0;
+}
+
##################################################
##################################################
@@ -3296,49 +4475,42 @@ ENDYESNO
Main handler. Calls &assessparms and &crsenv subroutines.
=cut
+
##################################################
##################################################
-# use Data::Dumper;
-
sub handler {
my $r=shift;
- if ($r->header_only) {
- &Apache::loncommon::content_type($r,'text/html');
- $r->send_http_header;
- return OK;
- }
+ &reset_caches();
+
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+ return OK if $r->header_only;
+
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['action','state',
'pres_marker',
'pres_value',
'pres_type',
- 'udom','uname','symb','serial']);
+ 'udom','uname','symb','serial','timebase']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
text=>"Parameter Manager",
faq=>10,
- bug=>'Instructor Interface'});
+ bug=>'Instructor Interface',
+ help => 'Parameter_Manager'});
# ----------------------------------------------------- Needs to be in a course
my $parm_permission =
(&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
&Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
$env{'request.course.sec'}));
- if ($env{'request.course.id'} && $parm_permission) {
-
- # Start Page
- &Apache::loncommon::content_type($r,'text/html');
- $r->send_http_header;
-
-
- # id numbers can change on re-ordering of folders
-
- &resetsymbcache();
+ my $exists = &check_for_course_info();
+ if ($env{'request.course.id'} && $parm_permission && $exists) {
#
# Main switch on form.action and form.state, as appropriate
#
@@ -3347,45 +4519,48 @@ sub handler {
if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
&& (!$env{'form.dis'})) || ($env{'form.symb'})) {
&assessparms($r);
-
} elsif (! exists($env{'form.action'})) {
- $r->print(&header());
- $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
- 'Parameter Manager'));
&print_main_menu($r,$parm_permission);
- } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
- &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
- text=>"Course Environment"});
+ } elsif ($env{'form.action'} eq 'crsenv') {
&crsenv($r);
- } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
- &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
- text=>"Overview Mode"});
+ } elsif ($env{'form.action'} eq 'setoverview') {
&overview($r);
- } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) {
- &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
- text=>"Restrict Metadata"});
+ } elsif ($env{'form.action'} eq 'addmetadata') {
+ &addmetafield($r);
+ } elsif ($env{'form.action'} eq 'ordermetadata') {
+ &order_meta_fields($r);
+ } elsif ($env{'form.action'} eq 'setrestrictmeta') {
&setrestrictmeta($r);
- } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) {
- &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
- text=>"Overview Mode"});
+ } elsif ($env{'form.action'} eq 'newoverview') {
&newoverview($r);
- } elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) {
- &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
- text=>"Set Defaults"});
+ } elsif ($env{'form.action'} eq 'setdefaults') {
&defaultsetter($r);
- } elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
- &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
- text=>"Table Mode",
- help => 'Course_Setting_Parameters'});
+ } elsif ($env{'form.action'} eq 'settable') {
&assessparms($r);
- }
-
+ } elsif ($env{'form.action'} eq 'parameterchangelog') {
+ &parm_change_log($r);
+ } elsif ($env{'form.action'} eq 'cleanparameters') {
+ &clean_parameters($r);
+ } elsif ($env{'form.action'} eq 'dateshift1') {
+ &date_shift_one($r);
+ } elsif ($env{'form.action'} eq 'dateshift2') {
+ &date_shift_two($r);
+ } elsif ($env{'form.action'} eq 'categorizecourse') {
+ &assign_course_categories($r);
+ }
} else {
# ----------------------------- Not in a course, or not allowed to modify parms
- $env{'user.error.msg'}=
- "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
+ if ($exists) {
+ $env{'user.error.msg'}=
+ "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
+ } else {
+ $env{'user.error.msg'}=
+ "/adm/parmset::0:1:Course environment gone, reinitialize the course";
+ }
return HTTP_NOT_ACCEPTABLE;
}
+ &reset_caches();
+
return OK;
}