--- loncom/interface/lonwhatsnew.pm 2006/01/06 22:50:29 1.46 +++ loncom/interface/lonwhatsnew.pm 2006/03/15 19:41:26 1.52 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.46 2006/01/06 22:50:29 albertel Exp $ +# $Id: lonwhatsnew.pm,v 1.52 2006/03/15 19:41:26 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; @@ -178,12 +183,12 @@ sub display_main_box { &display_actions_box($r,$tabbg,$command,$refpage,\%threshold_titles, \%interval_titles,\%initpage,$cdom,$crs,$checkallowed); } + my $end_page = &Apache::loncommon::end_page(); $r->print(<
- - +$end_page END_OF_BLOCK } @@ -196,8 +201,7 @@ END_OF_BLOCK 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"; @@ -221,14 +225,7 @@ END '; } - return(< -Course Action Items -$scripttag - -$bodytag -ENDHEAD + return &Apache::loncommon::start_page('Course Action Items',$scripttag); } #------------------------------- @@ -311,7 +308,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,21 +561,34 @@ sub display_discussion_config { if ($current eq '') { $current = 'on'; } - my %status = ( $current => 'checked="checked"'); - - $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?").'  '); + 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('

-
'. -&mt('Display of unread post counts?').'  + - -    - + '); - $r->print('

-
'); + $r->print('
+ +         + + '); return; } @@ -694,7 +704,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; @@ -703,17 +712,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); @@ -734,8 +732,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 @@ -758,73 +756,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()) { @@ -877,6 +828,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"})) {