[LON-CAPA-cvs] cvs: loncom /interface lonparmset.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Tue, 11 Sep 2007 01:59:30 -0000
albertel Mon Sep 10 21:59:30 2007 EDT
Modified files:
/loncom/interface lonparmset.pm
Log:
- BUG#5220, PARM -> 'new overview' was not sorting the
parameters into correct order, attempting to make the
process a bit clearer
- also made the sort by student then realm obey the standardkeyorder
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.380 loncom/interface/lonparmset.pm:1.381
--- loncom/interface/lonparmset.pm:1.380 Tue Sep 4 20:58:57 2007
+++ loncom/interface/lonparmset.pm Mon Sep 10 21:59:30 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.380 2007/09/05 00:58:57 albertel Exp $
+# $Id: lonparmset.pm,v 1.381 2007/09/11 01:59:30 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2582,6 +2582,26 @@
return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
}
+sub parse_listdata_key {
+ my ($key,$listdata) = @_;
+ # split into student/section affected, and
+ # the realm (folder/resource part and parameter
+ my ($student,$realm) =
+ ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
+ # if course wide student would be undefined
+ if (!defined($student)) {
+ ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
+ }
+ # strip off the .type if it's not the Question type parameter
+ if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
+ $realm=~s/\.type//;
+ }
+ # split into resource+part and parameter name
+ my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
+ my ($res, $part) = ($res =~/^(.*)\.(.*)$/);
+ return ($student,$res,$part,$parm);
+}
+
sub listdata {
my ($r,$resourcedata,$listdata,$sortorder)=@_;
# Start list output
@@ -2593,40 +2613,48 @@
$tableopen=0;
my $foundkeys=0;
my %keyorder=&standardkeyorder();
+
foreach my $thiskey (sort {
+ my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
+ my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
+
+ # get the numerical order for the param
+ $aparm=$keyorder{'parameter_0_'.$aparm};
+ $bparm=$keyorder{'parameter_0_'.$bparm};
+
+ my $result=0;
+
if ($sortorder eq 'realmstudent') {
- my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
- my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/);
- if (!defined($astudent)) {
- ($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
+ if ($ares ne $bres ) {
+ $result = ($ares cmp $bres);
+ } elsif ($astudent ne $bstudent) {
+ $result = ($astudent cmp $bstudent);
+ } elsif ($apart ne $bpart ) {
+ $result = ($apart cmp $bpart);
}
- if (!defined($bstudent)) {
- ($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
+ } else {
+ if ($astudent ne $bstudent) {
+ $result = ($astudent cmp $bstudent);
+ } elsif ($ares ne $bres ) {
+ $result = ($ares cmp $bres);
+ } elsif ($apart ne $bpart ) {
+ $result = ($apart cmp $bpart);
}
- $arealm=~s/\.type//;
- my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/);
- $aparm=$keyorder{'parameter_0_'.$aparm};
- $brealm=~s/\.type//;
- my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/);
- $bparm=$keyorder{'parameter_0_'.$bparm};
- if ($ares eq $bres) {
- if (defined($aparm) && defined($bparm)) {
- ($aparm <=> $bparm);
- } elsif (defined($aparm)) {
- -1;
- } elsif (defined($bparm)) {
- 1;
- } else {
- ($arealm cmp $brealm) || ($astudent cmp $bstudent);
- }
- } else {
- ($arealm cmp $brealm) || ($astudent cmp $bstudent);
+ }
+
+ if (!$result) {
+ if (defined($aparm) && defined($bparm)) {
+ $result = ($aparm <=> $bparm);
+ } elsif (defined($aparm)) {
+ $result = -1;
+ } elsif (defined($bparm)) {
+ $result = 1;
}
- } else {
- $a cmp $b;
}
+
+ $result;
} keys %{$listdata}) {
-
+
if ($$listdata{$thiskey.'.type'}) {
my $thistype=$$listdata{$thiskey.'.type'};
if ($$resourcedata{$thiskey.'.type'}) {