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

raeburn raeburn@source.lon-capa.org
Sun, 29 Mar 2009 17:56:44 -0000


raeburn		Sun Mar 29 17:56:44 2009 EDT

  Modified files:              
    /loncom/interface	slotrequest.pm 
  Log:
  - Don't show "History" link for slot in slot listing if not student-schedulable
  - Show warning if slot history page reached for unknown slot or for non-student-schedulable slot.
  
  
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.92 loncom/interface/slotrequest.pm:1.93
--- loncom/interface/slotrequest.pm:1.92	Fri Mar 27 11:39:07 2009
+++ loncom/interface/slotrequest.pm	Sun Mar 29 17:56:43 2009
@@ -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.92 2009/03/27 11:39:07 bisitz Exp $
+# $Id: slotrequest.pm,v 1.93 2009/03/29 17:56:43 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1351,9 +1351,13 @@
 
         my $remove_all=&remove_link($slot,'remove all').'<br />';
 
-        if ($ids ne '') { undef($delete); }
-	if ($slots{$slot}{'type'} ne 'schedulable_student' 
-	    || $ids eq '') { 
+        if ($ids eq '') {
+            undef($remove_all);
+        } else {
+            undef($delete);
+        }
+	if ($slots{$slot}{'type'} ne 'schedulable_student') {
+            undef($showlog); 
 	    undef($remove_all);
 	}
 
@@ -1748,6 +1752,26 @@
 
 sub show_reservations_log {
     my ($r) = @_;
+    my $badslot;
+    if ($env{'form.slotname'} eq '') {
+        $r->print('<div class="LC_warning">'.&mt('No slot name provided').'</div>');
+        $badslot = 1;
+    } else {
+        my %slot=&Apache::lonnet::get_slot($env{'form.slotname'});
+        if (keys(%slot) == 0) {
+            $r->print('<div class="LC_warning">'.&mt('Invalid slot name: [_1]',$env{'form.slotname'}).'</div>');
+            $badslot = 1;
+        } elsif ($slot{type} ne 'schedulable_student') {
+            my $description = &get_description($env{'form.slotname'},\%slot);
+            $r->print('<div class="LC_warning">'.&mt('Reservation history unavailable for non-student-schedulable slot: [_1].',$description).'</div>');
+            $badslot = 1;
+        }
+    }
+    if ($badslot) {
+        $r->print('<p><a href="/adm/slotrequest?command=showslots">'.
+                  &mt('Return to slot list').'</a></p>');
+        return;
+    }
     my $formname = 'reservationslog';
     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
@@ -1810,8 +1834,8 @@
 
     my %slot=&Apache::lonnet::get_slot($env{'form.slotname'});
     my $description = $slot{'description'};
-    $r->print('<div class="LC_fontsize_large">'.
-              &mt('Reservation changes for slot: [_1]',$description).'</div>');
+    $r->print('<span class="LC_fontsize_large">'.
+              &mt('Reservation changes for student-schedulable slot: [_1]',$description).'</span><br />');
 
     $r->print(&display_filter($formname,$cdom,$cnum,\%curr,$version,\@allsymbs));
     my $showntablehdr = 0;
@@ -1912,7 +1936,9 @@
     }
     $r->print('<input type="hidden" name="page" value="'.$curr{'page'}.'" />'.
               '<input type="hidden" name="slotname" value="'.$env{'form.slotname'}.'" />'.
-              '<input type="hidden" name="command" value="slotlog" /></form>');
+              '<input type="hidden" name="command" value="slotlog" /></form>'.
+              '<p><a href="/adm/slotrequest?command=showslots">'.
+              &mt('Return to slot list').'</a></p>');
     return;
 }
 
@@ -1964,7 +1990,7 @@
     my ($formname,$cdom,$cnum,$curr,$version,$allsymbs) = @_;
     my $nolink = 1;
     my (%titles,%maptitles);
-    my $output = '<table><tr><td valign="top">'.
+    my $output = '<br /><table><tr><td valign="top">'.
                  '<span class="LC_nobreak"><b>'.&mt('Changes/page:').'</b><br />'.
                  &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
                                               (&mt('all'),5,10,20,50,100,1000,10000)).