[LON-CAPA-cvs] cvs: loncom /homework lonhomework.pm lonsimpleproblemedit.pm /interface loncommon.pm /xml lonxml.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 30 Nov 2004 22:57:17 -0000


albertel		Tue Nov 30 17:57:17 2004 EDT

  Modified files:              
    /loncom/homework	lonsimpleproblemedit.pm lonhomework.pm 
    /loncom/interface	loncommon.pm 
    /loncom/xml	lonxml.pm 
  Log:
   - fixing at least BUG#3648, BUG#3649, simple problem editor now uses ::ssi to get the rendering of the problem.
  
  
Index: loncom/homework/lonsimpleproblemedit.pm
diff -u loncom/homework/lonsimpleproblemedit.pm:1.10 loncom/homework/lonsimpleproblemedit.pm:1.11
--- loncom/homework/lonsimpleproblemedit.pm:1.10	Thu Dec 11 16:23:58 2003
+++ loncom/homework/lonsimpleproblemedit.pm	Tue Nov 30 17:57:16 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Problem Parameter Setting "Editor"
 #
-# $Id: lonsimpleproblemedit.pm,v 1.10 2003/12/11 21:23:58 www Exp $
+# $Id: lonsimpleproblemedit.pm,v 1.11 2004/11/30 22:57:16 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -50,23 +50,12 @@
 }
 
 sub rawrendering {
-    my ($request,$uri)=@_;
-    my $problem=&Apache::lonnet::getfile
-                            (&Apache::lonnet::filelocation('',$uri));
-    &Apache::lonnet::devalidatecourseresdata(
-		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
-		     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'});
-    my $uname=$ENV{'user.name'};
-    my $udom=$ENV{'user.domain'};
-    $ENV{'user.name'}=time;
-    $ENV{'user.domain'}=time;
-    my $result = &Apache::lonxml::xmlparse($request,'web', $problem);
-    undef($Apache::lonhomework::parsing_a_problem);
-    $ENV{'user.name'}=$uname;
-    $ENV{'user.domain'}=$udom;
-    $result=~s/^.*\<body[^\>]*\>//si;
-    $result=~s/\<\/body[^\>]*\>.*$//si;
-    return $result;
+    my ($symb)=@_;
+    my %data=('show_errors'=>'on',
+	      'devalidatecourseresdata'=>'on');
+    return &Apache::loncommon::get_student_view($symb,time,time,
+						$ENV{'request.course.id'},
+						'web',\%data);
 }
 
 sub questiontext {
@@ -208,7 +197,7 @@
     if ($symb) {
 	$r->print('<h1>'.&Apache::lonnet::gettitle($symb).'</h1>');
 	$r->print('<table border="2" bgcolor="#FFFFFF" width="100%"><tr><td>'.
-                  &rawrendering($r,$uri).
+                  &rawrendering($symb).
                   '</td></tr></table><br />');
         $r->print('<form method="post">');
 # Question Type        
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.184 loncom/homework/lonhomework.pm:1.185
--- loncom/homework/lonhomework.pm:1.184	Mon Nov 29 17:13:34 2004
+++ loncom/homework/lonhomework.pm	Tue Nov 30 17:57:16 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.184 2004/11/29 22:13:34 albertel Exp $
+# $Id: lonhomework.pm,v 1.185 2004/11/30 22:57:16 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -385,6 +385,12 @@
                                                '/'.$ENV{'request.course.sec'});
     }
     $Apache::lonhomework::viewgrades = $viewgrades;
+    if ($Apache::lonhomework::browse eq 'F' && 
+	$ENV{'form.devalidatecourseresdata'} eq 'on') {
+	my (undef,$courseid) = &Apache::lonxml::whichuser();
+	&Apache::lonnet::devalidatecourseresdata($ENV{"course.$courseid.num"},
+					      $ENV{"course.$courseid.domain"});
+    }
     return ''
 }
 
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.235 loncom/interface/loncommon.pm:1.236
--- loncom/interface/loncommon.pm:1.235	Tue Nov 30 14:08:18 2004
+++ loncom/interface/loncommon.pm	Tue Nov 30 17:57:16 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.235 2004/11/30 19:08:18 raeburn Exp $
+# $Id: loncommon.pm,v 1.236 2004/11/30 22:57:16 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2285,7 +2285,7 @@
   if (defined($moreenv)) {
       %form=(%form,%{$moreenv});
   }
-  if ($target eq 'tex') {$form{'grade_target'} = 'tex';}
+  if (defined($target)) { $form{'grade_target'} = $target; }
   $feedurl=&Apache::lonnet::clutter($feedurl);
   my $userview=&Apache::lonnet::ssi_body($feedurl,%form);
   $userview=~s/\<body[^\>]*\>//gi;
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.347 loncom/xml/lonxml.pm:1.348
--- loncom/xml/lonxml.pm:1.347	Mon Nov 29 17:45:51 2004
+++ loncom/xml/lonxml.pm	Tue Nov 30 17:57:16 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.347 2004/11/29 22:45:51 albertel Exp $
+# $Id: lonxml.pm,v 1.348 2004/11/30 22:57:16 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1377,9 +1377,17 @@
     }
 }
 
+sub show_error_warn_msg {
+    return (($Apache::lonxml::debug eq 1) ||
+	    ($ENV{'request.state'} eq 'construct') ||
+	    ($Apache::lonhomework::browse eq 'F'
+	     &&
+	     $ENV{'form.show_errors'} eq 'on'));
+}
+
 sub error {
     $errorcount++;
-    if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) {
+    if ( &show_error_warn_msg() ) {
 	# If printing in construction space, put the error inside <pre></pre>
 	push(@Apache::lonxml::error_messages,
 	     $Apache::lonxml::warnings_error_header.
@@ -1419,7 +1427,7 @@
     $warningcount++;
   
     if ($ENV{'form.grade_target'} ne 'tex') {
-	if ($ENV{'request.state'} eq 'construct' || $Apache::lonxml::debug) {
+	if ( &show_error_warn_msg() ) {
 	    my $request=$Apache::lonxml::request;
 	    if (!$request) { $request=Apache->request; }
 	    push(@Apache::lonxml::warning_messages,