[LON-CAPA-cvs] cvs: loncom /homework lonhomework.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Mon, 24 Dec 2007 06:35:19 -0000
raeburn Mon Dec 24 01:35:19 2007 EDT
Modified files:
/loncom/homework lonhomework.pm
Log:
Two column display for radio buttons used to select a template.
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.286 loncom/homework/lonhomework.pm:1.287
--- loncom/homework/lonhomework.pm:1.286 Tue Nov 20 12:53:22 2007
+++ loncom/homework/lonhomework.pm Mon Dec 24 01:35:18 2007
@@ -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.287 2007/12/24 06:35:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1082,11 +1082,33 @@
'/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 = '<div class="LC_left_float">';
+ $midpoint = int($numfiles/2);
+ if ($numfiles%2) {
+ $midpoint ++;
+ }
+ }
+ my $count = 0;
foreach my $file (@files) {
next if ($file->[1] !~ /\S/);
$result .=
'<label><input type="radio" name="template" value="'.$file->[0].'" />'.
- $file->[1].'</label><br />';
+ $file->[1].'</label><br />'."\n";
+ $count ++;
+ if ((!$seconddiv) && ($count >= $midpoint)) {
+ $result .= '</div>'."\n".'<div class="LC_left_float">'."\n";
+ $seconddiv = 1;
+ }
+ }
+ if ($numfiles > 0) {
+ $result .= '</div>'."\n".'<div class="LC_clear_float_footer"></div>'."\n";
}
return $result;
}