[LON-CAPA-cvs] cvs: loncom /interface/statistics lonstathelpers.pm

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 19 Jan 2004 21:29:46 -0000


matthew		Mon Jan 19 16:29:46 2004 EDT

  Added files:                 
    /loncom/interface/statistics	lonstathelpers.pm 
  Log:
  Adding lonstathelpers.pm to hold routines needed by multiple statistics 
  modules.
  
  

Index: loncom/interface/statistics/lonstathelpers.pm
+++ loncom/interface/statistics/lonstathelpers.pm
# The LearningOnline Network with CAPA
#
# $Id: lonstathelpers.pm,v 1.1 2004/01/19 21:29:46 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
####################################################
####################################################

=pod

=head1 NAME

Apache::lonstathelpers - helper routines used by statistics

=head1 SYNOPSIS

This module provides a place to consolidate much of the statistics 
routines that are needed across multiple statistics functions.

=head1 OVERVIEW


=over 4

=cut

####################################################
####################################################
package Apache::lonstathelpers;

use strict;
use Apache::lonnet();
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::loncoursedata();
use Apache::lonstatistics;
use Apache::lonlocal;
use HTML::Entities();
use Time::Local();
use Spreadsheet::WriteExcel();

####################################################
####################################################

=pod

=item &render_resource($resource)

Input: a resource generated from 
&Apache::loncoursedata::get_sequence_assessment_data().

Retunrs: a scalar containing html for a rendering of the problem
within a table.

=cut

####################################################
####################################################
sub render_resource {
    my ($resource) = @_;
    ##
    ## Render the problem
    my $base;
    ($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|);
    $base = "http://".$ENV{'SERVER_NAME'}.$base;
    my $rendered_problem = 
        &Apache::lonnet::ssi_body($resource->{'src'});
    $rendered_problem =~ s/<\s*form\s*/<nop /g;
    $rendered_problem =~ s|(<\s*/form\s*>)|<\/nop>|g;
    return '<table bgcolor="ffffff"><tr><td>'.
        '<base href="'.$base.'" />'.
        $rendered_problem.
        '</td></tr></table>';
}

1;

__END__