--- loncom/interface/lonwhatsnew.pm 2008/12/12 15:48:05 1.83 +++ loncom/interface/lonwhatsnew.pm 2008/12/20 01:39:47 1.84 @@ -1,5 +1,5 @@ # -# $Id: lonwhatsnew.pm,v 1.83 2008/12/12 15:48:05 raeburn Exp $ +# $Id: lonwhatsnew.pm,v 1.84 2008/12/20 01:39:47 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -490,8 +490,9 @@ sub display_actions_box { } } + my $itemserror; if ($needitems) { - &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread); + $itemserror = &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread); } if ($show{'coursenormalmail'}) { $msgcount = &getnormalmail(\@newmsgs); @@ -533,7 +534,7 @@ sub display_actions_box { if ($displayed == $halfway) { $r->print(' '); } - &display_launcher($r,$actionitem,$refpage,$checkallowed,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,\%interval,$countunread,\%expired,$expirecount,\%activated,$activecount,$crstype); + &display_launcher($r,$actionitem,$refpage,$checkallowed,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,\%interval,$countunread,\%expired,$expirecount,\%activated,$activecount,$crstype,$itemserror); $displayed ++; } } @@ -786,23 +787,23 @@ sub display_launcher { $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered, $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs, $interval,$countunread,$expired,$expirecount,$activated,$activecount, - $crstype) = @_; + $crstype,$itemserror) = @_; if ($$checkallowed{$action}) { &start_box($r,$show,$headings,$action,$refpage,$action); if ($$show{$action}) { if ($action eq 'handgrading') { # UNGRADED ITEMS - &display_handgrade($r,$tograde,$ungraded); + &display_handgrade($r,$tograde,$ungraded,$itemserror); } elsif ($action eq 'haserrors') { # BOMBS - &display_haserrors($r,$bombs,$bombed,$res_title); + &display_haserrors($r,$bombs,$bombed,$res_title,$itemserror); } elsif ($action eq 'versionchanges') { # VERSION CHANGES - &display_versionchanges($r,$changed,$res_title,$interval->{'versions'}); + &display_versionchanges($r,$changed,$res_title,$interval->{'versions'},$itemserror); } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS &display_abovethreshold($r,$refpage,$warnings,$triggered, - $res_title); + $res_title,$itemserror); } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION &display_coursediscussion($r,$newdiscussions,$unread, - $countunread,$res_title); + $countunread,$res_title,$itemserror); } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES &display_coursenormalmail($r,$msgcount,$newmsgs); } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES @@ -825,6 +826,10 @@ sub getitems { $tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show, $starttime,$countunread) = @_; my $navmap = Apache::lonnavmaps::navmap->new(); + if (!defined($navmap)) { + my $itemserror = ''.&mt('An error occurred retrieving information about the course.').'
'.&mt('It is recommended that you [_1]re-select the course[_2].','','').'
'; + return $itemserror; + } # 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;}); @@ -883,6 +888,7 @@ sub getitems { } } + return; } sub check_discussions { @@ -1446,7 +1452,7 @@ sub checkversions { } sub display_handgrade { - my ($r,$tograde,$ungraded) = @_; + my ($r,$tograde,$ungraded,$itemserror) = @_; my %lt = &Apache::lonlocal::texthash( 'prna' => 'Problem Name', 'nmun' => 'Number ungraded', @@ -1469,13 +1475,15 @@ sub display_handgrade { } $r->print(''.$$ungraded{$res}{title}.''.$$ungraded{$res}{count}.''); } + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print(''.$lt{'nopr'}.''); } } sub display_haserrors { - my ($r,$bombs,$bombed,$res_title) = @_; + my ($r,$bombs,$bombed,$res_title,$itemserror) = @_; my $bombnum = 0; my %lt = &Apache::lonlocal::texthash( reso => 'Resource', @@ -1494,6 +1502,8 @@ sub display_haserrors { ''. $$bombed{$bomb}{errorcount}.''); } + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print(''.$lt{'noer'}.''); } @@ -1501,7 +1511,7 @@ sub display_haserrors { } sub display_abovethreshold { - my ($r,$refpage,$warnings,$triggered,$res_title) = @_; + my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror) = @_; my %lt = &Apache::lonlocal::texthash( reso => 'Resource', part => 'Part', @@ -1557,13 +1567,15 @@ sub display_abovethreshold { } } $r->print('
'); + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print(''.$lt{'nopr'}.''); } } sub display_versionchanges { - my ($r,$changed,$res_title,$interval) = @_; + my ($r,$changed,$res_title,$interval,$itemserror) = @_; my %lt = &Apache::lonlocal::texthash( 'reso' => 'Resource', 'revd' => 'Last revised', @@ -1590,6 +1602,8 @@ sub display_versionchanges { $$changed{$item}{'current'}.''. $$changed{$item}{'version'}.''); } + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print('' .&mt('No '.$interval).''); @@ -1655,7 +1669,7 @@ sub display_rolechanges { } sub display_coursediscussion { - my ($r,$newdiscussions,$unread,$countunread,$res_title) = @_; + my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_; my $lctype = lc(&Apache::loncommon::course_type()); my %lt = &Apache::lonlocal::texthash( 'loca' => 'Location', @@ -1703,6 +1717,8 @@ sub display_coursediscussion { } $r->print("\n"); } + } elsif ($itemserror) { + $r->print(''.$itemserror.''); } else { $r->print(''.$lt{'noun'}.''); }