Diff for /loncom/interface/lonnavmaps.pm between versions 1.196 and 1.209

version 1.196, 2003/06/10 18:42:18 version 1.209, 2003/06/23 15:53:35
Line 72  my %statusIconMap = Line 72  my %statusIconMap =
       $resObj->TRIES_LEFT         => 'navmap.open.gif',        $resObj->TRIES_LEFT         => 'navmap.open.gif',
       $resObj->INCORRECT          => 'navmap.wrong.gif',        $resObj->INCORRECT          => 'navmap.wrong.gif',
       $resObj->OPEN               => 'navmap.open.gif',        $resObj->OPEN               => 'navmap.open.gif',
       $resObj->ATTEMPTED          => 'navmap.open.gif',        $resObj->ATTEMPTED          => 'navmap.ellipsis.gif',
       $resObj->ANSWER_SUBMITTED   => '' );        $resObj->ANSWER_SUBMITTED   => '' );
   
 my %iconAltTags =   my %iconAltTags = 
Line 92  my %colormap = Line 92  my %colormap =
       $resObj->TRIES_LEFT             => '',        $resObj->TRIES_LEFT             => '',
       $resObj->INCORRECT              => '',        $resObj->INCORRECT              => '',
       $resObj->OPEN                   => '',        $resObj->OPEN                   => '',
       $resObj->NOTHING_SET            => '' );        $resObj->NOTHING_SET            => '',
         $resObj->ATTEMPTED              => '',
         $resObj->ANSWER_SUBMITTED       => ''
         );
 # And a special case in the nav map; what to do when the assignment  # And a special case in the nav map; what to do when the assignment
 # is not yet done and due in less then 24 hours  # is not yet done and due in less then 24 hours
 my $hurryUpColor = "#FF0000";  my $hurryUpColor = "#FF0000";
Line 161  sub real_handler { Line 164  sub real_handler {
     # Now that we've displayed some stuff to the user, init the navmap      # Now that we've displayed some stuff to the user, init the navmap
     $navmap->init();      $navmap->init();
   
     $r->print('<br>&nbsp;');  
     $r->rflush();      $r->rflush();
   
     # Check that it's defined      # Check that it's defined
Line 244  sub real_handler { Line 246  sub real_handler {
         }          }
     } else {      } else {
         $r->print("<a href='navmaps?jumpToFirstHomework'>" .          $r->print("<a href='navmaps?jumpToFirstHomework'>" .
                   "Go To My First Homework Problem</a><br />");                    "Go To My First Homework Problem</a>&nbsp;&nbsp;&nbsp;&nbsp;");
     }      }
   
     my $suppressEmptySequences = 0;      my $suppressEmptySequences = 0;
     my $filterFunc = undef;      my $filterFunc = undef;
       my $resource_no_folder_link = 0;
   
     # Display only due homework.      # Display only due homework.
     my $showOnlyHomework = 0;      my $showOnlyHomework = 0;
     if ($ENV{QUERY_STRING} eq 'showOnlyHomework') {      if ($ENV{QUERY_STRING} eq 'showOnlyHomework') {
         $showOnlyHomework = 1;          $showOnlyHomework = 1;
         $suppressEmptySequences = 1;          $suppressEmptySequences = 1;
         $filterFunc = sub { my $res = shift;           $filterFunc = sub { my $res = shift; 
                             return $res->completable() || $res->is_sequence();                              return $res->completable() || $res->is_map();
                         };                          };
         $r->print("<p><font size='+2'>Uncompleted Homework</font></p>");          $r->print("<p><font size='+2'>Uncompleted Homework</font></p>");
         $ENV{'form.filter'} = '';          $ENV{'form.filter'} = '';
         $ENV{'form.condition'} = 1;          $ENV{'form.condition'} = 1;
    $resource_no_folder_link = 1;
     } else {      } else {
         $r->print("<a href='navmaps?showOnlyHomework'>" .          $r->print("<a href='navmaps?showOnlyHomework'>" .
                   "Show Only Uncompleted Homework</a><br />");                    "Show Only Uncompleted Homework</a>&nbsp;&nbsp;&nbsp;&nbsp;");
     }      }
   
     # renderer call      # renderer call
Line 272  sub real_handler { Line 277  sub real_handler {
                        'suppressNavmap' => 1,                         'suppressNavmap' => 1,
                        'suppressEmptySequences' => $suppressEmptySequences,                         'suppressEmptySequences' => $suppressEmptySequences,
                        'filterFunc' => $filterFunc,                         'filterFunc' => $filterFunc,
          'resource_no_folder_link' => $resource_no_folder_link,
                        'r' => $r};                         'r' => $r};
     my $render = render($renderArgs);      my $render = render($renderArgs);
     $navmap->untieHashes();      $navmap->untieHashes();
Line 378  sub getDescription { Line 384  sub getDescription {
         return "Excused by instructor";          return "Excused by instructor";
     }      }
     if ($status == $res->ATTEMPTED) {      if ($status == $res->ATTEMPTED) {
         return "Not yet graded.";          return "Answer submitted, not yet graded.";
     }      }
     if ($status == $res->TRIES_LEFT) {      if ($status == $res->TRIES_LEFT) {
         my $tries = $res->tries($part);          my $tries = $res->tries($part);
Line 410  sub dueInLessThen24Hours { Line 416  sub dueInLessThen24Hours {
     my $part = shift;      my $part = shift;
     my $status = $res->status($part);      my $status = $res->status($part);
   
     return ($status == $res->OPEN() || $status == $res->ATTEMPTED() ||      return ($status == $res->OPEN() ||
             $status == $res->TRIES_LEFT()) &&              $status == $res->TRIES_LEFT()) &&
            $res->duedate() && $res->duedate() < time()+(24*60*60) &&             $res->duedate() && $res->duedate() < time()+(24*60*60) &&
            $res->duedate() > time();             $res->duedate() > time();
Line 552  Apache::lonnavmap - Subroutines to handl Line 558  Apache::lonnavmap - Subroutines to handl
   
 The main handler generates the navigational listing for the course,  The main handler generates the navigational listing for the course,
 the other objects export this information in a usable fashion for  the other objects export this information in a usable fashion for
 other modules  other modules.
   
 =head1 Object: render  =head1 Subroutine: render
   
 The navmap renderer package provides a sophisticated rendering of the  The navmap renderer package provides a sophisticated rendering of the
 standard navigation maps interface into HTML. The provided nav map  standard navigation maps interface into HTML. The provided nav map
Line 568  understand then "undef, undef, undef, 1, Line 574  understand then "undef, undef, undef, 1,
 undef, 0" when you mostly want default behaviors.  undef, 0" when you mostly want default behaviors.
   
 The package provides a function called 'render', called as  The package provides a function called 'render', called as
 Apache::lonnavmaps::renderer->render({}).  Apache::lonnavmaps::render({}).
   
 =head2 Overview of Columns  =head2 Overview of Columns
   
Line 576  The renderer will build an HTML table fo Line 582  The renderer will build an HTML table fo
 it. The table is consists of several columns, and a row for each  it. The table is consists of several columns, and a row for each
 resource (or possibly each part). You tell the renderer how many  resource (or possibly each part). You tell the renderer how many
 columns to create and what to place in each column, optionally using  columns to create and what to place in each column, optionally using
 one or more of the preparent columns, and the renderer will assemble  one or more of the prepared columns, and the renderer will assemble
 the table.  the table.
   
 Any additional generally useful column types should be placed in the  Any additional generally useful column types should be placed in the
Line 594  argument hash passed to the renderer, an Line 600  argument hash passed to the renderer, an
 be inserted into the HTML representation as it.  be inserted into the HTML representation as it.
   
 The pre-packaged column names are refered to by constants in the  The pre-packaged column names are refered to by constants in the
 Apache::lonnavmaps::renderer namespace. The following currently exist:  Apache::lonnavmaps namespace. The following currently exist:
   
 =over 4  =over 4
   
Line 602  Apache::lonnavmaps::renderer namespace. Line 608  Apache::lonnavmaps::renderer namespace.
   
 The general info about the resource: Link, icon for the type, etc. The  The general info about the resource: Link, icon for the type, etc. The
 first column in the standard nav map display. This column also accepts  first column in the standard nav map display. This column also accepts
 the following parameter in the renderer hash:  the following parameters in the renderer hash:
   
 =over 4  =over 4
   
Line 835  sub render_resource { Line 841  sub render_resource {
     my $linkopen = "<a href='$link'>";      my $linkopen = "<a href='$link'>";
     my $linkclose = "</a>";      my $linkclose = "</a>";
   
     # Default icon: HTML page      # Default icon: unknown page
     my $icon = "<img src='/adm/lonIcons/html.gif' alt='' border='0' />";      my $icon = "<img src='/adm/lonIcons/unknown.gif' alt='' border='0' />";
           
     if ($resource->is_problem()) {      if ($resource->is_problem()) {
         if ($part eq '0' || $params->{'condensed'}) {          if ($part eq '0' || $params->{'condensed'}) {
Line 844  sub render_resource { Line 850  sub render_resource {
         } else {          } else {
             $icon = $params->{'indentString'};              $icon = $params->{'indentString'};
         }          }
       } else {
    my $curfext= (split (/\./,$resource->src))[-1];
    my $embstyle = &Apache::loncommon::fileembstyle($curfext);
    # The unless conditional that follows is a bit of overkill
    if (!(!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn')) {
       $icon = "<img src='/adm/lonIcons/$curfext.gif' alt='' border='0' />";
    }
     }      }
   
     # Display the correct map icon to open or shut map      # Display the correct map icon to open or shut map
Line 854  sub render_resource { Line 867  sub render_resource {
             $nowOpen = !$nowOpen;              $nowOpen = !$nowOpen;
         }          }
   
    my $folderType = $resource->is_sequence() ? 'folder' : 'page';
   
         if (!$params->{'resource_no_folder_link'}) {          if (!$params->{'resource_no_folder_link'}) {
             $icon = 'navmap.folder.' . ($nowOpen ? 'closed' : 'open') . '.gif';              $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif';
             $icon = "<img src='/adm/lonIcons/$icon' alt='' border='0' />";              $icon = "<img src='/adm/lonIcons/$icon' alt='' border='0' />";
   
             $linkopen = "<a href='" . $params->{'url'} . '?' .               $linkopen = "<a href='" . $params->{'url'} . '?' . 
Line 871  sub render_resource { Line 886  sub render_resource {
                 "&folderManip=1'>";                  "&folderManip=1'>";
         } else {          } else {
             # Don't allow users to manipulate folder              # Don't allow users to manipulate folder
             $icon = 'navmap.folder.' . ($nowOpen ? 'closed' : 'open') .              $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') .
                 '.nomanip.gif';                  '.nomanip.gif';
             $icon = "<img src='/adm/lonIcons/$icon' alt='' border='0' />";              $icon = "<img src='/adm/lonIcons/$icon' alt='' border='0' />";
   
Line 919  sub render_resource { Line 934  sub render_resource {
         $nonLinkedText .= ' (' . $resource->countParts() . ' parts)';          $nonLinkedText .= ' (' . $resource->countParts() . ' parts)';
     }      }
   
     if (!$params->{'resource_nolink'}) {      if (!$params->{'resource_nolink'} && $src !~ /^\/uploaded\// &&
    !$resource->is_sequence()) {
         $result .= "  $curMarkerBegin<a href='$link'>$title$partLabel</a>$curMarkerEnd $nonLinkedText</td>";          $result .= "  $curMarkerBegin<a href='$link'>$title$partLabel</a>$curMarkerEnd $nonLinkedText</td>";
     } else {      } else {
         $result .= "  $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText</td>";          $result .= "  $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText</td>";
Line 966  sub render_communication_status { Line 982  sub render_communication_status {
         }          }
     }      }
   
       if ($params->{'multipart'} && $part != '0') {
    $discussionHTML = $feedbackHTML = $errorHTML = '';
       }
   
     return "<td width=\"75\" align=\"left\" valign=\"center\">$discussionHTML$feedbackHTML$errorHTML&nbsp;</td>";      return "<td width=\"75\" align=\"left\" valign=\"center\">$discussionHTML$feedbackHTML$errorHTML&nbsp;</td>";
   
 }  }
Line 1001  sub render_long_status { Line 1021  sub render_long_status {
         $params->{'multipart'} && $part eq "0";          $params->{'multipart'} && $part eq "0";
                                   
     my $color;      my $color;
     if ($resource->is_problem() && ($resource->countParts() <= 1 || $part ne '') ) {      if ($resource->is_problem() && ($resource->countParts() <= 1) ) {
         $color = $colormap{$resource->status};          $color = $colormap{$resource->status};
                   
         if (dueInLessThen24Hours($resource, $part) ||          if (dueInLessThen24Hours($resource, $part) ||
Line 1289  sub render { Line 1309  sub render {
   
             if (ref($curRes)) {               if (ref($curRes)) { 
                 # Parallel pre-processing: Do sequences have non-filtered-out children?                  # Parallel pre-processing: Do sequences have non-filtered-out children?
                 if ($curRes->is_sequence()) {                  if ($curRes->is_map()) {
                     $curRes->{DATA}->{HAS_VISIBLE_CHILDREN} = 0;                      $curRes->{DATA}->{HAS_VISIBLE_CHILDREN} = 0;
                     # Sequences themselves do not count as visible children,                      # Sequences themselves do not count as visible children,
                     # unless those sequences also have visible children.                      # unless those sequences also have visible children.
Line 1352  sub render { Line 1372  sub render {
         }           } 
   
         # If this is an empty sequence and we're filtering them, continue on          # If this is an empty sequence and we're filtering them, continue on
         if ($curRes->is_sequence() && $args->{'suppressEmptySequences'} &&          if ($curRes->is_map() && $args->{'suppressEmptySequences'} &&
             !$curRes->{DATA}->{HAS_VISIBLE_CHILDREN}) {              !$curRes->{DATA}->{HAS_VISIBLE_CHILDREN}) {
             next;              next;
         }          }
Line 1411  sub render { Line 1431  sub render {
                         @parts = ($parts[0]);                          @parts = ($parts[0]);
                         $args->{'condensed'} = 1;                          $args->{'condensed'} = 1;
                     }                      }
                       
                 }                  }
    # Multipart problem with one part: always "condense" (happens
    #  to match the desirable behavior)
    if ($curRes->countParts() == 1) {
       @parts = ($parts[0]);
       $args->{'condensed'} = 1;
    }
             }              }
         }           } 
                           
Line 1474  sub render { Line 1499  sub render {
         }          }
     } continue {      } continue {
         $curRes = $it->next();          $curRes = $it->next();
   
    if ($r) {
       # If we have the connection, make sure the user is still connected
       my $c = $r->connection;
       if ($c->aborted()) {
    Apache::lonnet::logthis("navmaps aborted");
    # Who cares what we do, nobody will see it anyhow.
    return '';
       }
    }
     }      }
           
     # Print out the part that jumps to #curloc if it exists      # Print out the part that jumps to #curloc if it exists
Line 1586  sub new { Line 1621  sub new {
         return undef;          return undef;
     }      }
   
     # try copying into memory      $self->{NAV_HASH} = \%navmaphash;
     my %tmpnavhash;  
     while (my ($k, $v) = each(%navmaphash)) {  
  $tmpnavhash{$k} = $v;  
     }  
     untie %navmaphash;  
   
     $self->{NAV_HASH} = \%tmpnavhash;  
     $self->{PARM_HASH} = \%parmhash;      $self->{PARM_HASH} = \%parmhash;
     $self->{INITED} = 0;      $self->{INITED} = 0;
   
Line 2126  corresponds to where you want the iterat Line 2154  corresponds to where you want the iterat
 navmap->finishResource(). filterHash is a hash used as a set  navmap->finishResource(). filterHash is a hash used as a set
 containing strings representing the resource IDs, defaulting to  containing strings representing the resource IDs, defaulting to
 empty. Condition is a 1 or 0 that sets what to do with the filter  empty. Condition is a 1 or 0 that sets what to do with the filter
 hash: If a 0, then only resource that exist IN the filterHash will be  hash: If a 0, then only resources that exist IN the filterHash will be
 recursed on. If it is a 1, only resources NOT in the filterHash will  recursed on. If it is a 1, only resources NOT in the filterHash will
 be recursed on. Defaults to 0. forceTop is a boolean value. If it is  be recursed on. Defaults to 0. forceTop is a boolean value. If it is
 false (default), the iterator will only return the first level of map  false (default), the iterator will only return the first level of map
Line 2198  sub min { Line 2226  sub min {
     if ($a < $b) { return $a; } else { return $b; }      if ($a < $b) { return $a; } else { return $b; }
 }  }
   
 # In the CVS repository, documentation of this algorithm is included   
 # in /doc/lonnavdocs, as a PDF and .tex source. Markers like **1**  
 # will reference the same location in the text as the part of the  
 # algorithm is running through.  
   
 sub new {  sub new {
     # magic invocation to create a class instance      # magic invocation to create a class instance
     my $proto = shift;      my $proto = shift;
Line 2258  sub new { Line 2281  sub new {
     # that isn't just a redirector.      # that isn't just a redirector.
     my $resource; my $resourceCount = 0;      my $resource; my $resourceCount = 0;
   
       # Documentation on this algorithm can be found in the CVS repository at 
       # /docs/lonnavdocs; these "**#**" markers correspond to documentation
       # in that file.
     # **1**      # **1**
   
     foreach my $pass (@iterations) {      foreach my $pass (@iterations) {
Line 2936  sub is_map { my $self=shift; return defi Line 2962  sub is_map { my $self=shift; return defi
 sub is_page {  sub is_page {
     my $self=shift;      my $self=shift;
     my $src = $self->src();      my $src = $self->src();
     return ($src =~ /page$/);      return $self->navHash("is_map_", 1) && 
    $self->navHash("map_type_" . $self->map_pc()) eq 'page';
 }  }
 sub is_problem {  sub is_problem {
     my $self=shift;      my $self=shift;
Line 2946  sub is_problem { Line 2973  sub is_problem {
 sub is_sequence {  sub is_sequence {
     my $self=shift;      my $self=shift;
     my $src = $self->src();      my $src = $self->src();
     return ($src =~ /sequence$/);      return $self->navHash("is_map_", 1) && 
    $self->navHash("map_type_" . $self->map_pc()) eq 'sequence';
 }  }
   
 # Private method: Shells out to the parmval in the nav map, handler parts.  # Private method: Shells out to the parmval in the nav map, handler parts.
Line 3021  sub map_type { Line 3049  sub map_type {
     return $self->navHash("map_type_$pc", 0);      return $self->navHash("map_type_$pc", 0);
 }  }
   
   
   
 #####  #####
 # Property queries  # Property queries
 #####  #####

Removed from v.1.196  
changed lines
  Added in v.1.209


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>