--- loncom/homework/lonhomework.pm 2007/11/20 17:53:22 1.286 +++ loncom/homework/lonhomework.pm 2008/01/14 14:32:14 1.288 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.286 2007/11/20 17:53:22 albertel Exp $ +# $Id: lonhomework.pm,v 1.288 2008/01/14 14:32:14 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -292,9 +292,9 @@ sub check_slot_access { } } - my @slots= - (split(':',&Apache::lonnet::EXT("resource.0.availablestudent")), - split(':',&Apache::lonnet::EXT("resource.0.available"))); + my $availablestudent = &Apache::lonnet::EXT("resource.0.availablestudent"); + my $available = &Apache::lonnet::EXT("resource.0.available"); + my @slots= (split(':',$availablestudent),split(':',$available)); # if (!@slots) { # return ($status,$datemsg); @@ -421,7 +421,8 @@ sub check_access { &Apache::lonxml::debug("symb:".$symb); #if ($env{'request.state'} ne "construct" && $symb ne '') { if ($env{'request.state'} ne "construct") { - my $allowed=&check_ip_acc(&Apache::lonnet::EXT("resource.$id.acc")); + my $idacc = &Apache::lonnet::EXT("resource.$id.acc"); + my $allowed=&check_ip_acc($idacc); if (!$allowed && ($Apache::lonhomework::browse ne 'F')) { $status='INVALID_ACCESS'; $date=&mt("can not be accessed from your location."); @@ -1082,11 +1083,33 @@ sub get_template_list { '/templates/*.'.$glob_extension); @files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title'))]} (@files); @files = sort {$a->[1] cmp $b->[1]} (@files); + my ($midpoint,$seconddiv,$numfiles); + $numfiles = 0; + foreach my $file (@files) { + next if ($file->[1] !~ /\S/); + $numfiles ++; + } + if ($numfiles > 0) { + $result = '
'; + $midpoint = int($numfiles/2); + if ($numfiles%2) { + $midpoint ++; + } + } + my $count = 0; foreach my $file (@files) { next if ($file->[1] !~ /\S/); $result .= '
'; + $file->[1].'
'."\n"; + $count ++; + if ((!$seconddiv) && ($count >= $midpoint)) { + $result .= '
'."\n".'
'."\n"; + $seconddiv = 1; + } + } + if ($numfiles > 0) { + $result .= '
'."\n".''."\n"; } return $result; }