--- loncom/interface/slotrequest.pm 2010/10/31 15:32:10 1.109 +++ loncom/interface/slotrequest.pm 2012/06/09 15:41:26 1.113 @@ -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.109 2010/10/31 15:32:10 raeburn Exp $ +# $Id: slotrequest.pm,v 1.113 2012/06/09 15:41:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -137,16 +137,20 @@ sub check_for_reservation { return 'error: Unable to determine current status'; } my @got; - my @sorted_slots = &Apache::loncommon::sorted_slots(\@slots,\%slots); + my @sorted_slots = &Apache::loncommon::sorted_slots(\@slots,\%slots,'starttime'); foreach my $slot_name (@sorted_slots) { next if (!defined($slots{$slot_name}) || !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 { @@ -641,16 +645,19 @@ sub get_slot { STUFF - $r->print('

'.&mt('Reservation currently unchanged').'

'. - '

'); + $r->print('

'.&mt('Reservation currently unchanged').'

'); if ($slot_name ne '') { - $r->print(&mt('To complete the transaction you [_1]must[_2] confirm you want the change to [_3] to be processed.' - ,'','',''.$description2.'').'
' - .'

' - .&mt('or').'

'.&mt('you will continue with the reservation you already had: [_1]' - ,''.$description1.'').'

'); + $r->print('

'.&mt('To complete the transaction you [_1]must confirm[_2] you want to [_3]process the change[_4] to [_5].' + ,'','','','',''.$description2.'') + .'
' + .&mt('Or you can choose to [_1]make no change[_2] and continue[_2] with the reservation you already had: [_3].' + ,'','',''.$description1.'') + .'

' + .'' + .(' 'x3) + .'' + .'

'); } - &return_link($r); $r->print(< STUFF @@ -753,6 +760,11 @@ sub allowed_slot { 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; @@ -830,7 +842,7 @@ sub show_choices { my ($r,$symb,$formname)=@_; my ($cnum,$cdom)=&get_course(); - my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum); + my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom); my $consumed_uniqueperiods = &get_consumed_uniqueperiods(\%slots); if (ref($consumed_uniqueperiods) eq 'HASH') { if (&Apache::lonnet::error(%$consumed_uniqueperiods)) { @@ -870,7 +882,7 @@ sub show_choices { $output .= ' '. &mt('Return to last resource').''; } - $r->print($output); + $r->print('

'.$output.'

'); return; } if ($env{'form.command'} eq 'manageresv') { @@ -1093,6 +1105,7 @@ sub show_table { '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', @@ -1105,11 +1118,12 @@ sub show_table { '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') @@ -1220,7 +1234,7 @@ sub show_table { 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'}}) @@ -1302,6 +1316,8 @@ sub show_table { &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'})) { @@ -1409,6 +1425,9 @@ LOGLINK if (exists($show{'startreserve'})) { $colspan++;$r->print("$start_reserve\n"); } + if (exists($show{'endreserve'})) { + $colspan++;$r->print("$end_reserve\n"); + } if (exists($show{'reservationmsg'})) { $colspan++;$r->print("$reservemsg\n"); } @@ -1547,6 +1566,8 @@ sub manage_reservations { } elsif ($slot_status == $resource->RESERVABLE) { $msg=&mt('Reservation needed'); $get_choices = 1; + } elsif ($slot_status == $resource->RESERVABLE_LATER) { + $msg=&mt('Reservation needed: will be reservable later.'); } elsif ($slot_status == $resource->NOTRESERVABLE) { $msg=&mt('Reservation needed: none available.'); } elsif ($slot_status == $resource->UNKNOWN) { @@ -2163,6 +2184,8 @@ sub slot_change_messaging { $msgtitle = &mt('Status of messages about saved reservation'); } elsif ($action eq 'release') { $msgtitle = &mt('Status of messages about dropped reservation'); + } elsif ($action eq 'nochange') { + $msgtitle = &mt('Status of messages about unchanged existing reservation'); } return ''.$msgtitle.'' .'