File:  [LON-CAPA] / rat / lonratsrv.pm
Revision 1.40: download - view: text, annotated - select for diffs
Thu Nov 20 13:51:22 2008 UTC (15 years, 5 months ago) by jms
Branches: MAIN
CVS tags: HEAD
Added/edited POD documentation

    1: # The LearningOnline Network with CAPA
    2: # Server for RAT Maps
    3: #
    4: # $Id: lonratsrv.pm,v 1.40 2008/11/20 13:51:22 jms Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: 
   29: =head1 NAME
   30: 
   31: Apache::lonratsrv
   32: 
   33: =head1 SYNOPSIS
   34: 
   35: Handler that takes output from RAT and stores
   36: it on disk. Handles the upper hidden frame of
   37: the added window that comes up in RAT. (3
   38: frames come up in RAT server, code, and
   39: output. This module handles server
   40: connection.)
   41: 
   42: This is part of the LearningOnline Network with CAPA project
   43: described at http://www.lon-capa.org.
   44: 
   45: =cut
   46: 
   47: package Apache::lonratsrv;
   48: 
   49: use strict;
   50: use Apache::Constants qw(:common);
   51: use LONCAPA();
   52: use LONCAPA::map();
   53: 
   54: 
   55: # ================================================================ Main Handler
   56: 
   57: sub handler {
   58:   my $r=shift;
   59:   &Apache::loncommon::content_type($r,'text/html');
   60:   $r->send_http_header;
   61: 
   62:   return OK if $r->header_only;
   63: 
   64:   my $url=$r->uri;
   65:   $url=~m{/(\w+)/ratserver$};
   66:   my $mode=$1;
   67: 
   68:   $url=~s{/loadonly/ratserver$}{/save/ratserver};
   69:   
   70:   my $fn=$r->filename;
   71:   my $lonDocRoot=$r->dir_config('lonDocRoot');
   72:   if ( $fn =~ /\Q$lonDocRoot\E/ ) {
   73:       #internal authentication, needs fixup.
   74:       $fn = $url;
   75:       $fn=~s{^/~($LONCAPA::username_re)}{/home/$1/public_html};
   76:       $fn=~s{/[^/]*/ratserver$}{};
   77:   }
   78:   my $errtext='';
   79:   my $infotext='';
   80:   my $outtext='';
   81: 
   82:   if ($mode ne 'loadonly') {
   83:      ($errtext,$infotext)=&LONCAPA::map::savemap($fn,$errtext);
   84:   }
   85:   ($outtext,$errtext,$infotext)=&LONCAPA::map::loadmap($fn,$errtext,$infotext);
   86: 
   87:   my $start_page =
   88:       &Apache::loncommon::start_page('Alert',undef,
   89: 				     {'only_body' => 1,
   90: 				      'bgcolor'   => '#FFFFFF',});
   91:   my $end_page =
   92:       &Apache::loncommon::end_page();
   93: 
   94:   $r->print(<<ENDDOCUMENT);
   95: $start_page
   96: <form name="storage" method="post" action="$url">
   97: <input type="hidden" name="output" value="$outtext" />
   98: </form>
   99: <script type ="text/javascript">
  100:     parent.flag=1;
  101: </script>
  102: ENDDOCUMENT
  103:     if (($errtext ne '') || ($infotext ne '')) {
  104: 	$r->print(<<ENDSCRIPT);
  105: <script type="text/javascript">
  106:     alert("$infotext $errtext");
  107: </script>
  108: ENDSCRIPT
  109:     }
  110:     $r->print($end_page);
  111: 
  112:   return OK;
  113: }
  114: 
  115: 1;
  116: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>