--- loncom/interface/lonnavmaps.pm 2009/09/23 14:30:45 1.423.4.2
+++ loncom/interface/lonnavmaps.pm 2012/07/09 18:30:46 1.444.2.4.2.1
@@ -1,7 +1,8 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.423.4.2 2009/09/23 14:30:45 gci Exp $
+# $Id: lonnavmaps.pm,v 1.444.2.4.2.1 2012/07/09 18:30:46 raeburn Exp $
+
#
# Copyright Michigan State University Board of Trustees
#
@@ -477,6 +478,7 @@ use Apache::loncommon();
use Apache::lonenc();
use Apache::lonlocal;
use Apache::lonnet;
+
use POSIX qw (floor strftime);
use Time::HiRes qw( gettimeofday tv_interval );
use LONCAPA;
@@ -491,7 +493,7 @@ sub NOTHING { return 3; }
my $resObj = "Apache::lonnavmaps::resource";
-# Keep these mappings in sync with lonquickgrades, which uses the colors
+# Keep these mappings in sync with lonquickgrades, which usesthe colors
# instead of the icons.
my %statusIconMap =
(
@@ -504,10 +506,13 @@ my %statusIconMap =
$resObj->ERROR => ''
);
-my %iconAltTags =
- ( 'navmap.correct.gif' => 'Correct',
- 'navmap.wrong.gif' => 'Incorrect',
- 'navmap.open.gif' => 'Open' );
+my %iconAltTags = #texthash does not work here
+ ( 'navmap.correct.gif' => 'Correct',
+ 'navmap.wrong.gif' => 'Incorrect',
+ 'navmap.open.gif' => 'Open',
+ 'navmap.partial.gif' => 'Partially Correct',
+ 'navmap.ellipsis.gif' => 'Attempted',
+ );
# Defines a status->color mapping, null string means don't color
my %colormap =
@@ -522,6 +527,7 @@ my %colormap =
$resObj->INCORRECT => '',
$resObj->OPEN => '',
$resObj->NOTHING_SET => '',
+ $resObj->CREDIT_ATTEMPTED => '',
$resObj->ATTEMPTED => '',
$resObj->ANSWER_SUBMITTED => '',
$resObj->PARTIALLY_CORRECT => '#006600'
@@ -597,7 +603,7 @@ sub getLinkForResource {
my ($map,$id,$src)=&Apache::lonnet::decode_symb($res->symb());
if ($map=~/\.page$/) {
my $url=&Apache::lonnet::clutter($map);
- $anchor=&escape($src->shown_symb());
+ $anchor=&escape($res->shown_symb());
return ($url,$res->shown_symb(),$anchor);
}
}
@@ -695,12 +701,17 @@ sub getDescription {
return &mt("Excused by instructor");
}
if ($status == $res->ATTEMPTED) {
- if ($res->src() eq '/res/gci/gci/internal/submission.problem') {
- return &mt('Question(s) submitted for review');
+ if ($res->is_anonsurvey($part) || $res->is_survey($part)) {
+ return &mt("Survey submission recorded");
} else {
return &mt("Answer submitted, not yet graded");
}
}
+ if ($status == $res->CREDIT_ATTEMPTED) {
+ if ($res->is_anonsurvey($part) || $res->is_survey($part)) {
+ return &mt("Credit for survey submission");
+ }
+ }
if ($status == $res->TRIES_LEFT) {
my $tries = $res->tries($part);
my $maxtries = $res->maxtries($part);
@@ -719,11 +730,7 @@ sub getDescription {
}
}
if ($status == $res->ANSWER_SUBMITTED) {
- if ($res->src() eq '/res/gci/gci/internal/submission.problem') {
- return &mt('Question(s) submitted for review');
- } else {
- return &mt('Answer submitted');
- }
+ return &mt('Answer submitted');
}
}
@@ -888,11 +895,6 @@ sub render_resource {
my $link = $params->{"resourceLink"};
# The URL part is not escaped at this point, but the symb is...
- # The stuff to the left of the ? must have ' replaced by \' since
- # it will be quoted with ' in the href.
-
- my ($left,$right) = split(/\?/, $link);
- $link = $left.'?'.$right;
my $src = $resource->src();
my $it = $params->{"iterator"};
@@ -905,35 +907,32 @@ sub render_resource {
my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
# If this is a new branch, label it so
if ($params->{'isNewBranch'}) {
- $newBranchText = ' ';
+ $newBranchText = " ";
}
# links to open and close the folder
-
- my $linkopen = "";
-
-
+ my $whitespace = $location.'/whitespace_21.gif';
+ my $linkopen = " "." ";
my $linkclose = " ";
# Default icon: unknown page
- my $icon = " ";
+ my $icon = " ";
if ($resource->is_problem()) {
if ($part eq '0' || $params->{'condensed'}) {
- $icon = ' ';
+ $icon .='" />';
} else {
$icon = $params->{'indentString'};
}
} else {
- $icon = " ";
+ $icon = " ";
}
# Display the correct map icon to open or shut map
@@ -943,15 +942,15 @@ sub render_resource {
if ($it->{CONDITION}) {
$nowOpen = !$nowOpen;
}
-
+
my $folderType = $resource->is_sequence() ? 'folder' : 'page';
my $title=$resource->title;
- $title=~s/\"/\"/g;
+ $title=~s/\"/\&qout;/g;
if (!$params->{'resource_no_folder_link'}) {
$icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif';
- $icon = " ";
-
+ $icon = " "
+ ." ";
$linkopen = "{'url'} . '?' .
$params->{'queryString'} . '&filter=';
$linkopen .= ($nowOpen xor $it->{CONDITION}) ?
@@ -966,10 +965,8 @@ sub render_resource {
} else {
# Don't allow users to manipulate folder
- $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') .
- '.nomanip.gif';
- $icon = " ";
+ $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif';
+ $icon = " "." ";
$linkopen = "";
$linkclose = "";
@@ -985,10 +982,11 @@ sub render_resource {
if (($resource->is_practice()) && ($resource->is_raw_problem())) {
$nonLinkedText .=' '.&mt('not graded').' ';
}
-
- # We're done preparing and finally ready to start the rendering
- my $result = "
";
+ # We're done preparing and finally ready to start the rendering
+ my $result = ' ';
+ my $newfolderType = $resource->is_sequence() ? 'folder' : 'page';
+
my $indentLevel = $params->{'indentLevel'};
if ($newBranchText) { $indentLevel--; }
@@ -998,7 +996,6 @@ sub render_resource {
}
# Decide what to display
-
$result .= "$newBranchText$linkopen$icon$linkclose";
my $curMarkerBegin = '';
@@ -1007,9 +1004,9 @@ sub render_resource {
# Is this the current resource?
if (!$params->{'displayedHereMarker'} &&
$resource->symb() eq $params->{'here'} ) {
- $curMarkerBegin = '> ';
- $curMarkerEnd = '< ';
- $params->{'displayedHereMarker'} = 1;
+ $curMarkerBegin = '';
+ $curMarkerEnd = ' ';
+ $params->{'displayedHereMarker'} = 1;
}
if ($resource->is_problem() && $part ne '0' &&
@@ -1029,9 +1026,9 @@ sub render_resource {
$target=' target="loncapaclient" ';
}
if (!$params->{'resource_nolink'} && !$resource->is_sequence() && !$resource->is_empty_sequence) {
- $result .= " $curMarkerBegin$title$partLabel $curMarkerEnd $nonLinkedText ";
+ $result .= "$curMarkerBegin$title$partLabel $curMarkerEnd$nonLinkedText";
} else {
- $result .= " $curMarkerBegin$title$partLabel$curMarkerEnd $nonLinkedText";
+ $result .= "$curMarkerBegin$linkopen$title$partLabel$curMarkerEnd$nonLinkedText";
}
return $result;
@@ -1051,7 +1048,7 @@ sub render_communication_status {
my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc");
if ($resource->hasDiscussion()) {
$discussionHTML = $linkopen .
- ' ' .
+ ' ' .
$linkclose;
}
@@ -1061,8 +1058,7 @@ sub render_communication_status {
if ($msgid) {
$feedbackHTML .= ' '
- . ' ';
+ . ' ';
}
}
}
@@ -1076,8 +1072,7 @@ sub render_communication_status {
$errorcount++;
$errorHTML .= ' '
- . ' ';
+ . ' ';
}
}
}
@@ -1085,8 +1080,7 @@ sub render_communication_status {
if ($params->{'multipart'} && $part != '0') {
$discussionHTML = $feedbackHTML = $errorHTML = '';
}
-
- return "$discussionHTML$feedbackHTML$errorHTML ";
+ return "$discussionHTML$feedbackHTML$errorHTML ";
}
sub render_quick_status {
@@ -1102,28 +1096,28 @@ sub render_quick_status {
}
my $linkopen = "";
my $linkclose = " ";
-
+
+ $result .= '';
if ($resource->is_problem() &&
!$firstDisplayed) {
-
my $icon = $statusIconMap{$resource->simpleStatus($part)};
my $alt = $iconAltTags{$icon};
if ($icon) {
my $location=
&Apache::loncommon::lonhttpdurl("/adm/lonIcons/$icon");
- $result .= " $linkopen $linkclose \n";
+ $result .= $linkopen.' '.$linkclose;
} else {
- $result .= " \n";
+ $result .= " ";
}
} else { # not problem, no icon
- $result .= " \n";
+ $result .= " ";
}
-
+ $result .= "\n";
return $result;
}
sub render_long_status {
my ($resource, $part, $params) = @_;
- my $result = "\n";
+ my $result = ' ';
my $firstDisplayed = !$params->{'condensed'} &&
$params->{'multipart'} && $part eq "0";
@@ -1427,7 +1421,7 @@ sub render {
my $printKey = $args->{'printKey'};
my $printCloseAll = $args->{'printCloseAll'};
if (!defined($printCloseAll)) { $printCloseAll = 1; }
-
+
# Print key?
if ($printKey) {
$result .= '';
@@ -1453,19 +1447,22 @@ sub render {
if ($printCloseAll && !$args->{'resource_no_folder_link'}) {
my ($link,$text);
if ($condition) {
- $link='"navmaps?condition=0&filter=&'.$queryString.
- '&here='.&escape($here).'"';
+ $link='navmaps?condition=0&filter=&'.$queryString.
+ '&here='.&escape($here);
$text='Close all folders';
} else {
- $link='"navmaps?condition=1&filter=&'.$queryString.
- '&here='.&escape($here).'"';
+ $link='navmaps?condition=1&filter=&'.$queryString.
+ '&here='.&escape($here);
$text='Open all folders';
}
+ if ($env{'form.register'}) {
+ $link .= '®ister='.$env{'form.register'};
+ }
if ($args->{'caller'} eq 'navmapsdisplay') {
&add_linkitem($args->{'linkitems'},'changefolder',
- 'location.href='.$link,$text);
+ "location.href='$link'",$text);
} else {
- $result.=''.&mt($text).' ';
+ $result.= ''.&mt($text).' ';
}
$result .= "\n";
}
@@ -1481,6 +1478,9 @@ sub render {
END
+ if ($env{'form.register'}) {
+ $result .= ' ';
+ }
if ($args->{'sort'} eq 'discussion') {
my $totdisc = 0;
my $haveDisc = '';
@@ -1504,52 +1504,52 @@ END
if ($args->{'caller'} eq 'navmapsdisplay') {
$result .= ''.
- &Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT').' ';
- if ($env{'environment.remotenavmap'} ne 'on') {
- $result .= ' ';
- } else {
- $result .= '';
- }
- $result.=&show_linkitems($args->{'linkitems'});
+ &Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT').' '.
+ ''.&mt('Tools:').' '.
+ &show_linkitems_toolbar($args->{'linkitems'});
if ($args->{'sort_html'}) {
if ($env{'environment.remotenavmap'} ne 'on') {
- $result.=' '.
- ''.$args->{'sort_html'}.' ';
- } else {
- $result.=' '.
- $args->{'sort_html'}.' ';
- }
- }
+ $result .= ' '.
+ ''.$args->{'sort_html'}.' ';
+ } else {
+ $result .= ' '.
+ $args->{'sort_html'}.' ';
+ }
+ } else {
+ $result .= '';
+ }
$result .= '
';
} elsif ($args->{'sort_html'}) {
$result.=$args->{'sort_html'};
}
- $result .= " \n";
+ #$result .= " \n";
if ($r) {
$r->print($result);
$r->rflush();
$result = "";
}
# End parameter setting
-
+
+ $result .= " \n";
+
# Data
- $result .= '' ."\n";
+ $result.=&Apache::loncommon::start_data_table("LC_tableOfContent");
+
my $res = "Apache::lonnavmaps::resource";
my %condenseStatuses =
( $res->NETWORK_FAILURE => 1,
$res->NOTHING_SET => 1,
$res->CORRECT => 1 );
- my @backgroundColors = ("#FFFFFF", "#F6F6F6");
# Shared variables
$args->{'counter'} = 0; # counts the rows
$args->{'indentLevel'} = 0;
$args->{'isNewBranch'} = 0;
- $args->{'condensed'} = 0;
- my $location=
- &Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace1.gif");
- $args->{'indentString'} = setDefault($args->{'indentString'}, " ");
+ $args->{'condensed'} = 0;
+
+ my $location = &Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21.gif");
+ $args->{'indentString'} = setDefault($args->{'indentString'}, " ");
$args->{'displayedHereMarker'} = 0;
# If we're suppressing empty sequences, look for them here. Use DFS for speed,
@@ -1768,16 +1768,15 @@ END
if (defined($anchor)) { $anchor='#'.$anchor; }
my $srcHasQuestion = $src =~ /\?/;
$args->{"resourceLink"} = $src.
- ($srcHasQuestion?'&':'?') .
+ ($srcHasQuestion?'&':'?') .
'symb=' . &escape($symb).$anchor;
}
# Now, we've decided what parts to show. Loop through them and
# show them.
foreach my $part (@parts) {
$rownum ++;
- my $backgroundColor = $backgroundColors[$rownum % scalar(@backgroundColors)];
- $result .= " \n";
+ $result .= &Apache::loncommon::start_data_table_row();
# Set up some data about the parts that the cols might want
my $filter = $it->{FILTER};
@@ -1803,7 +1802,7 @@ END
}
$result .= $colHTML . "\n";
}
- $result .= " \n";
+ $result .= &Apache::loncommon::end_data_table_row();
$args->{'isNewBranch'} = 0;
}
@@ -1831,16 +1830,15 @@ END
# it's quite likely this might fix other browsers, too, and
# certainly won't hurt anything.
if ($displayedJumpMarker) {
- $result .= "
-";
+");
}
- $result .= "
";
-
+ $result.=&Apache::loncommon::end_data_table();
+
if ($r) {
$r->print($result);
$result = "";
@@ -1856,40 +1854,42 @@ sub add_linkitem {
$$linkitems{$name}{'text'}=&mt($text);
}
-sub show_linkitems {
- my ($linkitems)=@_;
- my @linkorder = ("blank","launchnav","closenav","firsthomework",
+sub show_linkitems_toolbar {
+ my ($linkitems,$condition)=@_;
+ my @linkorder = ("launchnav","closenav","firsthomework",
"everything","uncompleted","changefolder","clearbubbles");
-
- my $result .= (<
-
-