[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm

bowersj2 lon-capa-cvs@mail.lon-capa.org
Fri, 10 Jan 2003 18:45:30 -0000


bowersj2		Fri Jan 10 13:45:30 2003 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
  Log:
  Should fix the bomb problems, and the feedback problems? Also dropped a couple
  of comments that I shouldn't have.
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.123 loncom/interface/lonnavmaps.pm:1.124
--- loncom/interface/lonnavmaps.pm:1.123	Fri Jan 10 12:46:46 2003
+++ loncom/interface/lonnavmaps.pm	Fri Jan 10 13:45:30 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.123 2003/01/10 17:46:46 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.124 2003/01/10 18:45:30 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -96,6 +96,11 @@
                                           ''));
     $r->print('<script>window.focus();</script>');
 
+    $r->rflush();
+
+    # Now that we've displayed some stuff to the user, init the navmap
+    $navmap->init();
+
     $r->print('<table border="0" cellpadding="2" cellspacing="0">');
     my $date=localtime;
     $r->print('<tr><td align="right" valign="bottom">Key:&nbsp;&nbsp;</td>');
@@ -178,9 +183,6 @@
     $r->print('<br>&nbsp;');
     $r->rflush();
 
-    # Now that we've displayed some stuff to the user, init the navmap
-    $navmap->init();
-
     # Check that it's defined
     if (!($navmap->courseMapDefined())) {
         $r->print('<font size="+2" color="red">Coursemap undefined.</font>' .
@@ -600,7 +602,7 @@
                 $r->print("</td>\n");
 
                 # SECOND COL: Is there text, feedback, errors??
-                my $discussionHTML = ""; my $feedbackHTML = "";
+                my $discussionHTML = ""; my $feedbackHTML = ""; my $errorHTML = "";
 
                 if ($curRes->hasDiscussion()) {
                     $discussionHTML = $linkopen .
@@ -620,7 +622,19 @@
                     }
                 }
 
-                $r->print("<td width=\"75\" align=\"left\" valign=\"center\">$discussionHTML$feedbackHTML&nbsp;</td>");
+                if ($curRes->getErrors()) {
+                    my $errors = $curRes->getErrors();
+                    foreach (split(/,/, $errors)) {
+                        if ($_) {
+                            $errorHTML .= '&nbsp;<a href="/adm/email?display='
+                                . &Apache::lonnet::escape($_) . '">'
+                                . '<img src="/adm/lonMisc/bomb.gif" '
+                                . 'border="0" /></a>';
+                        }
+                    }
+                }
+
+                $r->print("<td width=\"75\" align=\"left\" valign=\"center\">$discussionHTML$feedbackHTML$errorHTML&nbsp;</td>");
 
                 # Is this the first displayed part of a multi-part problem
                 # that has not been condensed, so we should suppress these two
@@ -1060,7 +1074,7 @@
         my %emailstatus = &Apache::lonnet::dump('email_status');
         my $logoutTime = $emailstatus{'logout'};
         my $courseLeaveTime = $emailstatus{'logout_'.$ENV{'request.course.id'}};
-        $self->{LAST_CHECK} = ($courseLeaveTime > $logoutTime ?
+        $self->{LAST_CHECK} = ($courseLeaveTime < $logoutTime ?
                                $courseLeaveTime : $logoutTime);
         my %discussiontime = &Apache::lonnet::dump('discussiontimes', 
                                                    $cdom, $cnum);
@@ -1141,18 +1155,19 @@
     $self->untieHashes();
 }
 
-# Private function: Does the given resource (as a symb string) have
+# Does the given resource (as a symb string) have
 # current discussion? Returns 0 if chat/mail data not extracted.
 sub hasDiscussion {
     my $self = shift;
     my $symb = shift;
     if (!defined($self->{DISCUSSION_TIME})) { return 0; }
 
+    #return defined($self->{DISCUSSION_TIME}->{$symb});
     return $self->{DISCUSSION_TIME}->{$symb} >
            $self->{LAST_CHECK};
 }
 
-# Private function: Does the given resource (as a symb string) have
+# Does the given resource (as a symb string) have
 # current feedback? Returns the string in the feedback hash, which
 # will be false if it does not exist.
 sub getFeedback { 
@@ -1164,6 +1179,14 @@
     return $self->{FEEDBACK}->{$symb};
 }
 
+sub getErrors { 
+    my $self = shift;
+    my $src = shift;
+    
+    if (!defined($self->{ERROR_MSG})) { return ""; }
+    return $self->{ERROR_MSG}->{$src};
+}
+
 =pod
 
 =item * B<getById>(id): Based on the ID of the resource (1.1, 3.2, etc.), get a resource object for that resource. This method, or other methods that use it (as in the resource object) is the only proper way to obtain a resource object.
@@ -2229,7 +2252,16 @@
 
 sub getFeedback {
     my $self = shift;
-    return $self->{NAV_MAP}->getFeedback($self->src());
+    my $source = $self->src();
+    if ($source !~ /^\/res\//) { $source = substr $source, 5; }
+    return $self->{NAV_MAP}->getFeedback($source);
+}
+
+sub getErrors {
+    my $self = shift;
+    my $source = $self->src();
+    if ($source =~ /^\/res\//) { $source = substr $source, 5; }
+    return $self->{NAV_MAP}->getErrors($source);
 }
 
 =pod