--- loncom/interface/lonwhatsnew.pm 2006/01/06 22:50:29 1.46 +++ loncom/interface/lonwhatsnew.pm 2006/05/30 12:46:09 1.55 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.46 2006/01/06 22:50:29 albertel Exp $ +# $Id: lonwhatsnew.pm,v 1.55 2006/05/30 12:46:09 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -39,6 +39,8 @@ use Apache::lonuserstate; use Apache::Constants qw(:common :http); use Time::Local; use GDBM_File; +use lib '/home/httpd/lib/perl/'; +use LONCAPA; #---------------------------- # handler @@ -100,28 +102,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')); + ("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')); + ("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')); + ("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')); + ("What's New?",#'Course_Action_Items_Initialization' + )); } else { $r->print(&Apache::lonhtmlcommon::breadcrumbs - (undef,"What's New?",'Course_Action_Items_Display')); + ("What's New?",#'Course_Action_Items_Display' + )); } &display_main_box($r,$command,$refpage,\%checkallowed); return OK; @@ -178,12 +185,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 +203,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 +227,7 @@ END '; } - return(< -Course Action Items -$scripttag - -$bodytag -ENDHEAD + return &Apache::loncommon::start_page('Course Action Items',$scripttag); } #------------------------------- @@ -311,7 +310,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 +563,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 +706,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 +714,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 +734,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 +758,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()) { @@ -856,7 +809,7 @@ sub check_bombed { my @bombs = split(/,/, $errors); my $errorcount = scalar(@bombs); my $errorlink = ''. + &escape($bombs[0]).'">'. $title.''; $$bombed{$symb}{errorcount} = $errorcount; $$bombed{$symb}{errorlink} = $errorlink; @@ -877,6 +830,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"})) { @@ -916,8 +872,8 @@ sub check_thresholds { $$triggered{$symb}{title} = $resource->title; foreach my $part (@parts) { if (exists($stats{$part}{users})) { - my $resetname = 'reset_'.&Apache::lonnet::escape($symb."\0".$part); - my $resettitle = 'title_'.&Apache::lonnet::escape($symb."\0".$part); + my $resetname = 'reset_'.&escape($symb."\0".$part); + my $resettitle = 'title_'.&escape($symb."\0".$part); if ($$triggered{$symb}{numparts}) { $$triggered{$symb}{text} .= ''."\n"; } @@ -933,7 +889,7 @@ sub check_thresholds { '.$stats{$part}{attempts}.' '.$stats{$part}{degdiff}.' '.$lastreset{$part}.' - + '; $$triggered{$symb}{numparts} ++; } @@ -1004,8 +960,8 @@ sub process_reset { my %titles = (); foreach my $key (keys(%env)) { next if ($key !~ /^form\.reset_(.+)$/); - my $title = &Apache::lonnet::unescape($env{'form.title_'.$1}); - my $reset_item = &Apache::lonnet::unescape($1); + my $title = &unescape($env{'form.title_'.$1}); + my $reset_item = &unescape($1); my %curr_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item); my %aggregates = (); my ($symb,$part) = split(/\0/,$reset_item); @@ -1063,7 +1019,7 @@ sub getnormalmail { my @messages = sort(&Apache::lonnet::getkeys('nohist_email')); foreach my $message (@messages) { - my $msgid=&Apache::lonnet::escape($message); + my $msgid=&escape($message); my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)= &Apache::lonmsg::unpackmsgid($msgid); if (($fromcid) && ($fromcid eq $env{'request.course.id'})) { @@ -1075,7 +1031,6 @@ sub getnormalmail { if ($shortsubj eq '') { $shortsubj = &mt('No subject'); } - $shortsubj = &Apache::lonnet::unescape($shortsubj); push(@{$newmsgs}, { msgid => $msgid, sendtime => $sendtime, @@ -1107,7 +1062,6 @@ sub getcritmail { if ($shortsubj eq '') { $shortsubj = &mt('No subject'); } - $shortsubj = &Apache::lonnet::unescape($shortsubj); push(@{$critmsgs}, { msgid => $msgid, sendtime => $sendtime, @@ -1181,7 +1135,7 @@ sub display_handgrade { } my ($map,$id,$url)=&Apache::lonnet::decode_symb($res); my $linkurl=&Apache::lonnet::clutter($url); - $linkurl .= '?symb='.&Apache::lonnet::escape($res); + $linkurl .= '?symb='.&escape($res); $r->print(''.$$ungraded{$res}{title}.''.$$ungraded{$res}{count}.''); $rowNum ++; @@ -1252,7 +1206,7 @@ sub display_abovethreshold { if ($$triggered{$res}{numparts} > 1) { $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"'; } - $linkurl .= '?symb='.&Apache::lonnet::escape($res); + $linkurl .= '?symb='.&escape($res); $r->print(''.$$triggered{$res}{title}.''.$$triggered{$res}{text}); $warningnum ++; } @@ -1286,7 +1240,7 @@ sub display_versionchanges { } my ($map,$id,$url)=&Apache::lonnet::decode_symb($item); my $linkurl=&Apache::lonnet::clutter($url); - $linkurl .= '?symb='.&Apache::lonnet::escape($item); + $linkurl .= '?symb='.&escape($item); $r->print(''.$$res_title{$item}.''.$$changed{$item}{'revdate'}.''.$$changed{$item}{'current'}.''.$$changed{$item}{'version'}.''); $changenum ++;