NAME

Apache::loncommon - pile of common routines


SYNOPSIS

Common routines for manipulating connections, student answers, domains, common Javascript fragments, etc.


OVERVIEW

A collection of commonly used subroutines that don't have a natural home anywhere else. This collection helps remove redundancy from other modules and increase efficiency of memory usage.


HTML and Javascript Functions


=head1 Excel and CSV file utility routines


Routines for form select boxes


Decoding the User Agent


Authentication Routines


Domains and Authentication

Returns default authentication type and an associated argument as listed in file 'domain.tab'.


Thesaurus Functions


User Name Functions


Access .tab File Data


Alternate Problem Views


Domain Template Functions


HTML Helpers


User Information Routines


HTTP Helpers


CSV Upload/Handling functions


cgi-bin script and graphing routines

get_cgi_id

Inputs: none

Returns an id which can be used to pass environment variables to various cgi-bin scripts. These environment variables will be removed from the users environment after a given time by the routine &Apache::lonnet::transfer_profile_to_env.

DrawBarGraph

Facilitates the plotting of data in a (stacked) bar graph. Puts plot definition data into the users environment in order for graph.png to plot it. Returns an <img> tag for the plot. The bars on the plot are labeled '1','2',...,'n'.

Inputs:

$Title: string, the title of the plot
$xlabel: string, text describing the X-axis of the plot
$ylabel: string, text describing the Y-axis of the plot
$Max: scalar, the maximum Y value to use in the plot If $Max is < any data point, the graph will not be rendered.
$colors: array ref holding the colors to be used for the data sets when they are plotted. If undefined, default values will be used.
$labels: array ref holding the labels to use on the x-axis for the bars.
@Values: An array of array references. Each array reference holds data to be plotted in a stacked bar chart.
If the final element of @Values is a hash reference the key/value pairs will be added to the graph definition.

Returns:

An <img> tag which references graph.png and the appropriate identifying information for the plot.

DrawXYGraph

Facilitates the plotting of data in an XY graph. Puts plot definition data into the users environment in order for graph.png to plot it. Returns an <img> tag for the plot.

Inputs:

$Title: string, the title of the plot
$xlabel: string, text describing the X-axis of the plot
$ylabel: string, text describing the Y-axis of the plot
$Max: scalar, the maximum Y value to use in the plot If $Max is < any data point, the graph will not be rendered.
$colors: Array ref containing the hex color codes for the data to be plotted in. If undefined, default values will be used.
$Xlabels: Array ref containing the labels to be used for the X-axis.
$Ydata: Array ref containing Array refs. Each of the contained arrays will be plotted as a separate curve.
%Values: hash indicating or overriding any default values which are passed to graph.png. Possible values are: width, xskip, x_ticks, x_tick_offset, among others.

Returns:

An <img> tag which references graph.png and the appropriate identifying information for the plot.

DrawXYYGraph

Facilitates the plotting of data in an XY graph with two Y axes. Puts plot definition data into the users environment in order for graph.png to plot it. Returns an <img> tag for the plot.

Inputs:

$Title: string, the title of the plot
$xlabel: string, text describing the X-axis of the plot
$ylabel: string, text describing the Y-axis of the plot
$colors: Array ref containing the hex color codes for the data to be plotted in. If undefined, default values will be used.
$Xlabels: Array ref containing the labels to be used for the X-axis.
$Ydata1: The first data set
$Min1: The minimum value of the left Y-axis
$Max1: The maximum value of the left Y-axis
$Ydata2: The second data set
$Min2: The minimum value of the right Y-axis
$Max2: The maximum value of the left Y-axis
%Values: hash indicating or overriding any default values which are passed to graph.png. Possible values are: width, xskip, x_ticks, x_tick_offset, among others.

Returns:

An <img> tag which references graph.png and the appropriate identifying information for the plot.


Statistics helper routines?

Bad place for them but what the hell.

&chartlink

Returns a link to the chart for a specific student.

Inputs:

$linktext: The text of the link
$sname: The students username
$sdomain: The students domain


Course Environment Routines

&restore_course_settings
&store_course_settings

Restores/Store indicated form parameters from the course environment. Will not overwrite existing values of the form parameters.

Inputs: a scalar describing the data (e.g. 'chart', 'problem_analysis')

a hash ref describing the data to be stored. For example:


%Save_Parameters = ('Status' => 'scalar',
    'chartoutputmode' => 'scalar',
    'chartoutputdata' => 'scalar',
    'Section' => 'array',
    'Group' => 'array',
    'StudentData' => 'array',
    'Maps' => 'array');

Returns: both routines return nothing


Domain E-mail Routines

&build_recipient_list

Build recipient lists for three types of e-mail: (a) Error Reports, (b) Package Updates, (c) Help requests, generated by lonerrorhandler.pm, CHECKRPMS and lonsupportreq.pm respectively.

Inputs: defmail (scalar - email address of default recipient), mailing type (scalar - errormail, packagesmail, or helpdeskmail), defdom (domain for which to retrieve configuration settings), origmail (scalar - email address of recipient from loncapa.conf, i.e., predates configuration by DC via domainprefs.pm

Returns: comma separated list of addresses to which to send e-mail.