Diff for /loncom/interface/lonnavmaps.pm between versions 1.520 and 1.527

version 1.520, 2016/05/30 02:45:38 version 1.527, 2017/02/18 23:39:16
Line 995  sub render_resource { Line 995  sub render_resource {
             $linkopen = "";              $linkopen = "";
             $linkclose = "";              $linkclose = "";
         }          }
         if ((&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&          if (((&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) ||
                 (&Apache::lonnet::allowed('cev',$env{'request.course.id'}))) &&
             ($resource->symb=~/\_\_\_[^\_]+\_\_\_uploaded/)) {              ($resource->symb=~/\_\_\_[^\_]+\_\_\_uploaded/)) {
             if (!$params->{'map_no_edit_link'}) {              if (!$params->{'map_no_edit_link'}) {
                 my $icon = &Apache::loncommon::lonhttpdurl('/res/adm/pages').'/editmap.png';                  my $icon = &Apache::loncommon::lonhttpdurl('/res/adm/pages').'/editmap.png';
Line 1540  END Line 1541  END
  $result.='</form>';   $result.='</form>';
     }      }
     if (($args->{'caller'} eq 'navmapsdisplay') &&      if (($args->{'caller'} eq 'navmapsdisplay') &&
         (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {          ((&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) ||
            (&Apache::lonnet::allowed('cev',$env{'request.course.id'})))) {
         my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};          my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
         my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};          my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
         if ($env{'course.'.$env{'request.course.id'}.'.url'} eq           if ($env{'course.'.$env{'request.course.id'}.'.url'} eq 
Line 1682  END Line 1684  END
  undef($args->{'sort'});   undef($args->{'sort'});
     }      }
   
       # Determine if page will be served with https in case
       # it contains a syllabus which uses an external URL
       # which points at an http site.
   
       my ($is_ssl,$cdom,$cnum);
       if ($ENV{'SERVER_PORT'} == 443) {
           $is_ssl = 1;
       }
       if ($env{'request.course.id'}) {
           $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
           $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
       }
   
     while (1) {      while (1) {
  if ($args->{'sort'}) {   if ($args->{'sort'}) {
Line 1815  END Line 1829  END
  $stack=$it->getStack();   $stack=$it->getStack();
     }      }
     ($src,$symb,$anchor)=getLinkForResource($stack);      ($src,$symb,$anchor)=getLinkForResource($stack);
               my $srcHasQuestion = $src =~ /\?/;
               if ($env{'request.course.id'}) {
                   if (($src =~ m{^\Q/public/$cdom/$cnum/syllabus\E($|\?)}) && ($is_ssl) &&
                       ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {
                       $src .= ($srcHasQuestion? '&amp;' : '?') . 'usehttp=1';
                       $srcHasQuestion = 1;
                   }
               }
     if (defined($anchor)) { $anchor='#'.$anchor; }      if (defined($anchor)) { $anchor='#'.$anchor; }
     my $srcHasQuestion = $src =~ /\?/;  
     $args->{"resourceLink"} = $src.      $args->{"resourceLink"} = $src.
  ($srcHasQuestion?'&amp;':'?') .   ($srcHasQuestion?'&amp;':'?') .
  'symb=' . &escape($symb).$anchor;   'symb=' . &escape($symb).$anchor;
Line 2686  sub parmval_real { Line 2707  sub parmval_real {
         }          }
         foreach my $item (@recurseup) {          foreach my $item (@recurseup) {
             my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what;              my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what;
             last if (defined($$useropt{$norecursechk}));              if (defined($$useropt{$norecursechk})) {
                   if ($what =~ /\.(encrypturl|hiddenresource)$/) {
                       return [$$useropt{$norecursechk},'map'];
                   } else {
                       last;
                   }
               }
             my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what;              my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what;
             if (defined($$useropt{$recursechk})) { return [$$useropt{$recursechk},'map']; }               if (defined($$useropt{$recursechk})) { return [$$useropt{$recursechk},'map']; } 
         }          }
Line 2704  sub parmval_real { Line 2731  sub parmval_real {
         }          }
         foreach my $item (@recurseup) {          foreach my $item (@recurseup) {
             my $norecursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(all).'.$what;              my $norecursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(all).'.$what;
             last if (defined($$courseopt{$norecursechk}));              if (defined($$courseopt{$norecursechk})) {
                   if ($what =~ /\.(encrypturl|hiddenresource)$/) {
                       return [$$courseopt{$norecursechk},'map'];
                   } else {
                      last;
                   }
               }
             my $recursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(rec).'.$what;              my $recursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(rec).'.$what;
             if (defined($$courseopt{$recursechk})) { return [$$courseopt{$recursechk},'map']; }                    if (defined($$courseopt{$recursechk})) { return [$$courseopt{$recursechk},'map']; }      
         }          }
Line 2721  sub parmval_real { Line 2754  sub parmval_real {
         }          }
         foreach my $item (@recurseup) {          foreach my $item (@recurseup) {
             my $norecursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(all).'.$what;              my $norecursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(all).'.$what;
             last if (defined($$courseopt{$norecursechk}));              if (defined($$courseopt{$norecursechk})) {
                   if ($what =~ /\.(encrypturl|hiddenresource)$/) {
                       return [$$courseopt{$norecursechk},'map'];
                   } else {
                       last;
                   }
               }
             my $recursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(rec).'.$what;              my $recursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(rec).'.$what;
             if (defined($$courseopt{$recursechk})) { return [$$courseopt{$recursechk},'map']; }              if (defined($$courseopt{$recursechk})) { return [$$courseopt{$recursechk},'map']; }
         }          }
Line 2755  sub parmval_real { Line 2794  sub parmval_real {
         }          }
         foreach my $item (@recurseup) {          foreach my $item (@recurseup) {
             my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what;              my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what;
             last if (defined($$courseopt{$norecursechk}));              if (defined($$courseopt{$norecursechk})) {
                   if ($what =~ /\.(encrypturl|hiddenresource)$/) {
                       return [$$courseopt{$norecursechk},'map'];
                   } else {
                       last;
                   }
               }
             my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what;              my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what;
             if (defined($$courseopt{$recursechk})) {              if (defined($$courseopt{$recursechk})) {
                 return [$$courseopt{$recursechk},'map'];                  return [$$courseopt{$recursechk},'map'];
Line 2792  sub recurseup_maps { Line 2837  sub recurseup_maps {
         if (ref($res)) {          if (ref($res)) {
             my @pcs = split(/,/,$res->map_hierarchy());              my @pcs = split(/,/,$res->map_hierarchy());
             shift(@pcs);              shift(@pcs);
             pop(@pcs);  
             if (@pcs) {              if (@pcs) {
                 @recurseup = map { &Apache::lonnet::declutter($self->getByMapPc($_)->src()); } reverse(@pcs);                  @recurseup = map { &Apache::lonnet::declutter($self->getByMapPc($_)->src()); } reverse(@pcs);
             }              }
Line 2895  sub get_mapparam { Line 2939  sub get_mapparam {
         }          }
         foreach my $item (@recurseup) {          foreach my $item (@recurseup) {
             my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what;              my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what;
             last if (defined($$useropt{$norecursechk}));              if (defined($$useropt{$norecursechk})) {
                   if ($what =~ /\.(encrypturl|hiddenresource)$/) {
                       return $$useropt{$norecursechk};
                   } else {
                       last;
                   }
               }
             my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what;              my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what;
             if (defined($$useropt{$recursechk})) {              if (defined($$useropt{$recursechk})) {
                 return $$useropt{$recursechk};                  return $$useropt{$recursechk};
Line 2920  sub get_mapparam { Line 2970  sub get_mapparam {
         }          }
         foreach my $item (@recurseup) {          foreach my $item (@recurseup) {
             my $norecursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(all).'.$what;              my $norecursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(all).'.$what;
             last if (defined($$courseopt{$norecursechk}));              if (defined($$courseopt{$norecursechk})) {
                   if ($what =~ /\.(encrypturl|hiddenresource)$/) {
                       return $$courseopt{$norecursechk};
                   } else {
                       last;
                   }
               }
             my $recursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(rec).'.$what;              my $recursechk=$usercourseprefix.'.['.$cgroup.'].'.$item.'___(rec).'.$what;
             if (defined($$courseopt{$recursechk})) {              if (defined($$courseopt{$recursechk})) {
                 return $$courseopt{$recursechk};                  return $$courseopt{$recursechk};
Line 2944  sub get_mapparam { Line 3000  sub get_mapparam {
         }          }
         foreach my $item (@recurseup) {          foreach my $item (@recurseup) {
             my $norecursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(all).'.$what;              my $norecursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(all).'.$what;
             last if (defined($$courseopt{$norecursechk}));              if (defined($$courseopt{$norecursechk})) {
                   if ($what =~ /\.(encrypturl|hiddenresource)$/) {
                       return $$courseopt{$norecursechk};
                   } else {
                       last;
                   }
               }
             my $recursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(rec).'.$what;              my $recursechk=$usercourseprefix.'.['.$csec.'].'.$item.'___(rec).'.$what;
             if (defined($$courseopt{$recursechk})) {              if (defined($$courseopt{$recursechk})) {
                 return $$courseopt{$recursechk};                  return $$courseopt{$recursechk};
Line 2975  sub get_mapparam { Line 3037  sub get_mapparam {
         if (@recurseup) {          if (@recurseup) {
             foreach my $item (@recurseup) {              foreach my $item (@recurseup) {
                 my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what;                  my $norecursechk=$usercourseprefix.'.'.$item.'___(all).'.$what;
                 last if (defined($$courseopt{$norecursechk}));                  if (defined($$courseopt{$norecursechk})) {
                       if ($what =~ /\.(encrypturl|hiddenresource)$/) {
                           return $$courseopt{$norecursechk};
                       } else {
                           last;
                       }
                   }
                 my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what;                  my $recursechk=$usercourseprefix.'.'.$item.'___(rec).'.$what;
                 if (defined($$courseopt{$recursechk})) {                  if (defined($$courseopt{$recursechk})) {
                     return $$courseopt{$recursechk};                      return $$courseopt{$recursechk};
Line 4153  sub enclosing_map_src { Line 4221  sub enclosing_map_src {
 }  }
 sub symb {  sub symb {
     my $self=shift;      my $self=shift;
       if (defined $self->{SYMB}) { return $self->{SYMB}; }
     (my $first, my $second) = $self->{ID} =~ /(\d+).(\d+)/;      (my $first, my $second) = $self->{ID} =~ /(\d+).(\d+)/;
     my $symbSrc = &Apache::lonnet::declutter($self->src());      my $symbSrc = &Apache::lonnet::declutter($self->src());
     my $symb = &Apache::lonnet::declutter($self->navHash('map_id_'.$first))       my $symb = &Apache::lonnet::declutter($self->navHash('map_id_'.$first)) 
Line 4787  sub getReturnHash { Line 4856  sub getReturnHash {
     my $self = shift;      my $self = shift;
           
     if (!defined($self->{RETURN_HASH})) {      if (!defined($self->{RETURN_HASH})) {
         my %tmpHash  = &Apache::lonnet::restore($self->{SYMB},undef,$self->{DOMAIN},$self->{USERNAME});          #my %tmpHash  = &Apache::lonnet::restore($self->{SYMB},undef,$self->{DOMAIN},$self->{USERNAME});
         $self->{RETURN_HASH} = \%tmpHash;          #$self->{RETURN_HASH} = \%tmpHash;
           # When info is retrieved for several resources (as when rendering a directory),
           # it is much faster to use the user profile dump and avoid repeated lonnet requests
           # (especially since lonnet::currentdump is using Lond directly whenever possible,
           # and lonnet::restore is not at this point).
           $self->{NAV_MAP}->get_user_data();
           $self->{RETURN_HASH} = $self->{NAV_MAP}->{STUDENT_DATA}->{$self->{SYMB}};
     }      }
 }         }       
   
Line 5563  sub check_for_slot { Line 5638  sub check_for_slot {
         my $cnum=$env{'course.'.$cid.'.num'};          my $cnum=$env{'course.'.$cid.'.num'};
         my $now = time;          my $now = time;
         my $num_usable_slots = 0;          my $num_usable_slots = 0;
           my ($checkedin,$checkedinslot,%consumed_uniq,%slots);
         if (@slots > 0) {          if (@slots > 0) {
             my %slots=&Apache::lonnet::get('slots',[@slots],$cdom,$cnum);              %slots=&Apache::lonnet::get('slots',[@slots],$cdom,$cnum);
             if (&Apache::lonnet::error(%slots)) {              if (&Apache::lonnet::error(%slots)) {
                 return (UNKNOWN);                  return (UNKNOWN);
             }              }
             my @sorted_slots = &Apache::loncommon::sorted_slots(\@slots,\%slots,'starttime');              my @sorted_slots = &Apache::loncommon::sorted_slots(\@slots,\%slots,'starttime');
             my ($checkedin,$checkedinslot);  
             foreach my $slot_name (@sorted_slots) {              foreach my $slot_name (@sorted_slots) {
                 next if (!defined($slots{$slot_name}) || !ref($slots{$slot_name}));                  next if (!defined($slots{$slot_name}) || !ref($slots{$slot_name}));
                 my $end = $slots{$slot_name}->{'endtime'};                  my $end = $slots{$slot_name}->{'endtime'};
Line 5603  sub check_for_slot { Line 5678  sub check_for_slot {
                     $num_usable_slots ++;                      $num_usable_slots ++;
                 }                  }
             }              }
             my ($is_correct,$got_grade);              my ($is_correct,$wait_for_grade);
             if ($self->is_task()) {              if ($self->is_task()) {
                 my $taskstatus = $self->taskstatus();                  my $taskstatus = $self->taskstatus();
                 $is_correct = (($taskstatus eq 'pass') ||                   $is_correct = (($taskstatus eq 'pass') || 
                                ($self->solved() =~ /^correct_/));                                 ($self->solved() =~ /^correct_/));
                 $got_grade = ($taskstatus =~ /^(?:pass|fail)$/);                  unless ($taskstatus =~ /^(?:pass|fail)$/) {
                       $wait_for_grade = 1;
                   }
             } else {              } else {
                 $got_grade = 1;                  unless ($self->completable()) {
                 $is_correct = ($self->solved() =~ /^correct_/);                         $wait_for_grade = 1;
                   }
                   unless (($self->problemstatus($part) eq 'no') ||
                           ($self->problemstatus($part) eq 'no_feedback_ever')) {
                       $is_correct = ($self->solved($part) =~ /^correct_/);
                       $wait_for_grade = 0;
                   }
             }              }
             ($checkedin,$checkedinslot) = $self->checkedin();              ($checkedin,$checkedinslot) = $self->checkedin();
             if ($checkedin) {              if ($checkedin) {
                 if (!$got_grade) {                  if (ref($slots{$checkedinslot}) eq 'HASH') {
                       $consumed_uniq{$checkedinslot} = $slots{$checkedinslot}{'uniqueperiod'};
                   }
                   if ($wait_for_grade) {
                     return (WAITING_FOR_GRADE);                      return (WAITING_FOR_GRADE);
                 } elsif ($is_correct) {                  } elsif ($is_correct) {
                     return (CORRECT);                       return (CORRECT); 
Line 5653  sub check_for_slot { Line 5739  sub check_for_slot {
                         }                          }
                     }                      }
                     if ($canuse) {                      if ($canuse) {
                           if ($checkedin) {
                               if (ref($consumed_uniq{$checkedinslot}) eq 'ARRAY') {
                                   my ($uniqstart,$uniqend)=@{$consumed_uniq{$checkedinslot}};
                                   if ($reservable->{'now'}{$slot}{'uniqueperiod'} =~ /^(\d+),(\d+)$/) {
                                       my ($new_uniq_start,$new_uniq_end) = ($1,$2);
                                       next if (!
                                           ($uniqstart < $new_uniq_start && $uniqend < $new_uniq_start) ||
                                           ($uniqstart > $new_uniq_end   &&  $uniqend > $new_uniq_end  ));
                                   }
                               }
                           }
                         return(RESERVABLE,$reservable->{'now'}{$slot}{'endreserve'});                          return(RESERVABLE,$reservable->{'now'}{$slot}{'endreserve'});
                     }                      }
                 }                  }
Line 5683  sub check_for_slot { Line 5780  sub check_for_slot {
                         $canuse = 1;                          $canuse = 1;
                     }                      }
                     if ($canuse) {                      if ($canuse) {
                           if ($checkedin) {
                               if (ref($consumed_uniq{$checkedinslot}) eq 'ARRAY') {
                                   my ($uniqstart,$uniqend)=@{$consumed_uniq{$checkedinslot}};
                                   if ($reservable->{'future'}{$slot}{'uniqueperiod'} =~ /^(\d+),(\d+)$/) {
                                       my ($new_uniq_start,$new_uniq_end) = ($1,$2);
                                       next if (!
                                           ($uniqstart < $new_uniq_start && $uniqend < $new_uniq_start) ||
                                           ($uniqstart > $new_uniq_end   &&  $uniqend > $new_uniq_end  ));
                                   }
                               }
                           }
                         return(RESERVABLE_LATER,$reservable->{'future'}{$slot}{'startreserve'});                          return(RESERVABLE_LATER,$reservable->{'future'}{$slot}{'startreserve'});
                     }                      }
                 }                  }

Removed from v.1.520  
changed lines
  Added in v.1.527


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