[LON-CAPA-cvs] cvs: loncom /homework lonsimpleproblemedit.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 14 Dec 2004 18:24:17 -0000


albertel		Tue Dec 14 13:24:17 2004 EDT

  Modified files:              
    /loncom/homework	lonsimpleproblemedit.pm 
  Log:
  - multiple simple problems in a .page can now be edited,
  - the 'Student View' link for a simple problem in a .page takes you back to the whole .page
  
  
Index: loncom/homework/lonsimpleproblemedit.pm
diff -u loncom/homework/lonsimpleproblemedit.pm:1.12 loncom/homework/lonsimpleproblemedit.pm:1.13
--- loncom/homework/lonsimpleproblemedit.pm:1.12	Tue Nov 30 18:28:57 2004
+++ loncom/homework/lonsimpleproblemedit.pm	Tue Dec 14 13:24:17 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Problem Parameter Setting "Editor"
 #
-# $Id: lonsimpleproblemedit.pm,v 1.12 2004/11/30 23:28:57 albertel Exp $
+# $Id: lonsimpleproblemedit.pm,v 1.13 2004/12/14 18:24:17 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,6 +33,7 @@
 use Apache::loncommon;
 use Apache::lonnet;
 use Apache::lonlocal;
+use Apache::lonnavmaps;
 
 my %qparms;
 my $prefix;
@@ -127,6 +128,18 @@
 ENDFOIL
 }
 
+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; }
+    }
+    my ($src,$symb,$anchor)=&Apache::lonnavmaps::getLinkForResource($it->getStack());
+    if (defined($anchor)) { $anchor='#'.$anchor; }
+    return $src.'?symb='.&Apache::lonnet::escape($symb).$anchor;
+}
+
 sub handler {
     my $r = shift;
 
@@ -146,7 +159,7 @@
 # ----------------------------------------------------- Figure out where we are
     my $uri=$r->uri;
     $uri=~s/\/smpedit$//;
-    my $symb=&Apache::lonnet::symbread($uri);
+    my $symb=&Apache::lonnet::symbread();
 
 # ------------------------------------------------ Prefix for everything stored
     $prefix=$ENV{'request.course.id'}.'.'.$symb.'.0.';
@@ -198,7 +211,7 @@
     if ($symb) {
 	$r->print('<h1>'.&Apache::lonnet::gettitle($symb).'</h1>');
 	$r->print('<table width="100%" bgcolor="#FFFFAA" border="2"><tr><td>'.
-                '<a href="'.$uri.'">'.&mt('Student View').'</a> - '.&mt('Note: it can take up to 10 minutes for changes to take effect for all users.').
+                '<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.').
 		  &Apache::loncommon::help_open_topic('Caching').'</td></tr></table>');
 	$r->print('<table border="2" bgcolor="#FFFFFF" width="100%"><tr><td>'.
                   &rawrendering($symb).