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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 08 Nov 2005 03:13:20 -0000


albertel		Mon Nov  7 22:13:20 2005 EDT

  Modified files:              
    /loncom/interface	slotrequest.pm 
  Log:
  - can pick what parts of a slot to see
  
  
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.28 loncom/interface/slotrequest.pm:1.29
--- loncom/interface/slotrequest.pm:1.28	Wed Nov  2 17:46:12 2005
+++ loncom/interface/slotrequest.pm	Mon Nov  7 22:13:20 2005
@@ -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.28 2005/11/02 22:46:12 albertel Exp $
+# $Id: slotrequest.pm,v 1.29 2005/11/08 03:13:20 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -468,24 +468,52 @@
 <input type="submit" name="newslot" value="'.&mt('Create a New Slot').'" />
 </form>');
     }
+    
+    my %Saveable_Parameters = ('show' => 'array');
+
+    &Apache::loncommon::store_course_settings('chart',\%Saveable_Parameters);
+    &Apache::loncommon::restore_course_settings('chart',\%Saveable_Parameters);
+
+    my %fields=&Apache::lonlocal::texthash(
+	     'name'         => 'Slot Name',
+	     'description'  => 'Description',
+	     'type'         => 'Type',
+	     'starttime'    => 'Start time',
+	     'endtime'      => 'End Time',
+             'startreserve' => 'Time students can start reserving',
+	     'secret'       => 'Secret Word',
+	     'maxspace'     => 'Maxium # of students',
+	     'ip'           => 'IP or DNS restrictions',
+	     'symb'         => 'Resource slot is restricted to.',
+	     'uniqueperiod' => 'Period of time slot is unique',
+	     'proctor'      => 'List of proctors');
+    my @order=('name','description','type','starttime','endtime',
+	       'startreserve','secret','maxspace','ip','symb',
+	       'uniqueperiod','proctor');
+    my @sel = 
+	(exists($env{'form.show'})) ? &Apache::loncommon::get_env_multiple('form.show')
+	                            : keys(%fields);
+    my %sel =  map { $_ => 1 } (@sel);
+
+    $r->print('<form method="POST" action="/adm/slotrequest">
+<input type="hidden" name="command" value="showslots" />
+<input type="submit" name="start" value="'.&mt('Change').'" />');
+    $r->print('<table><tr><td>Show: '.&Apache::loncommon::multiple_select_form('show',\@sel,6,\%fields,\@order).
+	      '</td></tr></table>');
     my $linkstart='<a href="/adm/slotrequest?command=showslots&amp;order=';
     $r->print('<table border="1">
 <tr>
-  <th></th>
-  <th>'.$linkstart.'name"        >Slot name</a></th>
-  <th>'.$linkstart.'type"        >Type</a></th>
-  <th>'.$linkstart.'description" >Description</a></th>
-  <th>'.$linkstart.'starttime"   >Start Time</a></th>
-  <th>'.$linkstart.'endtime"     >End Time</a></th>
-  <th>'.$linkstart.'startreserve">Time Students Can Start Reserving</a></th>
-  <th>'.$linkstart.'secret"      >Secret</a></th>
-  <th>'.$linkstart.'maxspace"    >Max space</a></th>
-  <th>                            Scheduled Students</th>
-  <th>'.$linkstart.'unique"      >Unique Period</a></th>
-</tr>');
+  <th></th>');
+    foreach my $which (@order) {
+	if ($which ne 'proctor' && exists($sel{$which})) {
+	    $r->print('<th>'.$linkstart.$which.'">'.$fields{$which}.'</a></th>');
+	}
+    }
+    $r->print('<th>Scheduled Students</th></tr>');
+
     my %name_cache;
     my $slotsort = sub {
-	if ($env{'form.order'}=~/^(type|description|endtime|maxspace)$/) {
+	if ($env{'form.order'}=~/^(type|description|endtime|startreserve|maxspace|ip|symb)$/) {
 	    if (lc($slots{$a}->{$env{'form.order'}})
 		ne lc($slots{$b}->{$env{'form.order'}})) {
 		return (lc($slots{$a}->{$env{'form.order'}}) 
@@ -495,7 +523,7 @@
 	    if (lc($a) cmp lc($b)) {
 		return lc($a) cmp lc($b);
 	    }
-	} elsif ($env{'form.order'} eq 'unique') {
+	} elsif ($env{'form.order'} eq 'uniqueperiod') {
 	    
 	    if ($slots{$a}->{'uniqueperiod'}[0] 
 		ne $slots{$b}->{'uniqueperiod'}[0]) {
@@ -535,18 +563,31 @@
 	    $unique=localtime($slots{$slot}{'uniqueperiod'}[0]).','.
 		localtime($slots{$slot}{'uniqueperiod'}[1]);
 	}
-	my @proctors = map {
-	    my ($uname,$udom)=split(/@/,$_);
-	    my $fullname=$name_cache{$_};
-	    if (!defined($fullname)) {
-		&Apache::lonnet::logthis("Gettign $uname $udom");
-		$fullname = &Apache::loncommon::plainname($uname,$udom);
-		$fullname =~s/\s/&nbsp;/g;
-		$name_cache{$_} = $fullname;
-	    }
-	    &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
-	} (sort(split(/\s*,\s*/,$slots{$slot}->{'proctor'})));
-	
+	my $title;
+	if (exists($slots{$slot}{'symb'})) {
+	    my (undef,undef,$res)=
+		&Apache::lonnet::decode_symb($slots{$slot}{'symb'});
+	    $res =   &Apache::lonnet::clutter($res);
+	    $title = &Apache::lonnet::gettitle($slots{$slot}{'symb'});
+	    $title='<a href="'.$res.'?symb='.$slots{$slot}{'symb'}.'">'.$title.'</a>';
+	}
+	my @proctors;
+	my $rowspan=1;
+	my $colspan=1;
+	if (exists($sel{'proctor'})) {
+	    $rowspan=2;
+	    @proctors= map {
+		my ($uname,$udom)=split(/@/,$_);
+		my $fullname=$name_cache{$_};
+		if (!defined($fullname)) {
+		    &Apache::lonnet::logthis("Gettign $uname $udom");
+		    $fullname = &Apache::loncommon::plainname($uname,$udom);
+		    $fullname =~s/\s/&nbsp;/g;
+		    $name_cache{$_} = $fullname;
+		}
+		&Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
+	    } (sort(split(/\s*,\s*/,$slots{$slot}->{'proctor'})));
+	}
 	my $proctors=join(', ',@proctors);
 
 	my $edit=(<<EDITFORM);
@@ -555,24 +596,49 @@
   <input type="submit" name="Edit" value="Edit" />
 </form>
 EDITFORM
-	$r->print(<<STUFF);
-<tr>
- <td rowspan="2">$edit</td>
- <td>$slot</td>
- <td>$slots{$slot}->{'type'}</td>
- <td>$description</td>
- <td>$start</td>
- <td>$end</td>
- <td>$start_reserve</td>
- <td>$slots{$slot}->{'secret'}</td>
- <td>$slots{$slot}->{'maxspace'}</td>
- <td>$ids</td>
- <td>$unique</td>
-</tr>
+ 
+        $r->print("<tr>\n<td rowspan=\"$rowspan\">$edit</td>\n");
+	if (exists($sel{'name'})) {
+	    $colspan++;$r->print("<td>$slot</td>");
+	}
+	if (exists($sel{'type'})) {
+	    $colspan++;$r->print("<td>$slots{$slot}->{'type'}</td>\n");
+	}
+	if (exists($sel{'description'})) {
+	    $colspan++;$r->print("<td>$description</td>\n");
+	}
+	if (exists($sel{'starttime'})) {
+	    $colspan++;$r->print("<td>$start</td>\n");
+	}
+	if (exists($sel{'endtime'})) {
+	    $colspan++;$r->print("<td>$end</td>\n");
+	}
+	if (exists($sel{'startreserve'})) {
+	    $colspan++;$r->print("<td>$start_reserve</td>\n");
+	}
+	if (exists($sel{'secret'})) {
+	    $colspan++;$r->print("<td>$slots{$slot}{'secret'}</td>\n");
+	}
+	if (exists($sel{'maxspace'})) {
+	    $colspan++;$r->print("<td>$slots{$slot}{'maxspace'}</td>\n");
+	}
+	if (exists($sel{'ip'})) {
+	    $colspan++;$r->print("<td>$slots{$slot}{'ip'}</td>\n");
+	}
+	if (exists($sel{'symb'})) {
+	    $colspan++;$r->print("<td>$title</td>\n");
+	}
+	if (exists($sel{'uniqueperiod'})) {
+	    $colspan++;$r->print("<td>$unique</td>\n");
+	}
+	$colspan++;$r->print("<td>$ids</td>\n</tr>\n");
+	if (exists($sel{'proctor'})) {
+	    $r->print(<<STUFF);
 <tr>
- <td colspan="10">$proctors</td>
+ <td colspan="$colspan">$proctors</td>
 </tr>
 STUFF
+        }
     }
     $r->print('</table>');
 }