--- loncom/interface/lonwhatsnew.pm 2006/01/06 22:37:27 1.45
+++ loncom/interface/lonwhatsnew.pm 2006/03/04 05:59:01 1.51
@@ -1,5 +1,5 @@
#
-# $Id: lonwhatsnew.pm,v 1.45 2006/01/06 22:37:27 albertel Exp $
+# $Id: lonwhatsnew.pm,v 1.51 2006/03/04 05:59:01 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -100,28 +100,33 @@ sub handler {
({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage,
text=>"Change thresholds"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs
- (undef,"What's New?",'Course_Action_Items_Thresholds'));
+ (undef,"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
- (undef,"What's New?",'Course_Action_Items_Intervals'));
+ (undef,"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
- (undef,"What's New?",'Course_Action_Items_Intervals'));
+ (undef,"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
- (undef,"What's New?",'Course_Action_Items_Initialization'));
+ (undef,"What's New?",#'Course_Action_Items_Initialization'
+ ));
} else {
$r->print(&Apache::lonhtmlcommon::breadcrumbs
- (undef,"What's New?",'Course_Action_Items_Display'));
+ (undef,"What's New?",#'Course_Action_Items_Display'
+ ));
}
&display_main_box($r,$command,$refpage,\%checkallowed);
return OK;
@@ -311,7 +316,7 @@ sub display_actions_box {
}
}
$r->print($lt{'pgse'}.' '.&mt('Currently: [_1]',''.$currinit.'').
- ' '.&mt('[_1] for just [_2]','Change',
+ ' '.&mt('[_1] for just [_2]','Change',
'this course').' '.&mt('or for all [_1].',
'$lt{'hial'}
@@ -564,24 +569,34 @@ sub display_discussion_config {
if ($current eq '') {
$current = 'on';
}
- my %status = (
- on => 'checked="checked"',
- off => 'checked="checked"',
- );
- $status{$current} = '';
- $r->print(' '.&mt('Choose whether or not to display a count of the number of new posts for each resource or bulletin board which has unread posts.').' '.&mt('This can increase the time taken to gather data for the [_1] page by a few seconds.',"What's New?").' '.&mt('Currently set to [_1] .'),"$current.");
+ my %opposite = (
+ 'on' => 'off',
+ 'off' => 'on',
+ );
+ $r->print('');
+ $r->print(' '.&mt('Choose whether or not to display a count of the number of new posts for each resource or bulletin board which has unread posts.').' '.&mt('This can increase the time taken to gather data for the [_1] page by a few seconds.',"What's New?").' '.&mt('Currently set to [_1].',''.$current.''));
$r->print('
-');
+ $r->print('
+
+  
+
+ ');
return;
}
@@ -697,7 +712,6 @@ sub getitems {
# force retrieve Resource to seed the part id cache we'll need it later
my @allres=$navmap->retrieveResources(undef,
sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;});
- my %lastreadtime;
my %resourcetracker;
my $discussiontime;
@@ -706,17 +720,6 @@ sub getitems {
&checkversions($cdom,$crs,$navmap,$changed,$starttime);
}
- if ($$show{'coursediscussion'}) {
- my %lastread = &Apache::lonnet::dump('nohist_'.
- $env{'request.course.id'}.'_discuss',
- $env{'user.domain'},$env{'user.name'},'lastread');
- foreach my $key (keys(%lastread)) {
- my $newkey = $key;
- $newkey =~ s/_lastread$//;
- $lastreadtime{$newkey} = $lastread{$key};
- }
- }
-
if ($$show{'abovethreshold'}) {
%resourcetracker = &Apache::lonnet::dump('nohist_resourcetracker',
$cdom,$crs);
@@ -737,8 +740,8 @@ sub getitems {
# Check if there are unread discussion postings
if ($$show{'coursediscussion'}) {
- &check_discussions($cdom,$crs,$resource,$symb,$ressymb,$title,
- $newdiscussions,$unread);
+ &check_discussions($resource,$symb,$ressymb,$title,
+ $newdiscussions,$unread,$countunread);
}
# Check for ungraded problems
@@ -761,73 +764,26 @@ sub getitems {
}
}
- my $hasdiscussion = @{$newdiscussions};
- if ($$show{'coursediscussion'} && $hasdiscussion) { # Get time of last post;
- $discussiontime = $navmap->{DISCUSSION_TIME};
- foreach my $ressymb (@{$newdiscussions}) {
- $$unread{$ressymb}{'lastpost'} = $$discussiontime{$ressymb};
- }
- if ($countunread eq 'on') { #Get count of unread postings for each resource
- my $discussiondata = $navmap->get_discussion_data();
- foreach my $ressymb (@{$newdiscussions}) {
- &get_discussions($cdom,$crs,$discussiondata,$ressymb,
- $unread,\%lastreadtime);
- }
- }
- }
}
sub check_discussions {
- my ($cdom,$crs,$resource,$symb,$ressymb,$title,$newdiscussions,
- $unread) = @_;
- if ($resource->hasDiscussion()) {
- %{$$unread{$ressymb}} = ();
- $$unread{$ressymb}{'title'} = $title;
- $$unread{$ressymb}{'symb'} = $symb;
- push(@{$newdiscussions}, $ressymb);
- }
-}
+ my ($resource,$symb,$ressymb,$title,$newdiscussions,$unread,
+ $countunread) = @_;
-sub get_discussions {
- my ($cdom,$crs,$discussiondata,$ressymb,$unread,$lastreadtime) = @_;
- my $prevread = 0;
- my $unreadcount = 0;
- if (defined($$lastreadtime{$ressymb})) {
- $prevread = $$lastreadtime{$ressymb};
- }
- my $version = $$discussiondata{'version:'.$ressymb};
- if ($version) {
- my $hiddenflag = 0;
- my $deletedflag = 0;
- my ($hidden,$deleted);
- for (my $id=$version; $id>0; $id--) {
- my $vkeys=$$discussiondata{$id.':keys:'.$ressymb};
- my @keys=split(/:/,$vkeys);
- if (grep/^hidden$/,@keys) {
- unless ($hiddenflag) {
- $hidden = $$discussiondata{$id.':'.$ressymb.':hidden'};
- $hiddenflag = 1;
- }
- } elsif (grep/^deleted$/,@keys) {
- unless ($deletedflag) {
- $deleted = $$discussiondata{$id.':'.$ressymb.':deleted'};
- $deletedflag = 1;
- }
- } else {
- unless (($hidden =~/\.$id\./) || ($deleted =~/\.$id\./)) {
- if ($prevread <$$discussiondata{$id.':'.$ressymb.':timestamp'}) {
- $unreadcount ++;
- $$unread{$ressymb}{$unreadcount} = $id.': '.
- $$discussiondata{$id.':'.$ressymb.':subject'};
- }
- }
- }
- }
- $$unread{$ressymb}{'unreadcount'} = $unreadcount;
+ if (!$resource->hasDiscussion()) { return; }
+
+ %{$$unread{$ressymb}} = ();
+ $$unread{$ressymb}{'title'} = $title;
+ $$unread{$ressymb}{'symb'} = $symb;
+ push(@{$newdiscussions}, $ressymb);
+
+ $$unread{$ressymb}{'lastpost'} = $resource->last_post_time();
+
+ if ($countunread eq 'on') {
+ $$unread{$ressymb}{'unreadcount'} = $resource->unread_discussion();
}
}
-
sub check_handgraded {
my ($resource,$symb,$title,$cdom,$cnum,$ungraded,$tograde) = @_;
if ($resource->is_problem()) {
@@ -880,6 +836,9 @@ sub check_thresholds {
if ($resource->handgrade($part) eq 'yes') {
next;
}
+ if ($resource->is_survey($part)) {
+ next;
+ }
%{$stats{$part}} = ();
my ($attempts,$users,$corrects,$degdiff,$av_attempts);
if (exists($$resourcetracker{$symb."\0".$part."\0attempts"})) {