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
@@ -2864,48 +3503,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) = @_;
@@ -2918,43 +3572,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);
}
}
}
@@ -2993,6 +3651,7 @@ 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 =
( { divider=>'Settings for Your Course',
@@ -3010,6 +3669,11 @@ ENDMAINFORMHEAD
url => '/adm/slotrequest?command=showslots',
permission => $vgr,
},
+ { text => 'Reset Student Access Times',
+ url => '/adm/helper/resettimes.helper',
+ permission => $mgr,
+ },
+
{ text => 'Set Parameter Setting Default Actions',
action => 'setdefaults',
permission => $parm_permission,
@@ -3070,36 +3734,200 @@ ENDMAINFORMHEAD
}
### 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=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;
-
$r->print(&Apache::loncommon::start_page('Restrict Metadata'));
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
@@ -3117,12 +3945,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,
@@ -3134,25 +3968,70 @@ sub setrestrictmeta {
}
&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) = @_;
@@ -3308,20 +4187,22 @@ ENDYESNO
}
$r->print(&Apache::loncommon::end_data_table().
"\n \n".
+ &mt('Save Rules')."' />\n".
&Apache::loncommon::end_page());
return;
}
sub components {
- my ($key,$uname,$udom,$exeuser,$exedomain)=@_;
- my $typeflag=0;
- if ($key=~/\.type$/) {
+ my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
+
+ if ($typeflag) {
$key=~s/\.type$//;
- $typeflag=1;
}
+
+ 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;
@@ -3345,31 +4226,33 @@ sub components {
$realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
}
my $what=$part.'.'.$name;
- return ($realm,$section,$name,$part,$typeflag,
+ 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)=@_;
- 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 {
@@ -3401,13 +4284,7 @@ sub parm_change_log {
\%saveable_parameters);
&Apache::loncommon::restore_course_settings('parameter_log',
\%saveable_parameters);
- if (!$env{'form.show'}) { $env{'form.show'}=10; }
-
- my $countselect =
- &Apache::lonmeta::selectbox('show',$env{'form.show'},undef,
- (&mt('all'),10,20,50,100,1000,10000));
-
- $r->print(''.&mt('[_1] Records',$countselect).' '.
+ $r->print(&Apache::loncommon::display_filter().
''.&Apache::lonhtmlcommon::checkbox('includetypes',$env{'form.includetypes'},'1').
' '.&mt('Include parameter types').' '.
' ');
@@ -3419,10 +4296,27 @@ sub parm_change_log {
&mt('Parameter').''.&mt('Part').' '.&mt('New Value').' '.&mt('Announce').' '.
&Apache::loncommon::end_data_table_header_row());
my $shown=0;
- foreach my $id (sort { $parmlog{$b}{'exe_time'}<=>$parmlog{$a}{'exe_time'} } (keys(%parmlog))) {
+ 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=$#changes+1;
- if (!$env{'form.includetypes'}) { $count=$count/2; }
+ my $count = 0;
my $time =
&Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
my $plainname =
@@ -3441,66 +4335,86 @@ sub parm_change_log {
$parmlog{$id}{'exe_udom'});
}
my $row_start=&Apache::loncommon::start_data_table_row();
- $r->print($row_start.''.$time.'
- '.$about_me_link.
- ''.$parmlog{$id}{'exe_uname'}.
- ':'.$parmlog{$id}{'exe_udom'}.' '.
- $send_msg_link.' ');
my $makenewrow=0;
my %istype=();
+ my $output;
foreach my $changed (reverse(sort(@changes))) {
- my $value=$parmlog{$id}{'logentry'}->{$changed};
- my ($realm,$section,$parmname,$part,$typeflag,$what,$middle,$uname,$udom,$issection,$realmdescription)=
- &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'});
+ 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) {
- if (!$env{'form.includetypes'}) { next; }
$istype{$parmname}=$value;
+ if (!$env{'form.includetypes'}) { next; }
}
- if ($makenewrow) { $r->print($row_start); } else { $makenewrow=1; }
- $r->print(''.$realm.' '.$section.' '.
+ $count++;
+ if ($makenewrow) {
+ $output .= $row_start;
+ } else {
+ $makenewrow=1;
+ }
+ $output .=' '.$realm.' '.$section.' '.
&standard_parameter_names($parmname).' '.
- ($part?&mt('Part: [_1]',$part):&mt('All Parts')).' ');
+ ($part?&mt('Part: [_1]',$part):&mt('All Parts')).' ';
my $stillactive=0;
- if ($parmlog{$id}{'deleteflag'}) {
- $r->print(&mt('Deleted'));
+ if ($parmlog{$id}{'delflag'}) {
+ $output .= &mt('Deleted');
} else {
if ($typeflag) {
- $r->print(&mt('Type: [_1]',&standard_parameter_names($value)));
+ $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})) {
- $r->print(&Apache::lonlocal::locallocaltime($value));
+ $output .= &Apache::lonlocal::locallocaltime($value);
} else {
- $r->print($value);
+ $output .= $value;
}
if ($value ne $all[$level]) {
- $r->print(''.&mt('Not active anymore').' ');
+ $output .= ''.&mt('Not active anymore').' ';
} else {
$stillactive=1;
}
}
}
- $r->print(' ');
+ $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)) {
- $r->print(' '.
- &Apache::loncommon::messagewrapper('Notify User',$uname,$udom,$title,$description).
- ' ');
+ $output .=
+ &Apache::loncommon::messagewrapper('Notify User',
+ $uname,$udom,$title,
+ $description);
} else {
- $r->print(''.
- &Apache::lonrss::course_blog_link($id,$title,$description).
- ' ');
+ $output .=
+ &Apache::lonrss::course_blog_link($id,$title,
+ $description);
}
- } else {
- $r->print(' ');
}
- $r->print(&Apache::loncommon::end_data_table_row());
+ $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++;
}
- $shown++;
if (!($env{'form.show'} eq &mt('all')
|| $shown<=$env{'form.show'})) { last; }
}
@@ -3508,6 +4422,12 @@ sub parm_change_log {
$r->print(&Apache::loncommon::end_page());
}
+sub check_for_course_info {
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ return 1 if ($navmap);
+ return 0;
+}
+
##################################################
##################################################
@@ -3518,14 +4438,15 @@ sub parm_change_log {
Main handler. Calls &assessparms and &crsenv subroutines.
=cut
+
##################################################
##################################################
-# use Data::Dumper;
-
sub handler {
my $r=shift;
+ &reset_caches();
+
if ($r->header_only) {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
@@ -3536,7 +4457,7 @@ sub handler {
'pres_marker',
'pres_value',
'pres_type',
- 'udom','uname','symb','serial']);
+ 'udom','uname','symb','serial','timebase']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
@@ -3551,17 +4472,15 @@ sub handler {
(&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) {
+ my $exists = &check_for_course_info();
+
+ if ($env{'request.course.id'} && $parm_permission && $exists) {
# Start Page
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
- # id numbers can change on re-ordering of folders
-
- &resetsymbcache();
-
#
# Main switch on form.action and form.state, as appropriate
#
@@ -3585,6 +4504,14 @@ sub handler {
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
text=>"Overview Mode"});
&overview($r);
+ } elsif ($env{'form.action'} eq 'addmetadata' && $parm_permission) {
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
+ text=>"Add Metadata Field"});
+ &addmetafield($r);
+ } elsif ($env{'form.action'} eq 'ordermetadata' && $parm_permission) {
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
+ text=>"Add Metadata Field"});
+ &order_meta_fields($r);
} elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) {
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
text=>"Restrict Metadata"});
@@ -3606,13 +4533,34 @@ sub handler {
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
text=>"Parameter Change Log"});
&parm_change_log($r);
- }
+ } elsif ($env{'form.action'} eq 'cleanparameters' && $parm_permission) {
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
+ text=>"Clean Parameters"});
+ &clean_parameters($r);
+ } elsif ($env{'form.action'} eq 'dateshift1' && $parm_permission) {
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
+ text=>"Shifting Dates"});
+ &date_shift_one($r);
+ } elsif ($env{'form.action'} eq 'dateshift2' && $parm_permission) {
+ &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
+ text=>"Shifting Dates"});
+ &date_shift_two($r);
+ } elsif ($env{'form.action'} eq 'categorizecourse' && $parm_permission) {
+ &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;
}