[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Sun, 29 Aug 2004 03:55:24 -0000
This is a MIME encoded message
--albertel1093751724
Content-Type: text/plain
albertel Sat Aug 28 23:55:24 2004 EDT
Modified files:
/loncom/interface lonnavmaps.pm
Log:
- integrating Stuarts changes and some changes that I think improve them
--albertel1093751724
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20040828235524.txt"
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.280 loncom/interface/lonnavmaps.pm:1.281
--- loncom/interface/lonnavmaps.pm:1.280 Fri Aug 27 16:34:13 2004
+++ loncom/interface/lonnavmaps.pm Sat Aug 28 23:55:24 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.280 2004/08/27 20:34:13 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.281 2004/08/29 03:55:24 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -84,7 +84,7 @@
my $hurryUpColor = "#FF0000";
sub launch_win {
- my ($mode,$script)=@_;
+ my ($mode,$script,$toplinkitems)=@_;
my $result;
if ($script ne 'no') {
$result.='<script type="text/javascript">';
@@ -99,8 +99,8 @@
$result.='</script>';
}
if ($mode eq 'link') {
- $result.='<a href="javascript:launch_navmapwin();void(0);">'
- .&mt("Launch navigation window")."</a> ";
+ &add_linkitem($toplinkitems,'launchnav','launch_navmapwin()',
+ "Launch navigation window");
}
return $result;
}
@@ -178,6 +178,8 @@
&Apache::loncommon::no_cache($r);
$r->send_http_header;
+ my %toplinkitems=();
+
if ($ENV{QUERY_STRING} eq 'collapseExternal') {
&Apache::lonnet::put('environment',{'remotenavmap' => 'off'});
&Apache::lonnet::appenv('environment.remotenavmap' => 'off');
@@ -308,18 +310,16 @@
}
if ($ENV{'environment.remotenavmap'} ne 'on') {
- $r->print(&launch_win('link','yes'));
+ $r->print(&launch_win('link','yes',\%toplinkitems));
}
if ($ENV{'environment.remotenavmap'} eq 'on') {
-# $r->print("<a href='navmaps?collapseExternal'>" .
- $r->print("<a href='javascript:collapse();void(0);'>" .
- &mt("Close navigation window").
- "</a> ");
+ &add_linkitem(\%toplinkitems,'closenav','collapse()',
+ "Close navigation window");
}
my $jumpToFirstHomework = 0;
# Check to see if the student is jumping to next open, do-able problem
- if ($ENV{QUERY_STRING} eq 'jumpToFirstHomework') {
+ if ($ENV{QUERY_STRING} =~ /^jumpToFirstHomework/) {
$jumpToFirstHomework = 1;
# Find the next homework problem that they can do.
my $iterator = $navmap->getIterator(undef, undef, undef, 1);
@@ -352,8 +352,9 @@
$r->print("<font size='+2'>All homework assignments have been completed.</font><br /><br />");
}
} else {
- $r->print("<a href='navmaps?jumpToFirstHomework'>" .
- &mt("Go To My First Homework Problem")."</a> ");
+ &add_linkitem(\%toplinkitems,'firsthomework',
+ 'location.href="navmaps?jumpToFirstHomework"',
+ "Go To My First Homework Problem");
}
my $suppressEmptySequences = 0;
@@ -368,15 +369,18 @@
$filterFunc = sub { my $res = shift;
return $res->completable() || $res->is_map();
};
- $r->print("<a href='navmaps?sort=$ENV{'form.sort'}'>" .
- &mt("Show Everything")."</a> ");
+ &add_linkitem(\%toplinkitems,'everything',
+ 'location.href="locatnavmaps?sort='.$ENV{'form.sort'}.'"',
+ "Show Everything");
$r->print("<p><font size='+2'>".&mt("Uncompleted Homework")."</font></p>");
$ENV{'form.filter'} = '';
$ENV{'form.condition'} = 1;
$resource_no_folder_link = 1;
} else {
- $r->print("<a href='navmaps?sort=$ENV{'form.sort'}&showOnlyHomework=1'>" .
- &mt("Show Only Uncompleted Homework")."</a> ");
+ &add_linkitem(\%toplinkitems,'uncompleted',
+ 'location.href="navmaps?sort='.$ENV{'form.sort'}.
+ '&showOnlyHomework=1"',
+ "Show Only Uncompleted Homework");
}
my %selected=($ENV{'form.sort'} => 'selected=on');
@@ -392,6 +396,7 @@
</nobr>
</form>");
# renderer call
+ &Apache::lonnet::logthis(join(':',keys(%toplinkitems)));
my $renderArgs = { 'cols' => [0,2,3],
'sort' => $ENV{'form.sort'},
'url' => '/adm/navmaps',
@@ -401,7 +406,9 @@
'filterFunc' => $filterFunc,
'resource_no_folder_link' => $resource_no_folder_link,
'sort_html'=> $sort_html,
- 'r' => $r};
+ 'r' => $r,
+ 'caller' => 'navmapsdisplay',
+ 'linkitems' => \%toplinkitems};
my $render = render($renderArgs);
$navmap->untieHashes();
@@ -1522,20 +1529,27 @@
}
if ($printCloseAll && !$args->{'resource_no_folder_link'}) {
+ my ($link,$text);
if ($condition) {
- $result.="<a href=\"navmaps?condition=0&filter=&$queryString" .
- "&here=" . Apache::lonnet::escape($here) .
- "\">".&mt('Close All Folders')."</a>";
+ $link='"navmaps?condition=0&filter=&'.$queryString.
+ '&here='.&Apache::lonnet::escape($here).'"';
+ $text='Close All Folders';
} else {
- $result.="<a href=\"navmaps?condition=1&filter=&$queryString" .
- "&here=" . Apache::lonnet::escape($here) .
- "\">".&mt('Open All Folders')."</a>";
- }
+ $link='"navmaps?condition=1&filter=&'.$queryString.
+ '&here='.&Apache::lonnet::escape($here).'"';
+ $text='Open All Folders';
+ }
+ if ($args->{'caller'} eq 'navmapsdisplay') {
+ &add_linkitem($args->{'linkitems'},'changefolder',
+ 'location.href='.$link,$text);
+ } else {
+ $result.='<a href='.$link.'>'.&mt($text).'</a>';
+ }
$result .= "\n";
}
# Check for any unread discussions in all resources.
- if (!$args->{'resource_no_folder_link'}) {
+ if ($args->{'caller'} eq 'navmapsdisplay') {
my $totdisc = 0;
my $haveDisc = '';
my @allres=$navmap->retrieveResources();
@@ -1553,22 +1567,34 @@
}
if ($totdisc > 0) {
$haveDisc =~ s/:$//;
- my %lt = &Apache::lonlocal::texthash(
- 'mapr' => 'Mark all posts read',
- );
- $result .= (<<END);
- <a href="javascript:document.clearbubbles.submit()">$lt{'mapr'}</a> <a href="javascript:void(open('/adm/help/NavMaps_MarkPosts_Read.hlp', 'Help_for_NavMaps_MarkPosts', 'menubar=0,toolbar=1,scrollbars=1,width=350,height=400,resizable=yes'))" title="Online Help"><image src="/adm/help/gif/smallHelp.gif" border="0" alt="(Help: NavMaps_MarkPostsLink)" /></a>
+ my $navurl = $ENV{'QUERY_STRING'};
+ &add_linkitem($args->{'linkitems'},'clearbubbles',
+ 'document.clearbubbles.submit()',
+ 'Mark all posts read');
+ $result .= (<<END);
<form name="clearbubbles" method="post" action="/adm/feedback">
<input type="hidden" name="navurl" value="$ENV{'QUERY_STRING'}" />
<input type="hidden" name="navmaps" value="$haveDisc" />
</form>
END
- } else {
- $result .= '<br />';
}
}
- if ($args->{'sort_html'}) { $result.=$args->{'sort_html'}; }
+ if ($args->{'caller'} eq 'navmapsdisplay') {
+ $result.=&show_linkitems($args->{'linkitems'});
+ if ($args->{'sort_html'}) {
+ if ($ENV{'environment.remotenavmap'} ne 'on') {
+ $result.='<td> </td><td> </td><td> </td>'.
+ '<td align="right">'.$args->{'sort_html'}.'</td></tr>';
+ } else {
+ $result.='</tr><tr><td align="left"><br />'.
+ $args->{'sort_html'}.'</td></tr>';
+ }
+ }
+ $result .= '</table>';
+ } elsif ($args->{'sort_html'}) {
+ $result.=$args->{'sort_html'};
+ }
$result .= "<br />\n";
if ($r) {
@@ -1879,6 +1905,45 @@
return $result;
}
+sub add_linkitem {
+ my ($linkitems,$name,$cmd,$text)=@_;
+ $$linkitems{$name}{'cmd'}=$cmd;
+ $$linkitems{$name}{'text'}=&mt($text);
+}
+
+sub show_linkitems {
+ my ($linkitems)=@_;
+ my @linkorder = ("launchnav","closenav","firsthomework","everything",
+ "uncompleted","changefolder","clearbubbles");
+
+ my $result .= (<<ENDBLOCK);
+<script type="text/javascript">
+ function changeNavDisplay () {
+ var navchoice = document.linkitems.toplink[document.linkitems.toplink.selectedIndex].value;
+ENDBLOCK
+ foreach my $link (@linkorder) {
+ $result.= "if (navchoice == '$link') {".
+ $linkitems->{$link}{'cmd'}."}\n";
+ }
+ $result.='}
+ </script>
+ <table><tr><td align="left">
+ <form name="linkitems" method="post">
+ <nobr><select name="toplink">'."\n";
+ foreach my $link (@linkorder) {
+ if (defined($linkitems->{$link})) {
+ if ($linkitems->{$link}{'text'} ne '') {
+ $result .= ' <option value="'.$link.'">'.
+ $linkitems->{$link}{'text'}."</option>\n";
+ }
+ }
+ }
+ $result .= '</select> <input type="button" name="chgnav"
+ value="Go" onClick="javascript:changeNavDisplay()" />
+ </nobr></form></td>'."\n";
+ return $result;
+}
+
1;
package Apache::lonnavmaps::navmap;
--albertel1093751724--