[LON-CAPA-cvs] cvs: loncom /interface lonnavdisplay.pm lonnavmaps.pm
raeburn
raeburn at source.lon-capa.org
Tue Dec 27 23:11:05 EST 2011
raeburn Wed Dec 28 04:11:05 2011 EDT
Modified files:
/loncom/interface lonnavmaps.pm lonnavdisplay.pm
Log:
- Additional item in hash ref passed as argument to lonnavmaps::render
- notools -- if true then standard Tools table not shown at top of
Contents page.
- notools used when the course has just been created (and contains a single
item which is not a homework problem (e.g., syllabus or navmaps item).
- show "Content Editor" icon and text instead.
-------------- next part --------------
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.477 loncom/interface/lonnavmaps.pm:1.478
--- loncom/interface/lonnavmaps.pm:1.477 Sun Dec 25 20:41:53 2011
+++ loncom/interface/lonnavmaps.pm Wed Dec 28 04:11:05 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.477 2011/12/25 20:41:53 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.478 2011/12/28 04:11:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
@@ -1466,8 +1466,10 @@
$link .= '®ister='.$env{'form.register'};
}
if ($args->{'caller'} eq 'navmapsdisplay') {
- &add_linkitem($args->{'linkitems'},'changefolder',
- "location.href='$link'",$text);
+ unless ($args->{'notools'}) {
+ &add_linkitem($args->{'linkitems'},'changefolder',
+ "location.href='$link'",$text);
+ }
} else {
$result.= '<a href="'.$link.'">'.&mt($text).'</a>';
}
@@ -1475,7 +1477,7 @@
}
# Check for any unread discussions in all resources.
- if ($args->{'caller'} eq 'navmapsdisplay') {
+ if (($args->{'caller'} eq 'navmapsdisplay') && (!$args->{'notools'})) {
&add_linkitem($args->{'linkitems'},'clearbubbles',
'document.clearbubbles.submit()',
'Mark all posts read');
@@ -1507,15 +1509,16 @@
}
}
$result.='</form>';
- if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- if ($env{'course.'.$env{'request.course.id'}.'.url'} eq
- "uploaded/$cdom/$cnum/default.sequence") {
- &add_linkitem($args->{'linkitems'},'edittoplevel',
- "javascript:gocmd('/adm/coursedocs','editdocs');",
- 'Content Editor');
- }
+ }
+ if (($args->{'caller'} eq 'navmapsdisplay') &&
+ (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ if ($env{'course.'.$env{'request.course.id'}.'.url'} eq
+ "uploaded/$cdom/$cnum/default.sequence") {
+ &add_linkitem($args->{'linkitems'},'edittoplevel',
+ "javascript:gocmd('/adm/coursedocs','editdocs');",
+ 'Content Editor');
}
}
@@ -1859,25 +1862,29 @@
sub show_linkitems_toolbar {
my ($args,$condition) = @_;
- my $result =
- '<table><tr><td>'.
- &Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',undef,'RAT').
- '</td>'.
- '<td> </td>'.
- '<td class="LC_middle">'.&mt('Tools:').'</td>';
+ my $result;
if (ref($args) eq 'HASH') {
if (ref($args->{'linkitems'}) eq 'HASH') {
+ my $numlinks = scalar(keys(%{$args->{'linkitems'}}));
+ if ($numlinks > 1) {
+ $result = '<td>'.
+ &Apache::loncommon::help_open_menu('Navigation Screen','Navigation_Screen',
+ undef,'RAT').
+ '</td>'.
+ '<td> </td>'.
+ '<td class="LC_middle">'.&mt('Tools:').'</td>';
+ }
+ $result .= '<td align="left">'."\n".
+ '<span class="LC_nobreak">'."\n".
+ '<ul id="LC_toolbar">';
my @linkorder = ('firsthomework','everything','uncompleted',
'changefolder','clearbubbles','edittoplevel');
- $result .='<td align="left">'."\n".
- '<span class="LC_nobreak">'."\n".
- '<ul id="LC_toolbar">';
foreach my $link (@linkorder) {
- my $link_id = 'LC_content_toolbar_'.$link;
if (ref($args->{'linkitems'}{$link}) eq 'HASH') {
if ($args->{'linkitems'}{$link}{'text'} ne '') {
$args->{'linkitems'}{$link}{'cmd'}=~s/"/'/g;
if ($args->{'linkitems'}{$link}{'cmd'}) {
+ my $link_id = 'LC_content_toolbar_'.$link;
if ($link eq 'changefolder') {
if ($condition) {
$link_id='LC_content_toolbar_changefolder_toggled';
@@ -1896,14 +1903,20 @@
}
}
$result .= '</ul>'.
- '</span></td>'."\n";
+ '</span></td>';
+ if (($numlinks==1) && (exists($args->{'linkitems'}{'edittoplevel'}))) {
+ $result .= '<td><a href="'.$args->{'linkitems'}{'edittoplevel'}{'cmd'}.'">'.
+ &mt('Content Editor').'</a></td>';
+ }
}
if ($args->{'sort_html'}) {
$result .= '<td> </td><td> </td><td> </td>'.
'<td align="right">'.$args->{'sort_html'}.'</td>';
}
}
- $result .= '</tr></table>';
+ if ($result) {
+ $result = "<table><tr>$result</tr></table>";
+ }
return $result;
}
Index: loncom/interface/lonnavdisplay.pm
diff -u loncom/interface/lonnavdisplay.pm:1.20 loncom/interface/lonnavdisplay.pm:1.21
--- loncom/interface/lonnavdisplay.pm:1.20 Sun Dec 25 20:41:53 2011
+++ loncom/interface/lonnavdisplay.pm Wed Dec 28 04:11:05 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavdisplay.pm,v 1.20 2011/12/25 20:41:53 raeburn Exp $
+# $Id: lonnavdisplay.pm,v 1.21 2011/12/28 04:11:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -113,21 +113,31 @@
return OK;
}
- # See if there's only one map in the top-level, if we don't
- # already have a filter... if so, automatically display it
- # (older code; should use retrieveResources)
- if ($ENV{QUERY_STRING} !~ /filter/) {
- my $iterator = $navmap->getIterator(undef, undef, undef, 0);
- my $curRes;
- my $sequenceCount = 0;
- my $sequenceId;
- while ($curRes = $iterator->next()) {
- if (ref($curRes) && $curRes->is_sequence()) {
+ my @resources = $navmap->retrieveResources();
+ my $sequenceCount = 0;
+ my $problemCount = 0;
+ my $notaprobCount = 0;
+ my $sequenceId;
+ my $notools;
+ foreach my $curRes (@resources) {
+ if (ref($curRes)) {
+ if ($curRes->is_sequence()) {
$sequenceCount++;
$sequenceId = $curRes->map_pc();
+ } elsif ($curRes->is_problem()) {
+ $problemCount ++;
+ } else {
+ $notaprobCount ++;
}
}
-
+ }
+ if (($sequenceCount == 1) && (!$problemCount) && ($notaprobCount <= 1)) {
+ $notools = 1;
+ }
+
+ # If there's only one map in the top-level and we don't
+ # already have a filter, automatically display it
+ if ($ENV{QUERY_STRING} !~ /filter/) {
if ($sequenceCount == 1) {
# The automatic iterator creation in the render call
# will pick this up. We know the condition because
@@ -183,9 +193,11 @@
if ($env{'form.register'}) {
$link .= '®ister='.$env{'form.register'};
}
- &Apache::lonnavmaps::add_linkitem(\%toplinkitems,'firsthomework',
- 'location.href="'.$link.'"',
- "Show my first due problem");
+ unless ($notools) {
+ &Apache::lonnavmaps::add_linkitem(\%toplinkitems,'firsthomework',
+ 'location.href="'.$link.'"',
+ "Show my first due problem");
+ }
}
my $suppressEmptySequences = 0;
@@ -216,13 +228,18 @@
if ($env{'form.register'}) {
$link .= '®ister='.$env{'form.register'};
}
- &Apache::lonnavmaps::add_linkitem(\%toplinkitems,'uncompleted',
- 'location.href="'.$link.'"',
- 'Show only uncompleted problems');
+ unless ($notools) {
+ &Apache::lonnavmaps::add_linkitem(\%toplinkitems,'uncompleted',
+ 'location.href="'.$link.'"',
+ 'Show only uncompleted problems');
+ }
}
my %selected=($env{'form.sort'} => ' selected="selected"');
- my $sort_html=('<form name="sortForm" action="">
+ my $sort_html;
+ unless ($notools) {
+ $sort_html=(
+ '<form name="sortForm" action="">
<span class="LC_nobreak">
<input type="hidden" name="showOnlyHomework" value="'.$env{'form.showOnlyHomework'}.'" />
'.&mt('Sort by:').'
@@ -235,6 +252,7 @@
<input type="hidden" name="register" value="'.$env{'form.register'}.'" />
</span>
</form>');
+ }
# renderer call
my $renderArgs = { 'cols' => [0,1,2,3],
'sort' => $env{'form.sort'},
@@ -247,7 +265,9 @@
'sort_html'=> $sort_html,
'r' => $r,
'caller' => 'navmapsdisplay',
- 'linkitems' => \%toplinkitems};
+ 'linkitems' => \%toplinkitems,
+ 'notools' => $notools};
+
my $render = &Apache::lonnavmaps::render($renderArgs);
# If no resources were printed, print a reassuring message so the
More information about the LON-CAPA-cvs
mailing list