[LON-CAPA-cvs] cvs: loncom /html/adm/helper newslot.helper /interface lonhelper.pm lonnavmaps.pm slotrequest.pm

raeburn raeburn at source.lon-capa.org
Sun Dec 18 12:15:08 EST 2011


raeburn		Sun Dec 18 17:15:08 2011 EDT

  Modified files:              
    /loncom/interface	slotrequest.pm lonnavmaps.pm lonhelper.pm 
    /loncom/html/adm/helper	newslot.helper 
  Log:
  - Can define end time for student schedulable slot reservations.
  - Wording change for slot helper to clarify what 'Any time' means
    for slot reservations, or for when slot is uniquely selectable.
  
  
-------------- next part --------------
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.110 loncom/interface/slotrequest.pm:1.111
--- loncom/interface/slotrequest.pm:1.110	Mon Jan  3 18:04:56 2011
+++ loncom/interface/slotrequest.pm	Sun Dec 18 17:15:03 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler for requesting to have slots added to a students record
 #
-# $Id: slotrequest.pm,v 1.110 2011/01/03 18:04:56 raeburn Exp $
+# $Id: slotrequest.pm,v 1.111 2011/12/18 17:15:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -143,10 +143,14 @@
 		 !ref($slots{$slot_name}));
 	&Apache::lonxml::debug(time." $slot_name ".
 			       $slots{$slot_name}->{'starttime'}." -- ".
-			       $slots{$slot_name}->{'startreserve'});
-	if ($slots{$slot_name}->{'endtime'} > time &&
-	    $slots{$slot_name}->{'startreserve'} < time) {
-	    # between start of reservation times and end of slot
+			       $slots{$slot_name}->{'startreserve'}." -- ".
+                               $slots{$slot_name}->{'endreserve'});
+	if (($slots{$slot_name}->{'endtime'} > time) &&
+	    ($slots{$slot_name}->{'startreserve'} < time) &&
+            ((!$slots{$slot_name}->{'endreserve'}) || 
+             ($slots{$slot_name}->{'endreserve'} > time))) {
+	    # between start of reservation time and end of reservation time
+            # and before end of slot
 	    if ($mode eq 'allslots') {
 		push(@got,$slot_name);
 	    } else {
@@ -756,6 +760,11 @@
     if ($slot->{'startreserve'} > time) {
 	return 0;
     }
+    # reserve time ended
+    if (($slot->{'endreserve'}) &&
+        ($slot->{'endreserve'} < time)) {
+        return 0;
+    }    
     &Apache::lonxml::debug("$slot_name reserve good");
 
     my $userallowed=0;
@@ -1096,6 +1105,7 @@
 	     'starttime'       => 'Start time',
 	     'endtime'         => 'End Time',
              'startreserve'    => 'Time students can start reserving',
+             'endreserve'      => 'Time students can no longer reserve',
              'reservationmsg'  => 'Message triggered by reservation',
 	     'secret'          => 'Secret Word',
 	     'space'           => '# of students/max',
@@ -1108,11 +1118,12 @@
 	     'proctor'         => 'List of proctors');
     if ($crstype eq 'Community') {
         $show_fields{'startreserve'} = &mt('Time members can start reserving');
+        $show_fields{'endreserve'} = &mt('Time members can no longer reserve');
         $show_fields{'scheduled'} = &mt('Scheduled Members');
     }
     my @show_order=('name','description','type','starttime','endtime',
-		    'startreserve','reservationmsg','secret','space','ip','symb',
-		    'allowedsections','allowedusers','uniqueperiod',
+		    'startreserve','endreserve','reservationmsg','secret','space',
+		    'ip','symb','allowedsections','allowedusers','uniqueperiod',
 		    'scheduled','proctor');
     my @show = 
 	(exists($env{'form.show'})) ? &Apache::loncommon::get_env_multiple('form.show')
@@ -1223,7 +1234,7 @@
 
     my %name_cache;
     my $slotsort = sub {
-	if ($env{'form.order'}=~/^(type|description|endtime|startreserve|ip|symb|allowedsections|allowedusers|reservationmsg)$/) {
+	if ($env{'form.order'}=~/^(type|description|endtime|startreserve|endreserve|ip|symb|allowedsections|allowedusers|reservationmsg)$/) {
 	    if (lc($slots{$a}->{$env{'form.order'}})
 		ne lc($slots{$b}->{$env{'form.order'}})) {
 		return (lc($slots{$a}->{$env{'form.order'}}) 
@@ -1305,6 +1316,8 @@
 		 &Apache::lonlocal::locallocaltime($slots{$slot}->{'endtime'}):'');
 	my $start_reserve=($slots{$slot}->{'startreserve'}?
 			   &Apache::lonlocal::locallocaltime($slots{$slot}->{'startreserve'}):'');
+        my $end_reserve=($slots{$slot}->{'endreserve'}?
+                         &Apache::lonlocal::locallocaltime($slots{$slot}->{'endreserve'}):'');
 	
 	my $unique;
 	if (ref($slots{$slot}{'uniqueperiod'})) {
@@ -1412,6 +1425,9 @@
 	if (exists($show{'startreserve'})) {
 	    $colspan++;$r->print("<td>$start_reserve</td>\n");
 	}
+        if (exists($show{'endreserve'})) {
+            $colspan++;$r->print("<td>$end_reserve</td>\n");
+        }
         if (exists($show{'reservationmsg'})) {
             $colspan++;$r->print("<td>$reservemsg</td>\n");
         }
@@ -2347,6 +2363,7 @@
 	    ['starttime','Start Time of slot'],
 	    ['endtime','End Time of slot'],
 	    ['startreserve','Reservation Start Time'],
+            ['endreserve','Reservation End Time'],
             ['reservationmsg','Message when reservation changed'],
 	    ['ip','IP or DNS restriction'],
 	    ['proctor','List of proctor ids'],
@@ -2429,6 +2446,16 @@
 	    next;
 	}
 
+        if ($entries{$fields{'endreserve'}}) {
+            $slot{'endreserve'}=
+                &UnixDate($entries{$fields{'endreserve'}},"%s");
+        }
+        if (defined($slot{'endreserve'})
+            && $slot{'endreserve'} > $slot{'starttime'}) {
+            push(@errors,"$name not created -- Slot's reservation end time is after the slot's start time.");
+            next;
+        }
+
         if ($slot{'type'} eq 'schedulable_student') {
             if ($entries{$fields{'reservationmsg'}}) {
                  if (($entries{$fields{'reservationmsg'}} eq 'only_student') ||
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.471 loncom/interface/lonnavmaps.pm:1.472
--- loncom/interface/lonnavmaps.pm:1.471	Sun Dec  4 16:27:06 2011
+++ loncom/interface/lonnavmaps.pm	Sun Dec 18 17:15:03 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.471 2011/12/04 16:27:06 www Exp $
+# $Id: lonnavmaps.pm,v 1.472 2011/12/18 17:15:03 raeburn Exp $
 
 #
 # Copyright Michigan State University Board of Trustees
@@ -5118,6 +5118,7 @@
                 my $ip = $slots{$slot_name}->{'ip'};
                 if ($self->simpleStatus() == OPEN) {
                     my $startreserve = $slots{$slot_name}->{'startreserve'};
+                    my $endreserve = $slots{$slot_name}->{'endreserve'};
                     my @proctors;
                     if ($slots{$slot_name}->{'proctor'} ne '') {
                         @proctors = split(',',$slots{$slot_name}->{'proctor'});
@@ -5143,7 +5144,9 @@
                             }
                         } else {
                             if ($start > $now) {
-                                return (RESERVABLE,$startreserve,$slot_name);
+                                if (!$endreserve || $endreserve > $now) {   
+                                    return (RESERVABLE,$startreserve,$slot_name);
+                                }
                             }
                         }
                     }
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.187 loncom/interface/lonhelper.pm:1.188
--- loncom/interface/lonhelper.pm:1.187	Mon Nov  7 18:22:03 2011
+++ loncom/interface/lonhelper.pm	Sun Dec 18 17:15:03 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.187 2011/11/07 18:22:03 raeburn Exp $
+# $Id: lonhelper.pm,v 1.188 2011/12/18 17:15:03 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1913,7 +1913,13 @@
 	if ($anytime) {
 	    $result.=' checked="checked" '
 	}
-	$result.="name='${var}anytime'/>".&mt('Any time').'</label>'
+        my $anytimetext = &mt('Any time');
+        if (($var eq 'startreserve') || ($var eq 'endreserve')) {
+            $anytimetext = &mt('Any time before slot starts');
+        } elsif (($var eq 'startunique') || ($var eq 'endunique')) {
+            $anytimetext = &mt('No restriction on uniqueness');     
+        }
+	$result.="name='${var}anytime'/>".$anytimetext.'</label>'
     }
     return $result;
 
Index: loncom/html/adm/helper/newslot.helper
diff -u loncom/html/adm/helper/newslot.helper:1.27 loncom/html/adm/helper/newslot.helper:1.28
--- loncom/html/adm/helper/newslot.helper:1.27	Sun Oct 31 15:32:15 2010
+++ loncom/html/adm/helper/newslot.helper	Sun Dec 18 17:15:08 2011
@@ -112,6 +112,20 @@
         </validator>
       </date>
       <message>
+        </p><p>Time students can no longer reserve:<br />   
+      </message>
+      <date variable="endreserve" hoursminutes="1" anytime="1">
+        <defaultvalue>
+          return &{$helper->{DATA}{origslot}}('endreserve','anytime');
+        </defaultvalue>
+        <validator>
+           if (defined($val) && $val > $helper->{'VARS'}{'starttime'}) {
+               return 'Reservation end time must come before the slot has started.';
+           }
+           return undef;
+        </validator>
+      </date>
+      <message>
          </p><p>Maximum number of students allowed in this slot:<br />   
       </message>
       <string variable="maxspace" size="4">
@@ -168,6 +182,7 @@
       <clause>$helper->{'VARS'}{'type'} eq 'preassigned'</clause>
       <exec>
         delete($helper->{'VARS'}{'startreserve'});
+        delete($helper->{'VARS'}{'endreserve'});
         delete($helper->{'VARS'}{'maxspace'});
         delete($helper->{'VARS'}{'startunique'});
         delete($helper->{'VARS'}{'endunique'});
@@ -330,6 +345,10 @@
 		$slot{'startreserve'} = $helper->{'VARS'}{'startreserve'};
 	}
 
+        if ( $helper->{'VARS'}{'endreserve'} > 0) {
+            $slot{'endreserve'} = $helper->{'VARS'}{'endreserve'};
+        }
+
 	if ( $helper->{'VARS'}{'startunique'} > 0 &&
 	     $helper->{'VARS'}{'endunique'} > 0 ) {
 	    $slot{'uniqueperiod'} = [$helper->{'VARS'}{'startunique'},
@@ -395,6 +414,11 @@
 		    &Apache::lonlocal::locallocaltime($slot{'startreserve'}).'</li>';
 	}
 
+        if (exists($slot{'endreserve'})) {
+            $result.="\n".'<li> '.$labels{'endreserve'}.': '.
+                    &Apache::lonlocal::locallocaltime($slot{'endreserve'}).'</li>';
+        }
+
         if (exists($slot{'reservationmsg'})) {
             my %options = &Apache::slotrequest::slot_reservationmsg_options();
             $result.="\n".'<li> '.$labels{'reservationmsg'}.': '.


More information about the LON-CAPA-cvs mailing list