[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm

sakharuk lon-capa-cvs@mail.lon-capa.org
Mon, 12 May 2003 20:29:39 -0000


sakharuk		Mon May 12 16:29:39 2003 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  It's possible now to print single resource with or without answer. After carefull testing on all kinds of problems I'll add this option for any other items from printing menu. (Some additional technical work still has to be done - Subroutines,...). Note, that I've tested this feature only on the numerical responce problems. 
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.162 loncom/interface/lonprintout.pm:1.163
--- loncom/interface/lonprintout.pm:1.162	Mon May 12 14:47:07 2003
+++ loncom/interface/lonprintout.pm	Mon May 12 16:29:39 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.162 2003/05/12 18:47:07 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.163 2003/05/12 20:29:39 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1381,6 +1381,24 @@
 	    &Apache::lonnet::appenv(%moreenv);
 	    my $texversion=&Apache::lonnet::ssi($currentURL);
 	    &Apache::lonnet::delenv('form.grade_target','form.textwidth','form.counter');
+	    if($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
+		$moreenv{'form.grade_target'}='answer';
+		&Apache::lonnet::appenv(%moreenv);
+		my $answer=&Apache::lonnet::ssi($currentURL);
+		&Apache::lonnet::delenv('form.grade_target');
+		my $start=index($answer,'<table',0);
+		my $finish=index($answer,'</table>',$start);
+		if ($start!=-1 && $finish!=-1) {$answer=substr($answer,$start,$finish-$start+8);}
+		$answer=~s/<\/td>\s*<td>/ \\\\ \\hline /g;
+                $answer=~s/<table([^>]*)>/\\vskip 0 mm \\begin{tabular}{|c|}\\hline /;
+	        $answer=~s/<\/table>/\\end{tabular}\\vskip 0 mm/;
+	        $answer=~s/<tr>\s*<td>//;
+	        $answer=~s/<\/td>\s*<\/tr>/\\\\ \\hline /;
+	        $answer=~s/<b>([^\#]*)<\/b>/\\verb|$1|/;
+	        $answer=~s/<i>([^\#]*)<\/i>/\\textit{$1}/;
+#		$r->print('<pre>'.$answer.'</pre>'); return OK;
+		$texversion=~s/(\\end{document})/$answer$1/;
+	    }
 	    $result .= $texversion;
 	    if ($currentURL=~m/\.page\s*$/) {
 		($result,$number_of_columns) = &page_cleanup($result);
@@ -1587,7 +1605,7 @@
 	foreach $key (keys %{$helper->{'VARS'}}) {
 	    $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'<-<br />');
 	}
-	return OK;
+#	return OK;
 	
 	
 	&output_data_new($r,$helper);
@@ -1893,8 +1911,8 @@
 	$paramHash->{'variable'} = 'ANSWER_TYPE';   
 	$helper->declareVar('ANSWER_TYPE');         
         $paramHash->{CHOICES} = [
-                                   ['Print without answer', '1'],
-                                   ['Print with answers', '0'] ];
+                                   ['Print without answer', 'yes'],
+                                   ['Print with answers', 'no'] ];
         Apache::lonhelper::choices->new();
     }