--- rat/lonpage.pm 2002/03/26 23:12:57 1.35 +++ rat/lonpage.pm 2002/06/20 17:47:35 1.40 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Page Handler # -# $Id: lonpage.pm,v 1.35 2002/03/26 23:12:57 www Exp $ +# $Id: lonpage.pm,v 1.40 2002/06/20 17:47:35 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -48,6 +48,7 @@ use Apache::loncommon(); use Apache::lonxml(); use HTML::TokeParser; use GDBM_File; +use Apache::lonsequence; # -------------------------------------------------------------- Module Globals my %hash; @@ -146,15 +147,19 @@ sub handler { if ($ENV{'browser.mathml'}) { $r->content_type('text/xml'); } else { - $r->content_type('text/html'); + $r->content_type('text/html'); } $r->send_http_header; return OK; } + + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['forceselect','launch']); - my $requrl=$r->uri; + my $requrl=$r->uri; + my $target = $ENV{'form.grade_target'}; # ----------------------------------------------------------------- Tie db file - if ($ENV{'request.course.fn'}) { + if (($ENV{'request.course.fn'}) && (!$ENV{'form.forceselect'})) { my $fn=$ENV{'request.course.fn'}; if (-e "$fn.db") { if (tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER,0640)) { @@ -191,6 +196,7 @@ sub handler { # ------------------------------------------------------------------ Page parms + my $number_of_columns = 1; my $j; my $lcm=1; my $contents=0; @@ -331,43 +337,56 @@ sub handler { # ------------------------------------------------------------------ Build page # ---------------------------------------------------------------- Send headers - if ($isxml) { - $r->content_type('text/xml'); - $r->send_http_header; - $r->print($xmlheader); - } else { - $r->content_type('text/html'); - $r->send_http_header; - $r->print(''); - } + unless ($target eq 'tex') { + if ($isxml) { + $r->content_type('text/xml'); + $r->send_http_header; + $r->print($xmlheader); + } else { + $r->content_type('text/html'); + $r->send_http_header; + $r->print(''); + } # ------------------------------------------------------------------------ Head - $r->print("\n\n".$allmeta); - $allscript=~ - s/\/\/ BEGIN LON\-CAPA Internal.+\/\/ END LON\-CAPA Internal\s//gs; - if ($allscript) { - $r->print("\n\n"); - } - $r->print(&Apache::lonxml::registerurl(1,undef)); - $r->print("\n\n"); + $r->print("\n\n".$allmeta); + $allscript=~ + s/\/\/ BEGIN LON\-CAPA Internal.+\/\/ END LON\-CAPA Internal\s//gs; + if ($allscript) { + $r->print("\n\n"); + } + $r->print(&Apache::lonxml::registerurl(1,undef)); + $r->print("\n\n"); # ------------------------------------------------------------------ Start body - if ($isxml) { - $r->print($xmlbody); - } else { - $r->print( - ''); - } + if ($isxml) { + $r->print($xmlbody); + } else { + $r->print(''); + } # ------------------------------------------------------------------ Start form - if ($nforms) { - $r->print('
'); - } + if ($nforms) { + $r->print(''); + } + } else { + $r->print('\documentclass[letterpaper]{article} + \newcommand{\keephidden}[1]{} + \usepackage[dvips]{graphicx} + \usepackage{epsfig} + \usepackage{calc} + \begin{document}'); + } # ----------------------------------------------------------------- Start table - $r->print(''); + if ($target eq 'tex') { + $r->print('\begin{tabular}INSERT'); + } else { + $r->print('
'); + } for ($i=0;$i<=$#rows;$i++) { if ($rows[$i]) { - $r->print("\n"); + unless ($target eq 'tex') { + $r->print("\n"); + } my @colcont=split(/\&/,$rows[$i]); my $avespan=$lcm/($#colcont+1); for ($j=0;$j<=$#colcont;$j++) { @@ -389,67 +408,94 @@ sub handler { '___'.$resid.'___'. &Apache::lonnet::declutter($hash{'src_'.$rid}); $metainfo.= - ''. ''. ''. - ''. + ''. ''. ''. - ''. + ''. ''. ''; } $metainfo.='

'; - $r->print(''); + unless ($target eq 'tex') { + $r->print(''); + } else { + $number_of_columns++; + $r->print(' & '); + } } - $r->print(''); + unless ($target eq 'tex') { + $r->print(''); + } else { + $number_of_columns = 1; + $r->print('REMOVE\\\\'); + } } } - $r->print("\n
print('print(' bgcolor="'. - $ssibgcolor{$rid}.'"'); - } - $r->print('>'.$metainfo.'print(' text="'.$ssitext{$rid}.'"'); - } - if ($ssilink{$rid}) { - $r->print(' link="'.$ssilink{$rid}.'"'); - } - if ($ssitext{$rid}) { - $r->print(' vlink="'.$ssivlink{$rid}.'"'); - } - if ($ssialink{$rid}) { - $r->print(' alink="'.$ssialink{$rid}.'"'); - } - - $r->print('>'.$ssibody{$rid}.''); - } elsif ($cellemb{$rid} eq 'img') { + unless ($target eq 'tex') { + if ($ssibgcolor{$rid}) { + $r->print(' bgcolor="'. + $ssibgcolor{$rid}.'"'); + } + $r->print('>'.$metainfo.'print(' text="'.$ssitext{$rid}.'"'); + } + if ($ssilink{$rid}) { + $r->print(' link="'.$ssilink{$rid}.'"'); + } + if ($ssitext{$rid}) { + $r->print(' vlink="'.$ssivlink{$rid}.'"'); + } + if ($ssialink{$rid}) { + $r->print(' alink="'.$ssialink{$rid}.'"'); + } + $r->print('>'); + } + $r->print($ssibody{$rid}); + unless ($target eq 'tex') { + $r->print(''); + } + } elsif ($cellemb{$rid} eq 'img') { $r->print('>'.$metainfo.''); } elsif ($cellemb{$rid} eq 'emb') { $r->print('>'.$metainfo.''); } - $r->print('
"); + unless ($target eq 'tex') { + $r->print("\n"); + } else { + $r->print('\end{tabular}'); + } # ---------------------------------------------------------------- Submit, etc. if ($nforms) { $r->print( '
'); } - $r->print(''.&Apache::lonxml::xmlend()); + unless ($target eq 'tex') { + $r->print(''.&Apache::lonxml::xmlend()); + } else { + $r->print('\end{document}'.$number_of_columns); + } # -------------------------------------------------------------------- End page } # ------------------------------------------------------------- End render page } else { $r->content_type('text/html'); $r->send_http_header; - $r->print('Page undefined.'); + &Apache::lonsequence::viewmap($r,$requrl); } # ------------------------------------------------------------------ Untie hash unless (untie(%hash)) { @@ -462,8 +508,10 @@ sub handler { } } } - $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized"; - return HTTP_NOT_ACCEPTABLE; + $r->content_type('text/html'); + $r->send_http_header; + &Apache::lonsequence::viewmap($r,$requrl); + return OK; } 1;