Diff for /loncom/interface/lonnavmaps.pm between versions 1.282 and 1.292

version 1.282, 2004/08/29 04:09:27 version 1.292, 2004/09/18 16:55:33
Line 127  sub nav_control_js { Line 127  sub nav_control_js {
   
 function gonav(url) {  function gonav(url) {
    if (w_loncapanav_flag != 1) {     if (w_loncapanav_flag != 1) {
       go(url);        gopost(url,'');
    }  else {     }  else {
       navwindow=window.open(url,        navwindow=window.open(url,
                   "loncapanav","height=600,width=400,scrollbars=1");                     "loncapanav","height=600,width=400,scrollbars=1"); 
Line 262  ENDSUBM Line 262  ENDSUBM
               &Apache::loncommon::bodytag('Navigate Course Contents','',                &Apache::loncommon::bodytag('Navigate Course Contents','',
   $addentries,$body_only,'',    $addentries,$body_only,'',
   $ENV{'form.register'}));    $ENV{'form.register'}));
     $r->print('<script>window.focus();</script>'.      $r->print('<script>window.focus();</script>');
       &Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT'));  
             
     $r->rflush();      $r->rflush();
   
     # Check that it's defined      # Check that it's defined
     if (!($navmap->courseMapDefined())) {      if (!($navmap->courseMapDefined())) {
    $r->print(&Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT'));
         $r->print('<font size="+2" color="red">Coursemap undefined.</font>' .          $r->print('<font size="+2" color="red">Coursemap undefined.</font>' .
                   '</body></html>');                    '</body></html>');
         return OK;          return OK;
Line 354  ENDSUBM Line 354  ENDSUBM
     } else {      } else {
  &add_linkitem(\%toplinkitems,'firsthomework',   &add_linkitem(\%toplinkitems,'firsthomework',
       'location.href="navmaps?jumpToFirstHomework"',        'location.href="navmaps?jumpToFirstHomework"',
       "Go To My First Homework Problem");        "Show Me My First Homework Problem");
     }      }
   
     my $suppressEmptySequences = 0;      my $suppressEmptySequences = 0;
Line 396  ENDSUBM Line 396  ENDSUBM
                  </nobr>                   </nobr>
                </form>");                 </form>");
     # renderer call      # renderer call
     my $renderArgs = { 'cols' => [0,2,3],      my $renderArgs = { 'cols' => [0,1,2,3],
        'sort' => $ENV{'form.sort'},         'sort' => $ENV{'form.sort'},
                        'url' => '/adm/navmaps',                         'url' => '/adm/navmaps',
                        'navmap' => $navmap,                         'navmap' => $navmap,
Line 1580  END Line 1580  END
     }      }
   
     if ($args->{'caller'} eq 'navmapsdisplay') {      if ($args->{'caller'} eq 'navmapsdisplay') {
           $result .= '<table><tr><td>'.
                      &Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT').'</td>';
    if ($ENV{'environment.remotenavmap'} ne 'on') {
       $result .= '<td>&nbsp;</td>'; 
           } else {
       $result .= '</tr><tr>'; 
           }
  $result.=&show_linkitems($args->{'linkitems'});   $result.=&show_linkitems($args->{'linkitems'});
         if ($args->{'sort_html'}) {          if ($args->{'sort_html'}) {
     if ($ENV{'environment.remotenavmap'} ne 'on') {      if ($ENV{'environment.remotenavmap'} ne 'on') {
Line 1678  END Line 1685  END
  return &$oldFilterFunc($res);   return &$oldFilterFunc($res);
     };      };
  @resources=$navmap->retrieveResources(undef,$filterFunc);   @resources=$navmap->retrieveResources(undef,$filterFunc);
  @resources= sort {lc($a->compTitle) cmp lc($b->compTitle)} @resources;   @resources= sort {
       my ($atitle,$btitle) = (lc($a->compTitle),lc($b->compTitle));
       $atitle=~s/^\s*//;
       $btitle=~s/^\s*//;
       return $atitle cmp $btitle
       } @resources;
     } elsif ($args->{'sort'} eq 'duedate') {      } elsif ($args->{'sort'} eq 'duedate') {
  @resources=$navmap->retrieveResources(undef,   @resources=$navmap->retrieveResources(undef,
        sub { shift->is_problem(); });         sub { shift->is_problem(); });
Line 1916  sub show_linkitems { Line 1928  sub show_linkitems {
      "uncompleted","changefolder","clearbubbles");       "uncompleted","changefolder","clearbubbles");
           
     my $result .= (<<ENDBLOCK);      my $result .= (<<ENDBLOCK);
                 <td align="left">
 <script type="text/javascript">  <script type="text/javascript">
     function changeNavDisplay () {      function changeNavDisplay () {
  var navchoice = document.linkitems.toplink[document.linkitems.toplink.selectedIndex].value;   var navchoice = document.linkitems.toplink[document.linkitems.toplink.selectedIndex].value;
Line 1926  ENDBLOCK Line 1939  ENDBLOCK
     }      }
     $result.='}      $result.='}
               </script>                </script>
               <table><tr><td align="left">  
                    <form name="linkitems" method="post">                     <form name="linkitems" method="post">
                        <nobr><select name="toplink">'."\n";                         <nobr><select name="toplink">'."\n";
     foreach my $link (@linkorder) {      foreach my $link (@linkorder) {
Line 3893  Returns the number of parts of the probl Line 3905  Returns the number of parts of the probl
 for single part problems, returns 1. For multipart, it returns the  for single part problems, returns 1. For multipart, it returns the
 number of parts in the problem, not including psuedo-part 0.   number of parts in the problem, not including psuedo-part 0. 
   
   =item * B<countResponses>():
   
   Returns the total number of responses in the problem a student can answer.
   
   =item * B<responseTypes>():
   
   Returns a hash whose keys are the response types.  The values are the number 
   of times each response type is used.  This is for the I<entire> problem, not 
   just a single part.
   
 =item * B<multipart>():  =item * B<multipart>():
   
 Returns true if the problem is multipart, false otherwise. Use this instead  Returns true if the problem is multipart, false otherwise. Use this instead
Line 3939  sub countParts { Line 3961  sub countParts {
     return scalar(@{$parts}); # + $delta;      return scalar(@{$parts}); # + $delta;
 }  }
   
   sub countResponses {
       my $self = shift;
       my $count;
       foreach my $part ($self->parts()) {
           $count+= $self->responseIds($part);
       }
       return $count;
   }
   
   sub responseTypes {
       my $self = shift;
       my %responses;
       foreach my $part ($self->parts()) {
           foreach my $responsetype ($self->responseType($part)) {
               $responses{$responsetype}++ if (defined($responsetype));
           }
       }
       return %responses;
   }
   
 sub multipart {  sub multipart {
     my $self = shift;      my $self = shift;
     return $self->countParts() > 1;      return $self->countParts() > 1;
Line 4026  sub extractParts { Line 4068  sub extractParts {
         }          }
                   
   
           # These hashes probably do not need names that end with "Hash"....
         my %responseIdHash;          my %responseIdHash;
         my %responseTypeHash;          my %responseTypeHash;
   
Line 4061  sub extractParts { Line 4104  sub extractParts {
             }              }
         }          }
  my $resorder = &Apache::lonnet::metadata($self->src(),'responseorder');   my $resorder = &Apache::lonnet::metadata($self->src(),'responseorder');
           #
           # Reorder the arrays in the %responseIdHash and %responseTypeHash
  if ($resorder) {   if ($resorder) {
     my @resorder=split(/,/,$resorder);      my @resorder=split(/,/,$resorder);
     foreach my $part (keys(%responseIdHash)) {      foreach my $part (keys(%responseIdHash)) {
  my %resids = map { ($_,1) } @{ $responseIdHash{$part} };   my $i=0;
    my %resids = map { ($_,$i++) } @{ $responseIdHash{$part} };
  my @neworder;   my @neworder;
  foreach my $possibleid (@resorder) {   foreach my $possibleid (@resorder) {
     if (exists($resids{$possibleid})) {      if (exists($resids{$possibleid})) {
  push(@neworder,$possibleid);   push(@neworder,$resids{$possibleid});
     }      }
  }   }
  $responseIdHash{$part}=\@neworder;   my @ids;
    my @type;
    foreach my $element (@neworder) {
       push (@ids,$responseIdHash{$part}->[$element]);
       push (@type,$responseTypeHash{$part}->[$element]);
    }
    $responseIdHash{$part}=\@ids;
    $responseTypeHash{$part}=\@type;
     }      }
  }   }
         $self->{RESPONSE_IDS} = \%responseIdHash;          $self->{RESPONSE_IDS} = \%responseIdHash;
Line 4267  sub getCompletionStatus { Line 4320  sub getCompletionStatus {
   
     # Left as separate if statements in case we ever do more with this      # Left as separate if statements in case we ever do more with this
     if ($status eq 'correct_by_student') {return $self->CORRECT;}      if ($status eq 'correct_by_student') {return $self->CORRECT;}
       if ($status eq 'correct_by_scantron') {return $self->CORRECT;}
     if ($status eq 'correct_by_override') {return $self->CORRECT_BY_OVERRIDE; }      if ($status eq 'correct_by_override') {return $self->CORRECT_BY_OVERRIDE; }
     if ($status eq 'incorrect_attempted') {return $self->INCORRECT; }      if ($status eq 'incorrect_attempted') {return $self->INCORRECT; }
     if ($status eq 'incorrect_by_override') {return $self->INCORRECT_BY_OVERRIDE; }      if ($status eq 'incorrect_by_override') {return $self->INCORRECT_BY_OVERRIDE; }

Removed from v.1.282  
changed lines
  Added in v.1.292


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