[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
sakharuk
lon-capa-cvs@mail.lon-capa.org
Thu, 21 Mar 2002 16:15:34 -0000
sakharuk Thu Mar 21 11:15:34 2002 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
primary sequence output for problems is fixed
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.17 loncom/interface/lonprintout.pm:1.18
--- loncom/interface/lonprintout.pm:1.17 Wed Mar 20 17:14:30 2002
+++ loncom/interface/lonprintout.pm Thu Mar 21 11:15:34 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.17 2002/03/20 22:14:30 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.18 2002/03/21 16:15:34 sakharuk Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -118,60 +118,41 @@
$result .= $texversion;
} elsif ($choice eq 'Standard LaTeX output for the primary sequence') {
- my @master_seq = ();
- my $keyword = 0;
- my $output_seq = '';
- my $current_file = '/res/'.$ENV{'request.ambiguous'};
- $current_file =~ s/(\/res\/physnet\/physnet)(\/m\d+)\/(.*)/$1$2$2\.sequence/;
- while ($current_file ne '') {
- my $file=&Apache::lonnet::filelocation("",$current_file);
- my $filecontents=&Apache::lonnet::getfile($file);
- my @file_seq = &content_map($filecontents);
- if (defined @file_seq) {
-#-- adding an additional array to the master one
- if (defined @master_seq) {
- my $old_value = $#master_seq;
- my $total_value = $#master_seq + $#file_seq +2;
- for (my $j=0; $j<=$old_value-$keyword+1; $j++) {
- $master_seq[$total_value-$j] = $master_seq[$old_value-$j];
- }
- for (my $j=0; $j<=$#file_seq; $j++){
- $master_seq[$keyword+$j] = $file_seq[$j];
+#-- where is the primary sequence containing file?
+ my %moreenv;
+ my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'});
+ $_ = $symbolic;
+ m/([^_]+)_/;
+ my $primary_sequence = '/res/'.$1;
+#-- open and analyses the primary sequence
+ my $sequence_file=&Apache::lonnet::filelocation("",$primary_sequence);
+ my $sequencefilecontents=&Apache::lonnet::getfile($sequence_file);
+ my @master_seq = &content_map($sequencefilecontents);
+#-- produce an output string
+ for (my $i=0;$i<=$#master_seq;$i++) {
+ $_ = $master_seq[$i];
+ m/\"(.*)\"/;
+ $_ = $1;
+ my $urlp = $1;
+ if (/\.problem/) {
+ my %moreenv;
+ $moreenv{'form.grade_target'}='tex';
+ &Apache::lonnet::appenv(%moreenv);
+ my $texversion=&Apache::lonnet::ssi($urlp);
+ &Apache::lonnet::delenv('form.grade_target');
+ $texversion =~ s!\.gif!\.eps!;
+ $result .= $texversion;
}
- @file_seq = ();
- $keyword = 0;
- } else {
- @master_seq = @file_seq;
- @file_seq = ();
- }
}
-#-- checking wether .sequence file is among the set of files
- $current_file = '';
- for (my $i=0; $i<=$#file_seq; $i++) {
- $_ = $file_seq[$i];
- if (m/(.*)\.sequence/) {
- $current_file = $_;
- $keyword = $i;
- last;
- }
- }
- }
-#-- produce an output string
- for (my $i=0;$i<=$#master_seq;$i++) {
- $_ = $master_seq[$i];
- m/\"(.*)\"/;
- if (index($1,'-tc.xml',0)==-1) {
- my $file=&Apache::lonnet::filelocation("",$1);
- my $filecontents=&Apache::lonnet::getfile($file);
- $output_seq .= $filecontents;
+#-- additional cleanup for output
+ my $first_app = index($result,'\documentclass',0);
+ $first_app = index($result,'\documentclass',$first_app+5);
+ while ($first_app != -1) {
+ my $second_app = index($result,'begin{document}',$first_app);
+ $first_app = rindex($result,'\end{document}',$first_app);
+ substr($result,$first_app,$second_app-$first_app+15) = '\vskip 7 mm';
+ $first_app = index($result,'\documentclass',$first_app+5);
}
- }
-#-- cleanup of output string (temporary cbi-specific)
- $output_seq =~ s/<physnet>//g;
- $output_seq =~ s/<\/physnet>//g;
- $output_seq = '<physnet>'.$output_seq.' </physnet>';
-#-- final accord
- $result = &Apache::lonxml::xmlparse('tex',$output_seq,'',%mystyle);
} elsif ($choice eq 'Standard LaTeX output for the top level sequence') {
my @master_seq = ();
my $keyword = 0;
@@ -292,6 +273,7 @@
m/to=\"(\d+)\"/;
push @number_seq,$1;
$startlink = index($map_string,'from="'.$1.'"',$startlink);
+ $startlink = rindex($map_string,'<link ',$startlink);
}
my $stalink = index($map_string,' to="'.$number_seq[0].'"',$startlink);
while ($stalink != -1) {