[LON-CAPA-cvs] cvs: loncom(version_2_8_X) /interface lonwhatsnew.pm

raeburn raeburn@source.lon-capa.org
Sun, 21 Dec 2008 16:41:15 -0000


raeburn		Sun Dec 21 16:41:15 2008 EDT

  Modified files:              (Branch: version_2_8_X)
    /loncom/interface	lonwhatsnew.pm 
  Log:
  _ Backport 1.84.
  
  
Index: loncom/interface/lonwhatsnew.pm
diff -u loncom/interface/lonwhatsnew.pm:1.80.2.2 loncom/interface/lonwhatsnew.pm:1.80.2.3
--- loncom/interface/lonwhatsnew.pm:1.80.2.2	Wed Dec 17 19:22:00 2008
+++ loncom/interface/lonwhatsnew.pm	Sun Dec 21 16:41:15 2008
@@ -1,5 +1,5 @@
 #
-# $Id: lonwhatsnew.pm,v 1.80.2.2 2008/12/17 19:22:00 raeburn Exp $
+# $Id: lonwhatsnew.pm,v 1.80.2.3 2008/12/21 16:41:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -488,8 +488,9 @@
         }
     }
 
+    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);
@@ -531,7 +532,7 @@
             if ($displayed == $halfway) {
                 $r->print('</td><td>&nbsp;</td><td class="LC_right_col" >');
             }
-            &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 ++; 
         }
     }
@@ -778,23 +779,23 @@
         $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
@@ -817,6 +818,10 @@
         $tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show,
         $starttime,$countunread) = @_;
     my $navmap = Apache::lonnavmaps::navmap->new();
+    if (!defined($navmap)) {
+        my $itemserror = '<span class="LC_warning">'.&mt('An error occurred retrieving information about the course.').'<br />'.&mt('It is recommended that you [_1]re-select the course[_2].','<a href="/adm/roles">','</a>').'</span>';
+        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;});
@@ -875,6 +880,7 @@
         }
 
     }
+    return;
 }
 
 sub check_discussions {
@@ -1438,7 +1444,7 @@
 }
 
 sub display_handgrade {
-    my ($r,$tograde,$ungraded) = @_;
+    my ($r,$tograde,$ungraded,$itemserror) = @_;
     my %lt = &Apache::lonlocal::texthash(
                         'prna' => 'Problem Name',
                         'nmun' => 'Number ungraded',
@@ -1461,13 +1467,15 @@
             } 
             $r->print('<tr'.$css_class.'><td><a href="'.$linkurl.'">'.$$ungraded{$res}{title}.'</a></td><td class="LC_right_item">'.$$ungraded{$res}{count}.'</td></tr>');
         }
+    } elsif ($itemserror) {
+        $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
     } else {
         $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
     }
 }
 
 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',
@@ -1486,6 +1494,8 @@
                       '</td><td class="LC_right_item">'.
                       $$bombed{$bomb}{errorcount}.'</td></tr>');
         }
+    } elsif ($itemserror) {
+        $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
     } else {
         $r->print('<tr class="LC_empty_row"><td>'.$lt{'noer'}.'</td></tr>');
     }
@@ -1493,7 +1503,7 @@
 }
 
 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',
@@ -1549,13 +1559,15 @@
             }
         }
         $r->print('<tr class="LC_info_row"><td colspan="7" class="LC_right_item"><br /><input type="submit" name="counters" value="'.$lt{'rese'}.'" /></td></tr></form>');
+    } elsif ($itemserror) {
+        $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
     } else {
         $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
     }
 }
 
 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',
@@ -1582,6 +1594,8 @@
                       $$changed{$item}{'current'}.'</td><td>'.
                       $$changed{$item}{'version'}.'</td></tr>');
         }
+    } elsif ($itemserror) {
+        $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
     } else {
         $r->print('<tr class="LC_empty_row"><td>'
                  .&mt('No '.$interval).'</td></tr>');
@@ -1647,7 +1661,7 @@
 }
  
 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',
@@ -1695,6 +1709,8 @@
             }
             $r->print("</tr>\n");
         }
+    } elsif ($itemserror) {
+        $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
     } else {
         $r->print('<tr class="LC_empty_row"><td>'.$lt{'noun'}.'</td></tr>');
     }