--- loncom/interface/lonwhatsnew.pm 2005/04/07 06:56:23 1.5
+++ 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.5 2005/04/07 06:56:23 albertel Exp $
+# $Id: lonwhatsnew.pm,v 1.130 2024/09/11 05:20:52 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -35,8 +37,14 @@ use Apache::lonhtmlcommon();
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
@@ -45,22 +53,140 @@ use Time::Local;
sub handler {
my $r = shift;
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['command']);
+ if ($r->header_only) {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+ return OK;
+ }
+ &Apache::loncommon::get_unprocessed_cgi(
+ $ENV{'QUERY_STRING'},['command','refpage']);
my $command = $env{'form.command'};
+ my $refpage = $env{'form.refpage'};
+
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
- if ($command eq '') {
- $command = "info";
+ 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],
+ ['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'};
+ if (!($checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope))) {
+ $scope .= '/'.$env{'request.course.sec'};
+ if ( $check_section ) {
+ $checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope);
+ }
+ if ($checkallowed{$key}) {
+ $checkallowed{$key.'_section'} = $env{'request.course.sec'};
+ }
+ }
}
- $r->print(&display_header());
- if (! (($env{'request.course.fn'}) && (&Apache::lonnet::allowed('vsa',$env{'request.course.id'})))) {
- # Not in a course, or not allowed to modify parms
- $env{'user.error.msg'}="/adm/whatsnew:vsa:0:0:Cannot display student activity";
+ 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";
return HTTP_NOT_ACCEPTABLE;
}
- &display_main_box($r,$command);
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+
+ $r->print(&display_header($command,\%checkallowed));
+
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew',
+ text=>"What's New?"});
+ if (($command eq 'chgthreshold') && $checkallowed{'abovethreshold'}) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({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,
+ 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,
+ 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,
+ 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'
+ ));
+ } 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,$cdom,$crs);
+ return OK;
}
#------------------------------
@@ -70,105 +196,98 @@ sub handler {
#------------------------------
sub display_main_box {
- my ($r,$command) = @_;
+ my ($r,$command,$refpage,$checkallowed,$cdom,$crs) = @_;
my $domain=&Apache::loncommon::determinedomain();
- my $tabbg=&Apache::loncommon::designparm('coordinator.tabbg',$domain);
- $r->print(<
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Course Action Items |
-
-
- |
-
-
- |
-
-
- |
-
-
-
-
-
-
-END_OF_BLOCK
- &display_nav_box($r,$command);
- $r->print(' | | ');
- $r->print('');
-
- if ($command eq 'config') {
- &display_config_box($r);
+ my $function = &Apache::loncommon::get_users_function();
+ my $lctype = lc(&Apache::loncommon::course_type());
+ $r->print('');
+
+ my %threshold_titles = &Apache::lonlocal::texthash (
+ av_attempts => 'Average number of attempts',
+ degdiff => 'Degree of difficulty',
+ numstudents => 'Total number of students with submissions',
+ );
+ 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 %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",
+ whatsnew => "What's New Page",
+ userpref => 'your general user preferences',
+ coursespecific => "specific setting for this $lctype",
+ );
+
+ if (($command eq 'chgthreshold')
+ && $checkallowed->{'abovethreshold'}) {
+ &display_threshold_config($r,$refpage,\%threshold_titles,$cdom,$crs);
+ } elsif (($command eq 'chginterval')
+ && $checkallowed->{'versionchanges'}) {
+ &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');
+ } elsif (($command eq 'chgsessionlimit')
+ && $checkallowed->{'sessions'}) {
+ &display_interval_config($r,$refpage,\%interval_titles,'sessions');
} else {
- &display_actions_box($r);
+ &display_actions_box($r,$command,$refpage,\%threshold_titles,
+ \%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
}
+ my $end_page = &Apache::loncommon::end_page();
$r->print(<
- |
-
- |
-
-
- |
-
-
- |
-
-
|
-