File:  [LON-CAPA] / rat / lonratsrv.pm
Revision 1.42: download - view: text, annotated - select for diffs
Tue Oct 25 19:23:20 2011 UTC (12 years, 6 months ago) by www
Branches: MAIN
CVS tags: version_2_12_X, version_2_11_X, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, language_hyphenation_merge, language_hyphenation, HEAD, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse
Bug #1320

    1: # The LearningOnline Network with CAPA
    2: # Server for RAT Maps
    3: #
    4: # $Id: lonratsrv.pm,v 1.42 2011/10/25 19:23:20 www 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: 
   30: package Apache::lonratsrv;
   31: 
   32: use strict;
   33: use Apache::Constants qw(:common);
   34: use LONCAPA();
   35: use LONCAPA::map();
   36: 
   37: 
   38: # ================================================================ Main Handler
   39: 
   40: sub handler {
   41:   my $r=shift;
   42:   &Apache::loncommon::content_type($r,'text/html');
   43:   $r->send_http_header;
   44: 
   45:   return OK if $r->header_only;
   46: 
   47:   my $url=$r->uri;
   48:   $url=~m{/(\w+)/ratserver$};
   49:   my $mode=$1;
   50: 
   51:   $url=~s{/loadonly/ratserver$}{/save/ratserver};
   52:   
   53:   my $fn=$r->filename;
   54:   my $errtext='';
   55:   my $infotext='';
   56:   my $outtext='';
   57: 
   58:   if ($mode ne 'loadonly') {
   59:      ($errtext,$infotext)=&LONCAPA::map::savemap($fn,$errtext);
   60:   }
   61:   ($outtext,$errtext,$infotext)=&LONCAPA::map::loadmap($fn,$errtext,$infotext);
   62: 
   63:   my $start_page =
   64:       &Apache::loncommon::start_page('Alert',undef,
   65: 				     {'only_body' => 1,
   66: 				      'bgcolor'   => '#FFFFFF',});
   67:   my $end_page =
   68:       &Apache::loncommon::end_page();
   69: 
   70:   $r->print(<<ENDDOCUMENT);
   71: $start_page
   72: <form name="storage" method="post" action="$url">
   73: <input type="hidden" name="output" value="$outtext" />
   74: </form>
   75: <script type ="text/javascript">
   76:     parent.flag=1;
   77: </script>
   78: ENDDOCUMENT
   79:     if (($errtext ne '') || ($infotext ne '')) {
   80: 	$r->print(<<ENDSCRIPT);
   81: <script type="text/javascript">
   82:     alert("$infotext $errtext");
   83: </script>
   84: ENDSCRIPT
   85:     }
   86:     $r->print($end_page);
   87: 
   88:   return OK;
   89: }
   90: 
   91: 1;
   92: __END__
   93: 
   94: 
   95: =head1 NAME
   96: 
   97: Apache::lonratsrv
   98: 
   99: =head1 SYNOPSIS
  100: 
  101: Handler that takes output from RAT and stores
  102: it on disk. Handles the upper hidden frame of
  103: the added window that comes up in RAT. (3
  104: frames come up in RAT server, code, and
  105: output. This module handles server
  106: connection.)
  107: 
  108: This is part of the LearningOnline Network with CAPA project
  109: described at http://www.lon-capa.org.
  110: 
  111: =cut

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