--- loncom/interface/loncommon.pm 2003/03/20 16:17:37 1.88 +++ loncom/interface/loncommon.pm 2003/09/09 18:46:28 1.114 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.88 2003/03/20 16:17:37 www Exp $ +# $Id: loncommon.pm,v 1.114 2003/09/09 18:46:28 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -47,29 +47,15 @@ Apache::loncommon - pile of common routi =head1 SYNOPSIS -Referenced by other mod_perl Apache modules. +Common routines for manipulating connections, student answers, + domains, common Javascript fragments, etc. -Invocation: - &Apache::loncommon::SUBROUTINENAME(ARGUMENTS); +=head1 OVERVIEW -=head1 INTRODUCTION - -Common collection of used subroutines. This collection helps remove +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. -Current things done: - - Makes a table out of the previous homework attempts - Inputs result_from_symbread, user, domain, course_id - Reads in non-network-related .tab files - -This is part of the LearningOnline Network with CAPA project -described at http://www.lon-capa.org. - -=head2 General Subroutines - -=over 4 - =cut # End of POD header @@ -79,18 +65,17 @@ use strict; use Apache::lonnet(); use GDBM_File; use POSIX qw(strftime mktime); -use Apache::Constants qw(:common); +use Apache::Constants qw(:common :http :methods); use Apache::lonmsg(); use Apache::lonmenu(); my $readit; =pod -=item Global Variables - -=over 4 +=head1 Global Variables =cut + # ----------------------------------------------- Filetypes/Languages/Copyright my %language; my %cprtag; @@ -103,37 +88,45 @@ my %designhash; # ---------------------------------------------- Thesaurus variables +# FIXME: I don't think it's necessary to document these things; +# they're privately used - Jeremy + =pod -=item %Keywords +=over 4 + +=item * %Keywords A hash used by &keyword to determine if a word is considered a keyword. -=item $thesaurus_db_file +=item * $thesaurus_db_file Scalar containing the full path to the thesaurus database. +=back + =cut my %Keywords; my $thesaurus_db_file; +# ----------------------------------------------------------------------- BEGIN +# FIXME: I don't think this needs to be documented, it prepares +# private data structures - Jeremy =pod -=back - -=cut - -# ----------------------------------------------------------------------- BEGIN +=head1 General Subroutines -=pod +=over 4 -=item BEGIN() +=item * BEGIN() Initialize values from language.tab, copyright.tab, filetypes.tab, thesaurus.tab, and filecategories.tab. +=back + =cut # ----------------------------------------------------------------------- BEGIN @@ -151,8 +144,8 @@ BEGIN { while (<$fh>) { next if /^\#/; chomp; - my ($key,$val)=(split(/\s+/,$_,2)); - $language{$key}=$val; + my ($key,$two,$country,$three,$enc,$val)=(split(/\t/,$_)); + $language{$key}=$val.' - '.$enc; } } } @@ -228,21 +221,27 @@ BEGIN { } # end of unless($readit) } -# ============================================================= END BEGIN BLOCK + ############################################################### ## HTML and Javascript Helper Functions ## ############################################################### =pod -=item browser_and_searcher_javascript +=head1 HTML and Javascript Functions + +=over 4 + +=item * browser_and_searcher_javascript () -Returns scalar containing javascript to open a browser window -or a searcher window. Also creates +XXReturns a string +containing javascript with two functions, C and +C. Returned string does not contain EscriptE +tags. =over 4 -=item openbrowser(formname,elementname,only,omit) [javascript] +=item * openbrowser(formname,elementname,only,omit) [javascript] inputs: formname, elementname, only, omit @@ -255,7 +254,7 @@ with the given extension. Can be a comm 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] +=item * opensearcher(formname, elementname) [javascript] Inputs: formname, elementname @@ -266,7 +265,6 @@ of the element the selection from the se =cut -############################################################### sub browser_and_searcher_javascript { return < var stdeditbrowser; - function openstdbrowser(formname,uname,udom) { + function openstdbrowser(formname,uname,udom,roleflag) { var url = '/adm/pickstudent?'; var filter; eval('filter=document.'+formname+'.'+uname+'.value;'); @@ -329,7 +328,8 @@ sub studentbrowser_javascript { } url += 'form=' + formname + '&unameelement='+uname+ '&udomelement='+udom; - var title = 'Student Browser'; + if (roleflag) { url+="&roles=1"; } + var title = 'Student_Browser'; var options = 'scrollbars=1,resizable=1,menubar=0'; options += ',width=700,height=600'; stdeditbrowser = open(url,title,options,'1'); @@ -340,20 +340,54 @@ ENDSTDBRW } sub selectstudent_link { - my ($form,$unameele,$udomele)=@_; - unless ($ENV{'request.course.id'}) { return ''; } - unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { - return ''; + my ($form,$unameele,$udomele)=@_; + if ($ENV{'request.course.id'}) { + unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { + return ''; + } + return "Select User"; } - return "Select"; + if ($ENV{'request.role'}=~/^(au|dc|su)/) { + return "Select User"; + } + return ''; } -############################################################### +sub coursebrowser_javascript { + return (<<'ENDSTDBRW'); + +ENDSTDBRW +} + +sub selectcourse_link { + my ($form,$unameele,$udomele)=@_; + return "Select Course"; +} =pod -=item linked_select_forms(...) +=item * linked_select_forms(...) linked_select_forms returns a string containing a block and html for two tags +=item * $middletext, the text which appears between the tag +=item * $firstselectname, the name of the first tag +=item * $secondselectname, the name of the second form to allow a user to select options from a hash option_name => displayed text. @@ -613,7 +762,7 @@ See lonrights.pm for an example invocati sub select_form { my ($def,$name,%hash) = @_; my $selectform = " form to allow a user to select the domain to preform an operation in. See loncreateuser.pm for an example invocation and use. +If the $includeempty flag is set, it also includes an empty choice ("no domain +selected"); + =cut #------------------------------------------- sub select_dom_form { - my ($defdom,$name) = @_; + my ($defdom,$name,$includeempty) = @_; my @domains = get_domains(); + if ($includeempty) { @domains=('',@domains); } my $selectdomain = " form input. See loncreateuser.pm for an example. @@ -695,16 +848,24 @@ sub home_server_option_list { } return $result; } -############################################################### -## End of home server