--- loncom/interface/lonwhatsnew.pm 2006/05/31 14:25:02 1.57 +++ loncom/interface/lonwhatsnew.pm 2017/09/13 23:54:07 1.105.2.15 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.57 2006/05/31 14:25:02 raeburn Exp $ +# $Id: lonwhatsnew.pm,v 1.105.2.15 2017/09/13 23:54:07 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',1], + ['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,41 +120,62 @@ 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, + ({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage, text=>"Change thresholds"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs ("What's New?",#'Course_Action_Items_Thresholds' )); } elsif (($command eq 'chginterval') && $checkallowed{'versionchanges'} ) { &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'/adm/whatsnew?command=chginterval&refpage='.$refpage, + ({href=>'/adm/whatsnew?command=chginterval&refpage='.$refpage, text=>"Change interval"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs ("What's New?",#'Course_Action_Items_Intervals' )); } elsif (($command eq 'chgdisc') && $checkallowed{'coursediscussion'}) { &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'/adm/whatsnew?command=chgdisc&refpage='.$refpage, + ({href=>'/adm/whatsnew?command=chgdisc&refpage='.$refpage, text=>"Change discussion display"}); $r->print(&Apache::lonhtmlcommon::breadcrumbs ("What's New?",#'Course_Action_Items_Intervals' )); } elsif ($command eq 'courseinit') { &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'/adm/whatsnew?command=courseinit&refpage='.$refpage, + ({href=>'/adm/whatsnew?command=courseinit&refpage='.$refpage, text=>"Course initialization preference"}); $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,11 +186,10 @@ 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 $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain); - my $lctype = lc($env{'course.'.$env{'request.course.id'}.'.type'}); + my $lctype = lc(&Apache::loncommon::course_type()); $r->print('
');
my %threshold_titles = &Apache::lonlocal::texthash (
@@ -153,37 +197,65 @@ 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,$tabbg,\%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,$tabbg,$command,$refpage,\%threshold_titles,
+ &display_actions_box($r,$command,$refpage,\%threshold_titles,
\%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
}
my $end_page = &Apache::loncommon::end_page();
@@ -206,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";
';
}
- return &Apache::loncommon::start_page(&mt('[_1] Action Items',
- $env{'course.'.$env{'request.course.id'}.'.type'}),$scripttag);
+ my $course_type=&Apache::loncommon::course_type();
+ return &Apache::loncommon::start_page("What's New?",
+ $scripttag);
}
#-------------------------------
@@ -240,22 +367,19 @@ END
#-------------------------------
sub display_actions_box {
- my ($r,$tabbg,$command,$refpage,$threshold_titles,$interval_titles,
- $initpage,$cdom,$crs,$checkallowed) = @_;
- my $rowColor1 = "#ffffff";
- my $rowColor2 = "#eeeeee";
-
+ my ($r,$command,$refpage,$threshold_titles,$interval_titles,$initpage,
+ $cdom,$crs,$checkallowed) = @_;
my $udom = $env{'user.domain'};
my $uname = $env{'user.name'};
my $cid = $env{'request.course.id'};
- my $crstype = $env{'course.'.$cid.'.type'};
+ my $crstype = &Apache::loncommon::course_type();
my $lctype = lc($crstype);
my %stulabel = (
'Course' => 'students',
- 'Group' => 'members',
+ 'Community' => 'members',
);
my %lt = &Apache::lonlocal::texthash(
- 'yacc' => 'You are accessing an invalid course or group',
+ 'yacc' => 'You are accessing an invalid course',
'gtfr' => 'Go to first resource',
'hial' => 'Hide all',
'shal' => 'Show all',
@@ -274,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,14 +414,10 @@ sub display_actions_box {
$result = &store_courseinit_setting($uname,$udom,$cid,$initpage);
}
- my %threshold = (
- av_attempts => 2,
- degdiff => 0.5,
- numstudents => 2,
- );
+ 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',
@@ -302,26 +427,37 @@ sub display_actions_box {
my $currinit = $pagedesc{$initdisp}.' ('.$pagedesc{$initcontrol}.')';
unless ($cid) {
- $r->print(' '); + $r->print(' '.$lt{'yacc'}.' '); 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 [_1]',$lctype). - '. '); + $header .= &mt('Page set to be displayed after you have selected a role in this '.$lctype).'.' + .' ' + .&mt('Currently: [_1].',''.$currinit.'') + .' ' + .&mt('[_1]Change[_2] for just [_3]this '.$lctype.'[_4] or for [_5]all your courses/communities[_6].' + ,'' + ,'' + ,'' + ,'' + ,'' + ,'') + .' '; + + $r->print(&Apache::loncommon::head_subbox($header)); if ($command eq 'reset') { - $result = &process_reset($cdom,$crs); + $result = &process_reset($cdom,$crs,$checkallowed); } elsif ($command eq 'update') { $result = &process_update($uname,$udom,$threshold_titles); } elsif ($command eq 'newinterval') { @@ -333,48 +469,138 @@ sub display_actions_box { my $store_result=&store_display_settings($uname,$udom,$cid,$checkallowed); unless ($store_result eq 'ok') { - &Apache::lonnet::logthis('Error storing whatsnew settings: '. + &Apache::lonnet::logthis('Error saving whatsnew settings: '. $store_result.' for '.'user '.$uname.':'.$udom.' in '.$lctype.' '.$cid); - $result .= &mt('Unable to store visibility settings due to [_1]', - $store_result); + $result .= '' + .&mt('Unable to save visibility settings due to [_1]', + $store_result) + .''; } if ($result) { - $r->print($result.' '); + $r->print($result.' '); } $r->rflush(); - + my (%timediff,%interval); my %display_settings = &get_display_settings($uname,$udom,$cid); - my $timediff = $display_settings{$cid.':interval'}; - unless (defined($timediff)) { $timediff = 604800; } - my $now = time; - my $interval = $$interval_titles{$timediff}; - if ($timediff == -1) { - $timediff = time; - } - my $starttime = $now - $timediff; - my $countunread = $display_settings{$cid.':countunread'}; - unless (defined($countunread)) { - $countunread = 'on'; - } + $timediff{'versions'} = $display_settings{$cid.':interval'}; + unless (defined($timediff{'versions'})) { $timediff{'versions'} = 604800; } + $interval{'versions'} = $interval_titles->{'versions'}->{$timediff{'versions'}}; my %headings = &Apache::lonlocal::texthash( - coursediscussion => 'Unread '.$lctype.' discussion posts', - handgrading => 'Problems requiring handgrading', - haserrors => 'Problems with errors', - versionchanges => 'Resources in '.$lctype.' with version changes '.$interval, + coursediscussion => 'Unread '.$lctype.' discussion posts', + handgrading => 'Problems requiring handgrading', + haserrors => 'Problems with errors', coursenormalmail => 'New '.$lctype.' messages', - coursecritmail => 'New critical messages in '.$lctype, + coursecritmail => 'New critical messages in '.$lctype, ); + if ($timediff{'versions'} == -1) { + $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since start of '.$lctype); + } elsif ($timediff{'versions'} == 2592000) { + $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last month'); + } elsif ($timediff{'versions'} == 604800) { + $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last week'); + } elsif ($timediff{'versions'} == 86400) { + $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since yesterday'); + } + + $timediff{'oldroles'} = $display_settings{$cid.':oldroleinterval'}; + unless (defined($timediff{'oldroles'})) { $timediff{'oldroles'} = 604800; } + $interval{'oldroles'} = $interval_titles->{'oldroles'}->{$timediff{'oldroles'}}; + + if ($timediff{'oldroles'} == -1) { + $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since start of '.$lctype); + } elsif ($timediff{'oldroles'} == 2592000) { + $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last month'); + } elsif ($timediff{'oldroles'} == 604800) { + $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last week'); + } elsif ($timediff{'oldroles'} == 86400) { + $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since yesterday'); + } + + $timediff{'newroles'} = $display_settings{$cid.':newroleinterval'}; + unless (defined($timediff{'newroles'})) { $timediff{'newroles'} = 604800; } + $interval{'newroles'} = $interval_titles->{'newroles'}->{$timediff{'newroles'}}; + + if ($timediff{'newroles'} == -1) { + $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since start of '.$lctype); + } elsif ($timediff{'newroles'} == 2592000) { + $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last month'); + } elsif ($timediff{'newroles'} == 604800) { + $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last week'); + } elsif ($timediff{'newroles'} == 86400) { + $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since yesterday'); + } + + $timediff{'crslogin'} = $display_settings{$cid.':crslogininterval'}; + unless (defined($timediff{'crslogin'})) { $timediff{'crslogin'} = 604800; } + $interval{'crslogin'} = $interval_titles->{'crslogin'}->{$timediff{'crslogin'}}; + + if ($timediff{'crslogin'} == -1) { + $headings{'crslogin'} = &mt('Last login for anyone who has ever logged in'); + } elsif ($timediff{'crslogin'} == 2592000) { + $headings{'crslogin'} = &mt('Last login for users in last 30 days'); + } elsif ($timediff{'crslogin'} == 604800) { + $headings{'crslogin'} = &mt('Last login for users in last 7 days'); + } elsif ($timediff{'crslogin'} == 86400) { + $headings{'crslogin'} = &mt('Last login for users in last 24 hours'); + } + + my ($now,$starttime,$activatedstart,$expiredstart,$crsloginstart); + $now = time; + + if ($timediff{'versions'} == -1) { + $starttime = 0; + } else { + $starttime = $now - $timediff{'versions'}; + } + + if ($timediff{'newroles'} == -1) { + $activatedstart = 0; + } else { + $activatedstart = $now - $timediff{'newroles'}; + } + + if ($timediff{'oldroles'} == -1) { + $expiredstart = 0; + } else { + $expiredstart = $now - $timediff{'oldroles'}; + } + + if ($timediff{'crslogin'} == -1) { + $crsloginstart = 0; + } else { + $crsloginstart = $now - $timediff{'crslogin'}; + } + + my $countunread = $display_settings{$cid.':countunread'}; + unless (defined($countunread)) { + $countunread = 'on'; + } if ($$checkallowed{'abovethreshold'}) { &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs); } - $headings{'abovethreshold'} = &mt('Problems with av. attempts').' ≥ '.$threshold{'av_attempts'}.' '.&mt('or deg. difficulty').' ≥ '.$threshold{'degdiff'}.' '.&mt('and total number of [_1] with submissions',$stulabel{$crstype}).' ≥ '.$threshold{'numstudents'}; - - my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail'); + $headings{'abovethreshold'} = + &mt('(Problems with av. attempts ≥ [_1] or deg. difficulty ≥ [_2]) [_3] and total number of '.$stulabel{$crstype}.' with submissions ≥ [_4]', + $threshold{'av_attempts'},$threshold{'degdiff'}, + ' ',$threshold{'numstudents'}); + + my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles','crslogin'); + my %actioncolumn = ( + handgrading => 'left', + haserrors => 'left', + abovethreshold => 'left', + versionchanges => 'left', + coursediscussion => 'right', + coursenormalmail => 'right', + coursecritmail => 'right', + newroles => 'right', + oldroles => 'right', + crslogin => 'right', + ); foreach my $key (keys(%{$checkallowed})) { if ($key =~ /_section$/) { next; } @@ -387,7 +613,8 @@ sub display_actions_box { } foreach my $item (@actionorder) { - unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail') { + unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail' || + $item eq 'newroles' || $item eq 'oldroles') { if ($show{$item}) { $needitems = 1; last; @@ -395,8 +622,13 @@ sub display_actions_box { } } + my $itemserror; if ($needitems) { - &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,$rowColor1,$rowColor2,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread); + $itemserror = &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread,$checkallowed); + } + my $classlist; + if ($show{'oldroles'} || $show{'newroles'} || $show{'crslogin'}) { + $classlist = &Apache::loncoursedata::get_classlist(); } if ($show{'coursenormalmail'}) { $msgcount = &getnormalmail(\@newmsgs); @@ -404,7 +636,15 @@ sub display_actions_box { if ($show{'coursecritmail'}) { $critmsgcount = &getcritmail(\@critmsgs); } - + if ($show{'oldroles'}) { + $expirecount = &getexpired(\%expired,$expiredstart,'previous',$classlist); + } + if ($show{'newroles'}) { + $activecount = &getactivated(\%activated,$activatedstart,'active',$classlist); + } + if ($show{'crslogin'}) { + $logincount = &getloggedin($cdom,$crs,\%loggedin,$crsloginstart); + } $r->print(qq|$lt{'hial'} $lt{'shal'}
|