version 1.17, 2002/03/20 22:14:30
|
version 1.18, 2002/03/21 16:15:34
|
Line 118 ENDPART
|
Line 118 ENDPART
|
$result .= $texversion; |
$result .= $texversion; |
|
|
} elsif ($choice eq 'Standard LaTeX output for the primary sequence') { |
} elsif ($choice eq 'Standard LaTeX output for the primary sequence') { |
my @master_seq = (); |
#-- where is the primary sequence containing file? |
my $keyword = 0; |
my %moreenv; |
my $output_seq = ''; |
my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'}); |
my $current_file = '/res/'.$ENV{'request.ambiguous'}; |
$_ = $symbolic; |
$current_file =~ s/(\/res\/physnet\/physnet)(\/m\d+)\/(.*)/$1$2$2\.sequence/; |
m/([^_]+)_/; |
while ($current_file ne '') { |
my $primary_sequence = '/res/'.$1; |
my $file=&Apache::lonnet::filelocation("",$current_file); |
#-- open and analyses the primary sequence |
my $filecontents=&Apache::lonnet::getfile($file); |
my $sequence_file=&Apache::lonnet::filelocation("",$primary_sequence); |
my @file_seq = &content_map($filecontents); |
my $sequencefilecontents=&Apache::lonnet::getfile($sequence_file); |
if (defined @file_seq) { |
my @master_seq = &content_map($sequencefilecontents); |
#-- adding an additional array to the master one |
#-- produce an output string |
if (defined @master_seq) { |
for (my $i=0;$i<=$#master_seq;$i++) { |
my $old_value = $#master_seq; |
$_ = $master_seq[$i]; |
my $total_value = $#master_seq + $#file_seq +2; |
m/\"(.*)\"/; |
for (my $j=0; $j<=$old_value-$keyword+1; $j++) { |
$_ = $1; |
$master_seq[$total_value-$j] = $master_seq[$old_value-$j]; |
my $urlp = $1; |
} |
if (/\.problem/) { |
for (my $j=0; $j<=$#file_seq; $j++){ |
my %moreenv; |
$master_seq[$keyword+$j] = $file_seq[$j]; |
$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 |
#-- additional cleanup for output |
$current_file = ''; |
my $first_app = index($result,'\documentclass',0); |
for (my $i=0; $i<=$#file_seq; $i++) { |
$first_app = index($result,'\documentclass',$first_app+5); |
$_ = $file_seq[$i]; |
while ($first_app != -1) { |
if (m/(.*)\.sequence/) { |
my $second_app = index($result,'begin{document}',$first_app); |
$current_file = $_; |
$first_app = rindex($result,'\end{document}',$first_app); |
$keyword = $i; |
substr($result,$first_app,$second_app-$first_app+15) = '\vskip 7 mm'; |
last; |
$first_app = index($result,'\documentclass',$first_app+5); |
} |
|
} |
|
} |
|
#-- 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; |
|
} |
} |
} |
|
#-- 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') { |
} elsif ($choice eq 'Standard LaTeX output for the top level sequence') { |
my @master_seq = (); |
my @master_seq = (); |
my $keyword = 0; |
my $keyword = 0; |
Line 292 sub content_map {
|
Line 273 sub content_map {
|
m/to=\"(\d+)\"/; |
m/to=\"(\d+)\"/; |
push @number_seq,$1; |
push @number_seq,$1; |
$startlink = index($map_string,'from="'.$1.'"',$startlink); |
$startlink = index($map_string,'from="'.$1.'"',$startlink); |
|
$startlink = rindex($map_string,'<link ',$startlink); |
} |
} |
my $stalink = index($map_string,' to="'.$number_seq[0].'"',$startlink); |
my $stalink = index($map_string,' to="'.$number_seq[0].'"',$startlink); |
while ($stalink != -1) { |
while ($stalink != -1) { |