Apache::loncommon - pile of common routines
Common routines for manipulating connections, student answers, domains, common Javascript fragments, etc.
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.
openbrowser
and
opensearcher
. Returned string does not contain <script>
tags.
openbrowser(formname,elementname,only,omit)
[javascript]formname and elementname indicate the name of the html form and name of the element that the results of the browsing selection are to be placed in.
Specifying 'only' will restrict the browser to displaying only files with the given extension. Can be a comma separated list.
Specifying 'omit' will restrict the browser to NOT displaying files with the given extension. Can be a comma separated list.
formname and elementname specify the name of the html form and the name of the element the selection from the search results will be placed in.
linked_select_forms(...)
linked_select_forms takes the following ordered inputs:
Below is an example of such a hash. Only the 'text', 'default', and
'select2' keys must appear as stated. keys(%menu)
are the possible
values for the first select menu. The text that coincides with the
first menu value is given in $menu{$choice1}->{'text'}. The values
and text for the second menu are given in the hash pointed to by
$menu{$choice1}->{'select2'}.
my %menu = ( A1 => { text =>"Choice A1" , default => "B3", select2 => { B1 => "Choice B1", B2 => "Choice B2", B3 => "Choice B3", B4 => "Choice B4" } }, A2 => { text =>"Choice A2" , default => "C2", select2 => { C1 => "Choice C1", C2 => "Choice C2", C3 => "Choice C3" } }, A3 => { text =>"Choice A3" , default => "D6", select2 => { D1 => "Choice D1", D2 => "Choice D2", D3 => "Choice D3", D4 => "Choice D4", D5 => "Choice D5", D6 => "Choice D6", D7 => "Choice D7" } } );
$text will optionally be linked to the same topic, allowing you to link text in addition to the graphic. If you do not want to link text, but wish to specify one of the later parameters, pass an empty string.
$stayOnPage is a value that will be interpreted as a boolean. If true, the link will not open a new window. If false, the link will open a new window using Javascript. (Default is false.)
$width and $height are optional numerical parameters that will override the width and height of the popped up window, which may be useful for certain help topics with big pictures included.
csv_translate($text)
Currently supported formats:
Inputs: $workbook
Returns: $format, a hash reference.
The Javascript fragment returned by this function (no <script> tag)
must be written to the HTML page once. It will prove the Javascript
function ``change(name, content)''. Calling the change function with the
name of the section
you want to update, matching the name passed to changable_area
, and
the new content you want to put in there, will put the content into
that area.
Note: Netscape 4 only reserves enough space for the changable area to contain room for the original contents. You need to ``make space'' for whatever changes you wish to make, and be sure to check your code in Netscape 4. This feature in Netscape 4 is not powerful; it's adequate for updating a one-line status display, but little more. This script will set the space to 100% width, so you only need to worry about height in Netscape 4.
Modern browsers are much less limiting, and if you can commit to the user not using Netscape 4, this feature may be used freely with pretty much any HTML.
change_content_javascript
. $name is
the name you will use to reference the area later; do not repeat the
same name on a given HTML page more then once. $origContent is what
the area will originally contain, which can be left blank.
get_domains()
select_form($defdom,$name,%hash)
select_dom_form($defdom,$name,$includeempty)
If the $includeempty flag is set, it also includes an empty choice (``no domain selected'');
get_library_servers($domain)
home_server_option_list($domain)
Outputs:
See loncreateuser.pm for invocation and use examples.
Returns default authentication type and an associated argument as listed in file 'domain.tab'.
get_auth_defaults($target_domain)
returns the default authentication
type and an associated argument (initial password or a kerberos domain).
These values are stored in lonTabs/domain.tab
($def_auth, $def_arg) = &get_auth_defaults($target_domain);
If target_domain is not found in domain.tab, returns nothing ('').
get_kerberos_defaults($target_domain)
returns the default kerberos
version and domain. If not found in domain.tabs, it defaults to
version 4 and the domain of the server.
($def_version, $def_krb_domain) = &get_kerberos_defaults($target_domain);
keyword($word)
Uses global $thesaurus_db_file.
plainname($uname,$udom,$first)
nickname($uname,$udom)
``"nickname"''
if the user has a nickname or
``first middle last generation''
if the user does not
screenname($uname,$udom)
languageids()
languagedescription()
copyrightids()
copyrightdescription()
source_copyrightids()
source_copyrightdescription()
filecategories()
filecategorytypes()
fileembstyle()
filedescription()
filedescriptionex()
The output string is a table containing all desired attempts, if any.
get_student_answers()
Returns: A link to grades.pm such as to see the SUBM view of a student
Returns: Determines which domain should be used for designs
Returns: A link to a domain logo, if the domain logo exists. If the domain logo does not exist, a description of the domain.
Returns: value of designparamter $which
Inputs:
Returns: A uniform header for LON-CAPA web pages. If $bodyonly is nonzero, a string containing a <body> tag will be returned. If $bodyonly is undef or zero, an html string containing a <body> tag and other decorations will be returned.
Returns number of sections.
get_unprocessed_cgi($query,$possible_names)
Typically called with $ENV{'QUERY_STRING'} as the first parameter. $possible_names is an ref to an array of form element names. As an example: get_unprocessed_cgi($ENV{'QUERY_STRING'},['uname','udom']); will result in $ENV{'form.uname'} and $ENV{'form.udom'} being set.
cacheheader()
no_cache($r)
add_to_env($name,$value)
get_env_multiple($name)
returns an array of values
upfile_store($r)
load_tmp_file($r)
upfile_record_sep()
record_sep($record)
upfile_select_html()
csv_print_samples($r,$records)
csv_print_select_table($r,$records,$d)
$r is an Apache Request ref, $records is an arrayref from &Apache::loncommon::upfile_record_sep, $d is an array of 2 element arrays (internal name, displayed name,defaultcol)
csv_samples_select_table($r,$records,$d)
$r is an Apache Request ref, $records is an arrayref from &Apache::loncommon::upfile_record_sep, $d is an array of 2 element arrays (internal name, displayed name)
clean_excel_name($name)
check_if_partid_hidden($id,$symb,$udom,$uname)
1 if the part is to be hidden, undef if it is to be shown
Arguments are:
$id the id of the part to be checked $symb, optional the symb of the resource to check $udom, optional the domain of the user to check for $uname, optional the username of the user to check for
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.
Inputs:
Returns:
An <img> tag which references graph.png and the appropriate identifying information for the plot.
Inputs:
Returns:
An <img> tag which references graph.png and the appropriate identifying information for the plot.
Inputs:
Returns:
An <img> tag which references graph.png and the appropriate identifying information for the plot.
Bad place for them but what the hell.
Inputs:
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', 'StudentData' => 'array', 'Maps' => 'array');
Returns: both routines return nothing