--- loncom/interface/lonwhatsnew.pm 2008/03/11 00:44:09 1.75
+++ loncom/interface/lonwhatsnew.pm 2016/11/05 13:37:49 1.121
@@ -1,5 +1,5 @@
#
-# $Id: lonwhatsnew.pm,v 1.75 2008/03/11 00:44:09 raeburn Exp $
+# $Id: lonwhatsnew.pm,v 1.121 2016/11/05 13:37:49 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,11 +36,13 @@ use Apache::lonlocal;
use Apache::loncoursedata();
use Apache::lonnavmaps();
use Apache::lonuserstate;
+use Apache::lonuserutils;
use Apache::Constants qw(:common :http);
use Time::Local;
use GDBM_File;
use lib '/home/httpd/lib/perl/';
use LONCAPA;
+use HTML::Entities;
#----------------------------
# handler
@@ -60,14 +62,36 @@ sub handler {
my $command = $env{'form.command'};
my $refpage = $env{'form.refpage'};
- my %checkallowed = ( coursenormalmail => 1,
- coursecritmail => 1, );
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+
+ my ($isadhoc,%checkallowed);
+
+ if ($env{'request.role'} =~ m{^(cc|co)/}) {
+ my $rolecode = $1;
+ if ($env{"environment.internal.$cdom.$crs.$env{'request.role'}.adhoc"}) {
+ $isadhoc = 1;
+ }
+ } elsif ($env{'request.role'} =~ m{^cr/$cdom/$cdom\-domainconfig/(\w+)\./}) {
+ my $rolename = $1;
+ if ($env{"environment.internal.$cdom.$crs.cr/$cdom/$cdom-domainconfig/$rolename.adhoc"}) {
+ $isadhoc = 1;
+ }
+ }
+ unless ($isadhoc) {
+ %checkallowed = ( coursenormalmail => 1,
+ coursecritmail => 1,);
+ }
foreach my $perm_check (['whn','whatsnew',1],
['pch','coursediscussion',1],
['mgr','handgrading',1],
['vgr','abovethreshold',1],
- ['opa','haserrors',1],
- ['mdc','versionchanges',0],
+ ['vgr','haserrors',1],
+ ['whn','versionchanges',0],
+ ['vcl','newroles',1],
+ ['vcl','oldroles',1],
+ ['whn','crslogin',1],
+ ['mgr','resetcounters',1],
) {
my ($perm,$key,$check_section) = @{ $perm_check };
my $scope = $env{'request.course.id'};
@@ -84,7 +108,7 @@ sub handler {
if ( ! $env{'request.course.fn'} || ! $checkallowed{'whatsnew'}) {
# Not in a course, or no whn priv in course
- $env{'user.error.msg'}="/adm/whatsnew::whn:0:0:Cannot display what's new page";
+ $env{'user.error.msg'}="/adm/whatsnew:whn:0:0:Cannot display what's new page";
return HTTP_NOT_ACCEPTABLE;
}
@@ -96,7 +120,7 @@ sub handler {
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/whatsnew',
- text=>"Display Action Items"});
+ text=>"What's New?"});
if (($command eq 'chgthreshold') && $checkallowed{'abovethreshold'}) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage,
@@ -125,12 +149,33 @@ sub handler {
$r->print(&Apache::lonhtmlcommon::breadcrumbs
("What's New?",#'Course_Action_Items_Initialization'
));
+ } elsif ($command eq 'chgoldroleinterval' && $checkallowed{'oldroles'}) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage,
+ text=>"Change interval"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ ("What's New?",#'Course_Action_Items_Intervals'
+ ));
+ } elsif ($command eq 'chgnewroleinterval' && $checkallowed{'newroles'}) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage,
+ text=>"Change interval"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ ("What's New?",#'Course_Action_Items_Intervals'
+ ));
+ } elsif ($command eq 'chgcrslogininterval' && $checkallowed{'crslogin'}) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew?command=chgcrslogininterval&refpage='.$refpage,
+ text=>"Change interval"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ ("What's New?",#'Course_Action_Items_Intervals'
+ ));
} else {
$r->print(&Apache::lonhtmlcommon::breadcrumbs
("What's New?",#'Course_Action_Items_Display'
));
}
- &display_main_box($r,$command,$refpage,\%checkallowed);
+ &display_main_box($r,$command,$refpage,\%checkallowed,$cdom,$crs);
return OK;
}
@@ -141,7 +186,7 @@ sub handler {
#------------------------------
sub display_main_box {
- my ($r,$command,$refpage,$checkallowed) = @_;
+ my ($r,$command,$refpage,$checkallowed,$cdom,$crs) = @_;
my $domain=&Apache::loncommon::determinedomain();
my $function = &Apache::loncommon::get_users_function();
my $lctype = lc(&Apache::loncommon::course_type());
@@ -152,35 +197,63 @@ sub display_main_box {
degdiff => 'Degree of difficulty',
numstudents => 'Total number of students with submissions',
);
-
- my %interval_titles = &Apache::lonlocal::texthash (
- -1 => "since start of $lctype",
- 2592000 => 'since last month',
- 604800 => 'since last week',
- 86400 => 'since yesterday',
+ my %versions = (
+ -1 => "version changes since start of $lctype",
+ 2592000 => 'version changes since last month',
+ 604800 => 'version changes since last week',
+ 86400 => 'version changes since yesterday',
+ );
+ my %newroles = (
+ -1 => "roles which have become active since start of $lctype",
+ 2592000 => 'roles which have become active since last month',
+ 604800 => 'roles which have become active since last week',
+ 86400 => 'roles which have become active since yesterday',
+ );
+ my %oldroles = (
+ -1 => "roles which expired since start of $lctype",
+ 2592000 => 'roles which expired since last month',
+ 604800 => 'roles which expired since last week',
+ 86400 => 'roles which expired since yesterday',
+ );
+ my %crslogins = (
+ -1 => 'last logins for anyone who has ever logged in',
+ 2592000 => 'last logins for users in last 30 days',
+ 604800 => 'last logins for users in last 7 days',
+ 86400 => 'last logins for users in last 24 hours',
+ );
+ my %interval_titles = (
+ versions => \%versions,
+ newroles => \%newroles,
+ oldroles => \%oldroles,
+ crslogin => \%crslogins,
);
-
my %initpage = &Apache::lonlocal::texthash (
firstres => "first resource in the $lctype",
- whatsnew => "what's new? page",
+ whatsnew => "What's New Page",
userpref => 'your general user preferences',
coursespecific => "specific setting for this $lctype",
);
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
if (($command eq 'chgthreshold')
&& $checkallowed->{'abovethreshold'}) {
- &display_threshold_config($r,$refpage,\%threshold_titles,
- $cdom,$crs);
+ &display_threshold_config($r,$refpage,\%threshold_titles,$cdom,$crs);
} elsif (($command eq 'chginterval')
&& $checkallowed->{'versionchanges'}) {
- &display_interval_config($r,$refpage,\%interval_titles);
+ &display_interval_config($r,$refpage,\%interval_titles,'versions');
} elsif (($command eq 'chgdisc')
&& $checkallowed->{'coursediscussion'}) {
&display_discussion_config($r,$refpage);
} elsif ($command eq 'courseinit') {
&courseinit_config($r,$refpage,\%initpage);
+ } elsif (($command eq 'chgnewroleinterval')
+ && $checkallowed->{'newroles'}) {
+ &display_interval_config($r,$refpage,\%interval_titles,'newroles');
+ } elsif (($command eq 'chgoldroleinterval')
+ && $checkallowed->{'oldroles'}) {
+ &display_interval_config($r,$refpage,\%interval_titles,'oldroles');
+ } elsif (($command eq 'chgcrslogininterval')
+ && $checkallowed->{'crslogin'}) {
+ &display_interval_config($r,$refpage,\%interval_titles,'crslogin');
} else {
&display_actions_box($r,$command,$refpage,\%threshold_titles,
\%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
@@ -205,12 +278,15 @@ sub display_header {
my ($command,$checkallowed) = @_;
my $scripttag;
- unless ($command eq 'chgthreshold' || $command eq 'chginterval') {
+ unless ($command eq 'chgthreshold' || $command eq 'chginterval' ||
+ $command eq 'chgoldroleinterval' ||
+ $command eq 'chgnewroleinterval' || $command eq 'chgcrslogininterval') {
$scripttag = <<"END";
';
}
my $course_type=&Apache::loncommon::course_type();
- return &Apache::loncommon::start_page($course_type.' Action Items',
+ return &Apache::loncommon::start_page("What's New?",
$scripttag);
}
@@ -249,7 +376,7 @@ sub display_actions_box {
my $lctype = lc($crstype);
my %stulabel = (
'Course' => 'students',
- 'Group' => 'members',
+ 'Community' => 'members',
);
my %lt = &Apache::lonlocal::texthash(
'yacc' => 'You are accessing an invalid course',
@@ -271,7 +398,12 @@ sub display_actions_box {
my @warnings = ();
my $msgcount = 0;
my $critmsgcount = 0;
-
+ my $expirecount;
+ my %expired;
+ my $activecount;
+ my %activated;
+ my %loggedin;
+ my $logincount;
my %res_title = ();
my %show = ();
my $needitems = 0;
@@ -285,7 +417,7 @@ sub display_actions_box {
my %threshold = ();
my %pagedesc = &Apache::lonlocal::texthash (
firstres => 'First resource',
- whatsnew => "What's New? page",
+ whatsnew => "What's New Page",
userpref => 'user preference',
coursespecific => $lctype.' only',
default => 'default',
@@ -299,30 +431,33 @@ sub display_actions_box {
return;
}
+ my $header = '';
if ($refpage eq 'start') {
if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
&GDBM_READER(),0640)) {
- my $furl=$bighash{'first_url'};
+ my $furl=&HTML::Entities::encode($bighash{'first_url'},'"<>&');
untie(%bighash);
- $r->print(''.$lt{'gtfr'}.
- '
');
+ $header .= ''.$lt{'gtfr'}.
+ '
';
}
}
- $r->print(&mt('Page set to be displayed after you have selected a role in this '.$lctype).'.'
+ $header .= &mt('Page set to be displayed after you have selected a role in this '.$lctype).'.'
.' '
- .&mt('Currently: [_1]',$currinit)
- .'. '
-# &mt('Change for just this '.$lctype.'',$refpage).' '.
-# &mt('or for all your courses.',$refpage).'
');
+ $r->print('
+ ' '); @@ -510,28 +749,51 @@ sub display_threshold_config { #------------------------------- sub display_interval_config { - my ($r,$refpage,$interval_titles) = @_; + my ($r,$refpage,$interval_titles,$context) = @_; + my $setting = 'interval'; + if ($context eq 'oldroles') { + $setting = 'oldroleinterval'; + } elsif ($context eq 'newroles') { + $setting = 'newroleinterval'; + } my $lctype = lc(&Apache::loncommon::course_type()); my $current = &get_current($env{'user.name'},$env{'user.domain'}, - $env{'request.course.id'},'interval'); - $r->print(' '.&mt('Choose the time window to use for display of version changes for resources in the '.$lctype.'.').' '); + $env{'request.course.id'},$setting); + if ($context eq 'oldroles') { + $r->print(' '.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').' '); + } elsif ($context eq 'newroles') { + $r->print(' '.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' became available.').' '); + } elsif ($context eq 'crslogin') { + $r->print(' '.&mt('Choose the time window to use to display the last login by a user in the '.$lctype).' '); + } else { + $r->print(' '.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').' '); + } unless ($current eq '') { - $r->print(' '.&mt('Current value is [_1].',''. - $$interval_titles{$current}.'')); + if (ref($interval_titles->{$context}) eq 'HASH') { + $r->print(' '.&mt('Current value is "[_1]".',''. + $interval_titles->{$context}->{$current}.'').' '); + } } - $r->print(' + $r->print(' '); + &mt('Save').'" />'); return; } @@ -561,7 +823,13 @@ function toggle_countunread(choice) { document.discussionswitch.submit(); } '); - $r->print(' '.&mt('Choose whether or not to display a count of the number of new posts for each resource or bulletin board which has unread posts.').' '.&mt("This can increase the time taken to gather data for the 'What's New?' page by a few seconds.").' '.&mt("Currently set to $current.")); + $r->print(' ' + .&mt('Choose whether or not to display a count of the number of new posts for each resource or discussion board which has unread posts.') + .' ' + .&mt("This can increase the time taken to gather data for the [_1]What's New Page[_2] by a few seconds.",'','') + .' ' + .&mt('Currently set to [_1].',''.$current.'') + ); $r->print(' '); @@ -600,7 +868,7 @@ sub courseinit_config { 'anis' => 'and is set to display', 'padc' => 'Page display controlled by', 'chce' => 'Choose '.$lctype.' entry', - 'moce' => 'Modify '.$lctype.' entry', + 'moce' => 'Save', ); $r->print(<<"END"); $lt{'chwp'} @@ -661,27 +929,37 @@ sub display_launcher { my ($r,$action,$refpage,$checkallowed,$show,$headings,$res_title, $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered, $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs, - $interval,$countunread) = @_; + $interval,$countunread,$expired,$expirecount,$activated,$activecount, + $crstype,$itemserror,$loggedin,$logincount,$classlist) = @_; if ($$checkallowed{$action}) { - &start_box($r,$show,$headings,$action,$refpage,$action); + &start_box($r,$show,$headings,$action,$refpage); if ($$show{$action}) { if ($action eq 'handgrading') { # UNGRADED ITEMS - &display_handgrade($r,$tograde,$ungraded); + &display_handgrade($r,$tograde,$ungraded,$itemserror); } elsif ($action eq 'haserrors') { # BOMBS - &display_haserrors($r,$bombs,$bombed,$res_title); + &display_haserrors($r,$bombs,$bombed,$res_title,$itemserror); } elsif ($action eq 'versionchanges') { # VERSION CHANGES - &display_versionchanges($r,$changed,$res_title,$interval); + &display_versionchanges($r,$changed,$res_title,$interval->{'versions'},$itemserror); } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS &display_abovethreshold($r,$refpage,$warnings,$triggered, - $res_title); + $res_title,$itemserror,$checkallowed); } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION &display_coursediscussion($r,$newdiscussions,$unread, - $countunread,$res_title); + $countunread,$res_title,$itemserror); } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES &display_coursenormalmail($r,$msgcount,$newmsgs); } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES &display_coursecritmail($r,$critmsgcount,$critmsgs); + } elsif ($action eq 'newroles') { # ACTIVATED ROLES + &display_rolechanges($r,$activecount,$activated,$interval->{'newroles'}, + $crstype,$classlist); + } elsif ($action eq 'oldroles') { # EXPIRED ROLES + &display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'}, + $crstype,$classlist); + } elsif ($action eq 'crslogin') { #LAST LOGIN + &display_crslogins($r,$logincount,$loggedin,$interval->{'crslogin'}, + $crstype,$classlist); } } &end_box($r); @@ -692,8 +970,12 @@ sub display_launcher { sub getitems { my ($unread,$ungraded,$bombed,$triggered,$changed,$newdiscussions, $tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show, - $starttime,$countunread) = @_; + $starttime,$countunread,$checkallowed) = @_; my $navmap = Apache::lonnavmaps::navmap->new(); + if (!defined($navmap)) { + my $itemserror = ''.&mt('An error occurred retrieving information about the course.').' '.&mt('It is recommended that you [_1]re-select the course[_2].','','').''; + return $itemserror; + } # force retrieve Resource to seed the part id cache we'll need it later my @allres=$navmap->retrieveResources(undef, sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;}); @@ -748,10 +1030,12 @@ sub getitems { # Maxtries and degree of difficulty for problem parts, unless handgradeable if ($$show{'abovethreshold'}) { &check_thresholds($resource,$symb,\%resourcetracker, - $triggered,$threshold,$warnings); + $triggered,$threshold,$warnings, + $checkallowed); } } + return; } sub check_discussions { @@ -821,7 +1105,8 @@ sub check_bombed { } sub check_thresholds { - my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings) = @_; + my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings, + $checkallowed) = @_; # Compile maxtries and degree of difficulty for problem parts, unless handgradeable my @parts = @{$resource->parts()}; my %stats; @@ -831,6 +1116,9 @@ sub check_thresholds { if ($resource->handgrade($part) eq 'yes') { next; } + if ($resource->is_anonsurvey($part)) { + next; + } if ($resource->is_survey($part)) { next; } @@ -853,6 +1141,7 @@ sub check_thresholds { $av_attempts = $attempts/$users; $av_attempts = sprintf("%.2f",$av_attempts); } + &Apache::lonnet::statslog($symb,$part,$users,$av_attempts,$degdiff); if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) { $stats{$part}{degdiff} = $degdiff; $stats{$part}{attempts} = $av_attempts; @@ -883,8 +1172,12 @@ sub check_thresholds { | '.$stats{$part}{users}.' | '.$stats{$part}{attempts}.' | '.$stats{$part}{degdiff}.' | -'.$lastreset{$part}.' | -'; + | '.$lastreset{$part}.' | '; + if ($checkallowed->{'resetcounters'}) { + $$triggered{$symb}{text}[$partcount] .= + ''. + ' | '; + } $partcount ++; } $$triggered{$symb}{numparts} = $partcount; @@ -906,7 +1199,7 @@ sub get_curr_thresholds { my $thresholdcount = 0; my ($tmp) = %thresholdsettings; unless ($tmp =~ /^(con_lost|error|no_such_host)/i) { - foreach my $item (keys %{$threshold}) { + foreach my $item (keys(%{$threshold})) { if (exists($thresholdsettings{$cid.':threshold_'.$item})) { $$threshold{$item} = $thresholdsettings{$cid.':threshold_'.$item}; @@ -921,7 +1214,7 @@ sub get_curr_thresholds { $cdom,$crs,'internal.threshold'); my ($temp) = %coursesettings; unless ($temp =~ /^(con_lost|error|no_such_host)/i) { - foreach my $item (keys %{$threshold}) { + foreach my $item (keys(%{$threshold})) { unless (exists($thresholdsettings{$cid.':threshold_'.$item})) { if (exists($coursesettings{'internal.threshold_'.$item})) { $$threshold{$item} = @@ -946,7 +1239,11 @@ sub get_current { } sub process_reset { - my ($dom,$crs) = @_; + my ($dom,$crs,$checkallowed) = @_; + if (!$checkallowed->{'resetcounters'}) { + return ''.&mt('You do not the required privileges to reset counters'). + '|||
'.$$ungraded{$res}{title}.' | '.$$ungraded{$res}{count}.' | |||||||||
'.$itemserror.' | ||||||||||
'.$lt{'nopr'}.' | '. $$bombed{$bomb}{errorcount}.' | '); } + } elsif ($itemserror) { + $r->print('|||||||||
'.$itemserror.' | ||||||||||
'.$lt{'noer'}.' | ||||||||||
'.$itemserror.' | ||||||||||
'.$lt{'nopr'}.' | ||||||||||
'. @@ -1261,15 +1807,174 @@ sub display_versionchanges { $$changed{$item}{'current'}.' | '. $$changed{$item}{'version'}.' | |||||||||
'.$itemserror.' | ||||||||||
' + .&mt('No '.$interval).' | ||||||||||
'.$lt{'tich'}.' | '. + ''.$lt{'user'}.' | '. + ''.$lt{'role'}.' | '. + ''.$lt{'sec'}.' | '. + ''.$lt{'status'}.' | ||||||
'.&Apache::lonlocal::locallocaltime($item).' | '. + ''.$link.' | '. + ''.$role.' | '. + ''.$section.' | '. + ''.$status.' | ||||||
' + .&mt('There are no '.$interval).' | ||||||||||
'.$lt{'number'}.' | '. + ''.$lt{'role'}.' | '. + ''.$lt{'sec'}; + my (%bylastname,%counts); + if (ref($loggedin) eq 'HASH') { + my @logins = sort { $b <=> $a } (keys(%{$loggedin})); + my $numlogin = 0; + my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME(); + foreach my $item (@logins) { + if (ref($loggedin->{$item}) eq 'ARRAY') { + foreach my $user (@{$loggedin->{$item}}) { + if (ref($user) eq 'HASH') { + my $section; + my $role = + &Apache::lonnet::plaintext($user->{'role'},$crstype); + my $status = &mt($user->{'status'}); + if ($user->{'section'} eq '') { + $section = &mt('none'); + } else { + $section = $user->{'section'}; + } + $counts{$user->{'role'}}{$section} ++; + my $uname = $user->{'uname'}; + my $udom = $user->{'udom'}; + my $fullname; + if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') { + $fullname = $classlist->{$uname.':'.$udom}->[$fullnameidx]; + } else { + $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname'); + } + my $link = + &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom); + push(@{$bylastname{$fullname}}, + ' | '.$link.' | '. + ''.$role.' | '. + ''.$section.' | '); + } + } + } + } + my $table; + foreach my $person (sort(keys(%bylastname))) { + if (ref($bylastname{$person}) eq 'ARRAY') { + foreach my $item (@{$bylastname{$person}}) { + $numlogin ++; + my $css_class = $numlogin%2?' class="LC_odd_row"':''; + $table .= '|||||
'.$counts{$role}{$sec}.' | '. + ''.$showrole.' | '. + ''.$sec.' | ||||||||
'.$lt{'noup'}. - ' '.$interval.' | ||||||||||
'. + &mt('There are no '.$interval). + ' | ||||||||||
'.$itemserror.' | ||||||||||
'.$lt{'noun'}.' | ||||||||||
'.$mailcount. - '. | '. - $msg->{'shortsub'}.' | '. - $msg->{'from'}.':'.$msg->{'fromdom'}.' | '. - $msg->{'sendtime'}.' | |||||||
'.$mailcount + .'. | ' + .$msg->{'shortsub'}.' | ' + .$msg->{'from'}.':'.$msg->{'fromdom'}.' | ' + .$msg->{'sendtime'}.' | |||||||
'.
@@ -1420,24 +2127,34 @@ sub store_interval_setting {
my ($uname,$udom,$cid,$interval_titles) = @_;
my %interval_settings = ();
my $result;
- if (defined($env{'form.interval'})) {
- $interval_settings{$cid.':interval'} = $env{'form.interval'};
+ my $context = $env{'form.intervaltype'};
+ if ($env{'form.interval'} ne '') {
+ if ($context eq 'oldroles') {
+ $interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'};
+ } elsif ($context eq 'newroles') {
+ $interval_settings{$cid.':newroleinterval'} = $env{'form.interval'};
+ } elsif ($context eq 'crslogin') {
+ $interval_settings{$cid.':crslogininterval'} = $env{'form.interval'};
+ } else {
+ $interval_settings{$cid.':interval'} = $env{'form.interval'};
+ }
my $outcome = &Apache::lonnet::put('nohist_whatsnew',
\%interval_settings,$udom,$uname);
if ($outcome eq 'ok') {
- $result = &mt('Interval set to version changes [_1]',
- ''.$$interval_titles{$env{'form.interval'}}.'').' '; - + if (ref($interval_titles->{$context}) eq 'HASH') { + $result = &Apache::lonhtmlcommon::confirm_success(&mt('New filter setting: [_1].',''. + $interval_titles->{$context}->{$env{'form.interval'}}.'').' '); + } } else { my $lctype = lc(&Apache::loncommon::course_type()); - &Apache::lonnet::logthis('Error saving whatsnew interval setting'. + &Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'. ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid); - $result = &mt('Unable to set interval to [_1] due to [_2].', - ''.$$interval_titles{$env{'form.interval'}}.'', - ''.$outcome.'. '); + $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set interval to [_1] due to [_2].', + ''.$interval_titles->{$context}->{$env{'form.interval'}}.'', + ''.$outcome.''),1); } } - return $result; + return &Apache::loncommon::confirmwrapper($result); } sub store_discussion_setting { @@ -1449,20 +2166,20 @@ sub store_discussion_setting { my $outcome = &Apache::lonnet::put('nohist_whatsnew', \%discussion_settings,$udom,$uname); if ($outcome eq 'ok') { - $result = &mt('Count unread posts in discussions display set to [_1]', - ''.&mt($env{'form.countunread'}).'').' '; + $result = &Apache::lonhtmlcommon::confirm_success(&mt('Count unread posts in discussions display set to [_1]', + ''.&mt($env{'form.countunread'}).'').' '); } else { my $lctype = lc(&Apache::loncommon::course_type()); &Apache::lonnet::logthis('Error saving whatsnew countunread setting'. ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid); - $result = &mt('Unable to set "number unread posts display" to [_1]'. + $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set "number unread posts display" to [_1]'. ' due to [_2].', ''.&mt($env{'form.countunread'}).'', - ''.$outcome.'. '); + ''.$outcome.''),1); } } - return $result; + return &Apache::loncommon::confirmwrapper($result); } sub store_courseinit_setting { @@ -1487,27 +2204,29 @@ sub store_courseinit_setting { \%courseinit_settings,$udom,$uname); if ($outcome eq 'ok') { if ($page_control eq 'global preferences') { - $result = &mt("Page displayed after role selection in $lctype now set by user's global preferences."); + $result = &Apache::lonhtmlcommon::confirm_success(&mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'','')); } else { - $result = &mt('Page displayed after role selection in this '.$lctype.' set to [_2]',$lctype,$$initpage{$env{'form.courseinit_page'}}); + $result = &Apache::lonhtmlcommon::confirm_success(&mt('Page displayed after role selection in this '.$lctype.' set to [_1].' + ,''.$$initpage{$env{'form.courseinit_page'}}.'')); } } else { &Apache::lonnet::logthis('Error saving whatsnew courseinit '. 'setting: '.$outcome.' for '.$uname. ':'.$udom.' in '.$lctype.' '.$cid); if ($page_control eq 'global preferences') { - $result = &mt('Unable to set control of page display to [_1]'. + $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set control of page display to [_1]'. ' due to [_2].', ''.$page_control.'', - ''.$outcome.'. '); + ''.$outcome.''),1); } else { - $result = &mt('Unable to set page display, after role selection, for this '.$lctype.' to [_2] due to [_3]. ', - $$initpage{$env{'form.courseinit_page'}},$outcome); + $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].' + ,''.$$initpage{$env{'form.courseinit_page'}}.'' + ,''.$outcome.''),1); } } } } - return $result; + return &Apache::loncommon::confirmwrapper($result); } sub start_box { @@ -1539,24 +2258,46 @@ sub start_box { if ($$show{$caller}) { $r->print(' | ||||||||||
'.$lt{'chth'}.' | +'.$lt{'chth'}.' | |||||||||
'.$lt{'chin'}.' | +'.$lt{'chin'}.' | |||||||||
'.$lt{'chop'}.' | +'.$lt{'chop'}.' | |||||||||
'.$lt{'chin'}.' | +||||||||||
'.$lt{'chin'}.' | +||||||||||
'.$lt{'chin'}.' | +||||||||||