--- loncom/interface/lonparmset.pm 2005/06/06 15:46:02 1.213 +++ loncom/interface/lonparmset.pm 2005/06/06 17:38:07 1.214 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.213 2005/06/06 15:46:02 www Exp $ +# $Id: lonparmset.pm,v 1.214 2005/06/06 17:38:07 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -972,6 +972,20 @@ sub keysindisplayorder { } (keys %{$name}); } +sub sortmenu { + my ($r,$sortorder)=@_; + $r->print('
print(' checked="on"'); + } + $r->print(' />'.&mt('Sort by realm first, then student (group/section)')); + $r->print('
print(' checked="on"'); + } + $r->print(' />'.&mt('Sort by student (group/section) first, then realm')); +} + sub standardkeyorder { return ('parameter_0_opendate' => 1, 'parameter_0_duedate' => 2, @@ -2036,7 +2050,7 @@ sub extractuser { } sub listdata { - my ($r,$resourcedata,$listdata)=@_; + my ($r,$resourcedata,$listdata,$sortorder)=@_; # Start list output my $oldsection=''; @@ -2045,7 +2059,15 @@ sub listdata { my $pointer=0; $tableopen=0; my $foundkeys=0; - foreach my $thiskey (sort keys %{$listdata}) { + foreach my $thiskey (sort { + if ($sortorder eq 'realmstudent') { + my ($astudent,$arealm)=($a=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); + my ($bstudent,$brealm)=($b=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); + ($arealm cmp $brealm) || ($astudent cmp $bstudent); + } else { + $a cmp $b; + } + } keys %{$listdata}) { if ($$listdata{$thiskey.'.type'}) { my $thistype=$$listdata{$thiskey.'.type'}; if ($$resourcedata{$thiskey.'.type'}) { @@ -2072,19 +2094,32 @@ sub listdata { my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle); $realm=''.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).'
('.$url.' in '.$map.' id: '.$id.')
'; } - if ($section ne $oldsection) { - $r->print(&tableend()."\n

$section

"); - $oldsection=$section; - $oldrealm=''; - } - if ($realm ne $oldrealm) { - $r->print(&tableend()."\n

$realm

"); - $oldrealm=$realm; - $oldpart=''; + if ($sortorder eq 'realmstudent') { + if ($realm ne $oldrealm) { + $r->print(&tableend()."\n

$realm

"); + $oldrealm=$realm; + $oldsection=''; + } + if ($section ne $oldsection) { + $r->print(&tableend()."\n

$section

"); + $oldsection=$section; + $oldpart=''; + } + } else { + if ($section ne $oldsection) { + $r->print(&tableend()."\n

$section

"); + $oldsection=$section; + $oldrealm=''; + } + if ($realm ne $oldrealm) { + $r->print(&tableend()."\n

$realm

"); + $oldrealm=$realm; + $oldpart=''; + } } if ($part ne $oldpart) { $r->print(&tableend(). - "\n

".&mt('Part').": $part

"); + "\n".&mt('Part').": $part"); $oldpart=$part; } # @@ -2196,8 +2231,14 @@ ENDOVER &partmenu($r,\%allparts,\@psprt); $r->print(''); §ionmenu($r,\@selected_sections); - $r->print(''. - '

'); + + $r->print(''); + + my $sortorder=$env{'form.sortorder'}; + unless ($sortorder) { $sortorder='realmstudent'; } + &sortmenu($r,$sortorder); + + $r->print('

'); # Build the list data hash from the specified parms @@ -2248,7 +2289,7 @@ ENDOVER # List data - &listdata($r,$resourcedata,$listdata); + &listdata($r,$resourcedata,$listdata,$sortorder); } $r->print(&tableend(). ((($env{'form.store'}) || ($env{'form.dis'}))?'

':''). @@ -2280,9 +2321,14 @@ ENDOVER my $resourcedata=&readdata($crs,$dom); + + my $sortorder=$env{'form.sortorder'}; + unless ($sortorder) { $sortorder='realmstudent'; } + &sortmenu($r,$sortorder); + # List data - my $foundkeys=&listdata($r,$resourcedata,$resourcedata); + my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder); $r->print(&tableend().'

'. ($foundkeys?'':&mt('There are no parameters.')).'

');