--- loncom/interface/lonwhatsnew.pm 2010/08/09 23:39:43 1.98.2.2
+++ loncom/interface/lonwhatsnew.pm 2024/09/11 05:20:52 1.130
@@ -1,5 +1,7 @@
+# The LearningOnline Network
+# What's New in a course
#
-# $Id: lonwhatsnew.pm,v 1.98.2.2 2010/08/09 23:39:43 raeburn Exp $
+# $Id: lonwhatsnew.pm,v 1.130 2024/09/11 05:20:52 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -62,17 +64,37 @@ 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],
+ ['vcl','sessions',1],
+ ['mgr','resetcounters',1],
) {
my ($perm,$key,$check_section) = @{ $perm_check };
my $scope = $env{'request.course.id'};
@@ -89,7 +111,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;
}
@@ -151,12 +173,19 @@ sub handler {
$r->print(&Apache::lonhtmlcommon::breadcrumbs
("What's New?",#'Course_Action_Items_Intervals'
));
+ } elsif ($command eq 'chgsessionlimit' && $checkallowed{'sessions'}) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew?command=chgsessionlimit&refpage='.$refpage,
+ text=>"Change session range"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ ("What's New?",#'Course_Action_Items_Sessions'
+ ));
} 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;
}
@@ -167,7 +196,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());
@@ -197,16 +226,24 @@ sub display_main_box {
86400 => 'roles which expired since yesterday',
);
my %crslogins = (
- -1 => 'last login for anyone who has ever logged in',
- 2592000 => 'last login for users in last 30 days',
- 604800 => 'last login for users in last 7 days',
- 86400 => 'last login for users in last 24 hours',
+ -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 %sessions = (
+ 300 => 'course sessions active in the last 5 minutes',
+ 600 => 'course sessions active in the last 10 minutes',
+ 1800 => 'course sessions active in the last 30 minutes',
+ 7200 => 'course sessions active in the last 2 hours',
+ -7200 => 'course sessions with last activity more than 2 hours ago',
);
my %interval_titles = (
versions => \%versions,
newroles => \%newroles,
oldroles => \%oldroles,
crslogin => \%crslogins,
+ sessions => \%sessions,
);
my %initpage = &Apache::lonlocal::texthash (
firstres => "first resource in the $lctype",
@@ -214,13 +251,10 @@ sub display_main_box {
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,'versions');
@@ -237,7 +271,10 @@ sub display_main_box {
&display_interval_config($r,$refpage,\%interval_titles,'oldroles');
} elsif (($command eq 'chgcrslogininterval')
&& $checkallowed->{'crslogin'}) {
- &display_interval_config($r,$refpage,\%interval_titles,'crslogin');
+ &display_interval_config($r,$refpage,\%interval_titles,'crslogin');
+ } elsif (($command eq 'chgsessionlimit')
+ && $checkallowed->{'sessions'}) {
+ &display_interval_config($r,$refpage,\%interval_titles,'sessions');
} else {
&display_actions_box($r,$command,$refpage,\%threshold_titles,
\%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
@@ -263,10 +300,11 @@ sub display_header {
my $scripttag;
unless ($command eq 'chgthreshold' || $command eq 'chginterval' ||
- $command eq 'chgoldroleinterval' ||
+ $command eq 'chgoldroleinterval' ||
$command eq 'chgnewroleinterval' || $command eq 'chgcrslogininterval') {
$scripttag = <<"END";
-';
+ENDTOGG
}
my $course_type=&Apache::loncommon::course_type();
return &Apache::loncommon::start_page("What's New?",
@@ -346,7 +391,6 @@ function togglelogins() {
sub display_actions_box {
my ($r,$command,$refpage,$threshold_titles,$interval_titles,$initpage,
$cdom,$crs,$checkallowed) = @_;
- my $custommenu = &Apache::loncommon::needs_gci_custom();
my $udom = $env{'user.domain'};
my $uname = $env{'user.name'};
my $cid = $env{'request.course.id'};
@@ -382,6 +426,8 @@ sub display_actions_box {
my %activated;
my %loggedin;
my $logincount;
+ my %sessions;
+ my $sessioncount;
my %res_title = ();
my %show = ();
my $needitems = 0;
@@ -410,7 +456,7 @@ sub display_actions_box {
}
my $header = '';
- if (($refpage eq 'start') && (!$custommenu)) {
+ if ($refpage eq 'start') {
if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
&GDBM_READER(),0640)) {
my $furl=&HTML::Entities::encode($bighash{'first_url'},'"<>&');
@@ -419,8 +465,7 @@ sub display_actions_box {
'
';
}
}
- unless ($custommenu) {
- $header .= &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.'')
.' '
@@ -433,11 +478,10 @@ sub display_actions_box {
,'')
.' ';
- $r->print(&Apache::loncommon::head_subbox($header));
- }
+ $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') {
@@ -528,29 +572,49 @@ sub display_actions_box {
$headings{'crslogin'} = &mt('Last login for users in last 24 hours');
}
- my $now = time;
+ $timediff{'sessions'} = $display_settings{$cid.':sessionactivity'};
+ unless (defined($timediff{'sessions'})) { $timediff{'sessions'} = 7200; }
+ $interval{'sessions'} = $interval_titles->{'sessions'}->{$timediff{'sessions'}};
+
+ if ($timediff{'sessions'} == -7200) {
+ $headings{'sessions'} = &mt('Session with activity more than 2 hours ago');
+ } elsif ($timediff{'sessions'} == 7200) {
+ $headings{'sessions'} = &mt('Session with activity in last 2 hours');
+ } elsif ($timediff{'sessions'} == 1800) {
+ $headings{'sessions'} = &mt('Session with activity in last 30 minutes');
+ } elsif ($timediff{'sessions'} == 600) {
+ $headings{'sessions'} = &mt('Session with activity in last 10 minutes');
+ } elsif ($timediff{'sessions'} == 300) {
+ $headings{'sessions'} = &mt('Session with activity in last 5 minutes');
+ }
+
+ my ($now,$starttime,$activatedstart,$expiredstart,$crsloginstart);
+ $now = time;
+
if ($timediff{'versions'} == -1) {
- $timediff{'versions'} = time;
+ $starttime = 0;
+ } else {
+ $starttime = $now - $timediff{'versions'};
}
- my $starttime = $now - $timediff{'versions'};
if ($timediff{'newroles'} == -1) {
- $timediff{'newroles'} = time;
+ $activatedstart = 0;
+ } else {
+ $activatedstart = $now - $timediff{'newroles'};
}
- my $activatedstart = $now - $timediff{'newroles'};
if ($timediff{'oldroles'} == -1) {
- $timediff{'oldroles'} = time;
+ $expiredstart = 0;
+ } else {
+ $expiredstart = $now - $timediff{'oldroles'};
}
- my $expiredstart = $now - $timediff{'oldroles'};
-
if ($timediff{'crslogin'} == -1) {
- $timediff{'crslogin'} = time;
+ $crsloginstart = 0;
+ } else {
+ $crsloginstart = $now - $timediff{'crslogin'};
}
- my $crsloginstart = $now - $timediff{'crslogin'};
-
my $countunread = $display_settings{$cid.':countunread'};
unless (defined($countunread)) {
$countunread = 'on';
@@ -564,12 +628,20 @@ sub display_actions_box {
$threshold{'av_attempts'},$threshold{'degdiff'},
'
',$threshold{'numstudents'});
- my @actionorder;
- if ($custommenu) {
- @actionorder = ('coursenormalmail','coursecritmail','newroles','oldroles','crslogin');
- } else {
- @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles');
- }
+ my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles','crslogin','sessions');
+ my %actioncolumn = (
+ handgrading => 'left',
+ haserrors => 'left',
+ abovethreshold => 'left',
+ versionchanges => 'left',
+ coursediscussion => 'right',
+ coursenormalmail => 'right',
+ coursecritmail => 'right',
+ newroles => 'right',
+ oldroles => 'right',
+ crslogin => 'right',
+ sessions => 'right',
+ );
foreach my $key (keys(%{$checkallowed})) {
if ($key =~ /_section$/) { next; }
@@ -583,7 +655,8 @@ sub display_actions_box {
foreach my $item (@actionorder) {
unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail' ||
- $item eq 'newroles' || $item eq 'oldroles') {
+ $item eq 'newroles' || $item eq 'oldroles' ||
+ $item eq 'crslogin' || $item eq 'sessions') {
if ($show{$item}) {
$needitems = 1;
last;
@@ -593,7 +666,11 @@ sub display_actions_box {
my $itemserror;
if ($needitems) {
- $itemserror = &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%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'} || $show{'sessions'}) {
+ $classlist = &Apache::loncoursedata::get_classlist();
}
if ($show{'coursenormalmail'}) {
$msgcount = &getnormalmail(\@newmsgs);
@@ -602,15 +679,17 @@ sub display_actions_box {
$critmsgcount = &getcritmail(\@critmsgs);
}
if ($show{'oldroles'}) {
- $expirecount = &getexpired(\%expired,$expiredstart,'previous');
+ $expirecount = &getexpired(\%expired,$expiredstart,'previous',$classlist);
}
if ($show{'newroles'}) {
- $activecount = &getactivated(\%activated,$activatedstart,'active');
+ $activecount = &getactivated(\%activated,$activatedstart,'active',$classlist);
}
if ($show{'crslogin'}) {
$logincount = &getloggedin($cdom,$crs,\%loggedin,$crsloginstart);
}
-
+ if ($show{'sessions'}) {
+ $sessioncount = &getsessions($cdom,$crs,\%sessions,$timediff{'sessions'},$classlist);
+ }
$r->print(qq|$lt{'hial'}
$lt{'shal'}