File:  [LON-CAPA] / loncom / interface / statistics / lonstathelpers.pm
Revision 1.1: download - view: text, annotated - select for diffs
Mon Jan 19 21:29:46 2004 UTC (20 years, 6 months ago) by matthew
Branches: MAIN
CVS tags: HEAD
Adding lonstathelpers.pm to hold routines needed by multiple statistics
modules.

    1: # The LearningOnline Network with CAPA
    2: #
    3: # $Id: lonstathelpers.pm,v 1.1 2004/01/19 21:29:46 matthew Exp $
    4: #
    5: # Copyright Michigan State University Board of Trustees
    6: #
    7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    8: #
    9: # LON-CAPA is free software; you can redistribute it and/or modify
   10: # it under the terms of the GNU General Public License as published by
   11: # the Free Software Foundation; either version 2 of the License, or
   12: # (at your option) any later version.
   13: #
   14: # LON-CAPA is distributed in the hope that it will be useful,
   15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17: # GNU General Public License for more details.
   18: #
   19: # You should have received a copy of the GNU General Public License
   20: # along with LON-CAPA; if not, write to the Free Software
   21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22: #
   23: # /home/httpd/html/adm/gpl.txt
   24: #
   25: # http://www.lon-capa.org/
   26: #
   27: ####################################################
   28: ####################################################
   29: 
   30: =pod
   31: 
   32: =head1 NAME
   33: 
   34: Apache::lonstathelpers - helper routines used by statistics
   35: 
   36: =head1 SYNOPSIS
   37: 
   38: This module provides a place to consolidate much of the statistics 
   39: routines that are needed across multiple statistics functions.
   40: 
   41: =head1 OVERVIEW
   42: 
   43: 
   44: =over 4
   45: 
   46: =cut
   47: 
   48: ####################################################
   49: ####################################################
   50: package Apache::lonstathelpers;
   51: 
   52: use strict;
   53: use Apache::lonnet();
   54: use Apache::loncommon();
   55: use Apache::lonhtmlcommon();
   56: use Apache::loncoursedata();
   57: use Apache::lonstatistics;
   58: use Apache::lonlocal;
   59: use HTML::Entities();
   60: use Time::Local();
   61: use Spreadsheet::WriteExcel();
   62: 
   63: ####################################################
   64: ####################################################
   65: 
   66: =pod
   67: 
   68: =item &render_resource($resource)
   69: 
   70: Input: a resource generated from 
   71: &Apache::loncoursedata::get_sequence_assessment_data().
   72: 
   73: Retunrs: a scalar containing html for a rendering of the problem
   74: within a table.
   75: 
   76: =cut
   77: 
   78: ####################################################
   79: ####################################################
   80: sub render_resource {
   81:     my ($resource) = @_;
   82:     ##
   83:     ## Render the problem
   84:     my $base;
   85:     ($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|);
   86:     $base = "http://".$ENV{'SERVER_NAME'}.$base;
   87:     my $rendered_problem = 
   88:         &Apache::lonnet::ssi_body($resource->{'src'});
   89:     $rendered_problem =~ s/<\s*form\s*/<nop /g;
   90:     $rendered_problem =~ s|(<\s*/form\s*>)|<\/nop>|g;
   91:     return '<table bgcolor="ffffff"><tr><td>'.
   92:         '<base href="'.$base.'" />'.
   93:         $rendered_problem.
   94:         '</td></tr></table>';
   95: }
   96: 
   97: 1;
   98: 
   99: __END__

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