version 1.41, 2002/06/25 17:09:38
|
version 1.45, 2002/07/09 17:15:58
|
Line 33
|
Line 33
|
# 12/25,12/28 Gerd Kortemeyer |
# 12/25,12/28 Gerd Kortemeyer |
# YEAR=2002 |
# YEAR=2002 |
# 1/4 Gerd Kortemeyer |
# 1/4 Gerd Kortemeyer |
|
# 6/24,7/2 H. K. Ng |
|
|
# Makes a table out of the previous attempts |
# Makes a table out of the previous attempts |
# Inputs result_from_symbread, user, domain, course_id |
# Inputs result_from_symbread, user, domain, course_id |
Line 40
|
Line 41
|
|
|
# POD header: |
# POD header: |
|
|
|
=pod |
|
|
=head1 NAME |
=head1 NAME |
|
|
Apache::loncommon - pile of common routines |
Apache::loncommon - pile of common routines |
Line 104 my $theavecount;
|
Line 107 my $theavecount;
|
=item BEGIN() |
=item BEGIN() |
|
|
Initialize values from language.tab, copyright.tab, filetypes.tab, |
Initialize values from language.tab, copyright.tab, filetypes.tab, |
and filecategories.tab. |
thesaurus.tab, and filecategories.tab. |
|
|
=cut |
=cut |
|
|
# ----------------------------------------------------------------------- BEGIN |
# ----------------------------------------------------------------------- BEGIN |
|
|
BEGIN { |
BEGIN { |
Line 190 BEGIN {
|
Line 194 BEGIN {
|
|
|
} |
} |
# ============================================================= END BEGIN BLOCK |
# ============================================================= END BEGIN BLOCK |
|
############################################################### |
|
## HTML and Javascript Helper Functions ## |
|
############################################################### |
|
|
|
=pod |
|
|
|
=item browser_and_searcher_javascript |
|
|
|
Returns scalar containing javascript to open a browser window |
|
or a searcher window. Also creates |
|
|
|
=over 4 |
|
|
|
=item openbrowser(formname,elementname,only,omit) [javascript] |
|
|
|
inputs: formname, elementname, only, omit |
|
|
|
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 seperated list. |
|
|
|
Specifying 'omit' will restrict the browser to NOT displaying files |
|
with the given extension. Can be a comma seperated list. |
|
|
|
=item opensearcher(formname, elementname) [javascript] |
|
|
|
Inputs: formname, elementname |
|
|
|
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. |
|
|
|
=back |
|
|
|
=cut |
|
|
|
############################################################### |
|
sub browser_and_searcher_javascript { |
|
return <<END; |
|
var editbrowser; |
|
function openbrowser(formname,elementname,only,omit) { |
|
var url = '/res/?'; |
|
if (editbrowser == null) { |
|
url += 'launch=1&'; |
|
} |
|
url += 'catalogmode=interactive&'; |
|
url += 'mode=edit&'; |
|
url += 'form=' + formname + '&'; |
|
if (only != null) { |
|
url += 'only=' + only + '&'; |
|
} |
|
if (omit != null) { |
|
url += 'omit=' + omit + '&'; |
|
} |
|
url += 'element=' + elementname + ''; |
|
var title = 'Browser'; |
|
var options = 'scrollbars=1,resizable=1,menubar=0'; |
|
options += ',width=700,height=600'; |
|
editbrowser = open(url,title,options,'1'); |
|
editbrowser.focus(); |
|
} |
|
var editsearcher; |
|
function opensearcher(formname,elementname) { |
|
var url = '/adm/searchcat?'; |
|
if (editsearcher == null) { |
|
url += 'launch=1&'; |
|
} |
|
url += 'catalogmode=interactive&'; |
|
url += 'mode=edit&'; |
|
url += 'form=' + formname + '&'; |
|
url += 'element=' + elementname + ''; |
|
var title = 'Search'; |
|
var options = 'scrollbars=1,resizable=1,menubar=0'; |
|
options += ',width=700,height=600'; |
|
editsearcher = open(url,title,options,'1'); |
|
editsearcher.focus(); |
|
} |
|
END |
|
} |
|
|
|
|
|
|
|
############################################################### |
|
|
|
=pod |
|
|
=item linked_select_forms(...) |
=item linked_select_forms(...) |
|
|
Line 255 my %menu = ( A1 => { text =>"Choice A1"
|
Line 345 my %menu = ( A1 => { text =>"Choice A1"
|
} |
} |
); |
); |
|
|
=back |
|
|
|
=cut |
=cut |
|
|
# ------------------------------------------------ |
# ------------------------------------------------ |
Line 341 END
|
Line 429 END
|
|
|
############################################################### |
############################################################### |
|
|
|
=pod |
|
|
|
=item help_open_topic($topic, $stayOnPage, $width, $height) |
|
|
|
Returns a string corresponding to an HTML link to the given help $topic, where $topic corresponds to the name of a .tex file in /home/httpd/html/adm/help/tex, with underscores replaced by spaces. |
|
|
|
$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. |
|
|
|
=cut |
|
|
|
sub help_open_topic { |
|
my ($topic, $stayOnPage, $width, $height) = @_; |
|
$stayOnPage = 0 if (not defined $stayOnPage); |
|
$width = 350 if (not defined $width); |
|
$height = 400 if (not defined $height); |
|
my $filename = $topic; |
|
$filename =~ s/ /_/g; |
|
|
|
my $template; |
|
|
|
if (!$stayOnPage) |
|
{ |
|
$template = <<"ENDTEMPLATE"; |
|
<a href="javascript:void(open('/adm/help/${filename}.hlp', 'Help for $topic', 'menubar=0,s |
|
crollbars=1,width=$width,height=$height'))"><image |
|
src="/adm/help/gif/smallHelp.gif" |
|
border="0" alt="(Help: $topic)"></a> |
|
ENDTEMPLATE |
|
} |
|
else |
|
{ |
|
$template = <<"ENDTEMPLATE"; |
|
<a href="/adm/help/${filename}.hlp"><image |
|
src="/adm/help/gif/smallHelp.gif" |
|
border="0" alt="(Help: $topic)"></a> |
|
ENDTEMPLATE |
|
} |
|
|
|
return $template; |
|
|
|
} |
|
|
|
=pod |
|
|
=item csv_translate($text) |
=item csv_translate($text) |
|
|
Translate $text to allow it to be output as a 'comma seperated values' |
Translate $text to allow it to be output as a 'comma seperated values' |
Line 362 sub csv_translate {
|
Line 496 sub csv_translate {
|
############################################################### |
############################################################### |
#------------------------------------------- |
#------------------------------------------- |
|
|
|
=pod |
|
|
=item get_domains() |
=item get_domains() |
|
|
Returns an array containing each of the domains listed in the hosts.tab |
Returns an array containing each of the domains listed in the hosts.tab |
Line 382 sub get_domains {
|
Line 518 sub get_domains {
|
|
|
#------------------------------------------- |
#------------------------------------------- |
|
|
|
=pod |
|
|
=item select_dom_form($defdom,$name) |
=item select_dom_form($defdom,$name) |
|
|
Returns a string containing a <select name='$name' size='1'> form to |
Returns a string containing a <select name='$name' size='1'> form to |
Line 406 sub select_dom_form {
|
Line 544 sub select_dom_form {
|
|
|
#------------------------------------------- |
#------------------------------------------- |
|
|
|
=pod |
|
|
=item get_home_servers($domain) |
=item get_home_servers($domain) |
|
|
Returns a hash which contains keys like '103l3' and values like |
Returns a hash which contains keys like '103l3' and values like |
Line 428 sub get_home_servers {
|
Line 568 sub get_home_servers {
|
|
|
#------------------------------------------- |
#------------------------------------------- |
|
|
|
=pod |
|
|
=item home_server_option_list($domain) |
=item home_server_option_list($domain) |
|
|
returns a string which contains an <option> list to be used in a |
returns a string which contains an <option> list to be used in a |
Line 460 sub home_server_option_list {
|
Line 602 sub home_server_option_list {
|
## formname = the name given in the <form> tag. |
## formname = the name given in the <form> tag. |
#------------------------------------------- |
#------------------------------------------- |
|
|
|
=pod |
|
|
=item authform_xxxxxx |
=item authform_xxxxxx |
|
|
The authform_xxxxxx subroutines provide javascript and html forms which |
The authform_xxxxxx subroutines provide javascript and html forms which |
Line 778 sub filedescriptionex {
|
Line 922 sub filedescriptionex {
|
# $username,$domain - that of the student |
# $username,$domain - that of the student |
# $course - course name |
# $course - course name |
# $getattempt - leave blank if want all attempts, else put something. |
# $getattempt - leave blank if want all attempts, else put something. |
|
# $regexp - regular expression. If string matches regexp send to |
|
# $gradesub - routine that process the string if it matches regexp |
# |
# |
# output |
# output |
# formatted as a table all the attempts, if any. |
# formatted as a table all the attempts, if any. |
# |
# |
sub get_previous_attempt { |
sub get_previous_attempt { |
my ($symb,$username,$domain,$course,$getattempt)=@_; |
my ($symb,$username,$domain,$course,$getattempt,$regexp,$gradesub)=@_; |
my $prevattempts=''; |
my $prevattempts=''; |
|
no strict 'refs'; |
if ($symb) { |
if ($symb) { |
my (%returnhash)= |
my (%returnhash)= |
&Apache::lonnet::restore($symb,$course,$domain,$username); |
&Apache::lonnet::restore($symb,$course,$domain,$username); |
Line 796 sub get_previous_attempt {
|
Line 943 sub get_previous_attempt {
|
$lasthash{$_}=$returnhash{$version.':'.$_}; |
$lasthash{$_}=$returnhash{$version.':'.$_}; |
} |
} |
} |
} |
$prevattempts='<table border="0" width="100%"><tr><td bgcolor="#000000">'; |
$prevattempts='<table border="0" width="100%"><tr><td bgcolor="#777777">'; |
$prevattempts.='<table border="0" width="100%"><tr bgcolor="#e6ffff"><td>History</td>'; |
$prevattempts.='<table border="0" width="100%"><tr bgcolor="#e6ffff"><td>History</td>'; |
foreach (sort(keys %lasthash)) { |
foreach (sort(keys %lasthash)) { |
my ($ign,@parts) = split(/\./,$_); |
my ($ign,@parts) = split(/\./,$_); |
Line 834 sub get_previous_attempt {
|
Line 981 sub get_previous_attempt {
|
} else { |
} else { |
$value=$lasthash{$_}; |
$value=$lasthash{$_}; |
} |
} |
|
if ($_ =~/$regexp$/) {$value = &$gradesub($value)} |
$prevattempts.='<td>'.$value.' </td>'; |
$prevattempts.='<td>'.$value.' </td>'; |
} |
} |
$prevattempts.='</tr></table></td></tr></table>'; |
$prevattempts.='</tr></table></td></tr></table>'; |
Line 945 sub add_to_env {
|
Line 1093 sub add_to_env {
|
|
|
=pod |
=pod |
|
|
|
=back |
|
|
=head2 CSV Upload/Handling functions |
=head2 CSV Upload/Handling functions |
|
|
=over 4 |
=over 4 |