--- loncom/interface/slotrequest.pm 2015/09/27 22:35:39 1.130
+++ loncom/interface/slotrequest.pm 2016/05/21 21:13:58 1.132
@@ -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.130 2015/09/27 22:35:39 raeburn Exp $
+# $Id: slotrequest.pm,v 1.132 2016/05/21 21:13:58 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1494,7 +1494,8 @@ sub show_table {
'allowedusers' => 'Users slot is restricted to.',
'uniqueperiod' => 'Period of time slot is unique',
'scheduled' => 'Scheduled Students',
- 'proctor' => 'List of proctors');
+ 'proctor' => 'List of proctors',
+ 'iptied' => 'Unique IP each student',);
if ($crstype eq 'Community') {
$show_fields{'startreserve'} = &mt('Time members can start reserving');
$show_fields{'endreserve'} = &mt('Time members can no longer reserve');
@@ -1502,7 +1503,7 @@ sub show_table {
}
my @show_order=('name','description','type','starttime','endtime',
'startreserve','endreserve','reservationmsg','secret','space',
- 'ip','symb','allowedsections','allowedusers','uniqueperiod',
+ 'ip','iptied','symb','allowedsections','allowedusers','uniqueperiod',
'scheduled','proctor');
my @show =
(exists($env{'form.show'})) ? &Apache::loncommon::get_env_multiple('form.show')
@@ -1834,6 +1835,16 @@ LOGLINK
if (exists($show{'ip'})) {
$colspan++;$r->print("
$slots{$slot}{'ip'} | \n");
}
+ if (exists($show{'iptied'})) {
+ $colspan++;
+ if ($slots{$slot}{'iptied'} eq 'yes') {
+ $r->print(''.&mt('Yes')." | \n");
+ } elsif ($slots{$slot}{'iptied'} eq 'answer') {
+ $r->print(''.&mt('Yes, including post-answer date')." | \n");
+ } else {
+ $r->print(''.&mt('No')." | \n");
+ }
+ }
if (exists($show{'symb'})) {
$colspan++;$r->print("".join(' ',@titles)." | \n");
}
@@ -2952,6 +2963,7 @@ sub csvupload_fields {
['endreserve','Reservation End Time'],
['reservationmsg','Message when reservation changed'],
['ip','IP or DNS restriction'],
+ ['iptied','Unique IP each student'],
['proctor','List of proctor ids'],
['description','Slot Description'],
['maxspace','Maximum number of reservations'],
@@ -3023,8 +3035,12 @@ sub csv_upload_assign {
}
if ($entries{$fields{'startreserve'}}) {
- $slot{'startreserve'}=
- &UnixDate($entries{$fields{'startreserve'}},"%s");
+ my $date = &UnixDate($entries{$fields{'startreserve'}},"%s");
+ if ($date eq '') {
+ push(@errors,"$name -- No reservation start time set for slot -- value provided had invalid format");
+ } else {
+ $slot{'startreserve'} = $date;
+ }
}
if (defined($slot{'startreserve'})
&& $slot{'startreserve'} > $slot{'starttime'}) {
@@ -3033,8 +3049,12 @@ sub csv_upload_assign {
}
if ($entries{$fields{'endreserve'}}) {
- $slot{'endreserve'}=
- &UnixDate($entries{$fields{'endreserve'}},"%s");
+ my $date = &UnixDate($entries{$fields{'endreserve'}},"%s");
+ if ($date eq '') {
+ push(@errors,"$name -- No reservation end time set for slot -- value provided had invalid format");
+ } else {
+ $slot{'endreserve'} = $date;
+ }
}
if (defined($slot{'endreserve'})
&& $slot{'endreserve'} > $slot{'starttime'}) {
@@ -3062,6 +3082,11 @@ sub csv_upload_assign {
$slot{$key}=$entries{$fields{$key}};
}
}
+ if ($entries{$fields{'iptied'}} =~ /^\s*(yes|1)\s*$/i) {
+ $slot{'iptied'}='yes';
+ } elsif ($entries{$fields{'iptied'}} =~ /^\s*answer\s*$/i) {
+ $slot{'iptied'}='answer';
+ }
if ($entries{$fields{'allowedusers'}}) {
$entries{$fields{'allowedusers'}} =~ s/^\s+//;
$entries{$fields{'allowedusers'}} =~ s/\s+$//;
@@ -3094,12 +3119,14 @@ sub csv_upload_assign {
}
}
if ($entries{$fields{'uniqueperiod'}}) {
- my ($start,$end)=split(',',$entries{$fields{'uniqueperiod'}});
- my @times=(&UnixDate($start,"%s"),
- &UnixDate($end,"%s"));
- $slot{'uniqueperiod'}=\@times;
+ my ($start,$end)= map { &UnixDate($_,"%s"); } split(',',$entries{$fields{'uniqueperiod'}});
+ if (($start ne '') && ($end ne '')) {
+ $slot{'uniqueperiod'}=[$start,$end];
+ } else {
+ push(@errors,"$name -- Slot's unique period ignored -- one or both of the comma separated values for start and end had an invalid format");
+ }
}
- if (defined($slot{'uniqueperiod'})
+ if (ref($slot{'uniqueperiod'}) eq 'ARRAY'
&& $slot{'uniqueperiod'}[0] > $slot{'uniqueperiod'}[1]) {
push(@errors,"$name not created -- Slot's unique period start time is later than the unique period's end time.");
next;
@@ -3284,7 +3311,8 @@ sub handler {
my ($status) = &Apache::lonhomework::check_slot_access('0',$type);
if ($status eq 'CAN_ANSWER' ||
$status eq 'NEEDS_CHECKIN' ||
- $status eq 'WAITING_FOR_GRADE') {
+ $status eq 'WAITING_FOR_GRADE' ||
+ $status eq 'NEED_DIFFERENT_IP') {
&fail($r,'not_allowed');
return OK;
}