version 1.71, 2003/07/02 19:52:56
|
version 1.75, 2003/07/15 19:23:14
|
Line 218 sub javascript_validations {
|
Line 218 sub javascript_validations {
|
my $authheader = &Apache::loncommon::authform_header(%param); |
my $authheader = &Apache::loncommon::authform_header(%param); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
return (<<ENDPICK); |
return (<<ENDPICK); |
function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec) { |
function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail) { |
var foundatype=0; |
var foundatype=0; |
var message=''; |
var message=''; |
if (founduname==0) { |
if (founduname==0) { |
Line 254 function verify_message (vf,founduname,f
|
Line 254 function verify_message (vf,founduname,f
|
} |
} |
} |
} |
|
|
if (foundname==0) { message='No name fields specified. '; } |
if (foundname==0) { message='name fields'; } |
if (foundid==0) { message+='No ID or student number field specified. '; } |
if (foundid==0) { if (message!='') { message+=', '; } message+='student number field'; } |
if (foundsec==0) { message+='No section or group field specified. '; } |
if (foundsec==0) { if (message!='') { message+=', '; } message+='section or group field'; } |
|
if (foundemail==0) { if (message!='') { message+=', '; } message+='email address field'; } |
if (message!='') { |
if (message!='') { |
message+='Continue enrollment?'; |
message='Not specified (optional): '+message+'. Continue enrollment?'; |
if (confirm(message)) { |
if (confirm(message)) { |
vf.state.value='enrolling'; |
vf.state.value='enrolling'; |
vf.submit(); |
vf.submit(); |
Line 274 ENDPICK
|
Line 275 ENDPICK
|
|
|
} |
} |
|
|
|
sub javascript_validations_without_auth { |
|
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
|
return (<<ENDPICK); |
|
function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail) { |
|
var foundatype=0; |
|
var message=''; |
|
if (founduname==0) { |
|
alert('You need to specify the username field'); |
|
return; |
|
} |
|
if (foundname==0) { message='name fields'; } |
|
if (foundid==0) { if (message!='') { message+=', '; } message+='student number field'; } |
|
if (foundsec==0) { if (message!='') { message+=', '; } message+='section or group field'; } |
|
if (foundemail==0) { if (message!='') { message+=', '; } message+='email address field'; } |
|
if (message!='') { |
|
message='Not specified (optional): '+message+'. Continue enrollment?'; |
|
if (confirm(message)) { |
|
vf.state.value='enrolling'; |
|
vf.submit(); |
|
} |
|
} else { |
|
vf.state.value='enrolling'; |
|
vf.submit(); |
|
} |
|
} |
|
|
|
ENDPICK |
|
|
|
} |
|
|
############################################################### |
############################################################### |
############################################################### |
############################################################### |
sub upload_manager_javascript_forward_associate { |
sub upload_manager_javascript_forward_associate { |
Line 284 function verify(vf) {
|
Line 315 function verify(vf) {
|
var foundname=0; |
var foundname=0; |
var foundid=0; |
var foundid=0; |
var foundsec=0; |
var foundsec=0; |
|
var foundemail=0; |
var tw; |
var tw; |
for (i=0;i<=vf.nfields.value;i++) { |
for (i=0;i<=vf.nfields.value;i++) { |
tw=eval('vf.f'+i+'.selectedIndex'); |
tw=eval('vf.f'+i+'.selectedIndex'); |
Line 292 function verify(vf) {
|
Line 324 function verify(vf) {
|
if (tw==7) { foundid=1; } |
if (tw==7) { foundid=1; } |
if (tw==8) { foundsec=1; } |
if (tw==8) { foundsec=1; } |
if (tw==9) { foundpwd=1; } |
if (tw==9) { foundpwd=1; } |
|
if (tw==10) { foundemail=1; } |
} |
} |
verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec); |
verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail); |
} |
} |
|
|
// |
// |
Line 312 function verify(vf) {
|
Line 345 function verify(vf) {
|
// 7 = id |
// 7 = id |
// 8 = section |
// 8 = section |
// 9 = ipwd (password) |
// 9 = ipwd (password) |
// |
// 10 = email address |
|
|
function flip(vf,tf) { |
function flip(vf,tf) { |
var nw=eval('vf.f'+tf+'.selectedIndex'); |
var nw=eval('vf.f'+tf+'.selectedIndex'); |
var i; |
var i; |
Line 499 sub print_upload_manager_form {
|
Line 533 sub print_upload_manager_form {
|
['gen','Generation'], |
['gen','Generation'], |
['id','ID/Student Number'], |
['id','ID/Student Number'], |
['sec','Group/Section'], |
['sec','Group/Section'], |
['ipwd','Initial Password']); |
['ipwd','Initial Password'], |
|
['email','EMail Address']); |
if ($ENV{'form.upfile_associate'} eq 'reverse') { |
if ($ENV{'form.upfile_associate'} eq 'reverse') { |
&Apache::loncommon::csv_print_samples($r,\@records); |
&Apache::loncommon::csv_print_samples($r,\@records); |
$i=&Apache::loncommon::csv_print_select_table($r,\@records,\@d); |
$i=&Apache::loncommon::csv_print_select_table($r,\@records,\@d); |
Line 673 sub make_dates_default {
|
Line 708 sub make_dates_default {
|
return $result; |
return $result; |
} |
} |
|
|
# ======================================================= Menu Phase Two Enroll |
## |
|
## Single student enrollment routines (some of them) |
|
## |
|
sub get_student_username_domain_form { |
|
my $r = shift; |
|
my $domform = &Apache::loncommon::select_dom_form |
|
($r->dir_config('lonDefDomain'),'cudomain',0); |
|
$r->print(<<END); |
|
<input type="hidden" name="action" value="enrollstudent" /> |
|
<input type="hidden" name="state" value="gotusername" /> |
|
<h3>Enroll One Student</h3> |
|
<table> |
|
<tr><th>Username:</th> |
|
<td><input type="text" name="cuname" size="15" /></td></tr> |
|
<tr><th>Domain:</th> |
|
<td>$domform</td></tr> |
|
<tr><th> </th> |
|
<td> |
|
<input type="submit" name="Begin Enrollment" value="Begin Enrollment" /> |
|
</td></tr> |
|
</table> |
|
END |
|
return; |
|
} |
|
|
sub print_enroll_single_student_form { |
sub print_enroll_single_student_form { |
my $r=shift; |
my $r=shift; |
$r->print("<h3>Enroll One Student</h3>"); |
$r->print("<h3>Enroll One Student</h3>"); |
my $today = time; |
# |
my $halfyear = $today+15552000; |
my $username = $ENV{'form.cuname'}; |
my $defdom=$r->dir_config('lonDefDomain'); |
my $domain = $ENV{'form.cudomain'}; |
# Set up authentication forms |
my $home = &Apache::lonnet::homeserver($username,$domain); |
my ($krbdef,$krbdefdom) = |
# $new_user flags whether we are creating a new user or using an old one |
&Apache::loncommon::get_kerberos_defaults($defdom); |
my $new_user = 1; |
my $javascript_validations=&javascript_validations($krbdefdom); |
if ($home ne 'no_host') { |
my %param = ( formname => 'document.studentform', |
$new_user = 0; |
kerb_def_dom => $krbdefdom, |
} |
kerb_def_auth => $krbdef |
&Apache::lonnet::logthis('home = '.$home); |
); |
# |
my $krbform = &Apache::loncommon::authform_kerberos(%param); |
my $user_data_html = ''; |
my $intform = &Apache::loncommon::authform_internal(%param); |
my $javascript_validations = ''; |
my $locform = &Apache::loncommon::authform_local(%param); |
if ($new_user) { |
# Set up domain selection form |
my $defdom=$r->dir_config('lonDefDomain'); |
my $domform = &domain_form($defdom); |
# Set up authentication forms |
|
my ($krbdef,$krbdefdom) = |
|
&Apache::loncommon::get_kerberos_defaults($domain); |
|
$javascript_validations=&javascript_validations($krbdefdom); |
|
my %param = ( formname => 'document.studentform', |
|
kerb_def_dom => $krbdefdom, |
|
kerb_def_auth => $krbdef |
|
); |
|
my $krbform = &Apache::loncommon::authform_kerberos(%param); |
|
my $intform = &Apache::loncommon::authform_internal(%param); |
|
my $locform = &Apache::loncommon::authform_local(%param); |
|
# |
|
# Set up domain selection form |
|
my $homeserver_form = ''; |
|
my %servers = &Apache::loncommon::get_library_servers($domain); |
|
$homeserver_form = '<select name="lcserver" size="1">'."\n". |
|
'<option value="default" selected>default</option>'."\n"; |
|
while (my ($servername,$serverdescription) = each (%servers)) { |
|
$homeserver_form .= '<option value="'.$servername.'">'. |
|
$serverdescription."</option>\n"; |
|
} |
|
$homeserver_form .= "</select>\n"; |
|
# |
|
# |
|
$user_data_html = <<END; |
|
<h3>User Data for $username\@$domain</h3> |
|
<table> |
|
<tr><th>First Name:</th> |
|
<td><input type="text" name="cfirst" size="15"></td></tr> |
|
<tr><th>Middle Name:</th> |
|
<td><input type="text" name="cmiddle" size="15"></td></tr> |
|
<tr><th>Last Name:</th> |
|
<td><input type="text" name="clast" size="15"></td></tr> |
|
<tr><th>Generation:</th> |
|
<td><input type="text" name="cgen" size="5"> </td></tr> |
|
<tr><th>Home Server:</th> |
|
<td>$homeserver_form</td></tr> |
|
</table> |
|
<h3>Password</h3> |
|
Please select an authentication mechanism |
|
<table> |
|
<p> |
|
$krbform |
|
<br /> |
|
$intform |
|
<br /> |
|
$locform |
|
</p> |
|
END |
|
} else { |
|
# User already exists. Do not worry about authentication |
|
my %uenv = &Apache::lonnet::dump('environment',$domain,$username); |
|
$javascript_validations = &javascript_validations_without_auth(); |
|
$user_data_html = <<END; |
|
<h3>User Data for $username\@$domain</h3> |
|
<input type="hidden" name="lcserver" value="default" /> |
|
<table> |
|
<tr><th>First Name:</th> |
|
<td> |
|
<input type="text" name="cfirst" value="$uenv{'firstname'}" size="15" /> |
|
</td></tr> |
|
<tr><th>Middle Name:</th> |
|
<td> |
|
<input type="text" name="cmiddle" value="$uenv{'middlename'}" size="15" /> |
|
</td></tr> |
|
<tr><th>Last Name:</th> |
|
<td> |
|
<input type="text" name="clast"value="$uenv{'lastname'}" size="15" /> |
|
</td></tr> |
|
<tr><th>Generation:</th> |
|
<td> |
|
<input type="text" name="cgen" value="$uenv{'generation'}" size="5" /> |
|
</td></tr> |
|
</table> |
|
END |
|
} |
my $date_table = &date_setting_table(); |
my $date_table = &date_setting_table(); |
# Print it all out |
# Print it all out |
$r->print(<<END); |
$r->print(<<END); |
<input type="hidden" name="action" value="enrollstudent"> |
<input type="hidden" name="action" value="enrollstudent" /> |
<input type="hidden" name="state" value="done"> |
<input type="hidden" name="state" value="done" /> |
|
<input type="hidden" name="cuname" value="$username" /> |
|
<input type="hidden" name="lcdomain" value="$domain" /> |
<script type="text/javascript" language="Javascript"> |
<script type="text/javascript" language="Javascript"> |
function verify(vf) { |
function verify(vf) { |
var founduname=0; |
var founduname=0; |
Line 735 function clearpwd(vf) {
|
Line 870 function clearpwd(vf) {
|
} |
} |
|
|
</script> |
</script> |
<h3>Personal Data</h3> |
|
<table> |
|
<tr><td>First Name:</td><td> <input type="text" name="cfirst" size="15"></td></tr> |
|
<tr><td>Middle Name:</td><td> <input type="text" name="cmiddle" size="15"></td></tr> |
|
<tr><td>Last Name: </td><td><input type="text" name="clast" size="15"></td></tr> |
|
<tr><td>Generation: </td><td><input type="text" name="cgen" size="5"> </td></tr> |
|
</table> |
|
|
|
<h3>Login Data</h3> |
$user_data_html |
<p>Username: <input type="text" name="cuname" size="15"></p> |
|
<p>Domain: $domform</p> |
|
<p>Note: login settings below will not take effect if the user already exists |
|
</p><p> |
|
$krbform |
|
</p><p> |
|
$intform |
|
</p><p> |
|
$locform |
|
</p><p> |
|
|
|
<h3>Course Data</h3> |
<h3>Course Data</h3> |
|
|
Line 1466 sub upfile_drop_add {
|
Line 1584 sub upfile_drop_add {
|
####################################### |
####################################### |
## Enroll Students ## |
## Enroll Students ## |
####################################### |
####################################### |
$r->print('<h3>Enrolling Students</h3>'); |
$r->print('<h3>Enrolling Students</h3>'."\n".'<p>'); |
my $count=0; |
my $count=0; |
my $flushc=0; |
my $flushc=0; |
my %student=(); |
my %student=(); |
Line 1495 sub upfile_drop_add {
|
Line 1613 sub upfile_drop_add {
|
} |
} |
} |
} |
if ($entries{$fields{'username'}}=~/\W/) { |
if ($entries{$fields{'username'}}=~/\W/) { |
$r->print('<p><b>Unacceptable username: '. |
$r->print('<br /><b>Unacceptable username: '. |
$entries{$fields{'username'}}.' for user '. |
$entries{$fields{'username'}}.' for user '. |
$fname.' '.$mname.' '.$lname.' '.$gen.'</b><p>'); |
$fname.' '.$mname.' '.$lname.' '.$gen.'</b>'); |
} else { |
} else { |
# determine section number |
# determine section number |
my $sec=''; |
my $sec=''; |
Line 1515 sub upfile_drop_add {
|
Line 1633 sub upfile_drop_add {
|
} |
} |
$id=~tr/A-Z/a-z/; |
$id=~tr/A-Z/a-z/; |
} |
} |
|
# determine email address |
|
my $email=''; |
|
if (defined($fields{'email'})) { |
|
if (defined($entries{$fields{'email'}})) { |
|
$email=$entries{$fields{'email'}}; |
|
unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; } |
|
} |
|
} |
# determine student password |
# determine student password |
my $password=''; |
my $password=''; |
if ($genpwd) { |
if ($genpwd) { |
Line 1537 sub upfile_drop_add {
|
Line 1663 sub upfile_drop_add {
|
my $reply=&Apache::lonnet::modifystudent |
my $reply=&Apache::lonnet::modifystudent |
($domain,$username,$id,$amode,$password, |
($domain,$username,$id,$amode,$password, |
$fname,$mname,$lname,$gen,$sec,$enddate, |
$fname,$mname,$lname,$gen,$sec,$enddate, |
$startdate,$ENV{'form.forceid'},$desiredhost); |
$startdate,$ENV{'form.forceid'},$desiredhost, |
|
$email); |
if ($reply ne 'ok') { |
if ($reply ne 'ok') { |
$r->print('<p><b>'. |
$reply =~ s/^error://; |
'Error enrolling '.$username.': '. |
$r->print('<br /><b>'.$username.'</b>:'. |
$reply.'</b></p>'); |
' Unable to enroll: '.$reply); |
} else { |
} else { |
$count++; $flushc++; |
$count++; $flushc++; |
$student{$username}=1; |
$student{$username}=1; |
Line 1552 sub upfile_drop_add {
|
Line 1679 sub upfile_drop_add {
|
} |
} |
} |
} |
} else { |
} else { |
$r->print("<p><b>No password for $username</b><p>"); |
$r->print('<br /><b>'.$username.'</b>:'. |
|
' Unable to enroll: No password specified.'); |
} |
} |
} |
} |
} |
} |
} # end of foreach (@studentdata) |
} # end of foreach (@studentdata) |
$r->print('<p>Processed Students: '.$count.'</p>'); |
$r->print('</p><p>Processed Students: '.$count.'</p>'); |
$r->print("<p>If active, the new role will be available when the ". |
$r->print("<p>If active, the new role will be available when the ". |
"students next log in to LON-CAPA.</p>"); |
"students next log in to LON-CAPA.</p>"); |
##################################### |
##################################### |
Line 1633 The response to the request is governed
|
Line 1761 The response to the request is governed
|
upload enrolling enroll students based on upload |
upload enrolling enroll students based on upload |
drop undefined print the classlist ready to drop |
drop undefined print the classlist ready to drop |
drop done drop the selected students |
drop done drop the selected students |
enrollstudent undefined print single student enroll menu |
enrollstudent undefined print student username domain form |
|
enrollstudent gotusername print single student enroll menu |
enrollstudent enrolling enroll student |
enrollstudent enrolling enroll student |
classlist undefined print html classlist |
classlist undefined print html classlist |
classlist csv print csv classlist |
classlist csv print csv classlist |
Line 1701 sub handler {
|
Line 1830 sub handler {
|
} |
} |
} elsif ($ENV{'form.action'} eq 'enrollstudent') { |
} elsif ($ENV{'form.action'} eq 'enrollstudent') { |
if (! exists($ENV{'form.state'})) { |
if (! exists($ENV{'form.state'})) { |
|
&get_student_username_domain_form($r); |
|
} elsif ($ENV{'form.state'} eq 'gotusername') { |
&print_enroll_single_student_form($r); |
&print_enroll_single_student_form($r); |
} elsif ($ENV{'form.state'} eq 'enrolling') { |
} elsif ($ENV{'form.state'} eq 'enrolling') { |
&enroll_single_student($r); |
&enroll_single_student($r); |
} else { |
} else { |
&print_enroll_single_student_form($r); |
&get_student_username_domain_form($r); |
} |
} |
} elsif ($ENV{'form.action'} eq 'classlist') { |
} elsif ($ENV{'form.action'} eq 'classlist') { |
if (! exists($ENV{'form.state'})) { |
if (! exists($ENV{'form.state'})) { |