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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 21 Jun 2002 20:27:54 -0000


albertel		Fri Jun 21 16:27:54 2002 EDT

  Modified files:              
    /loncom/homework	lonhomework.pm structuretags.pm 
  Log:
  - CLOSES BUG#188, adds save and view button, and makes it clear that
    the view button will discard all changes.
  
  
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.79 loncom/homework/lonhomework.pm:1.80
--- loncom/homework/lonhomework.pm:1.79	Fri May 24 14:55:23 2002
+++ loncom/homework/lonhomework.pm	Fri Jun 21 16:27:54 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.79 2002/05/24 18:55:23 albertel Exp $
+# $Id: lonhomework.pm,v 1.80 2002/06/21 20:27:54 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -80,7 +80,11 @@
 	}
       } elsif ( $ENV{'form.problemmode'} eq 'Edit' ) {
 	if ( $ENV{'form.submitted'} eq 'edit' ) {
-	  return ('modified','edit');
+	  if ( $ENV{'form.submit'} eq 'Submit Changes and View' ) {
+	    return ('modified','web','asnwer');
+	  } else {
+	    return ('modified','edit');
+	  }
 	} else {
 	  return ('edit');
 	}
@@ -304,22 +308,30 @@
 				   \$ENV{'form.editxmltext'});
     if (!$error) { $problem=&Apache::lonnet::getfile($file); }
   }
-  my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem);
-  if ($cols > 80) { $cols = 80; }
-  $result.='<html><body bgcolor="#FFFFFF">
+  &Apache::lonhomework::showhashsubset(\%ENV,'^form');
+  if ( $ENV{'form.submit'} eq 'Submit Changes and View' ) {
+    &Apache::lonhomework::showhashsubset(\%ENV,'^form');
+    $ENV{'form.problemmode'}='View';
+    &renderpage($request,$file);
+  } else {
+    my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem);
+    if ($cols > 80) { $cols = 80; }
+    $result.='<html><body bgcolor="#FFFFFF">
             <form name="lonhomework" method="POST" action="'.
 	      $ENV{'request.uri'}.'">
             <input type="hidden" name="problemmode" value="EditXML" />
-            <input type="submit" name="problemmode" value="View" />
+            <input type="submit" name="problemmode" value="Discard Edits and View" />
             <input type="submit" name="problemmode" value="Edit" />
             <hr />
             <input type="submit" name="submit" value="Submit Changes" />
+            <input type="submit" name="submit" value="Submit Changes and View" />
             <input type="submit" name="Undo" value="undo" />
             <hr />
             <textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'.
 	      &HTML::Entities::encode($problem).'</textarea>
             </form></body></html>';
-  $request->print($result);
+    $request->print($result);
+  }
   return '';
 }
 
@@ -480,8 +492,10 @@
   &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:");
   # some times multiple problemmodes are submitted, need to select
   # the last one
+  &Apache::lonxml::debug("Problem Mode ".$ENV{'form.problemmode'});
   if ( defined($ENV{'form.problemmode'}) &&
        ref($ENV{'form.problemmode'}) ) {
+    &Apache::lonxml::debug("Problem Mode ".join(",",@$ENV{'form.problemmode'}));
     my $mode=$ENV{'form.problemmode'}->[-1];
     undef $ENV{'form.problemmode'};
     $ENV{'form.problemmode'}=$mode;
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.96 loncom/homework/structuretags.pm:1.97
--- loncom/homework/structuretags.pm:1.96	Thu Jun 20 13:48:35 2002
+++ loncom/homework/structuretags.pm	Fri Jun 21 16:27:54 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.96 2002/06/20 17:48:35 sakharuk Exp $
+# $Id: structuretags.pm,v 1.97 2002/06/21 20:27:54 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -290,10 +290,11 @@
 	$ENV{'request.uri'}.'">
        <input type="hidden" name="submitted" value="edit" />
        <input type="hidden" name="problemmode" value="Edit" />
-       <input type="submit" name="problemmode" value="View" />
+       <input type="submit" name="problemmode" value="Discard Edits and View" />
        <input type="submit" name="problemmode" value="EditXML" />
        <input type="submit" name="Undo" value="undo" /> <hr />
-       <input type="submit" name="submit" value="Submit Changes" /><br />
+       <input type="submit" name="submit" value="Submit Changes" />
+       <input type="submit" name="submit" value="Submit Changes and View" /><br />
       ';
     my $temp=&Apache::edit::insertlist($target,$token);
     $result.=$temp;
@@ -349,7 +350,8 @@
     }
   } elsif ($target eq 'edit') {
     &Apache::lonxml::debug("in end_problem with $target, edit");
-    $result='<br /><input type="submit" name="submit" value="Submit Changes" />';
+    $result ='<br /><input type="submit" name="submit" value="Submit Changes and Edit" />';
+    $result.='<input type="submit" name="submit" value="Submit Changes and View" />';
   } elsif ($target eq 'tex') {
       $result .= '\vskip 0.5mm\noindent\makebox[9.0cm][b]{\hrulefill}';
       if (not $ENV{'request.symb'} =~ m/\.page_/) {