');
+ }
}
sub get_slot {
@@ -620,7 +633,6 @@ sub get_slot {
my $description1=&get_description($slot_name,\%slot);
%slot=&Apache::lonnet::get_slot($env{'form.slotname'});
my $description2=&get_description($env{'form.slotname'},\%slot);
- $r->print('
'.&mt('Already have a reservation: [_1].',$description1).'
');
if ($slot_name ne $env{'form.slotname'}) {
$r->print(<
@@ -629,19 +641,24 @@ sub get_slot {
STUFF
- $r->print('
'
- .&mt('You can either [_1]Change[_2] your reservation from [_3] to [_4] or'
- ,''
- ,''.$description1.''
- ,''.$description2.'')
- .'
'
- );
- &return_link($r);
+ $r->print('
'.&mt('Reservation currently unchanged').'
');
+ if ($slot_name ne '') {
+ $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)
+ .''
+ .'
');
+ }
$r->print(<
STUFF
} else {
+ $r->print('
'.&mt('Already have a reservation: [_1].',$description1).'
');
&return_link($r);
}
return 0;
@@ -658,8 +675,15 @@ STUFF
.&mt('An error occurred while attempting to make a reservation. ([_1])',$1)
.'
');
} elsif ($reserved > -1) {
- $r->print('
'.&mt('Success: [_1]',$description).'
');
+ $r->print('
'.&mt('Successfully signed up: [_1]',$description).'
');
$retvalue = 1;
+ my $person = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'});
+ my $subject = &mt('Reservation change: [_1]',$description);
+ my $msgbody = &mt('Successful reservation by [_1] for [_2].',$person,$description);
+ my $msg = &slot_change_messaging($slot{'reservationmsg'},$subject,$msgbody,'reserve');
+ if ($msg) {
+ $r->print($msg);
+ }
} elsif ($reserved < 0) {
$r->print('
'.&mt('Already reserved: [_1]',$description).'
');
}
@@ -698,7 +722,8 @@ $lt{'or'}
STUFF
if (!$inhibit_return_link) {
- $r->print(&mt('or').'').&return_link($r);
+ $r->print(&mt('or').'');
+ &return_link($r);
} else {
$r->print('');
}
@@ -805,7 +830,7 @@ sub get_description {
}
sub show_choices {
- my ($r,$symb)=@_;
+ my ($r,$symb,$formname)=@_;
my ($cnum,$cdom)=&get_course();
my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum);
@@ -823,7 +848,7 @@ sub show_choices {
'');
return;
}
- my $available;
+ my (@available,$output);
&Apache::lonxml::debug("Checking Slots");
my @got_slots=&check_for_reservation($symb,'allslots');
if ($got_slots[0] =~ /^error: /) {
@@ -832,20 +857,33 @@ sub show_choices {
'');
return;
}
- $r->print('
');
foreach my $slot (sort
{ return $slots{$a}->{'starttime'} <=> $slots{$b}->{'starttime'} }
(keys(%slots))) {
&Apache::lonxml::debug("Checking Slot $slot");
- next if (!&allowed_slot($slot,$slots{$slot},undef,\%slots,
+ next if (!&allowed_slot($slot,$slots{$slot},$symb,\%slots,
$consumed_uniqueperiods));
- $available++;
-
+ push(@available,$slot);
+ }
+ if (!@available) {
+ $output = &mt('No available times.');
+ if ($env{'form.command'} ne 'manageresv') {
+ $output .= ' '.
+ &mt('Return to last resource').'';
+ }
+ $r->print($output);
+ return;
+ }
+ if ($env{'form.command'} eq 'manageresv') {
+ $output = '
';
+ } else {
+ $output = &Apache::loncommon::start_data_table();
+ }
+ foreach my $slot (@available) {
my $description=&get_description($slot,$slots{$slot});
-
- my $form=&mt('Unavailable');
+ my $form;
if ((grep(/^\Q$slot\E$/,@got_slots)) ||
&space_available($slot,$slots{$slot},$symb)) {
my $text=&mt('Select');
@@ -859,9 +897,9 @@ sub show_choices {
$consumed_uniqueperiods);
if ($conflict) {
if ($conflict =~ /^error: /) {
- $r->print('
'
- .&mt('Slot: [_1] has unknown status.',$description)
- .'
'
+ .&mt('Instructors may use a reservation system to place restrictions on when and where assignments can be worked on.')
+ .' '
+ .&mt('One example is for management of laboratory space, which is only available at certain times, and has a limited number of seats.')
+ .'
'
+ );
+ if (!defined($navmap)) {
+ $r->print('
');
+ if ($crstype eq 'Community') {
+ $r->print(&mt('Unable to retrieve information about community contents'));
+ } else {
+ $r->print(&mt('Unable to retrieve information about course contents'));
+ }
+ $r->print('
');
+ &Apache::lonnet::logthis('Manage Reservations - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
+ return;
+ }
+ my (%parent,%shownparent,%container,%container_title,%contents);
+ my ($depth,$count,$reservable,$lastcontainer,$rownum) = (0,0,0,0,0);
+ my @backgrounds = ("LC_odd_row","LC_even_row");
+ my $numcolors = scalar(@backgrounds);
+ my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21.gif");
+ my $slotheader = '
'.
+ &mt('Your reservation status for any such assignments is listed below:').
+ '
'.
+ '
'."\n";
+ my $shownheader = 0;
+ my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
+ while (my $resource = $it->next()) {
+ if ($resource == $it->BEGIN_MAP()) {
+ $depth++;
+ $parent{$depth} = $lastcontainer;
+ }
+ if ($resource == $it->END_MAP()) {
+ $depth--;
+ $lastcontainer = $parent{$depth};
+ }
+ if (ref($resource)) {
+ my $symb = $resource->symb();
+ my $ressymb = $symb;
+ $contents{$lastcontainer} ++;
+ next if (!$resource->is_problem() && !$resource->is_sequence() &&
+ !$resource->is_page());
+ $count ++;
+ if (($resource->is_sequence()) || ($resource->is_page())) {
+ $lastcontainer = $count;
+ $container{$lastcontainer} = $resource;
+ $container_title{$lastcontainer} = $resource->compTitle();
+ }
+ if ($resource->is_problem()) {
+ my ($useslots) = $resource->slot_control();
+ next if (($useslots eq '') || ($useslots =~ /^\s*no\s*$/i));
+ my ($msg,$get_choices,$slotdescription);
+ my $title = $resource->compTitle();
+ my $status = $resource->simpleStatus('0');
+ my ($slot_status,$date,$slot_name) = $resource->check_for_slot('0');
+ if ($slot_name ne '') {
+ my %slot=&Apache::lonnet::get_slot($slot_name);
+ $slotdescription=&get_description($slot_name,\%slot);
+ }
+ if ($slot_status == $resource->NOT_IN_A_SLOT) {
+ $msg=&mt('No current reservation.');
+ $get_choices = 1;
+ } elsif ($slot_status == $resource->NEEDS_CHECKIN) {
+ $msg=''.&mt('Reserved:').
+ ' '.$slotdescription.' '.
+ &mt('Access requires proctor validation.');
+ } elsif ($slot_status == $resource->WAITING_FOR_GRADE) {
+ $msg=&mt('Submitted and currently in grading queue.');
+ } elsif ($slot_status == $resource->CORRECT) {
+ $msg=&mt('Problem is unavailable.');
+ } elsif ($slot_status == $resource->RESERVED) {
+ $msg=''.&mt('Reserved:').
+ ' '.$slotdescription.' '.
+ &mt('Problem is currently available.');
+ } elsif ($slot_status == $resource->RESERVED_LOCATION) {
+ $msg=''.&mt('Reserved:').
+ ' '.$slotdescription.' '.
+ &mt('Problem is available at a different location.');
+ $get_choices = 1;
+ } elsif ($slot_status == $resource->RESERVED_LATER) {
+ $msg=''.&mt('Reserved:').
+ ' '.$slotdescription.' '.
+ &mt('Problem will be available later.');
+ $get_choices = 1;
+ } elsif ($slot_status == $resource->RESERVABLE) {
+ $msg=&mt('Reservation needed');
+ $get_choices = 1;
+ } elsif ($slot_status == $resource->NOTRESERVABLE) {
+ $msg=&mt('Reservation needed: none available.');
+ } elsif ($slot_status == $resource->UNKNOWN) {
+ $msg=&mt('Unable to determine status due to network problems.');
+ } else {
+ if ($status != $resource->OPEN) {
+ $msg = &Apache::lonnavmaps::getDescription($resource,'0');
+ }
+ }
+ $reservable ++;
+ my $treelevel = $depth;
+ my $higherup = $lastcontainer;
+ if ($depth > 1) {
+ my @maprows;
+ while ($treelevel > 1) {
+ if (ref($container{$higherup})) {
+ my $res = $container{$higherup};
+ last if (defined($shownparent{$higherup}));
+ my $maptitle = $res->compTitle();
+ my $type = 'sequence';
+ if ($res->is_page()) {
+ $type = 'page';
+ }
+ &show_map_row($treelevel,$location,$type,$maptitle,
+ \@maprows);
+ $shownparent{$higherup} = 1;
+ }
+ $treelevel --;
+ $higherup = $parent{$treelevel};
+ }
+ foreach my $item (@maprows) {
+ $rownum ++;
+ my $bgcolor = $backgrounds[$rownum % $numcolors];
+ if (!$shownheader) {
+ $r->print($slotheader);
+ $shownheader = 1;
+ }
+ $r->print('
');
+ }
+ if (!$reservable) {
+ $r->print('');
+ if ($crstype eq 'Community') {
+ $r->print(&mt('No community items currently require a reservation to gain access.'));
+ } else {
+ $r->print(&mt('No course items currently require a reservation to gain access.'));
+ }
+ $r->print('');
+ }
+ $r->print('
'.
+ &mt('Only changes made from servers running LON-CAPA [_1] or later are displayed.'
+ ,'2.9.0');
+ if ($version) {
+ $output .= ' '.&mt('This LON-CAPA server is version [_1]',$version);
+ }
+ $output .= '
';
+ return $output;
+}
+
+sub slot_change_messaging {
+ my ($setting,$subject,$msg,$action) = @_;
+ my $user = $env{'user.name'};
+ my $domain = $env{'user.domain'};
+ my ($message_status,$comment_status);
+ if ($setting eq 'only_student'
+ || $setting eq 'student_and_user_notes_screen') {
+ $message_status =
+ &Apache::lonmsg::user_normal_msg($user,$domain,$subject,$msg);
+ $message_status = '