--- loncom/interface/lonnavmaps.pm 2004/08/29 15:40:14 1.283 +++ loncom/interface/lonnavmaps.pm 2004/08/30 18:45:52 1.284 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.283 2004/08/29 15:40:14 raeburn Exp $ +# $Id: lonnavmaps.pm,v 1.284 2004/08/30 18:45:52 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4033,6 +4033,7 @@ sub extractParts { } + # These hashes probably do not need names that end with "Hash".... my %responseIdHash; my %responseTypeHash; @@ -4048,6 +4049,8 @@ sub extractParts { # So we have to use our knowlege of part names to figure out # where the part names begin and end, and even then, it is possible # to construct ambiguous situations. + # + my %response_type_by_id; foreach (split /,/, $metadata) { if ($_ =~ /^([a-zA-Z]+)response_(.*)/) { my $responseType = $1; @@ -4063,11 +4066,14 @@ sub extractParts { my $responseId = join('_', @otherChunks); push @{$responseIdHash{$partIdSoFar}}, $responseId; push @{$responseTypeHash{$partIdSoFar}}, $responseType; + $response_type_by_id{$responseId} = $responseType; } } } } my $resorder = &Apache::lonnet::metadata($self->src(),'responseorder'); + # + # Reorder the arrays in the %responseIdHash and %responseTypeHash if ($resorder) { my @resorder=split(/,/,$resorder); foreach my $part (keys(%responseIdHash)) { @@ -4081,6 +4087,15 @@ sub extractParts { $responseIdHash{$part}=\@neworder; } } + # + # Reorder the response types + foreach my $partid (keys(%responseIdHash)) { + delete($responseTypeHash{$partid}); + foreach my $respid (@{$responseIdHash{$partid}}) { + push(@{$responseTypeHash{$partid}}, + $response_type_by_id{$respid}); + } + } $self->{RESPONSE_IDS} = \%responseIdHash; $self->{RESPONSE_TYPES} = \%responseTypeHash; }