--- loncom/interface/lonwhatsnew.pm 2005/04/07 04:22:03 1.4
+++ loncom/interface/lonwhatsnew.pm 2005/12/19 23:24:40 1.38.2.1
@@ -1,5 +1,5 @@
#
-# $Id: lonwhatsnew.pm,v 1.4 2005/04/07 04:22:03 albertel Exp $
+# $Id: lonwhatsnew.pm,v 1.38.2.1 2005/12/19 23:24:40 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -35,8 +35,10 @@ use Apache::lonhtmlcommon();
use Apache::lonlocal;
use Apache::loncoursedata();
use Apache::lonnavmaps();
+use Apache::lonuserstate;
use Apache::Constants qw(:common :http);
use Time::Local;
+use GDBM_File;
#----------------------------
# handler
@@ -45,22 +47,57 @@ 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 = $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;
+ 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;
}
- &display_main_box($r,$command);
+ 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,
+ );
+
+ $r->print(&display_header($command,\%checkallowed));
+
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew',
+ text=>"Display Action Items"});
+ if (($command eq 'chgthreshold') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew?command=chgthreshold',
+ text=>"Change thresholds"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ (undef,'Course Action Items','Course_Action_Items_Thresholds'));
+ } elsif (($command eq 'chginterval') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/whatsnew?command=chginterval',
+ text=>"Change interval"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ (undef,'Course Action Items','Course_Action_Items_Intervals'));
+ } else {
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ (undef,'Course Action Items','Course_Action_Items_Display'));
+ }
+ &display_main_box($r,$command,\%checkallowed);
+ return OK;
}
#------------------------------
@@ -70,66 +107,39 @@ sub handler {
#------------------------------
sub display_main_box {
- my ($r,$command) = @_;
+ my ($r,$command,$checkallowed) = @_;
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 %interval_titles = (
+ -1 => 'since start of course',
+ 2592000 => 'since last month',
+ 604800 => 'since last week',
+ 86400 => 'since yesterday',
+ );
+
+ 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_threshold_config($r,$command,$tabbg,\%threshold_titles,
+ $cdom,$crs);
+ } elsif (($command eq 'chginterval') &&
+ (&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) {
+ &display_interval_config($r,\%interval_titles);
} else {
- &display_actions_box($r);
+ &display_actions_box($r,$command,\%threshold_titles,\%interval_titles,
+ $cdom,$crs,$checkallowed);
}
$r->print(<
- |
-
- |
-
-
- |
-
-
- |
-
-
|
@@ -138,37 +148,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
#
@@ -177,12 +156,36 @@ sub display_nav_box {
#-------------------------------
sub display_header{
+ my ($command,$checkallowed) = @_;
my $html=&Apache::lonxml::xmlbegin();
my $bodytag=&Apache::loncommon::bodytag('Course Action Items');
+ my $scripttag;
+ unless ($command eq 'chgthreshold' || $command eq 'chginterval') {
+ $scripttag = <<"END";
+
+';
+ }
return(<
Course Action Items
+$scripttag
$bodytag
ENDHEAD
@@ -196,330 +199,701 @@ ENDHEAD
#-------------------------------
sub display_actions_box() {
- my $r = shift;
-
+ my ($r,$command,$threshold_titles,$interval_titles,$cdom,$crs,
+ $checkallowed) = @_;
my $rowColor1 = "#ffffff";
my $rowColor2 = "#eeeeee";
- my $rowColor;
+
+ my $udom = $env{'user.domain'};
+ my $uname = $env{'user.name'};
+ my $cid = $env{'request.course.id'};
+
+ my %lt = &Apache::lonlocal::texthash(
+ 'yacc' => 'You are accessing an invalid course.',
+ 'gtfr' => 'Go to first resource',
+ 'chyp' => 'Change your preferences',
+ 'tsup' => 'to suppress display of this screen when accessing'.
+ ' this course in the future.',
+ 'hial' => 'Hide all',
+ 'shal' => 'Show all',
+ );
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 ($cid) {
+ $r->print('
'.$lt{'yacc'}.'
');
return;
}
- $r->print('Course Action Items
');
+ if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
+ &GDBM_READER(),0640)) {
+ my $furl=$bighash{'first_url'};
+ $r->print(''.$lt{'gtfr'}.
+ ''.
+ ' '.$lt{'chyp'}.' '.$lt{'tsup'}.'
');
+ untie(%bighash);
+ }
+
+ my $result;
+
+ if ($command eq 'reset') {
+ $result = &process_reset($cdom,$crs);
+ } elsif ($command eq 'update') {
+ $result = &process_update($cdom,$crs,$threshold_titles);
+ } elsif ($command eq 'newinterval') {
+ $result = &store_interval_setting($uname,$udom,$cid,$interval_titles);
+ }
-## UNREAD COURSE DISCUSSION POSTS ##
- $r->print(<<"END");
-
-
-
-
- Unread course discussion posts: |
-
-
-
-
-END
+ my $store_result=&store_display_settings($uname,$udom,$cid,$checkallowed);
- if (@newdiscussions > 0) {
-# @newdiscussions = sort { &cmp_title($a,$b) } @newdiscussions;
- my $rowNum = 0;
- foreach my $ressymb (@newdiscussions) {
- my $forum_title = $unread{$ressymb}{'title'};
- my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
- 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
| ');
+ unless ($store_result eq 'ok') {
+ &Apache::lonnet::logthis('Error storing whatsnew settings: '.
+ $store_result.' for '.'user '.$uname.':'.$udom.' in course '.$cid);
+ $result .= &mt('Unable to store visibility settings due to [_1]',
+ $store_result);
}
- $r->print(' | | ');
-## UNGRADED ITEMS ##
- $r->print(<
-
-
-
- Problems requiring handgrading: |
-
-
-
-END
+ if ($result) {
+ $r->print($result.' ');
+ }
+ $r->rflush();
- 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 %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 = 1;
+
+ 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 messages',
+ coursecritmail => 'New critical messages in course',
+ );
+
+ if ($$checkallowed{'abovethreshold'}) {
+ &get_curr_thresholds(\%threshold,$cdom,$crs);
+ }
+
+ $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'};
+
+ my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail');
+
+ foreach my $key (keys(%{$checkallowed})) {
+ $show{$key} = 0;
+ if ($$checkallowed{$key}) {
+ unless ($display_settings{$cid.':'.$key} eq 'hide') {
+ $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(' | | ');
+ if ($needitems) {
+ &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,$rowColor1,$rowColor2,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread);
+ }
+ if ($show{'coursenormalmail'}) {
+ &getnormalmail(\@newmsgs);
+ }
+ if ($show{'coursecritmail'}) {
+ &getcritmail(\@critmsgs);
+ }
- $r->print(<
-
-
-
-
- New critical messages in course |
-
-
-
-END
+ $r->print(qq|$lt{'hial'}
+ $lt{'shal'}
+
');
+
+ 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,$countunread);
+ $displayed ++;
}
- } else {
- $r->print(' No unread critical messages in course
| ');
}
-
- $r->print('
| ');
+ $r->print('
+
+ |
+
+
+ |
+
+ ');
+}
-## BOMBS ##
- $r->print(<
+#-------------------------------
+# display_threshold_config
+#
+# Display the threshold setting screen
+#
+#-------------------------------
+
+sub display_threshold_config {
+ 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('