--- loncom/html/adm/helper/newslot.helper 2015/09/27 22:35:50 1.32 +++ loncom/html/adm/helper/newslot.helper 2018/06/24 04:11:12 1.35 @@ -26,8 +26,32 @@ my $name=$helper->{VARS}{'origname'}; my %slot=&Apache::lonnet::get('slots', [$name], $cdom, $cnum); if (!ref($slot{$name})) { return $default; } - if (!exists($slot{$name}{$which})) { return $default; } - return $slot{$name}{$which}; + if (($which eq 'ipdeny') || ($which eq 'ipallow')) { + if (!exists($slot{$name}{'ip'})) { return $default; } + } else { + if (!exists($slot{$name}{$which})) { return $default; } + } + if (($which eq 'ipdeny') || ($which eq 'ipallow')) { + my @allows; + my @denies; + foreach my $item (split(',',$slot{$name}{'ip'})) { + $item =~ s/^\s*//; + $item =~ s/\s*$//; + if ($item =~ /^\!(.+)$/) { + push(@denies,$1); + } else { + push(@allows,$item); + } + } + if ($which eq 'ipdeny') { + return join(',',@denies); + } + if ($which eq 'ipallow') { + return join(',',@allows); + } + } else { + return $slot{$name}{$which}; + } } @@ -184,11 +208,34 @@ delete($helper->{'VARS'}{'startreserve'}); delete($helper->{'VARS'}{'endreserve'}); delete($helper->{'VARS'}{'maxspace'}); - delete($helper->{'VARS'}{'startunique'}); - delete($helper->{'VARS'}{'endunique'}); + +

Period of time when this slot can only be uniquely assigned:
   Start: + + + + my $default=&{$helper->{DATA}{origslot}}('uniqueperiod','anytime'); + if ($default eq 'anytime') { return 'anytime' }; + if (ref($default)) { return $default->[0]; } + return 'anytime'; + + +
   End:
+ + + my $default=&{$helper->{DATA}{origslot}}('uniqueperiod','anytime'); + if ($default eq 'anytime') { return 'anytime' }; + if (ref($default)) { return $default->[1]; } + return 'anytime'; + + + if (defined($val) && $val < $helper->{'VARS'}{'startunique'}) { + return 'End time must be later than the start time.'; + } + return undef; + + -

Proctored access: @@ -241,18 +288,47 @@ } + + +

IP restrictions -- allow from all except:
    + + + + + return undef; + + + return &{$helper->{DATA}{origslot}}('ipdeny'); + + -

IP restrictions:
    +

IP restrictions -- deny from all except:
    - + + return undef; - return &{$helper->{DATA}{origslot}}('ip'); + return &{$helper->{DATA}{origslot}}('ipallow'); + + +

Does each student need to use a unique IP address to access a resource with this slot?

+
+ + No. The student's IP address is not tied for later access to the same resource. + Yes. The IP address on a student's first access to a resource is tied for later access. + Yes. The IP address on a student's first access to a resource is tied for later access (including post-answer date). + + my $default=&{$helper->{DATA}{origslot}}('iptied'); + if ($default eq 'yes') { return 'yes'; } + if ($default eq 'answer') { return 'answer'; } + return 'no'; + +

@@ -363,12 +439,32 @@ $slot{$which} = $helper->{'VARS'}{$which}; } - foreach my $which ('ip','description','maxspace','secret') { + foreach my $which ('description','maxspace','secret') { if ( $helper->{'VARS'}{$which} =~/\S/ ) { $slot{$which} = $helper->{'VARS'}{$which}; } } + if ($helper->{'VARS'}{'ipdeny'} =~/\S/ ) { + foreach my $item (split(',',$helper->{'VARS'}{'ipdeny'})) { + $item =~ s/^\s*//; + $item =~ s/\s*$//; + $slot{'ip'} .= '!'.$item.','; + } + } + + if ($helper->{'VARS'}{'ipallow'} =~/\S/ ) { + foreach my $item (split(',',$helper->{'VARS'}{'ipallow'})) { + $item =~ s/^\s*//; + $item =~ s/\s*$//; + $slot{'ip'} .= $item.','; + } + } + + if ($slot{'ip'} ne '') { + $slot{'ip'} =~s /,$//; + } + if ($helper->{'VARS'}{'type'} eq 'schedulable_student') { if (($helper->{'VARS'}{'reservationmsg'} eq 'only_student') || ($helper->{'VARS'}{'reservationmsg'} eq 'student_and_user_notes_screen')) { @@ -403,6 +499,10 @@ $helper->{'VARS'}{'endunique'}]; } + if ( $helper->{'VARS'}{'iptied'} =~ /^(yes|answer)$/ ) { + $slot{'iptied'} = lc($helper->{'VARS'}{'iptied'}); + } + if ( $helper->{'VARS'}{'useproctor'} eq 'yes' && $helper->{'VARS'}{'proctor'} =~/\S/ ) { my @names; @@ -460,6 +560,15 @@ &HTML::Entities::encode($slot{$which}).''; } } + if (exists($slot{'iptied'})) { + $result.="\n".'
  • '.$labels{'iptied'}.': '; + if ($slot{'iptied'} eq 'yes') { + $result.=&Apache::lonlocal::mt('yes'); + } elsif ($slot{'iptied'} eq 'answer') { + $result.=&Apache::lonlocal::mt('yes, including post-answer date'); + } + $result.='
  • '; + } if (exists($slot{'symb'})) { $result.="\n".'
  • '.$labels{'symb'}.': '; if ($slot{'symb'} =~ /,/) {