--- loncom/interface/slotrequest.pm 2005/10/17 21:21:39 1.25
+++ loncom/interface/slotrequest.pm 2005/11/18 16:26:47 1.31
@@ -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.25 2005/10/17 21:21:39 albertel Exp $
+# $Id: slotrequest.pm,v 1.31 2005/11/18 16:26:47 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -53,11 +53,10 @@ sub fail {
}
sub start_page {
- my ($r)=@_;
+ my ($r,$title)=@_;
my $html=&Apache::lonxml::xmlbegin();
- $r->print($html.'
'.
- &mt('Request another Worktime').'');
- $r->print(&Apache::loncommon::bodytag('Requesting another Worktime'));
+ $r->print($html.''.&mt($title).'');
+ $r->print(&Apache::loncommon::bodytag($title));
}
sub end_page {
@@ -451,6 +450,49 @@ STUFF
$r->print('');
}
+sub to_show {
+ my ($when,$slot) = @_;
+ my $time=time;
+ my $week=60*60*24*7;
+ if ($when eq 'now') {
+ if ($time > $slot->{'starttime'} &&
+ $time < $slot->{'endtime'}) {
+ return 1;
+ }
+ return 0;
+ } elsif ($when eq 'nextweek') {
+ if ( ($time < $slot->{'starttime'} &&
+ ($time+$week) > $slot->{'starttime'})
+ ||
+ ($time < $slot->{'endtime'} &&
+ ($time+$week) > $slot->{'endtime'}) ) {
+ return 1;
+ }
+ return 0;
+ } elsif ($when eq 'lastweek') {
+ if ( ($time > $slot->{'starttime'} &&
+ ($time-$week) < $slot->{'starttime'})
+ ||
+ ($time > $slot->{'endtime'} &&
+ ($time-$week) < $slot->{'endtime'}) ) {
+ return 1;
+ }
+ return 0;
+ } elsif ($when eq 'willopen') {
+ if ($time < $slot->{'starttime'}) {
+ return 1;
+ }
+ return 0;
+ } elsif ($when eq 'wereopen') {
+ if ($time > $slot->{'endtime'}) {
+ return 1;
+ }
+ return 0;
+ }
+
+ return 1;
+}
+
sub show_table {
my ($r,$mgr)=@_;
@@ -461,29 +503,78 @@ sub show_table {
}
my $available;
if ($mgr eq 'F') {
+ $r->print('');
$r->print('');
+ $r->print('');
+ $r->print('
');
}
+
+ my %Saveable_Parameters = ('show' => 'array',
+ 'when' => 'scalar',
+ 'order' => 'scalar');
+
+ &Apache::loncommon::store_course_settings('slotrequest',\%Saveable_Parameters);
+ &Apache::loncommon::restore_course_settings('slotrequest',\%Saveable_Parameters);
+
+ my %show_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 @show_order=('name','description','type','starttime','endtime',
+ 'startreserve','secret','maxspace','ip','symb',
+ 'uniqueperiod','proctor');
+ my @show =
+ (exists($env{'form.show'})) ? &Apache::loncommon::get_env_multiple('form.show')
+ : keys(%show_fields);
+ my %show = map { $_ => 1 } (@show);
+
+ my %when_fields=&Apache::lonlocal::texthash(
+ 'now' => 'Open now',
+ 'nextweek' => 'Open within the next week',
+ 'lastweek' => 'Were open last week',
+ 'willopen' => 'Will open later',
+ 'wereopen' => 'Were open');
+ my @when_order=('now','nextweek','lastweek','willopen','wereopen');
+ $when_fields{'select_form_order'} = \@when_order;
+ my $when = (exists($env{'form.when'})) ? $env{'form.when'}
+ : 'now';
+
+ $r->print('