--- loncom/interface/lonnavmaps.pm 2004/08/30 18:45:52 1.284 +++ loncom/interface/lonnavmaps.pm 2004/09/20 15:23:13 1.294 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.284 2004/08/30 18:45:52 matthew Exp $ +# $Id: lonnavmaps.pm,v 1.294 2004/09/20 15:23:13 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -127,7 +127,7 @@ sub nav_control_js { function gonav(url) { if (w_loncapanav_flag != 1) { - go(url); + gopost(url,''); } else { navwindow=window.open(url, "loncapanav","height=600,width=400,scrollbars=1"); @@ -354,7 +354,7 @@ ENDSUBM } else { &add_linkitem(\%toplinkitems,'firsthomework', 'location.href="navmaps?jumpToFirstHomework"', - "Go To My First Homework Problem"); + "Show Me My First Homework Problem"); } my $suppressEmptySequences = 0; @@ -396,7 +396,7 @@ ENDSUBM "); # renderer call - my $renderArgs = { 'cols' => [0,2,3], + my $renderArgs = { 'cols' => [0,1,2,3], 'sort' => $ENV{'form.sort'}, 'url' => '/adm/navmaps', 'navmap' => $navmap, @@ -1428,7 +1428,7 @@ sub render { # We only need to do this if we need to open the maps to show the # current position. This will change the counter so we can't count # for the jump marker with this loop. - while (($curRes = $mapIterator->next()) && !$found) { + while ($here && ($curRes = $mapIterator->next()) && !$found) { if (ref($curRes) && $curRes->symb() eq $here) { my $mapStack = $mapIterator->getStack(); @@ -1685,7 +1685,12 @@ END return &$oldFilterFunc($res); }; @resources=$navmap->retrieveResources(undef,$filterFunc); - @resources= sort {lc($a->compTitle) cmp lc($b->compTitle)} @resources; + @resources= sort { + my ($atitle,$btitle) = (lc($a->compTitle),lc($b->compTitle)); + $atitle=~s/^\s*//; + $btitle=~s/^\s*//; + return $atitle cmp $btitle + } @resources; } elsif ($args->{'sort'} eq 'duedate') { @resources=$navmap->retrieveResources(undef, sub { shift->is_problem(); }); @@ -3900,6 +3905,16 @@ Returns the number of parts of the probl for single part problems, returns 1. For multipart, it returns the number of parts in the problem, not including psuedo-part 0. +=item * B(): + +Returns the total number of responses in the problem a student can answer. + +=item * B(): + +Returns a hash whose keys are the response types. The values are the number +of times each response type is used. This is for the I problem, not +just a single part. + =item * B(): Returns true if the problem is multipart, false otherwise. Use this instead @@ -3946,6 +3961,26 @@ sub countParts { return scalar(@{$parts}); # + $delta; } +sub countResponses { + my $self = shift; + my $count; + foreach my $part (@{$self->parts()}) { + $count+= scalar($self->responseIds($part)); + } + return $count; +} + +sub responseTypes { + my $self = shift; + my %responses; + foreach my $part ($self->parts()) { + foreach my $responsetype ($self->responseType($part)) { + $responses{$responsetype}++ if (defined($responsetype)); + } + } + return %responses; +} + sub multipart { my $self = shift; return $self->countParts() > 1; @@ -4049,8 +4084,6 @@ 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; @@ -4066,7 +4099,6 @@ sub extractParts { my $responseId = join('_', @otherChunks); push @{$responseIdHash{$partIdSoFar}}, $responseId; push @{$responseTypeHash{$partIdSoFar}}, $responseType; - $response_type_by_id{$responseId} = $responseType; } } } @@ -4077,25 +4109,24 @@ sub extractParts { if ($resorder) { my @resorder=split(/,/,$resorder); foreach my $part (keys(%responseIdHash)) { - my %resids = map { ($_,1) } @{ $responseIdHash{$part} }; + my $i=0; + my %resids = map { ($_,$i++) } @{ $responseIdHash{$part} }; my @neworder; foreach my $possibleid (@resorder) { if (exists($resids{$possibleid})) { - push(@neworder,$possibleid); + push(@neworder,$resids{$possibleid}); } } - $responseIdHash{$part}=\@neworder; + my @ids; + my @type; + foreach my $element (@neworder) { + push (@ids,$responseIdHash{$part}->[$element]); + push (@type,$responseTypeHash{$part}->[$element]); + } + $responseIdHash{$part}=\@ids; + $responseTypeHash{$part}=\@type; } } - # - # 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; } @@ -4289,6 +4320,7 @@ sub getCompletionStatus { # Left as separate if statements in case we ever do more with this if ($status eq 'correct_by_student') {return $self->CORRECT;} + if ($status eq 'correct_by_scantron') {return $self->CORRECT;} if ($status eq 'correct_by_override') {return $self->CORRECT_BY_OVERRIDE; } if ($status eq 'incorrect_attempted') {return $self->INCORRECT; } if ($status eq 'incorrect_by_override') {return $self->INCORRECT_BY_OVERRIDE; }