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

raeburn raeburn at source.lon-capa.org
Sun Oct 4 21:52:11 EDT 2015


raeburn		Mon Oct  5 01:52:11 2015 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm loncommon.pm 
  Log:
  - Usage restriction for a particular slot can be for one or more .sequences
    and/or .pages (in which case the slot may be used for all resources within
    those map(s)), or for one or more specific .problem(s).
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.509 loncom/interface/lonnavmaps.pm:1.510
--- loncom/interface/lonnavmaps.pm:1.509	Fri Sep 25 17:39:36 2015
+++ loncom/interface/lonnavmaps.pm	Mon Oct  5 01:52:10 2015
@@ -1,8 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.509 2015/09/25 17:39:36 raeburn Exp $
-
+# $Id: lonnavmaps.pm,v 1.510 2015/10/05 01:52:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5415,6 +5414,7 @@
             }
             my @sorted_slots = &Apache::loncommon::sorted_slots(\@slots,\%slots,'starttime');
             my ($checkedin,$checkedinslot);
+            my ($map) = &Apache::lonnet::decode_symb($symb);
             foreach my $slot_name (@sorted_slots) {
                 next if (!defined($slots{$slot_name}) || !ref($slots{$slot_name}));
                 my $end = $slots{$slot_name}->{'endtime'};
@@ -5475,16 +5475,58 @@
         if (ref($reservable) eq 'HASH') {
             if ((ref($reservable->{'now_order'}) eq 'ARRAY') && (ref($reservable->{'now'}) eq 'HASH')) {
                 foreach my $slot (reverse (@{$reservable->{'now_order'}})) {
-                    if (($reservable->{'now'}{$slot}{'symb'} eq '') ||
-                        ($reservable->{'now'}{$slot}{'symb'} eq $symb)) {
+                    my $canuse;
+                    if ($reservable->{'now'}{$slot}{'symb'} eq '') {
+                        $canuse = 1;
+                    } else {
+                        my %oksymbs;
+                        my @slotsymbs = split(/\s*,\s*/,$reservable->{'now'}{$slot}{'symb'});
+                        map { $oksymbs{$_} = 1; } @slotsymbs;
+                        if ($oksymbs{$symb}) {
+                            $canuse = 1;
+                        } else {
+                            foreach my $item (@slotsymbs) {
+                                if ($item =~ /\.(page|sequence)$/) {
+                                    (undef,undef, my $sloturl) = &Apache::lonnet::decode_symb($item);
+                                    if (($map ne '') && ($map eq $sloturl)) {
+                                        $canuse = 1;
+                                        last;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    if ($canuse) {
                         return(RESERVABLE,$reservable->{'now'}{$slot}{'endreserve'});
                     }
                 }
             }
             if ((ref($reservable->{'future_order'}) eq 'ARRAY') && (ref($reservable->{'future'}) eq 'HASH')) {
                 foreach my $slot (@{$reservable->{'future_order'}}) {
-                    if (($reservable->{'future'}{$slot}{'symb'} eq '') ||
-                        ($reservable->{'future'}{$slot}{'symb'} eq $symb)) {
+                    my $canuse;
+                    if ($reservable->{'future'}{$slot}{'symb'} eq '') {
+                        $canuse = 1;
+                    } elsif ($reservable->{'future'}{$slot}{'symb'} =~ /,/) {
+                        my %oksymbs;
+                        my @slotsymbs = split(/\s*,\s*/,$reservable->{'future'}{$slot}{'symb'});
+                        map { $oksymbs{$_} = 1; } @slotsymbs;
+                        if ($oksymbs{$symb}) {
+                            $canuse = 1;
+                        } else {
+                            foreach my $item (@slotsymbs) {
+                                if ($item =~ /\.(page|sequence)$/) {
+                                    (undef,undef, my $sloturl) = &Apache::lonnet::decode_symb($item);
+                                    if (($map ne '') && ($map eq $sloturl)) {
+                                        $canuse = 1;
+                                        last;
+                                    }
+                                }
+                            }
+                        }
+                    } elsif ($reservable->{'future'}{$slot}{'symb'} eq $symb) {
+                        $canuse = 1;
+                    }
+                    if ($canuse) {
                         return(RESERVABLE_LATER,$reservable->{'future'}{$slot}{'startreserve'});
                     }
                 }
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1228 loncom/interface/loncommon.pm:1.1229
--- loncom/interface/loncommon.pm:1.1228	Sun Aug 16 20:45:41 2015
+++ loncom/interface/loncommon.pm	Mon Oct  5 01:52:10 2015
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1228 2015/08/16 20:45:41 raeburn Exp $
+# $Id: loncommon.pm,v 1.1229 2015/10/05 01:52:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -10207,13 +10207,35 @@
 
 sub get_future_slots {
     my ($cnum,$cdom,$now,$symb) = @_;
+    my $map;
+    if ($symb) {
+        ($map) = &Apache::lonnet::decode_symb($symb);
+    }
     my (%reservable_now,%future_reservable, at sorted_reservable, at sorted_future);
     my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom);
     foreach my $slot (keys(%slots)) {
         next unless($slots{$slot}->{'type'} eq 'schedulable_student');
         if ($symb) {
-            next if (($slots{$slot}->{'symb'} ne '') && 
-                     ($slots{$slot}->{'symb'} ne $symb));
+            if ($slots{$slot}->{'symb'} ne '') {
+                my $canuse;
+                my %oksymbs;
+                my @slotsymbs = split(/\s*,\s*/,$slots{$slot}->{'symb'});
+                map { $oksymbs{$_} = 1; } @slotsymbs;
+                if ($oksymbs{$symb}) {
+                    $canuse = 1;
+                } else {
+                    foreach my $item (@slotsymbs) {
+                        if ($item =~ /\.(page|sequence)$/) {
+                            (undef,undef,my $sloturl) = &Apache::lonnet::decode_symb($item);
+                            if (($map ne '') && ($map eq $sloturl)) {
+                                $canuse = 1;
+                                last;
+                            }
+                        }
+                    }
+                }
+                next unless ($canuse);
+            }
         }
         if (($slots{$slot}->{'starttime'} > $now) &&
             ($slots{$slot}->{'endtime'} > $now)) {




More information about the LON-CAPA-cvs mailing list