--- loncom/interface/lonwhatsnew.pm 2005/04/05 22:49:17 1.1
+++ loncom/interface/lonwhatsnew.pm 2005/12/02 23:17:47 1.33
@@ -1,15 +1,44 @@
+#
+# $Id: lonwhatsnew.pm,v 1.33 2005/12/02 23:17:47 raeburn Exp $
+#
+# Copyright Michigan State University Board of Trustees
+#
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
+#
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
+#
+
+
package Apache::lonwhatsnew;
use strict;
use lib qw(/home/httpd/lib/perl);
use Apache::lonnet;
-use Apache::loncommon;
-use Apache::lonhtmlcommon;
+use Apache::loncommon();
+use Apache::lonhtmlcommon();
use Apache::lonlocal;
-use Apache::loncoursedata;
-use Apache::lonnavmaps;
+use Apache::loncoursedata();
+use Apache::lonnavmaps();
+use Apache::lonuserstate;
use Apache::Constants qw(:common :http);
use Time::Local;
+use GDBM_File;
#----------------------------
# handler
@@ -18,22 +47,47 @@ use Time::Local;
sub handler {
my $r = shift;
+ 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']);
- my $command = $ENV{'form.command'};
-
- if ($command eq '') {
- $command = "info";
+ my $command;
+ if ($env{'form.action'} eq 'reset') {
+ $command = 'reset';
+ } elsif ($env{'form.action'} eq 'update') {
+ $command = 'update';
+ } else {
+ $command = $env{'form.command'};
}
- $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";
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+ $r->print(&display_header($command));
+ if (! (($env{'request.course.fn'}) && (&Apache::lonnet::allowed('bre',$env{'request.course.id'})))) {
+ # Not in a course, or not allowed to view action items
+ $env{'user.error.msg'}="/adm/whatsnew:bre:0:0:Cannot display what's new screen";
return HTTP_NOT_ACCEPTABLE;
}
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ if (($command eq 'chgthreshold') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew?command=threshold',
+ text=>"Change thresholds"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ (undef,'Course Action Items','Course_Action_Items_Thresholds'));
+ } else {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew',
+ text=>"Display Action Items"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ (undef,'Course Action Items','Course_Action_Items_Display'));
+ }
&display_main_box($r,$command);
+ return OK;
}
#------------------------------
@@ -46,63 +100,22 @@ sub display_main_box {
my ($r,$command) = @_;
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);
+ $r->print('');
+
+ my %threshold_titles = (
+ av_attempts => 'Average number of attempts',
+ degdiff => 'Degree of difficulty',
+ numstudents => 'Total number of students with submissions',
+ );
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+
+ if (($command eq 'chgthreshold') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
+ &display_config_box($r,$command,$tabbg,\%threshold_titles,$cdom,$crs);
} else {
- &display_actions_box($r);
+ &display_actions_box($r,$command,\%threshold_titles,$cdom,$crs);
}
$r->print(<
- |
-
- |
-
-
- |
-
-
- |
-
-
|
@@ -111,37 +124,6 @@ END_OF_BLOCK
END_OF_BLOCK
}
-#------------------------------
-# display_nav_box
-#
-# Display the navigation box
-#------------------------------
-
-sub display_nav_box {
- my ($r,$command) = @_;
- $r->print(''."\n");
- if ($command eq "info") {
- $r->print('');
- $r->print('Action Items ');
- $r->print(' |
');
- } else {
- $r->print('');
- $r->print('Current Action Items ');
- $r->print(' |
');
- }
- $r->print(' |
');
- if ($command eq "config") {
- $r->print('');
- $r->print('Display options ');
- $r->print(' |
');
- } else {
- $r->print('');
- $r->print('Display options ');
- $r->print(' |
');
- }
- $r->print('
');
-}
-
#-------------------------------
# display_header
#
@@ -150,9 +132,10 @@ sub display_nav_box {
#-------------------------------
sub display_header{
+ my $html=&Apache::lonxml::xmlbegin();
my $bodytag=&Apache::loncommon::bodytag('Course Action Items');
return(<
+$html
Course Action Items
@@ -168,338 +151,593 @@ ENDHEAD
#-------------------------------
sub display_actions_box() {
- my $r = shift;
+ my ($r,$command,$threshold_titles,$cdom,$crs) = @_;
my $rowColor1 = "#ffffff";
my $rowColor2 = "#eeeeee";
- my $rowColor;
my %unread = ();
my %ungraded = ();
my %bombed = ();
+ my %triggered = ();
+ my %changed = ();
my @newmsgs = ();
my @critmsgs = ();
my @newdiscussions = ();
my @tograde = ();
my @bombs = ();
+ my @warnings = ();
+ my $msgcount = 0;
+ my $critmsgcount = 0;
+
+ my %res_title = ();
+ my %show = ();
+ my $needitems = 0;
+ my $boxcount = 0;
my $domain=&Apache::loncommon::determinedomain();
my $function;
- if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
+ if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
$function='coordinator';
}
- if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
+ if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
$function='admin';
}
+ my %threshold = (
+ av_attempts => 2,
+ degdiff => 0.5,
+ numstudents => 2,
+ );
+
my $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain);
my $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
- &getitems(\%unread,\%ungraded,\%bombed,\@newdiscussions,\@tograde,\@bombs);
- my ($msgcount,$critmsgcount) = &getmail(\@newmsgs,\@critmsgs);
-
- unless ($ENV{'request.course.id'}) {
- $r->print('
You are accessing an invalid course
');
+ unless ($env{'request.course.id'}) {
+ $r->print('
You are accessing an invalid course.
');
return;
}
- $r->print('Course Action Items
');
+ my %checkallowed = (
+ coursediscussion => &Apache::lonnet::allowed('pch',$env{'request.course.id'}),
+ handgrading => &Apache::lonnet::allowed('mgr',$env{'request.course.id'}),
+ abovethreshold => &Apache::lonnet::allowed('vgr',$env{'request.course.id'}),
+ haserrors => &Apache::lonnet::allowed('opa',$env{'request.course.id'}),
+ versionchanges => &Apache::lonnet::allowed('opa',$env{'request.course.id'}),
+ coursenormalmail => 1,
+ coursecritmail => 1,
+ );
+
+ my %display_settings = &get_display_settings();
+ my $starttime = 86400;
+ my %intervals = (
+ all => 'since resource creation',
+ -1 => 'since start of course',
+ 2592000 => 'since last month',
+ 604800 => 'since last week',
+ 86400 => 'since yesterday',
+ );
+ my $interval = $intervals{$starttime};
+
+ my %headings = &Apache::lonlocal::texthash(
+ coursediscussion => 'Unread course discussion posts',
+ handgrading => 'Problems requiring handgrading',
+ haserrors => 'Problems with errors',
+ versionchanges => 'Resources in course with version changes '.$interval,
+ coursenormalmail => 'New course message',
+ coursecritmail => 'New critical messages in course',
+ );
-## UNREAD COURSE DISCUSSION POSTS ##
- $r->print(<<"END");
-
-
-
-
- Unread course discussion posts: |
-
-
-
-
-END
-
- if (@newdiscussions > 0) {
-# @newdiscussions = sort { &cmp_title($a,$b) } @newdiscussions;
- my $rowNum = 0;
- foreach my $ressymb (@newdiscussions) {
- my $forum_title = $unread{$ressymb}{'title'};
- my ($map,$ind,$url)=&Apache::lonnet::decode_symb($ressymb);
- my $feedurl = &Apache::lonnet::clutter($url);
-# backward compatibility (bulletin boards used to be 'wrapped')
- if ($feedurl=~m|^/adm/wrapper/adm/.*/bulletinboard$|) {
- $feedurl=~s|^/adm/wrapper||;
- }
- my $unreadnum = keys %{$unread{$ressymb}};
- $unreadnum = $unreadnum - 2;
- if ($unreadnum > 0) {
- if ($rowNum %2 == 1) {
- $rowColor = $rowColor1;
- } else {
- $rowColor = $rowColor2;
- }
- $r->print(''.$forum_title.': | '.$unreadnum.' | ');
- $rowNum ++;
- }
- }
- } else {
- $r->print(' No unread posts in course discussions
| ');
+ if ($checkallowed{'abovethreshold'}) {
+ &get_curr_thresholds(\%threshold,$cdom,$crs);
}
- $r->print(' | | ');
-## UNGRADED ITEMS ##
- $r->print(<
-
-
-
- Problems requiring handgrading: |
-
-
-
-END
+ $headings{'abovethreshold'} = &mt('Problems with av. attempts').' ≥ '.$threshold{'av_attempts'}.' '.&mt('or deg. difficulty').' ≥ '.$threshold{'degdiff'}.' '.&mt('and total number of students with submissions').' ≥ '.$threshold{'numstudents'};
- if (@tograde > 0) {
- $r->print('Problem Name | Number ungraded | ');
- my $rowNum = 0;
- foreach my $res (@tograde) {
- if ($rowNum %2 == 1) {
- $rowColor = $rowColor1;
- } else {
- $rowColor = $rowColor2;
+ my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail');
+
+ foreach my $key (keys(%checkallowed)) {
+ $show{$key} = 0;
+ if ($checkallowed{$key}) {
+ unless ($display_settings{$key} eq 'off') {
+ $show{$key} = 1;
}
-
- $r->print(''.$ungraded{$res}{title}.' | '.$ungraded{$res}{count}.' | ');
- $rowNum ++;
}
- } else {
- $r->print(' No problems require handgrading
| ');
}
- $r->print(' | | |
');
- $r->print(' | ');
-## MESSAGES ##
- $r->print(<
-
-
-
-
- New course messages |
-
-
-
-
-END
- if ($msgcount > 0) {
- my $rowNum = 0;
- my $mailcount = 1;
- foreach my $msg (@newmsgs) {
- if ($rowNum %2 == 1) {
- $rowColor = $rowColor1;
- } else {
- $rowColor = $rowColor2;
+ foreach my $item (@actionorder) {
+ unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail') {
+ if ($show{$item}) {
+ $needitems = 1;
+ last;
}
- $r->print(''.$mailcount.'. | '.$msg->{'shortsub'}.' | '.$msg->{'from'}.'@'.$msg->{'fromdom'}.' | '.$msg->{'sendtime'}.' | ');
- $rowNum ++;
- $mailcount ++;
}
- } else {
- $r->print(' No new course messages
| ');
}
- $r->print(' | | ');
- $r->print(<
-
-
-
-
- New critical messages in course |
-
-
-
-END
+ if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
+ &GDBM_READER(),0640)) {
+ my $furl=$bighash{'first_url'};
+ $r->print('Go to first resource Change your preferences to suppress display of this screen when accessing courses as Course Coordinator in the future.
');
+ untie(%bighash);
+ }
- if ($critmsgcount > 0) {
- my $rowNum = 0;
- my $mailcount = 1;
- foreach my $msg (@critmsgs) {
- if ($rowNum %2 == 1) {
- $rowColor = $rowColor1;
- } else {
- $rowColor = $rowColor2;
+ my $result;
+
+ if ($command eq 'reset') {
+ $result = &process_reset($cdom,$crs);
+ } elsif ($command eq 'update') {
+ $result = &process_update($cdom,$crs,$threshold_titles);
+ }
+ if ($result) {
+ $r->print($result.' ');
+ }
+ $r->rflush();
+
+ if ($needitems) {
+ &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,$rowColor1,$rowColor2,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime);
+ }
+ if ($show{'coursenormalmail'}) {
+ &getnormalmail(\@newmsgs);
+ }
+ if ($show{'coursecritmail'}) {
+ &getcritmail(\@critmsgs);
+ }
+
+ $r->print(qq|Hide All Show All|);
+
+ $r->print('
');
+
+ my $displayed = 0;
+ my $totalboxes = keys(%checkallowed);
+ my $halfway = int($totalboxes/2) + $totalboxes%2;
+ foreach my $actionitem (@actionorder) {
+ if ($checkallowed{$actionitem}) {
+ if ($displayed == $halfway) {
+ $r->print(' | | ');
}
- $r->print(' | '.$mailcount.'. | '.$msg->{'shortsub'}.' | '.$msg->{'from'}.'@'.$msg->{'fromdom'}.' | '.$msg->{'sendtime'}.' | ');
- $rowNum ++;
- $mailcount ++;
+ &display_launcher($r,$actionitem,\%checkallowed,$tabbg,$rowColor1,$rowColor2,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,$interval);
+ $displayed ++;
}
- } else {
- $r->print(' No unread critical messages in course
| ');
}
-
- $r->print('
| ');
+ $r->print('
+
+ |
+
+
+ |
+
+ ');
+}
-## BOMBS ##
- $r->print(<
+#-------------------------------
+# display_config_box
+#
+# Display the threshold setting screen
+#
+#-------------------------------
+
+sub display_config_box() {
+ my ($r,$command,$tabbg,$threshold_titles,$cdom,$crs) = @_;
+ my %threshold = ();
+ my $rowColor1 = "#ffffff";
+ my $rowColor2 = "#eeeeee";
+ my $rowColor;
+
+ my @thresholditems = ("av_attempts","degdiff","numstudents");
+ my %threshold_titles = (
+ av_attempts => 'Average number of attempts',
+ degdiff => 'Degree of difficulty',
+ numstudents => 'Total number of students with submissions',
+ );
+ &get_curr_thresholds(\%threshold,$cdom,$crs);
+
+ $r->print('