[LON-CAPA-cvs] cvs: loncom /homework lonsimpleproblemedit.pm
raeburn
raeburn@source.lon-capa.org
Sun, 01 Feb 2009 20:40:28 -0000
raeburn Sun Feb 1 20:40:28 2009 EDT
Modified files:
/loncom/homework lonsimpleproblemedit.pm
Log:
- Check that $navmap object was available.
- Advise course re-initialization, if not.
Index: loncom/homework/lonsimpleproblemedit.pm
diff -u loncom/homework/lonsimpleproblemedit.pm:1.19 loncom/homework/lonsimpleproblemedit.pm:1.20
--- loncom/homework/lonsimpleproblemedit.pm:1.19 Fri Jun 30 01:16:41 2006
+++ loncom/homework/lonsimpleproblemedit.pm Sun Feb 1 20:40:28 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Simple Problem Parameter Setting "Editor"
#
-# $Id: lonsimpleproblemedit.pm,v 1.19 2006/06/30 01:16:41 albertel Exp $
+# $Id: lonsimpleproblemedit.pm,v 1.20 2009/02/01 20:40:28 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -143,13 +143,16 @@
sub get_parent_uri {
my ($cur_symb)=@_;
my $navmap = Apache::lonnavmaps::navmap->new();
- my $it = $navmap->getIterator(undef, undef, undef, 1);
- while ( my $res=$it->next()) {
- if (ref($res) && $res->symb() eq $cur_symb) { last; }
+ if (defined($navmap)) {
+ my $it = $navmap->getIterator(undef, undef, undef, 1);
+ while ( my $res=$it->next()) {
+ if (ref($res) && $res->symb() eq $cur_symb) { last; }
+ }
+ my ($src,$symb,$anchor)=&Apache::lonnavmaps::getLinkForResource($it->getStack());
+ if (defined($anchor)) { $anchor='#'.$anchor; }
+ return $src.'?symb='.&escape($symb).$anchor;
}
- my ($src,$symb,$anchor)=&Apache::lonnavmaps::getLinkForResource($it->getStack());
- if (defined($anchor)) { $anchor='#'.$anchor; }
- return $src.'?symb='.&escape($symb).$anchor;
+ return;
}
sub handler {
@@ -219,8 +222,14 @@
$spell_header));
if ($symb) {
$r->print('<h1>'.&Apache::lonnet::gettitle($symb).'</h1>');
- $r->print('<table width="100%" bgcolor="#FFFFAA" border="2"><tr><td>'.
- '<a href="'.&get_parent_uri($symb).'">'.&mt('Student View').'</a> - '.&mt('Note: it can take up to 10 minutes for changes to take effect for all users.').
+ $r->print('<table width="100%" bgcolor="#FFFFAA" border="2"><tr><td>');
+ my $displaylink = &get_parent_uri($symb);
+ if ($displaylink ne '') {
+ $r->print('<a href="'.$displaylink.'">'.&mt('Student View').'</a> - ');
+ } else {
+ $r->print('<span class="LC_error">'.&mt('An error occurred retrieving the link to this problem').'<br />'.&mt('You may need to [_1]re-select the course[_2] and then return to this resource to view it.','<a href="/adm/roles">','</a>').'</span><br />');
+ }
+ $r->print(&mt('Note: it can take up to 10 minutes for changes to take effect for all users.').
&Apache::loncommon::help_open_topic('Caching').'</td></tr></table>');
$r->print('<table border="2" bgcolor="#FFFFFF" width="100%"><tr><td>'.
&rawrendering($symb).