--- loncom/interface/lonnavmaps.pm 2006/04/20 04:30:11 1.378
+++ loncom/interface/lonnavmaps.pm 2006/07/25 00:57:51 1.390
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.378 2006/04/20 04:30:11 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.390 2006/07/25 00:57:51 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,6 +40,8 @@ use Apache::lonnet;
use POSIX qw (floor strftime);
use Data::Dumper; # for debugging, not always
use Time::HiRes qw( gettimeofday tv_interval );
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
# symbolic constants
sub SYMB { return 1; }
@@ -258,7 +260,10 @@ MENU
}
# Header
- $r->print(&Apache::loncommon::start_page('Navigate Course Contents',$js,
+ my $course_type = &Apache::loncommon::course_type();
+ $r->print(&Apache::loncommon::start_page('Navigate '.$course_type.
+ ' Contents',
+ $js,
{'only_body' => $body_only,
'force_register' =>
$env{'form.register'},}));
@@ -268,9 +273,9 @@ MENU
# Check that it's defined
if (!($navmap->courseMapDefined())) {
- $r->print(&Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT'));
- $r->print(''.&mt('Coursemap undefined.').
- '' .
+ $r->print(&Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT'));
+ $r->print(''.&mt('Coursemap undefined.').
+ '' .
&Apache::loncommon::end_page());
return OK;
}
@@ -469,14 +474,14 @@ sub getLinkForResource {
my $anchor;
if ($res->is_page()) {
foreach (@$stack) { if (defined($_)) { $anchor = $_; } }
- $anchor=&Apache::lonnet::escape($anchor->shown_symb());
+ $anchor=&escape($anchor->shown_symb());
return ($res->link(),$res->shown_symb(),$anchor);
}
# in case folder was skipped over as "only sequence"
my ($map,$id,$src)=&Apache::lonnet::decode_symb($res->symb());
if ($map=~/\.page$/) {
my $url=&Apache::lonnet::clutter($map);
- $anchor=&Apache::lonnet::escape($src->shown_symb());
+ $anchor=&escape($src->shown_symb());
return ($url,$res->shown_symb(),$anchor);
}
}
@@ -1091,7 +1096,13 @@ sub render_resource {
if ($resource->is_problem()) {
if ($part eq '0' || $params->{'condensed'}) {
- $icon ='';
+ $icon = '
';
} else {
$icon = $params->{'indentString'};
}
@@ -1122,9 +1133,9 @@ sub render_resource {
removeFromFilter($filter, $mapId);
$linkopen .= "&condition=" . $it->{CONDITION} . '&hereType='
. $params->{'hereType'} . '&here=' .
- &Apache::lonnet::escape($params->{'here'}) .
+ &escape($params->{'here'}) .
'&jump=' .
- &Apache::lonnet::escape($resource->symb()) .
+ &escape($resource->symb()) .
"&folderManip=1\">";
} else {
@@ -1176,7 +1187,7 @@ sub render_resource {
!$params->{'condensed'}) {
my $displaypart=$resource->part_display($part);
$partLabel = " (".&mt('Part: [_1]', $displaypart).")";
- if ($link!~/\#/) { $link.='#'.&Apache::lonnet::escape($part); }
+ if ($link!~/\#/) { $link.='#'.&escape($part); }
$title = "";
}
@@ -1220,7 +1231,7 @@ sub render_communication_status {
foreach (split(/\,/, $feedback)) {
if ($_) {
$feedbackHTML .= ' '
+ . &escape($_) . '">'
. '
';
}
@@ -1235,7 +1246,7 @@ sub render_communication_status {
if ($_) {
$errorcount++;
$errorHTML .= ' '
+ . &escape($_) . '">'
. '
';
}
@@ -1469,7 +1480,7 @@ sub render {
$navmap = Apache::lonnavmaps::navmap->new();
if (!defined($navmap)) {
# no londer in course
- return ''.&mt('No course selected').'
+ return ''.&mt('No course selected').'
'.&mt('Select a course').'
';
}
}
@@ -1608,11 +1619,11 @@ sub render {
my ($link,$text);
if ($condition) {
$link='"navmaps?condition=0&filter=&'.$queryString.
- '&here='.&Apache::lonnet::escape($here).'"';
+ '&here='.&escape($here).'"';
$text='Close all folders';
} else {
$link='"navmaps?condition=1&filter=&'.$queryString.
- '&here='.&Apache::lonnet::escape($here).'"';
+ '&here='.&escape($here).'"';
$text='Open all folders';
}
if ($args->{'caller'} eq 'navmapsdisplay') {
@@ -1658,7 +1669,7 @@ END
if ($args->{'caller'} eq 'navmapsdisplay') {
$result .= '
'. - &Apache::loncommon::help_open_menu('','Navigation Screen','Navigation_Screen','',undef,'RAT').' | '; + &Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT').''; if ($env{'environment.remotenavmap'} ne 'on') { $result .= ''; } else { @@ -1923,7 +1934,7 @@ END my $srcHasQuestion = $src =~ /\?/; $args->{"resourceLink"} = $src. ($srcHasQuestion?'&':'?') . - 'symb=' . &Apache::lonnet::escape($symb).$anchor; + 'symb=' . &escape($symb).$anchor; } # Now, we've decided what parts to show. Loop through them and # show them. @@ -2228,7 +2239,7 @@ sub generate_email_discuss_status { foreach my $msgid (@keys) { if ((!$emailstatus{$msgid}) || ($emailstatus{$msgid} eq 'new')) { my $plain= - &Apache::lonnet::unescape(&Apache::lonnet::unescape($msgid)); + &LONCAPA::unescape(&LONCAPA::unescape($msgid)); if ($plain=~/ \[([^\]]+)\]\:/) { my $url=$1; if ($plain=~/\:Error \[/) { @@ -2574,7 +2585,7 @@ sub parmval_real { my $result=''; my ($mapname,$id,$fn)=&Apache::lonnet::decode_symb($symb); - + $mapname = &Apache::lonnet::deversion($mapname); # ----------------------------------------------------- Cascading lookup scheme my $rwhat=$what; $what=~s/^parameter\_//; @@ -3830,7 +3841,6 @@ sub contains_problem { } sub is_sequence { my $self=shift; - my $src = $self->src(); return $self->navHash("is_map_", 1) && $self->navHash("map_type_" . $self->map_pc()) eq 'sequence'; } @@ -3905,7 +3915,7 @@ Returns a string with the type of the ma sub map_finish { my $self = shift; my $src = $self->src(); - $src = Apache::lonnet::clutter($src); + $src = &Apache::lonnet::clutter($src); my $res = $self->navHash("map_finish_$src", 0); $res = $self->{NAV_MAP}->getById($res); return $res; @@ -3918,7 +3928,7 @@ sub map_pc { sub map_start { my $self = shift; my $src = $self->src(); - $src = Apache::lonnet::clutter($src); + $src = &Apache::lonnet::clutter($src); my $res = $self->navHash("map_start_$src", 0); $res = $self->{NAV_MAP}->getById($res); return $res; @@ -4030,14 +4040,24 @@ sub awarded { if (!defined($part)) { $part = '0'; } return $self->{NAV_MAP}->{STUDENT_DATA}->{$self->symb()}->{'resource.'.$part.'.awarded'}; } +# this should work exactly like the copy in lonhomework.pm sub duedate { (my $self, my $part) = @_; + my $date; my $interval=$self->parmval("interval", $part); - if ($interval) { + my $due_date=$self->parmval("duedate", $part); + if ($interval =~ /\d+/) { my $first_access=&Apache::lonnet::get_first_access('map',$self->symb); - if ($first_access) { return ($first_access+$interval); } + if (defined($first_access)) { + $interval = $first_access+$interval; + $date = ($interval < $due_date)? $interval : $due_date; + } else { + $date = $due_date; + } + } else { + $date = $due_date; } - return $self->parmval("duedate", $part); + return $date; } sub handgrade { (my $self, my $part) = @_; @@ -4155,7 +4175,7 @@ email data was not extracted when the na used like this: for (split(/\,/, $res->getFeedback())) { - my $link = &Apache::lonnet::escape($_); + my $link = &escape($_); ... and use the link as appropriate. @@ -4385,9 +4405,9 @@ 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. - foreach (split /,/, $metadata) { - if ($_ =~ /^([a-zA-Z]+)response_(.*)/ - || $_ =~ /^(Task)_(.*)/) { + foreach my $data (split /,/, $metadata) { + if ($data =~ /^([a-zA-Z]+)response_(.*)/ + || $data =~ /^(Task)_(.*)/) { my $responseType = $1; my $partStuff = $2; my $partIdSoFar = ''; @@ -4399,8 +4419,15 @@ sub extractParts { if ($parts{$partIdSoFar}) { my @otherChunks = @partChunks[$i+1..$#partChunks]; my $responseId = join('_', @otherChunks); - push @{$responseIdHash{$partIdSoFar}}, $responseId; - push @{$responseTypeHash{$partIdSoFar}}, $responseType; + if ($self->is_task()) { + push(@{$responseIdHash{$partIdSoFar}}, + $partIdSoFar); + } else { + push(@{$responseIdHash{$partIdSoFar}}, + $responseId); + } + push(@{$responseTypeHash{$partIdSoFar}}, + $responseType); } } } |