version 1.555, 2007/07/28 21:38:29
|
version 1.565, 2007/08/18 00:01:37
|
Line 334 sub studentbrowser_javascript {
|
Line 334 sub studentbrowser_javascript {
|
return (<<'ENDSTDBRW'); |
return (<<'ENDSTDBRW'); |
<script type="text/javascript" language="Javascript" > |
<script type="text/javascript" language="Javascript" > |
var stdeditbrowser; |
var stdeditbrowser; |
function openstdbrowser(formname,uname,udom,roleflag) { |
function openstdbrowser(formname,uname,udom,roleflag,ignorefilter) { |
var url = '/adm/pickstudent?'; |
var url = '/adm/pickstudent?'; |
var filter; |
var filter; |
eval('filter=document.'+formname+'.'+uname+'.value;'); |
if (!ignorefilter) { |
|
eval('filter=document.'+formname+'.'+uname+'.value;'); |
|
} |
if (filter != null) { |
if (filter != null) { |
if (filter != '') { |
if (filter != '') { |
url += 'filter='+filter+'&'; |
url += 'filter='+filter+'&'; |
Line 365 sub selectstudent_link {
|
Line 367 sub selectstudent_link {
|
return ''; |
return ''; |
} |
} |
return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele. |
return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele. |
'","'.$udomele.'");'."'>".&mt('Select User')."</a>"; |
'","'.$udomele.'","","1");'."'>".&mt('Select User')."</a>"; |
} |
} |
if ($env{'request.role'}=~/^(au|dc|su)/) { |
if ($env{'request.role'}=~/^(au|dc|su)/) { |
return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele. |
return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele. |
Line 1082 sub changable_area {
|
Line 1084 sub changable_area {
|
|
|
=pod |
=pod |
|
|
|
=item * resize_textarea_js |
|
|
|
emits the needed javascript to resize a textarea to be as big as possible |
|
|
|
creates a function resize_textrea that takes two IDs first should be |
|
the id of the element to resize, second should be the id of a div that |
|
surrounds everything that comes after the textarea, this routine needs |
|
to be attached to the <body> for the onload and onresize events. |
|
|
|
|
|
=cut |
|
|
|
sub resize_textarea_js { |
|
return <<"RESIZE"; |
|
<script type="text/javascript"> |
|
var Geometry = {}; |
|
function init_geometry() { |
|
if (Geometry.init) { return }; |
|
Geometry.init=1; |
|
if (window.innerHeight) { |
|
Geometry.getViewportHeight = function() { return window.innerHeight; }; |
|
} |
|
else if (document.documentElement && document.documentElement.clientHeight) { |
|
Geometry.getViewportHeight = |
|
function() { return document.documentElement.clientHeight; }; |
|
} |
|
else if (document.body.clientHeight) { |
|
Geometry.getViewportHeight = |
|
function() { return document.body.clientHeight; }; |
|
} |
|
} |
|
|
|
function resize_textarea(textarea_id,bottom_id) { |
|
init_geometry(); |
|
var textarea = document.getElementById(textarea_id); |
|
//alert(textarea); |
|
|
|
var textarea_top = textarea.offsetTop; |
|
var textarea_height = textarea.offsetHeight; |
|
var bottom = document.getElementById(bottom_id); |
|
var bottom_top = bottom.offsetTop; |
|
var bottom_height = bottom.offsetHeight; |
|
var window_height = Geometry.getViewportHeight(); |
|
var fudge = 23; |
|
var new_height = window_height-fudge-textarea_top-bottom_height; |
|
if (new_height < 300) { |
|
new_height = 300; |
|
} |
|
textarea.style.height=new_height+'px'; |
|
} |
|
</script> |
|
RESIZE |
|
|
|
} |
|
|
|
=pod |
|
|
=back |
=back |
|
|
=head1 Excel and CSV file utility routines |
=head1 Excel and CSV file utility routines |
Line 1422 sub select_level_form {
|
Line 1481 sub select_level_form {
|
|
|
=pod |
=pod |
|
|
=item * select_dom_form($defdom,$name,$includeempty) |
=item * select_dom_form($defdom,$name,$includeempty,$showdomdesc) |
|
|
Returns a string containing a <select name='$name' size='1'> form to |
Returns a string containing a <select name='$name' size='1'> form to |
allow a user to select the domain to preform an operation in. |
allow a user to select the domain to preform an operation in. |
Line 1431 See loncreateuser.pm for an example invo
|
Line 1490 See loncreateuser.pm for an example invo
|
If the $includeempty flag is set, it also includes an empty choice ("no domain |
If the $includeempty flag is set, it also includes an empty choice ("no domain |
selected"); |
selected"); |
|
|
|
If the $showdomdesc flag is set, the domain name is followed by the domain description. |
|
|
=cut |
=cut |
|
|
#------------------------------------------- |
#------------------------------------------- |
sub select_dom_form { |
sub select_dom_form { |
my ($defdom,$name,$includeempty) = @_; |
my ($defdom,$name,$includeempty,$showdomdesc) = @_; |
my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains()); |
my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains()); |
if ($includeempty) { @domains=('',@domains); } |
if ($includeempty) { @domains=('',@domains); } |
my $selectdomain = "<select name=\"$name\" size=\"1\">\n"; |
my $selectdomain = "<select name=\"$name\" size=\"1\">\n"; |
foreach my $dom (@domains) { |
foreach my $dom (@domains) { |
$selectdomain.="<option value=\"$dom\" ". |
$selectdomain.="<option value=\"$dom\" ". |
($dom eq $defdom ? 'selected="selected" ' : ''). |
($dom eq $defdom ? 'selected="selected" ' : '').'>'.$dom; |
">$dom</option>\n"; |
if ($showdomdesc) { |
|
if ($dom ne '') { |
|
my $domdesc = &Apache::lonnet::domain($dom,'description'); |
|
if ($domdesc ne '') { |
|
$selectdomain .= ' ('.$domdesc.')'; |
|
} |
|
} |
|
} |
|
$selectdomain .= "</option>\n"; |
} |
} |
$selectdomain.="</select>"; |
$selectdomain.="</select>"; |
return $selectdomain; |
return $selectdomain; |
Line 3395 Inputs:
|
Line 3464 Inputs:
|
|
|
=item * $args, optional argument valid values are |
=item * $args, optional argument valid values are |
no_auto_mt_title -> prevents &mt()ing the title arg |
no_auto_mt_title -> prevents &mt()ing the title arg |
|
inherit_jsmath -> when creating popup window in a page, |
|
should it have jsmath forced on by the |
|
current page |
|
|
=back |
=back |
|
|
Line 3451 sub bodytag {
|
Line 3523 sub bodytag {
|
|
|
# construct main body tag |
# construct main body tag |
my $bodytag = "<body $extra_body_attr>". |
my $bodytag = "<body $extra_body_attr>". |
&Apache::lontexconvert::init_math_support(); |
&Apache::lontexconvert::init_math_support($args->{'inherit_jsmath'}); |
|
|
if ($bodyonly) { |
if ($bodyonly) { |
return $bodytag; |
return $bodytag; |
Line 4709 Inputs: $title - optional title for the
|
Line 4781 Inputs: $title - optional title for the
|
|
|
no_auto_mt_title -> prevent &mt()ing the title arg |
no_auto_mt_title -> prevent &mt()ing the title arg |
|
|
|
inherit_jsmath -> when creating popup window in a page, |
|
should it have jsmath forced on by the |
|
current page |
|
|
=cut |
=cut |
|
|
sub start_page { |
sub start_page { |
Line 5555 sub user_picker {
|
Line 5631 sub user_picker {
|
} |
} |
$srchterm = $srch->{'srchterm'}; |
$srchterm = $srch->{'srchterm'}; |
} |
} |
|
|
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'usr' => 'Search for', |
'doma' => 'Domain/institution to search', |
'or' => 'or', |
'uname' => 'username', |
'in' => 'in', |
'lastname' => 'last name', |
'doma' => 'domain', |
|
'uname' => 'username', |
|
'lastname' => 'last name', |
|
'lastfirst' => 'last name, first name', |
'lastfirst' => 'last name, first name', |
'crs' => 'this course', |
'crs' => 'in this course', |
'dom' => 'this domain', |
'dom' => 'in this domain', |
'alc' => 'all LON-CAPA', |
'alc' => 'all LON-CAPA', |
'instd' => 'institutional directory', |
'instd' => 'in institutional directory', |
'exact' => 'as exact match to', |
'exact' => 'is', |
'contains' => 'contained in', |
'contains' => 'contains', |
); |
); |
my $domform = &select_dom_form($currdom,'srchdomain',1); |
my $domform = &select_dom_form($currdom,'srchdomain',1,1); |
|
|
my $srchinsel = ' <select name="srchin">'; |
my $srchinsel = ' <select name="srchin">'; |
|
|
my @srchins = ('crs','dom','alc','instd'); |
my @srchins = ('crs','dom','alc','instd'); |
Line 5617 sub user_picker {
|
Line 5688 sub user_picker {
|
} |
} |
$srchtypesel .= "\n </select>\n"; |
$srchtypesel .= "\n </select>\n"; |
|
|
|
my ($newuserscript,$new_user_create); |
|
|
|
if ($forcenewuser) { |
|
$new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\');" /> </p>'; |
|
$newuserscript = <<"ENDSCRIPT"; |
|
|
|
function setSearch(createnew) { |
|
if (createnew == 1) { |
|
for (var i=0; i<document.crtuser.srchby.length; i++) { |
|
if (document.crtuser.srchby.options[i].value == 'uname') { |
|
document.crtuser.srchby.selectedIndex = i; |
|
} |
|
} |
|
for (var i=0; i<document.crtuser.srchin.length; i++) { |
|
if ( document.crtuser.srchin.options[i].value == 'dom') { |
|
document.crtuser.srchin.selectedIndex = i; |
|
} |
|
} |
|
for (var i=0; i<document.crtuser.srchtype.length; i++) { |
|
if (document.crtuser.srchtype.options[i].value == 'exact') { |
|
document.crtuser.srchtype.selectedIndex = i; |
|
} |
|
} |
|
for (var i=0; i<document.crtuser.srchdomain.length; i++) { |
|
if (document.crtuser.srchdomain.options[i].value == '$env{'request.role.domain'}') { |
|
document.crtuser.srchdomain.selectedIndex = i; |
|
} |
|
} |
|
} |
|
} |
|
ENDSCRIPT |
|
|
|
} |
|
|
my $output = <<"END_BLOCK"; |
my $output = <<"END_BLOCK"; |
|
<script type="text/javascript"> |
|
function validateEntry() { |
|
|
|
var checkok = 1; |
|
var srchin; |
|
for (var i=0; i<document.crtuser.srchin.length; i++) { |
|
if ( document.crtuser.srchin[i].checked ) { |
|
srchin = document.crtuser.srchin[i].value; |
|
} |
|
} |
|
|
|
var srchtype = document.crtuser.srchtype.options[document.crtuser.srchtype.selectedIndex].value; |
|
var srchby = document.crtuser.srchby.options[document.crtuser.srchby.selectedIndex].value; |
|
var srchdomain = document.crtuser.srchdomain.options[document.crtuser.srchdomain.selectedIndex].value; |
|
var srchterm = document.crtuser.srchterm.value; |
|
var srchin = document.crtuser.srchin.options[document.crtuser.srchin.selectedIndex].value; |
|
var msg = ""; |
|
|
|
if (srchterm == "") { |
|
checkok = 0; |
|
msg += "You must include some text to search for.\\n"; |
|
} |
|
|
|
if (srchtype== 'contains') { |
|
if (srchterm.length < 3) { |
|
checkok = 0; |
|
msg += "The text you are searching for must contain at least three characters when using a 'contains' type search.\\n"; |
|
} |
|
} |
|
if (srchin == 'instd') { |
|
if (srchdomain == '') { |
|
checkok = 0; |
|
msg += "You must choose a domain when using an institutional directory search.\\n"; |
|
} |
|
} |
|
if (srchin == 'dom') { |
|
if (srchdomain == '') { |
|
checkok = 0; |
|
msg += "You must choose a domain when using a domain search.\\n"; |
|
} |
|
} |
|
if (srchby == 'lastfirst') { |
|
if (srchterm.indexOf(",") == -1) { |
|
checkok = 0; |
|
msg += "When using searching by last,first you must include a comma as separator between last name and first name.\\n"; |
|
} |
|
if (srchterm.indexOf(",") == srchterm.length -1) { |
|
checkok = 0; |
|
msg += "When searching by last,first you must include at least one character in the first name.\\n"; |
|
} |
|
} |
|
if (checkok == 0) { |
|
alert("The following need to be corrected before the search can be run:\\n"+msg); |
|
return; |
|
} |
|
if (checkok == 1) { |
|
document.crtuser.submit(); |
|
} |
|
} |
|
|
|
$newuserscript |
|
|
|
</script> |
|
|
|
$new_user_create |
|
|
<table> |
<table> |
<tr> |
<tr> |
<td align="right">$lt{'usr'}:</td><td><input type="text" size="15" name="srchterm" value="$srchterm" /></td> |
<td>$srchbysel |
<td> |
$srchtypesel |
$srchtypesel |
<input type="text" size="15" name="srchterm" value="$srchterm" /> |
</td> |
$srchinsel |
<td> |
</td> |
$srchbysel |
</tr> |
</td> |
<tr> |
</tr> |
<td>$lt{'doma'}: $domform</td> |
<tr> |
</td> |
<td align="right">$lt{'in'}:</td> |
</tr> |
<td colspan="2"> |
|
$srchinsel |
|
</td> |
|
</tr> |
|
<tr> |
|
<td align="right">$lt{'doma'}:</td><td colspan="2">$domform</td> |
|
</tr> |
|
</table> |
</table> |
<br /> |
<br /> |
END_BLOCK |
END_BLOCK |
if ($forcenewuser) { |
|
$output .= '<span class="LC_nobreak">'.&mt('Make new user if no match found: ').'<input type="radio" name="forcenew" value="1" onclick="javascript:setSearch()" />'.&mt('Yes').' <input type="radio" name="forcenew" value="0" checked="checked" />'.&mt('No').'</span><br />'; |
|
} |
|
return $output; |
return $output; |
} |
} |
|
|
|
|
|
|
=pod |
=pod |
|
|
=back |
=back |
Line 5903 sub record_sep {
|
Line 6067 sub record_sep {
|
$i++; |
$i++; |
} |
} |
} else { |
} else { |
my @allfields; |
my $separator=','; |
if ($env{'form.upfiletype'} eq 'semisv') { |
if ($env{'form.upfiletype'} eq 'semisv') { |
@allfields=split(/;/,$record,-1); |
$separator=';'; |
} else { |
|
@allfields=split(/\,/,$record,-1); |
|
} |
} |
my $i=0; |
my $i=0; |
my $j; |
# the character we are looking for to indicate the end of a quote or a record |
for ($j=0;$j<=$#allfields;$j++) { |
my $looking_for=$separator; |
my $field=$allfields[$j]; |
# do not add the characters to the fields |
if ($field=~/^\s*(\"|\')/) { |
my $ignore=0; |
my $delimiter=$1; |
# we just encountered a separator (or the beginning of the record) |
while (($field!~/$delimiter$/) && ($j<$#allfields)) { |
my $just_found_separator=1; |
$j++; |
# store the field we are working on here |
$field.=','.$allfields[$j]; |
my $field=''; |
} |
# work our way through all characters in record |
$field=~s/^\s*$delimiter//; |
foreach my $character ($record=~/(.)/g) { |
$field=~s/$delimiter\s*$//; |
if ($character eq $looking_for) { |
} |
if ($character ne $separator) { |
$components{&takeleft($i)}=$field; |
# Found the end of a quote, again looking for separator |
$i++; |
$looking_for=$separator; |
|
$ignore=1; |
|
} else { |
|
# Found a separator, store away what we got |
|
$components{&takeleft($i)}=$field; |
|
$i++; |
|
$just_found_separator=1; |
|
$ignore=0; |
|
$field=''; |
|
} |
|
next; |
|
} |
|
# single or double quotation marks after a separator indicate beginning of a quote |
|
# we are now looking for the end of the quote and need to ignore separators |
|
if ((($character eq '"') || ($character eq "'")) && ($just_found_separator)) { |
|
$looking_for=$character; |
|
next; |
|
} |
|
# ignore would be true after we reached the end of a quote |
|
if ($ignore) { next; } |
|
if (($just_found_separator) && ($character=~/\s/)) { next; } |
|
$field.=$character; |
|
$just_found_separator=0; |
} |
} |
|
# catch the very last entry, since we never encountered the separator |
|
$components{&takeleft($i)}=$field; |
} |
} |
return %components; |
return %components; |
} |
} |