--- loncom/interface/lonnavmaps.pm 2003/09/08 22:44:36 1.225 +++ loncom/interface/lonnavmaps.pm 2003/09/30 15:37:18 1.236 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.225 2003/09/08 22:44:36 bowersj2 Exp $ +# $Id: lonnavmaps.pm,v 1.236 2003/09/30 15:37:18 bowersj2 Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,6 +46,7 @@ use strict; use Apache::Constants qw(:common :http); use Apache::loncommon(); use Apache::lonmenu(); +use Apache::lonlocal; use POSIX qw (floor strftime); use Data::Dumper; # for debugging, not always used @@ -106,9 +107,9 @@ sub real_handler { # Handle header-only request if ($r->header_only) { if ($ENV{'browser.mathml'}) { - $r->content_type('text/xml'); + &Apache::loncommon::content_type($r,'text/xml'); } else { - $r->content_type('text/html'); + &Apache::loncommon::content_type($r,'text/html'); } $r->send_http_header; return OK; @@ -116,9 +117,9 @@ sub real_handler { # Send header, don't cache this page if ($ENV{'browser.mathml'}) { - $r->content_type('text/xml'); + &Apache::loncommon::content_type($r,'text/xml'); } else { - $r->content_type('text/html'); + &Apache::loncommon::content_type($r,'text/html'); } &Apache::loncommon::no_cache($r); $r->send_http_header; @@ -126,7 +127,6 @@ sub real_handler { # Create the nav map my $navmap = Apache::lonnavmaps::navmap->new(); - if (!defined($navmap)) { my $requrl = $r->uri; $ENV{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized"; @@ -134,7 +134,7 @@ sub real_handler { } $r->print("\n"); - $r->print("Navigate Course Contents"); + $r->print("".&mt('Navigate Course Contents').""); # ------------------------------------------------------------ Get query string &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['register']); @@ -221,7 +221,7 @@ sub real_handler { } } else { $r->print("" . - "Go To My First Homework Problem    "); + &mt("Go To My First Homework Problem")."    "); } my $suppressEmptySequences = 0; @@ -236,13 +236,13 @@ sub real_handler { $filterFunc = sub { my $res = shift; return $res->completable() || $res->is_map(); }; - $r->print("

Uncompleted Homework

"); + $r->print("

".&mt("Uncompleted Homework")."

"); $ENV{'form.filter'} = ''; $ENV{'form.condition'} = 1; $resource_no_folder_link = 1; } else { $r->print("" . - "Show Only Uncompleted Homework    "); + &mt("Show Only Uncompleted Homework")."    "); } # renderer call @@ -261,7 +261,7 @@ sub real_handler { # user knows there was no error. if ($renderArgs->{'counter'} == 0) { if ($showOnlyHomework) { - $r->print("

All homework is currently completed.

"); + $r->print("

".&mt("All homework is currently completed").".

"); } else { # both jumpToFirstHomework and normal use the same: course must be empty $r->print("

This course is empty.

"); } @@ -331,35 +331,35 @@ sub getDescription { my $status = $res->status($part); if ($status == $res->NETWORK_FAILURE) { - return "Having technical difficulties; please check status later"; + return &mt("Having technical difficulties; please check status later"); } if ($status == $res->NOTHING_SET) { - return "Not currently assigned."; + return &mt("Not currently assigned."); } if ($status == $res->OPEN_LATER) { return "Open " . timeToHumanString($res->opendate($part)); } if ($status == $res->OPEN) { if ($res->duedate($part)) { - return "Due " . timeToHumanString($res->duedate($part)); + return &mt("Due")." " .timeToHumanString($res->duedate($part)); } else { - return "Open, no due date"; + return &mt("Open, no due date"); } } if ($status == $res->PAST_DUE_ANSWER_LATER) { - return "Answer open " . timeToHumanString($res->answerdate($part)); + return &mt("Answer open")." " . timeToHumanString($res->answerdate($part)); } if ($status == $res->PAST_DUE_NO_ANSWER) { - return "Was due " . timeToHumanString($res->duedate($part)); + return &mt("Was due")." " . timeToHumanString($res->duedate($part)); } if ($status == $res->ANSWER_OPEN) { - return "Answer available"; + return &mt("Answer available"); } if ($status == $res->EXCUSED) { - return "Excused by instructor"; + return &mt("Excused by instructor"); } if ($status == $res->ATTEMPTED) { - return "Answer submitted, not yet graded."; + return &mt("Answer submitted, not yet graded"); } if ($status == $res->TRIES_LEFT) { my $tries = $res->tries($part); @@ -372,14 +372,14 @@ sub getDescription { } } if ($res->duedate()) { - return "Due " . timeToHumanString($res->duedate($part)) . + return &mt("Due")." " . timeToHumanString($res->duedate($part)) . " $triesString"; } else { - return "No due date $triesString"; + return &mt("No due date")." $triesString"; } } if ($status == $res->ANSWER_SUBMITTED) { - return 'Answer submitted'; + return &mt('Answer submitted'); } } @@ -429,9 +429,11 @@ sub timeToHumanString { my ($time) = @_; # zero, '0' and blank are bad times if (!$time) { - return 'never'; + return &mt('never'); } - + unless (&Apache::lonlocal::current_language()=~/^en/) { + return localtime($time); + } my $now = time(); my @time = localtime($time); @@ -1093,13 +1095,16 @@ sub render_long_status { return $result; } +# Colors obtained by taking the icons, matching the colors, and +# possibly reducing the Value (HSV) of the color, if it's too bright +# for text, generally by one third or so. my %statusColors = ( $resObj->CLOSED => '#000000', - $resObj->OPEN => '#000000', - $resObj->CORRECT => '#000000', - $resObj->INCORRECT => '#000000', - $resObj->ATTEMPTED => '#000000', + $resObj->OPEN => '#998b13', + $resObj->CORRECT => '#26933f', + $resObj->INCORRECT => '#c48207', + $resObj->ATTEMPTED => '#a87510', $resObj->ERROR => '#000000' ); my %statusStrings = @@ -1144,7 +1149,7 @@ sub render_parts_summary_status { } } - return $td . join (', ', @counts) . $endtd; + return $td . $resource->countParts() . ' parts: ' . join (', ', @counts) . $endtd; } my @preparedColumns = (\&render_resource, \&render_communication_status, @@ -1325,15 +1330,15 @@ sub render { $result.='Key:  '; if ($navmap->{LAST_CHECK}) { $result .= - ' New discussion since '. + ' '.&mt('New discussion since').' '. strftime("%A, %b %e at %I:%M %P", localtime($navmap->{LAST_CHECK})). '  '. - ' New message (click to open)

'. + ' '.&mt('New message (click to open)').'

'. ''; } else { $result .= '  '. - ' Discussions'. - '   New message (click to open)'. + ' '.&mt('Discussions').''. + '   '.&mt('New message (click to open)'). ''; } @@ -1344,11 +1349,11 @@ sub render { if ($condition) { $result.="Close All Folders"; + "\">".&mt('Close All Folders').""; } else { $result.="Open All Folders"; + "\">".&mt('Open All Folders').""; } $result .= "

\n"; } @@ -1972,7 +1977,7 @@ sub getById { sub getBySymb { my $self = shift; my $symb = shift; - my ($mapUrl, $id, $filename) = split (/___/, $symb); + my ($mapUrl, $id, $filename) = &Apache::lonnet::decode_symb($symb); my $map = $self->getResourceByUrl($mapUrl); return $self->getById($map->map_pc() . '.' . $id); } @@ -2048,7 +2053,7 @@ sub parmval_real { unless ($symb) { return ''; } my $result=''; - my ($mapname,$id,$fn)=split(/\_\_\_/,$symb); + my ($mapname,$id,$fn)=&Apache::lonnet::decode_symb($symb); # ----------------------------------------------------- Cascading lookup scheme my $rwhat=$what; @@ -3363,7 +3368,7 @@ sub opendate { } sub problemstatus { (my $self, my $part) = @_; - return $self->parmval("problemstatus", $part); + return lc $self->parmval("problemstatus", $part); } sub sig { (my $self, my $part) = @_; @@ -3541,7 +3546,11 @@ sub responseType { my $part = shift; $self->extractParts(); - return $self->{RESPONSE_TYPES}->{$part}; + if (defined($self->{RESPONSE_TYPES}->{$part})) { + return @{$self->{RESPONSE_TYPES}->{$part}}; + } else { + return undef; + } } sub responseIds { @@ -3549,7 +3558,11 @@ sub responseIds { my $part = shift; $self->extractParts(); - return $self->{RESPONSE_IDS}->{$part}; + if (defined($self->{RESPONSE_IDS}->{$part})) { + return @{$self->{RESPONSE_IDS}->{$part}}; + } else { + return undef; + } } # Private function: Extracts the parts information, both part names and @@ -3623,8 +3636,7 @@ sub extractParts { my @otherChunks = @partChunks[$i+1..$#partChunks]; my $responseId = join('_', @otherChunks); push @{$responseIdHash{$partIdSoFar}}, $responseId; - $responseTypeHash{$partIdSoFar} = $responseType; - last; + push @{$responseTypeHash{$partIdSoFar}}, $responseType; } } } @@ -3942,7 +3954,12 @@ sub status { #if ($self->{RESOURCE_ERROR}) { return NETWORK_FAILURE; } if ($completionStatus == NETWORK_FAILURE) { return NETWORK_FAILURE; } - my $suppressFeedback = lc($self->parmval("problemstatus", $part)) eq 'no'; + my $suppressFeedback = $self->problemstatus($part) eq 'no'; + # If there's an answer date and we're past it, don't + # suppress the feedback; student should know + if ($self->answerdate($part) && $self->answerdate($part) < time()) { + $suppressFeedback = 0; + } # There are a few whole rows we can dispose of: if ($completionStatus == CORRECT ||