version 1.164, 2007/07/26 23:48:53
|
version 1.178, 2009/02/04 13:21:48
|
Line 26
|
Line 26
|
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
# |
# |
############################################################### |
|
############################################################## |
=head1 NAME |
|
|
|
Apache::londropadd.pm |
|
|
|
=head1 SYNOPSIS |
|
|
|
drop & add students |
|
|
|
This is part of the LearningOnline Network with CAPA project |
|
described at http://www.lon-capa.org. |
|
|
|
=head1 SUBROUTINES |
|
|
|
=over |
|
|
|
=cut |
|
|
package Apache::londropadd; |
package Apache::londropadd; |
|
|
Line 42 use Apache::lonlocal;
|
Line 57 use Apache::lonlocal;
|
use Apache::longroup; |
use Apache::longroup; |
use LONCAPA(); |
use LONCAPA(); |
|
|
############################################################### |
|
############################################################### |
|
sub header { |
sub header { |
my $start_page=&Apache::loncommon::start_page('Enrollment Manager'); |
my ($jscript,$loaditems) = @_; |
|
my $start_page; |
|
if (ref($loaditems) eq 'HASH') { |
|
$start_page=&Apache::loncommon::start_page('Enrollment Manager',$jscript,{'add_entries' => $loaditems,}); |
|
} else { |
|
$start_page=&Apache::loncommon::start_page('Enrollment Manager',$jscript); |
|
} |
return(<<ENDHEAD); |
return(<<ENDHEAD); |
$start_page |
$start_page |
<form method="post" enctype="multipart/form-data" |
<form method="post" enctype="multipart/form-data" |
Line 53 $start_page
|
Line 72 $start_page
|
ENDHEAD |
ENDHEAD |
} |
} |
|
|
############################################################### |
=pod |
############################################################### |
|
# Drop student from all sections of a course, except optional $csec |
=item modifystudent() |
|
|
|
Drop student from all sections of a course, except optional $csec |
|
|
|
=cut |
|
|
sub modifystudent { |
sub modifystudent { |
my ($udom,$unam,$courseid,$csec,$desiredhost)=@_; |
my ($udom,$unam,$courseid,$csec,$desiredhost)=@_; |
# if $csec is undefined, drop the student from all the courses matching |
# if $csec is undefined, drop the student from all the courses matching |
Line 98 sub modifystudent {
|
Line 122 sub modifystudent {
|
return $result; |
return $result; |
} |
} |
|
|
############################################################### |
=pod |
############################################################### |
|
# build a domain and server selection form |
=item domain_form() |
|
|
|
build a domain and server selection form |
|
|
|
=cut |
|
|
sub domain_form { |
sub domain_form { |
my ($defdom) = @_; |
my ($defdom) = @_; |
# Set up domain and server selection forms |
# Set up domain and server selection forms |
Line 129 sub domain_form {
|
Line 158 sub domain_form {
|
return $result; |
return $result; |
} |
} |
|
|
############################################################### |
=pod |
############################################################### |
|
# Menu Phase One |
=item print_main_menu() |
|
|
|
Menu Phase One |
|
|
|
=cut |
|
|
sub print_main_menu { |
sub print_main_menu { |
my ($r,$permission)=@_; |
my ($r,$permission)=@_; |
# |
# |
Line 173 sub print_main_menu {
|
Line 207 sub print_main_menu {
|
{ text => 'Create a new group', |
{ text => 'Create a new group', |
help => 'Course_Create_Group', |
help => 'Course_Create_Group', |
permission => $permission->{'grp_manage'}, |
permission => $permission->{'grp_manage'}, |
url => '/adm/coursegroups?refpage=enrl&action=create', |
url => '/adm/coursegroups?refpage=enrl&action=create', |
}, |
}, |
{ text => 'Modify an existing group', |
{ text => 'Modify an existing group', |
help => 'Course_Modify_Group', |
help => 'Course_Modify_Group', |
permission => $permission->{'grp_manage'}, |
permission => $permission->{'grp_manage'}, |
url => '/adm/coursegroups?refpage=enrl&action=modify', |
url => '/adm/coursegroups?refpage=enrl&action=modify', |
}, |
}, |
{ text => 'Delete an existing group', |
{ text => 'Delete an existing group', |
help => 'Course_Delete_Group', |
help => 'Course_Delete_Group', |
permission => $permission->{'grp_manage'}, |
permission => $permission->{'grp_manage'}, |
url => '/adm/coursegroups?refpage=enrl&action=delete', |
url => '/adm/coursegroups?refpage=enrl&action=delete', |
}, |
}, |
{ text => 'Re-enable a deleted group', |
{ text => 'Re-enable a deleted group', |
help => 'Course_Reenable_Group', |
help => 'Course_Reenable_Group', |
permission => $permission->{'grp_manage'}, |
permission => $permission->{'grp_manage'}, |
url => '/adm/coursegroups?refpage=enrl&action=reenable', |
url => '/adm/coursegroups?refpage=enrl&action=reenable', |
}, |
}, |
{ text => 'Enter an existing group', |
{ text => 'Enter an existing group', |
help => 'Course_Display_Group', |
help => 'Course_Display_Group', |
permission => $permission->{'grp_view'}, |
permission => $permission->{'grp_view'}, |
url => '/adm/coursegroups?refpage=enrl&action=view', |
url => '/adm/coursegroups?refpage=enrl&action=view', |
}, |
}, |
); |
); |
my $menu_html = ''; |
my $menu_html = ''; |
Line 218 sub print_main_menu {
|
Line 252 sub print_main_menu {
|
return; |
return; |
} |
} |
|
|
############################################################### |
|
############################################################### |
|
sub hidden_input { |
sub hidden_input { |
my ($name,$value) = @_; |
my ($name,$value) = @_; |
return '<input type="hidden" name="'.$name.'" value="'.$value.'" />'."\n"; |
return '<input type="hidden" name="'.$name.'" value="'.$value.'" />'."\n"; |
} |
} |
|
|
|
|
|
|
sub print_upload_manager_header { |
sub print_upload_manager_header { |
my ($r,$datatoken,$distotal,$krbdefdom)=@_; |
my ($r,$datatoken,$distotal,$krbdefdom)=@_; |
my $javascript; |
my $javascript; |
Line 256 sub print_upload_manager_header {
|
Line 292 sub print_upload_manager_header {
|
$password_choice = 'int'; |
$password_choice = 'int'; |
} |
} |
# |
# |
my $javascript_validations=&javascript_validations('auth',$krbdefdom, |
my $javascript_validations = |
$password_choice); |
&javascript_validations('auth',$krbdefdom,$password_choice,undef, |
|
$env{'request.role.domain'}); |
my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':''); |
my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':''); |
$r->print('<h3>'.&mt('Uploading Class List')."</h3>\n". |
$r->print('<h3>'.&mt('Uploading Class List')."</h3>\n". |
"<hr>\n". |
"<hr>\n". |
Line 284 sub print_upload_manager_header {
|
Line 321 sub print_upload_manager_header {
|
$javascript."\n".$javascript_validations.'</script>'); |
$javascript."\n".$javascript_validations.'</script>'); |
} |
} |
|
|
############################################################### |
|
############################################################### |
|
|
|
|
|
sub javascript_validations { |
sub javascript_validations { |
my ($mode,$krbdefdom,$curr_authtype,$curr_authfield)=@_; |
my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain)=@_; |
my $authheader; |
my $authheader; |
if ($mode eq 'auth') { |
if ($mode eq 'auth') { |
my %param = ( formname => 'studentform', |
my %param = ( formname => 'studentform', |
Line 296 sub javascript_validations {
|
Line 335 sub javascript_validations {
|
$authheader = &Apache::loncommon::authform_header(%param); |
$authheader = &Apache::loncommon::authform_header(%param); |
} elsif ($mode eq 'createcourse') { |
} elsif ($mode eq 'createcourse') { |
my %param = ( formname => 'ccrs', |
my %param = ( formname => 'ccrs', |
kerb_def_dom => $krbdefdom, |
kerb_def_dom => $krbdefdom, |
curr_authtype => $curr_authtype ); |
curr_authtype => $curr_authtype ); |
$authheader = &Apache::loncommon::authform_header(%param); |
$authheader = &Apache::loncommon::authform_header(%param); |
} elsif ($mode eq 'modifycourse') { |
} elsif ($mode eq 'modifycourse') { |
Line 317 sub javascript_validations {
|
Line 356 sub javascript_validations {
|
name => 'The optional name field was not specified.', |
name => 'The optional name field was not specified.', |
snum => 'The optional student number field was not specified.', |
snum => 'The optional student number field was not specified.', |
section => 'The optional section field was not specified.', |
section => 'The optional section field was not specified.', |
email => 'The optional email address field was not specified.', |
email => 'The optional e-mail address field was not specified.', |
continue => 'Continue enrollment?', |
continue => 'Continue enrollment?', |
); |
); |
|
|
Line 325 sub javascript_validations {
|
Line 364 sub javascript_validations {
|
my $function_name =(<<END); |
my $function_name =(<<END); |
function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail) { |
function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail) { |
END |
END |
|
my ($authnum,%can_assign) = &Apache::loncommon::get_assignable_auth($domain); |
my $auth_checks; |
my $auth_checks; |
if ($mode eq 'createcourse') { |
if ($mode eq 'createcourse') { |
$auth_checks .= (<<END); |
$auth_checks .= (<<END); |
Line 339 END
|
Line 379 END
|
$auth_checks .= (<<END); |
$auth_checks .= (<<END); |
var foundatype=0; |
var foundatype=0; |
if (founduname==0) { |
if (founduname==0) { |
alert('$alert{'username'}'); |
alert('$alert{'username'}'); |
return; |
return; |
} |
} |
|
|
|
END |
|
if ($authnum > 1) { |
|
$auth_checks .= (<<END); |
// alert('current.radiovalue = '+current.radiovalue); |
// alert('current.radiovalue = '+current.radiovalue); |
if (current.radiovalue == null || current.radiovalue == '' || current.radiovalue == 'nochange') { |
if (current.radiovalue == null || current.radiovalue == '' || current.radiovalue == 'nochange') { |
// They did not check any of the login radiobuttons. |
// They did not check any of the login radiobuttons. |
Line 349 END
|
Line 393 END
|
return; |
return; |
} |
} |
END |
END |
|
} |
} |
} |
if ($mode eq 'createcourse') { |
if ($mode eq 'createcourse') { |
$auth_checks .= " |
$auth_checks .= " |
Line 410 END
|
Line 455 END
|
} |
} |
END |
END |
} else { |
} else { |
$section_checks = §ion_check_js(); |
$section_checks = &Apache::lonuserutils::section_check_js(); |
$optional_checks = (<<END); |
$optional_checks = (<<END); |
var message=''; |
var message=''; |
if (foundname==0) { |
if (foundname==0) { |
Line 458 END
|
Line 503 END
|
return $result; |
return $result; |
} |
} |
|
|
############################################################### |
|
############################################################### |
|
|
|
sub upload_manager_javascript_forward_associate { |
sub upload_manager_javascript_forward_associate { |
return(<<ENDPICK); |
return(<<ENDPICK); |
function verify(vf,sec_caller) { |
function verify(vf,sec_caller) { |
Line 551 function clearpwd(vf) {
|
Line 597 function clearpwd(vf) {
|
ENDPICK |
ENDPICK |
} |
} |
|
|
############################################################### |
|
############################################################### |
|
|
|
sub upload_manager_javascript_reverse_associate { |
sub upload_manager_javascript_reverse_associate { |
return(<<ENDPICK); |
return(<<ENDPICK); |
function verify(vf,sec_caller) { |
function verify(vf,sec_caller) { |
Line 606 function clearpwd(vf) {
|
Line 653 function clearpwd(vf) {
|
ENDPICK |
ENDPICK |
} |
} |
|
|
############################################################### |
|
############################################################### |
|
|
|
sub print_upload_manager_footer { |
sub print_upload_manager_footer { |
my ($r,$i,$keyfields,$defdom,$today,$halfyear)=@_; |
my ($r,$i,$keyfields,$defdom,$today,$halfyear)=@_; |
|
|
Line 660 sub print_upload_manager_footer {
|
Line 708 sub print_upload_manager_footer {
|
return; |
return; |
} |
} |
|
|
############################################################### |
|
############################################################### |
|
|
|
sub print_upload_manager_form { |
sub print_upload_manager_form { |
my $r=shift; |
my $r=shift; |
|
|
Line 715 sub print_upload_manager_form {
|
Line 764 sub print_upload_manager_form {
|
['id', &mt('ID/Student Number'),$env{'form.id_choice'}], |
['id', &mt('ID/Student Number'),$env{'form.id_choice'}], |
['sec', &mt('Section'), $env{'form.sec_choice'}], |
['sec', &mt('Section'), $env{'form.sec_choice'}], |
['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}], |
['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}], |
['email',&mt('EMail Address'), $env{'form.email_choice'}]); |
['email',&mt('E-mail Address'), $env{'form.email_choice'}]); |
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, |
$i=&Apache::loncommon::csv_print_select_table($r,\@records, |
Line 735 sub print_upload_manager_form {
|
Line 784 sub print_upload_manager_form {
|
&print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear); |
&print_upload_manager_footer($r,$i,$keyfields,$defdom,$today,$halfyear); |
} |
} |
|
|
############################################################### |
|
############################################################### |
|
|
|
|
|
sub enroll_single_student { |
sub enroll_single_student { |
my $r=shift; |
my ($r,$srcharray) = @_; |
# Remove non alphanumeric values from section |
# Remove non alphanumeric values from section |
$env{'form.csec'}=~s/\W//g; |
$env{'form.csec'}=~s/\W//g; |
# |
# |
Line 746 sub enroll_single_student {
|
Line 797 sub enroll_single_student {
|
# in the course is entirely separate from the action of enrolling the |
# in the course is entirely separate from the action of enrolling the |
# student. Also, a failure in setting the dates as default is not fatal |
# student. Also, a failure in setting the dates as default is not fatal |
# to the process of enrolling / modifying a student. |
# to the process of enrolling / modifying a student. |
my ($startdate,$enddate) = &get_dates_from_form(); |
my ($startdate,$enddate) = &Apache::lonuserutils::get_dates_from_form(); |
if ($env{'form.makedatesdefault'}) { |
if ($env{'form.makedatesdefault'}) { |
$r->print(&make_dates_default($startdate,$enddate)); |
$r->print(&Apache::lonuserutils::make_dates_default($startdate, |
|
$enddate)); |
} |
} |
|
|
$r->print('<h3>'.&mt('Enrolling Student').'</h3>'); |
$r->print('<h3>'.&mt('Enrolling Student').'</h3>'); |
Line 793 sub enroll_single_student {
|
Line 845 sub enroll_single_student {
|
$env{'form.lcdomain'}); |
$env{'form.lcdomain'}); |
if ((($amode) && ($genpwd)) || ($home ne 'no_host')) { |
if ((($amode) && ($genpwd)) || ($home ne 'no_host')) { |
# Clean out any old roles the student has in this class. |
# Clean out any old roles the student has in this class. |
&modifystudent($env{'form.lcdomain'},$env{'form.cuname'}, |
&Apache::lonuserutils::modifystudent($env{'form.lcdomain'},$env{'form.cuname'}, |
$env{'request.course.id'},$env{'form.csec'}, |
$env{'request.course.id'},$env{'form.csec'}, |
$desiredhost); |
$desiredhost); |
my $login_result = &Apache::lonnet::modifystudent |
my $login_result = &Apache::lonnet::modifystudent |
Line 823 sub enroll_single_student {
|
Line 875 sub enroll_single_student {
|
$r->print(&mt('Invalid username or domain')); |
$r->print(&mt('Invalid username or domain')); |
} |
} |
$r->print("<p><a href='/adm/dropadd?action=enrollstudent'>".&mt("Enroll another student")."</a></p>"); |
$r->print("<p><a href='/adm/dropadd?action=enrollstudent'>".&mt("Enroll another student")."</a></p>"); |
|
if (ref($srcharray) eq 'ARRAY') { |
|
foreach my $item (@{$srcharray},'ccuname','ccdomain') { |
|
$r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"); |
|
} |
|
} |
|
foreach my $item ('sortby','seluname','seludom') { |
|
if (exists($env{'form.'.$item})) { |
|
$r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"); |
|
} |
|
} |
|
$r->print('<input type="hidden" name="phase" value="get_user_info" />'."\n". |
|
'<input type="hidden" name="currstate" value="" />'."\n". |
|
'<input type="hidden" name="prevphase" value="" />'."\n". |
|
'<input type="hidden" name="action" value="enrollstudent" />'."\n". |
|
'<input type="hidden" name="state" value="gotusername" />'); |
} |
} |
|
|
sub setup_date_selectors { |
sub setup_date_selectors { |
Line 932 sub make_dates_default {
|
Line 999 sub make_dates_default {
|
return $result; |
return $result; |
} |
} |
|
|
## |
=pod |
## Single student enrollment routines (some of them) |
|
## |
=item get_student_username_domain_form() |
|
|
|
Single student enrollment routines (some of them) |
|
|
|
=cut |
|
|
sub get_student_username_domain_form { |
sub get_student_username_domain_form { |
my $r = shift; |
my ($r,$elements,$response,$srch,$forcenewuser) = @_; |
my $domform = &Apache::loncommon::select_dom_form |
my $loaditems = { |
($env{'course.'.$env{'request.course.id'}.'.domain'},'cudomain',0); |
'onload' => "javascript:setFormElements(document.studentform)", |
|
}; |
|
$r->print(&header(undef,$loaditems)); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:backPage(document.studentform,'','')", |
|
text=>"Single user search"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enroll Student', |
|
'Course_Add_Student')); |
|
my $defdom=$env{'request.role.domain'}; |
|
|
|
my $jscript = &Apache::loncommon::studentbrowser_javascript()."\n". |
|
'<script type="text/javascript">'."\n". |
|
&Apache::lonhtmlcommon::set_form_elements($elements->{'studentform'}). |
|
'</script>'."\n"; |
|
|
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'eos' => "Enroll One Student", |
'eos' => "Enroll One Student", |
'usr' => "Username", |
'usr' => "Username", |
Line 946 sub get_student_username_domain_form {
|
Line 1032 sub get_student_username_domain_form {
|
'been' => "Begin Enrollment", |
'been' => "Begin Enrollment", |
); |
); |
$r->print(<<END); |
$r->print(<<END); |
<input type="hidden" name="action" value="enrollstudent" /> |
$jscript |
<input type="hidden" name="state" value="gotusername" /> |
|
<h3>$lt{'eos'}</h3> |
<h3>$lt{'eos'}</h3> |
<table> |
|
<tr><td class="LC_dropadd_labeltext"><label for="cuname">$lt{'usr'}</label>:</td> |
|
<td><input type="text" name="cuname" size="15" /></td></tr> |
|
<tr><td class="LC_dropadd_labeltext"><label for="cudomain">$lt{'dom'}</label>:</td> |
|
<td>$domform</td></tr> |
|
<tr><td> </td> |
|
<td> |
|
<input type="submit" name="Begin Enrollment" value="$lt{'been'}" /> |
|
</td></tr> |
|
</table> |
|
<script type="text/javascript"> |
|
// the if prevents the script error if the browser can not handle this |
|
if ( document.studentform.cuname ) { document.studentform.cuname.focus(); } |
|
</script> |
|
END |
END |
|
$r->print($response); |
|
$r->print(&single_user_entry_form($defdom,$srch,$forcenewuser)); |
return; |
return; |
} |
} |
|
|
|
sub single_user_entry_form { |
|
my ($dom,$srch,$forcenewuser) = @_; |
|
my $userpicker = |
|
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser, |
|
'document.studentform'); |
|
my $srchbutton = &mt('Search'); |
|
my $output = <<"ENDDOCUMENT"; |
|
<input type="hidden" name="action" value="enrollstudent" /> |
|
<input type="hidden" name="state" value="gotusername" /> |
|
<input type="hidden" name="phase" value="get_user_info" /> |
|
$userpicker |
|
<input name="userrole" type="button" value="$srchbutton" onclick="javascript:validateEntry(document.studentform)" /> |
|
ENDDOCUMENT |
|
return $output; |
|
} |
|
|
sub print_enroll_single_student_form { |
sub print_enroll_single_student_form { |
my $r=shift; |
my ($r,$jscript,$ccuname,$ccdomain,$srch) = @_; |
|
$r->print(&header($jscript)); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:backPage(document.studentform,'','')", |
|
text=>"Single user search"}); |
|
if ($env{'form.phase'} eq 'userpicked') { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:backPage(document.studentform,'get_user_info','select')", |
|
text=>"Select user",}); |
|
} |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:backPage(document.studentform,'$env{'form.phase'}','modify')", |
|
text=>"Set enrollment",}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enroll Student', |
|
'Course_Add_Student')); |
$r->print("<h3>".&mt('Enroll One Student')."</h3>"); |
$r->print("<h3>".&mt('Enroll One Student')."</h3>"); |
# |
# |
my $username = &LONCAPA::clean_username($env{'form.cuname'}); |
my $home = &Apache::lonnet::homeserver($ccuname,$ccdomain); |
my $domain = &LONCAPA::clean_domain($env{'form.cudomain'}); |
|
my $home = &Apache::lonnet::homeserver($username,$domain); |
|
# $new_user flags whether we are creating a new user or using an old one |
# $new_user flags whether we are creating a new user or using an old one |
my $new_user = 1; |
my $new_user = 1; |
if ($home ne 'no_host') { |
if ($home ne 'no_host') { |
Line 983 sub print_enroll_single_student_form {
|
Line 1084 sub print_enroll_single_student_form {
|
my $user_data_html = ''; |
my $user_data_html = ''; |
my $javascript_validations = ''; |
my $javascript_validations = ''; |
if ($new_user) { |
if ($new_user) { |
|
my $usertoadd; |
|
my $instsrch = { |
|
srchin => 'instd', |
|
srchby => 'uname', |
|
srchtype => 'exact', |
|
srchterm => $ccuname, |
|
srchdomain => $ccdomain, |
|
}; |
|
if (($instsrch->{'srchterm'} ne '') && ($instsrch->{'srchdomain'} ne '')) { |
|
$usertoadd = $instsrch->{'srchterm'}.':'.$instsrch->{'srchdomain'}; |
|
} |
|
my (%dirsrch_results,%inst_results); |
|
if ($usertoadd) { |
|
if (&Apache::loncreateuser::directorysrch_check($instsrch) eq 'ok') { |
|
%dirsrch_results = &Apache::lonnet::inst_directory_query($instsrch); |
|
if (ref($dirsrch_results{$usertoadd}) eq 'HASH') { |
|
%inst_results = %{$dirsrch_results{$usertoadd}}; |
|
} |
|
} |
|
} |
|
|
my $defdom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $defdom=$env{'course.'.$env{'request.course.id'}.'.domain'}; |
# Set up authentication forms |
# Set up authentication forms |
my ($krbdef,$krbdefdom) = |
my ($krbdef,$krbdefdom) = |
&Apache::loncommon::get_kerberos_defaults($domain); |
&Apache::loncommon::get_kerberos_defaults($ccdomain); |
$javascript_validations=&javascript_validations('auth',$krbdefdom); |
$javascript_validations = |
|
&Apache::lonuserutils::javascript_validations('auth',$krbdefdom, |
|
undef,undef,$ccdomain); |
my %param = ( formname => 'document.studentform', |
my %param = ( formname => 'document.studentform', |
kerb_def_dom => $krbdefdom, |
kerb_def_dom => $krbdefdom, |
kerb_def_auth => $krbdef |
kerb_def_auth => $krbdef |
Line 998 sub print_enroll_single_student_form {
|
Line 1122 sub print_enroll_single_student_form {
|
# |
# |
# Set up domain selection form |
# Set up domain selection form |
my $homeserver_form = ''; |
my $homeserver_form = ''; |
my %servers = &Apache::lonnet::get_servers($domain,'library'); |
my %servers = &Apache::lonnet::get_servers($ccdomain,'library'); |
$homeserver_form = '<select name="lcserver" size="1">'."\n". |
$homeserver_form = '<select name="lcserver" size="1">'."\n". |
'<option value="default" selected>default</option>'."\n"; |
'<option value="default" selected>default</option>'."\n"; |
while (my ($servername,$serverdescription) = each (%servers)) { |
while (my ($servername,$serverdescription) = each (%servers)) { |
Line 1009 sub print_enroll_single_student_form {
|
Line 1133 sub print_enroll_single_student_form {
|
# |
# |
# |
# |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'udf' => "User Data for", |
'udf' => "Personal Data", |
'fn' => "First Name", |
'fn' => "First Name", |
'mn' => "Middle Name", |
'mn' => "Middle Name", |
'ln' => "Last Name", |
'ln' => "Last Name", |
'gen' => "Generation", |
'gen' => "Generation", |
'hs' => "Home Server", |
'hs' => "Home Server", |
'pswd' => "Password", |
'pswd' => "Login Data", |
'psam' => "Please select an authentication mechanism", |
'psam' => "Please select an authentication mechanism", |
'mail' => "Email Address" |
'mail' => "E-mail Address" |
); |
); |
my $authhelp=&Apache::loncommon::help_open_topic('Auth_Options'); |
my $authhelp=&Apache::loncommon::help_open_topic('Auth_Options'); |
$user_data_html = <<END; |
$user_data_html = <<END; |
<h3>$lt{'udf'} $username:$domain</h3> |
<h3>$lt{'udf'} $ccuname:$ccdomain</h3> |
<table> |
<table> |
<tr><td class="LC_dropadd_labeltext"><label for="cfirst">$lt{'fn'}</label>:</td> |
<tr><td class="LC_dropadd_labeltext"><label for="cfirst">$lt{'fn'}</label>:</td> |
<td><input type="text" name="cfirst" size="15" /></td></tr> |
<td><input type="text" name="cfirst" size="15" value="$inst_results{'firstname'}" /></td></tr> |
<tr><td class="LC_dropadd_labeltext"><label for="cmiddle">$lt{'mn'}</label>:</td> |
<tr><td class="LC_dropadd_labeltext"><label for="cmiddle">$lt{'mn'}</label>:</td> |
<td><input type="text" name="cmiddle" size="15" /></td></tr> |
<td><input type="text" name="cmiddle" size="15" value="$inst_results{'middlename'}" /></td></tr> |
<tr><td class="LC_dropadd_labeltext"><label for="clast">$lt{'ln'}</label>:</td> |
<tr><td class="LC_dropadd_labeltext"><label for="clast">$lt{'ln'}</label>:</td> |
<td><input type="text" name="clast" size="15" /></td></tr> |
<td><input type="text" name="clast" size="15" value="$inst_results{'lastname'}" /></td></tr> |
<tr><td class="LC_dropadd_labeltext"><label for="cgen">$lt{'gen'}</label>:</td> |
<tr><td class="LC_dropadd_labeltext"><label for="cgen">$lt{'gen'}</label>:</td> |
<td><input type="text" name="cgen" size="5" /> </td></tr> |
<td><input type="text" name="cgen" size="5" value="$inst_results{'generation'}" /> </td></tr> |
<tr><td class="LC_dropadd_labeltext"><label for="lcserver">$lt{'hs'}</label>:</td> |
<tr><td class="LC_dropadd_labeltext"><label for="lcserver">$lt{'hs'}</label>:</td> |
<td>$homeserver_form</td></tr> |
<td>$homeserver_form</td></tr> |
<tr><td class="LC_dropadd_labeltext"><label for="emailaddress">$lt{'mail'}</label>:</td> |
<tr><td class="LC_dropadd_labeltext"><label for="emailaddress">$lt{'mail'}</label>:</td> |
<td><input type="text" name="emailaddress" size="20" /></td></tr> |
<td><input type="text" name="emailaddress" size="20" value="$inst_results{'permanentemail'}" /></td></tr> |
</table> |
</table> |
<h3>$lt{'pswd'}</h3> |
<h3>$lt{'pswd'}</h3> |
$lt{'psam'}$authhelp |
$lt{'psam'}$authhelp |
<table> |
|
<p> |
<p> |
$krbform |
|
<br /> |
|
$intform |
|
<br /> |
|
$locform |
|
</p> |
|
END |
END |
|
if ($krbform ne '') { |
|
$user_data_html .= $krbform.'<br />'; |
|
} |
|
if ($intform ne '') { |
|
$user_data_html .= $intform.'<br />'; |
|
} |
|
if ($locform ne '') { |
|
$user_data_html .= $locform.'<br />'; |
|
} |
|
$user_data_html .= "\n</p>\n" |
} else { |
} else { |
# User already exists. Do not worry about authentication |
# User already exists. Do not worry about authentication |
my %uenv = &Apache::lonnet::dump('environment',$domain,$username); |
my %uenv = &Apache::lonnet::dump('environment',$ccdomain,$ccuname); |
$javascript_validations = &javascript_validations('noauth'); |
$javascript_validations = &Apache::lonuserutils::javascript_validations('noauth'); |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'udf' => "User Data for", |
'udf' => "User Data for", |
'fn' => "First Name", |
'fn' => "First Name", |
'mn' => "Middle Name", |
'mn' => "Middle Name", |
'ln' => "Last Name", |
'ln' => "Last Name", |
'gen' => "Generation", |
'gen' => "Generation", |
'mail' => "Email Address", |
'mail' => "E-mail Address", |
); |
); |
$user_data_html = <<END; |
$user_data_html = <<END; |
<h3>$lt{'udf'} $username:$domain</h3> |
<h3>$lt{'udf'} $ccuname:$ccdomain</h3> |
<input type="hidden" name="lcserver" value="default" /> |
<input type="hidden" name="lcserver" value="default" /> |
<table> |
<table> |
<tr><td class="LC_dropadd_labeltext"><label for="cfirst">$lt{'fn'}</label>:</td> |
<tr><td class="LC_dropadd_labeltext"><label for="cfirst">$lt{'fn'}</label>:</td> |
Line 1076 END
|
Line 1203 END
|
</table> |
</table> |
END |
END |
} |
} |
my $date_table = &date_setting_table(); |
my $date_table = &Apache::lonuserutils::date_setting_table(); |
# Print it all out |
# Print it all out |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'cd' => "Course Data", |
'cd' => "Course Data", |
Line 1087 END
|
Line 1214 END
|
); |
); |
$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="gotusername" /> |
<input type="hidden" name="cuname" value="$username" /> |
<input type="hidden" name="cuname" value="$ccuname" /> |
<input type="hidden" name="lcdomain" value="$domain" /> |
<input type="hidden" name="lcdomain" value="$ccdomain" /> |
<script type="text/javascript" language="Javascript"> |
<script type="text/javascript" language="Javascript"> |
function verify(vf,sec_caller) { |
function verify(vf,sec_caller) { |
var founduname=0; |
var founduname=0; |
Line 1149 $lt{'disn'}
|
Line 1276 $lt{'disn'}
|
<input type="button" onClick="verify(this.form,this.form.csec)" value="$lt{'eas'}" /> |
<input type="button" onClick="verify(this.form,this.form.csec)" value="$lt{'eas'}" /> |
</p> |
</p> |
END |
END |
|
$r->print('<input type="hidden" name="currstate" value="" />'."\n". |
|
'<input type="hidden" name="phase" value="" />'."\n". |
|
'<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />'."\n"); |
|
if (ref($srch) eq 'HASH') { |
|
foreach my $item (sort(keys(%{$srch}))) { |
|
$r->print('<input type="hidden" name="'.$item.'" value="'.$srch->{$item}.'" />'."\n"); |
|
} |
|
} |
|
foreach my $item ('sortby','seluname','seludom') { |
|
if (exists($env{'form.'.$item})) { |
|
$r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"); |
|
} |
|
} |
return; |
return; |
} |
} |
|
|
# ========================================================= Menu Phase Two Drop |
=pod |
|
|
|
=item print_drop_menu() |
|
|
|
Menu Phase Two Drop |
|
|
|
=cut |
|
|
sub print_drop_menu { |
sub print_drop_menu { |
my $r=shift; |
my $r=shift; |
$r->print("<h3>".&mt('Drop Students')."</h3>"); |
$r->print("<h3>".&mt('Drop Students')."</h3>"); |
Line 1167 sub print_drop_menu {
|
Line 1314 sub print_drop_menu {
|
return; |
return; |
} |
} |
|
|
# ============================================== view classlist |
|
|
=pod |
|
|
|
=item print_html_classlist() |
|
|
|
view classlist |
|
|
|
=cut |
|
|
sub print_html_classlist { |
sub print_html_classlist { |
my ($r,$mode,$permission) = @_; |
my ($r,$mode,$permission) = @_; |
if (! exists($env{'form.sortby'})) { |
if (! exists($env{'form.sortby'})) { |
Line 1257 sub print_html_classlist {
|
Line 1412 sub print_html_classlist {
|
} |
} |
} |
} |
|
|
# =================================================== Show student list to drop |
|
|
=pod |
|
|
|
=item show_class_list() |
|
|
|
Show student list to drop |
|
|
|
=cut |
|
|
sub show_class_list { |
sub show_class_list { |
my ($r,$mode,$linkto,$statusmode,$classlist,$keylist)=@_; |
my ($r,$mode,$linkto,$statusmode,$classlist,$keylist)=@_; |
my $cid=$env{'request.course.id'}; |
my $cid=$env{'request.course.id'}; |
Line 1281 sub show_class_list {
|
Line 1444 sub show_class_list {
|
} |
} |
my $displayphotos = $env{'form.displayphotos'}; |
my $displayphotos = $env{'form.displayphotos'}; |
|
|
|
if (! exists($env{'form.displayclickers'})) { |
|
$env{'form.displayclickers'} = 'off'; |
|
} |
|
my $displayclickers = $env{'form.displayclickers'}; |
|
|
# Print out header |
# Print out header |
unless ($mode eq 'autoenroll') { |
unless ($mode eq 'autoenroll') { |
$r->print(<<END); |
$r->print(<<END); |
Line 1290 END
|
Line 1458 END
|
$r->print(<<END); |
$r->print(<<END); |
<input type="hidden" name="sortby" value="$sortby" /> |
<input type="hidden" name="sortby" value="$sortby" /> |
<input type="hidden" name="displayphotos" value="$displayphotos" /> |
<input type="hidden" name="displayphotos" value="$displayphotos" /> |
|
<input type="hidden" name="displayclickers" value="$displayclickers" /> |
END |
END |
if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll') { |
if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll') { |
if ($linkto eq 'aboutme') { |
if ($linkto eq 'aboutme') { |
Line 1306 END
|
Line 1475 END
|
'start' => "start date", |
'start' => "start date", |
'end' => "end date", |
'end' => "end date", |
'type' => "enroll type/action", |
'type' => "enroll type/action", |
'email' => "email address", |
'email' => "e-mail address", |
|
'clicker'=> "clicker id", |
'photo' => "photo", |
'photo' => "photo", |
); |
); |
unless ($mode eq 'autoenroll') { |
unless ($mode eq 'autoenroll') { |
Line 1363 function photowindow(photolink) {
|
Line 1533 function photowindow(photolink) {
|
<a href="javascript:document.studentform.sortby.value='email';document.studentform.submit();">$lt{'email'}</a> |
<a href="javascript:document.studentform.sortby.value='email';document.studentform.submit();">$lt{'email'}</a> |
</th> |
</th> |
END |
END |
|
|
|
# Clicker display on or off? |
|
|
|
my %clicker_options = &Apache::lonlocal::texthash( |
|
'on' => 'Show', |
|
'off' => 'Hide', |
|
); |
|
my $clickerchg = 'on'; |
|
if ($displayclickers eq 'on') { |
|
$clickerchg = 'off'; |
|
} |
|
$r->print(' <th>'."\n".' '. |
|
'<a href="javascript:document.studentform.displayclickers.value='. |
|
"'".$clickerchg."'".';document.studentform.submit();">'. |
|
$clicker_options{$clickerchg}.'</a> '.$lt{'clicker'}."\n". |
|
' </th>'."\n"); |
|
|
|
# Photo display on or off? |
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { |
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { |
my %photo_options = &Apache::lonlocal::texthash( |
my %photo_options = &Apache::lonlocal::texthash( |
'on' => 'Show', |
'on' => 'Show', |
Line 1379 END
|
Line 1567 END
|
' </th>'."\n"); |
' </th>'."\n"); |
} |
} |
$r->print(" </tr>\n"); |
$r->print(" </tr>\n"); |
|
|
|
# Done with the HTML header line |
|
|
} elsif ($mode eq 'csv') { |
} elsif ($mode eq 'csv') { |
# |
# |
# Open a file |
# Open a file |
Line 1387 END
|
Line 1578 END
|
time.'_'.rand(1000000000).'.csv'; |
time.'_'.rand(1000000000).'.csv'; |
unless ($CSVfile = Apache::File->new('>/home/httpd'.$CSVfilename)) { |
unless ($CSVfile = Apache::File->new('>/home/httpd'.$CSVfilename)) { |
$r->log_error("Couldn't open $CSVfilename for output $!"); |
$r->log_error("Couldn't open $CSVfilename for output $!"); |
$r->print("Problems occured in writing the csv file. ". |
$r->print(&mt('Problems occurred in writing the csv file. ' |
"This error has been logged. ". |
.'This error has been logged. ' |
"Please alert your LON-CAPA administrator."); |
.'Please alert your LON-CAPA administrator.')); |
$CSVfile = undef; |
$CSVfile = undef; |
} |
} |
# |
# |
Line 1431 END
|
Line 1622 END
|
"active groups","email address"], |
"active groups","email address"], |
$format->{'bold'}); |
$format->{'bold'}); |
} |
} |
|
|
|
# Done with header lines in all formats |
|
|
# |
# |
# Sort the students |
# Sort the students |
my %index; |
my %index; |
Line 1474 END
|
Line 1668 END
|
|
|
my %emails = &Apache::loncommon::getemails($username,$domain); |
my %emails = &Apache::loncommon::getemails($username,$domain); |
my $email; |
my $email; |
foreach my $type ('critnotification', 'permanentemail', |
if ($emails{'permanentemail'} =~ /\S/) { |
'notification') { |
$email = $emails{'permanentemail'}; |
if ($emails{$type} =~ /\S/) { |
|
$email = $emails{$type}; |
|
last; |
|
} |
|
} |
} |
|
|
if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') { |
if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') { |
Line 1543 END
|
Line 1733 END
|
<td>$active_groups</td> |
<td>$active_groups</td> |
<td>$email</td> |
<td>$email</td> |
END |
END |
|
|
|
# Clickers |
|
if ($displayclickers eq 'on') { |
|
my $clickers = |
|
(&Apache::lonnet::userenvironment($domain,$username,'clickers'))[1]; |
|
if ($clickers!~/\w/) { $clickers='-'; } |
|
$r->print('<td>'.$clickers.'</td>'); |
|
} else { |
|
$r->print(' <td> </td> '); |
|
} |
|
|
|
# Photos |
|
|
if ($env{'course.'.$env{'request.course.id'}. |
if ($env{'course.'.$env{'request.course.id'}. |
'.internal.showphoto'}) { |
'.internal.showphoto'}) { |
if ($displayphotos eq 'on') { |
if ($displayphotos eq 'on') { |
Line 1619 END
|
Line 1822 END
|
} |
} |
|
|
|
|
# |
=pod |
# print out form for modification of a single students data |
|
# |
=item print_modify_student_form() |
|
|
|
print out form for modification of a single students data |
|
|
|
=cut |
|
|
sub print_modify_student_form { |
sub print_modify_student_form { |
my $r = shift(); |
my $r = shift(); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
Line 1632 sub print_modify_student_form {
|
Line 1840 sub print_modify_student_form {
|
# determine the students name information |
# determine the students name information |
my %info=&Apache::lonnet::get('environment', |
my %info=&Apache::lonnet::get('environment', |
['firstname','middlename', |
['firstname','middlename', |
'lastname','generation','id'], |
'lastname','generation','id', |
$sdom, $sname); |
'permanentemail'], $sdom, $sname); |
my ($tmp) = keys(%info); |
my ($tmp) = keys(%info); |
if ($tmp =~ /^(con_lost|error|no_such_host)/i) { |
if ($tmp =~ /^(con_lost|error|no_such_host)/i) { |
$r->print('<font color="#ff0000" size="+2">'.&mt('Error').'</font>'. |
$r->print('<font color="#ff0000" size="+2">'.&mt('Error').'</font>'. |
Line 1672 sub print_modify_student_form {
|
Line 1880 sub print_modify_student_form {
|
&Apache::lonlocal::locallocaltime($endtime)).'<br />'; |
&Apache::lonlocal::locallocaltime($endtime)).'<br />'; |
|
|
} |
} |
my $date_table = &date_setting_table($starttime,$endtime); |
my $date_table = |
|
&Apache::lonuserutils::date_setting_table($starttime,$endtime); |
# |
# |
if (! exists($env{'form.Status'}) || |
if (! exists($env{'form.Status'}) || |
$env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) { |
$env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) { |
Line 1687 sub print_modify_student_form {
|
Line 1896 sub print_modify_student_form {
|
'mn' => "Middle", |
'mn' => "Middle", |
'ln' => "Last", |
'ln' => "Last", |
'gen' => "Generation", |
'gen' => "Generation", |
|
'email' => "E-mail address", |
'sid' => "Student ID", |
'sid' => "Student ID", |
'disn' => "Disable ID/Student Number Safeguard and Force Change of Conflicting IDs (only do if you know what you are doing)", |
'disn' => "Disable ID/Student Number Safeguard and Force Change of Conflicting IDs (only do if you know what you are doing)", |
'sec' => "Section", |
'sec' => "Section", |
'sm' => "Submit Modifications", |
'sm' => "Submit Modifications", |
); |
); |
# Check if section name is valid |
# Check if section name is valid |
my $section_check = §ion_check_js(); |
my $section_check = &Apache::lonuserutils::section_check_js(); |
$r->print(<<"END"); |
$r->print(<<"END"); |
<script type="text/javascript"> |
<script type="text/javascript"> |
$section_check |
$section_check |
Line 1716 $lt{'odcc'}
|
Line 1926 $lt{'odcc'}
|
<input type="hidden" name="state" value="done" /> |
<input type="hidden" name="state" value="done" /> |
<input type="hidden" name="sortby" value="$sortby" /> |
<input type="hidden" name="sortby" value="$sortby" /> |
<input type="hidden" name="Status" value="$env{'form.Status'}" /> |
<input type="hidden" name="Status" value="$env{'form.Status'}" /> |
<h2>$lt{'mef'} $info{'firstname'} $info{'middlename'} |
<h3>$lt{'mef'} $info{'firstname'} $info{'middlename'} |
$info{'lastname'} $info{'generation'}, $sname:$sdom</h2> |
$info{'lastname'} $info{'generation'}, $sname:$sdom</h3> |
<p> |
<p> |
<b>$lt{'sn'}</b> |
<b>$lt{'sn'}</b> |
<table> |
<table> |
Line 1729 $info{'lastname'} $info{'generation'}, $
|
Line 1939 $info{'lastname'} $info{'generation'}, $
|
<input type="text" name="generation" value="$info{'generation'}" /></td></tr> |
<input type="text" name="generation" value="$info{'generation'}" /></td></tr> |
</table> |
</table> |
</p><p> |
</p><p> |
|
<b>$lt{'email'}</b>: <input type="text" name="permanentemail" value="$info{'permanentemail'}" size="30" /> |
|
</p><p> |
<b>$lt{'sid'}</b>: <input type="text" name="id" value="$info{'id'}" size="12" /> |
<b>$lt{'sid'}</b>: <input type="text" name="id" value="$info{'id'}" size="12" /> |
</p><p> |
</p><p> |
<label> |
<label> |
Line 1746 END
|
Line 1958 END
|
return; |
return; |
} |
} |
|
|
# |
|
# modify a single students section |
=pod |
# |
|
|
=item modify_single_student() |
|
|
|
modify a single students section |
|
|
|
=cut |
|
|
sub modify_single_student { |
sub modify_single_student { |
my ($r) = @_; |
my ($r) = @_; |
# |
# |
Line 1756 sub modify_single_student {
|
Line 1974 sub modify_single_student {
|
$env{'form.section'} =~ s/\W//g; |
$env{'form.section'} =~ s/\W//g; |
# |
# |
# Do the date defaults first |
# Do the date defaults first |
my ($starttime,$endtime) = &get_dates_from_form(); |
my ($starttime,$endtime) = &Apache::lonuserutils::get_dates_from_form(); |
if ($env{'form.makedatesdefault'}) { |
if ($env{'form.makedatesdefault'}) { |
$r->print(&make_dates_default($starttime,$endtime)); |
$r->print(&Apache::lonuserutils::make_dates_default($starttime, |
|
$endtime)); |
} |
} |
# Get the 'sortby' and 'Status' variables so the user goes back to their |
# Get the 'sortby' and 'Status' variables so the user goes back to their |
# previous screen |
# previous screen |
Line 1772 sub modify_single_student {
|
Line 1991 sub modify_single_student {
|
# Get the old data |
# Get the old data |
my %old=&Apache::lonnet::get('environment', |
my %old=&Apache::lonnet::get('environment', |
['firstname','middlename', |
['firstname','middlename', |
'lastname','generation','id'], |
'lastname','generation','id', |
$sdom, $slogin); |
'permanentemail'],$sdom, $slogin); |
$old{'section'} = &Apache::lonnet::getsection($sdom,$slogin, |
$old{'section'} = &Apache::lonnet::getsection($sdom,$slogin, |
$env{'request.course.id'}); |
$env{'request.course.id'}); |
my ($tmp) = keys(%old); |
my ($tmp) = keys(%old); |
Line 1788 sub modify_single_student {
|
Line 2007 sub modify_single_student {
|
my $middlename = $env{'form.middlename'}; |
my $middlename = $env{'form.middlename'}; |
my $lastname = $env{'form.lastname'}; |
my $lastname = $env{'form.lastname'}; |
my $generation = $env{'form.generation'}; |
my $generation = $env{'form.generation'}; |
|
my $permanentemail = $env{'form.permanentemail'}; |
my $section = $env{'form.section'}; |
my $section = $env{'form.section'}; |
my $courseid = $env{'request.course.id'}; |
my $courseid = $env{'request.course.id'}; |
my $sid = $env{'form.id'}; |
my $sid = $env{'form.id'}; |
Line 1812 sub modify_single_student {
|
Line 2032 sub modify_single_student {
|
'mn' => "Middle name", |
'mn' => "Middle name", |
'ln' => "Last name", |
'ln' => "Last name", |
'gen' => "Generation", |
'gen' => "Generation", |
|
'em' => "E-mail address", |
'sec' => "Section", |
'sec' => "Section", |
'ri' => "Role Information", |
'ri' => "Role Information", |
'st' => "Start Time", |
'st' => "Start Time", |
'et' => "End Time", |
'et' => "End Time", |
); |
); |
$r->print(<<END); |
$r->print(<<END); |
<h2>$lt{'mdu'} $slogin : $sdom </h2> |
<h3>$lt{'mdu'} $slogin:$sdom </h3> |
<h3>$lt{'si'}</h3> |
END |
<table rules="rows" border="1" cellpadding="3" > |
$r->print(<<END); |
<tr> |
|
<th> $lt{'fd'} </th> |
|
<th> $lt{'ov'} </th> |
|
<th> $lt{'nv'} </th> |
|
</tr> |
|
<tr> |
|
<td> <b>$lt{'fn'}</b> </td> |
|
<td> $old{'firstname'} </td> |
|
<td> $firstname </td> |
|
</tr><tr> |
|
<td> <b>$lt{'mn'}</b> </td> |
|
<td> $old{'middlename'} </td> |
|
<td> $middlename </td> |
|
</tr><tr> |
|
<td> <b>$lt{'ln'}</b> </td> |
|
<td> $old{'lastname'} </td> |
|
<td> $lastname </td> |
|
</tr><tr> |
|
<td> <b>$lt{'gen'}</b> </td> |
|
<td> $old{'generation'} </td> |
|
<td> $generation </td> |
|
</tr><tr> |
|
<td> <b>ID</b> </td> |
|
<td> $old{'id'} </td> |
|
<td> $sid </td> |
|
</tr><tr> |
|
<td> <b>$lt{'sec'}</b> </td> |
|
<td> $old{'section'} </td> |
|
<td> $section</td> |
|
</tr> |
|
</table> |
|
<h3>$lt{'ri'}</h3> |
|
<table> |
<table> |
<tr><td align="right"><b>$lt{'st'}:</b></td><td> $displayable_starttime </td></tr> |
<tr> |
<tr><td align="right"><b>$lt{'et'}:</b></td><td> $displayable_endtime </td></tr> |
<td> |
|
<table class="LC_nested_outer"> |
|
<tr> |
|
<th>$lt{si}</th> |
|
</tr> |
|
<tr> |
|
<td> |
|
<table class="LC_nested"> |
|
<tr class="LC_info_row"> |
|
<td class="LC_left_item"> $lt{'fd'} </td> |
|
<td class="LC_left_item"> $lt{'ov'} </td> |
|
<td class="LC_left_item"> $lt{'nv'} </td> |
|
</tr> |
|
<tr class="LC_odd_row"> |
|
<td class="LC_left_item"> <b>$lt{'fn'}</b> </td> |
|
<td class="LC_left_item"> $old{'firstname'} </td> |
|
<td class="LC_left_item"> $firstname </td> |
|
</tr> |
|
<tr> |
|
<td class="LC_left_item"> <b>$lt{'mn'}</b> </td> |
|
<td class="LC_left_item"> $old{'middlename'} </td> |
|
<td class="LC_left_item"> $middlename </td> |
|
</tr> |
|
<tr class="LC_odd_row"> |
|
<td class="LC_left_item"> <b>$lt{'ln'}</b> </td> |
|
<td class="LC_left_item"> $old{'lastname'} </td> |
|
<td class="LC_left_item"> $lastname </td> |
|
</tr> |
|
<tr> |
|
<td class="LC_left_item"> <b>$lt{'gen'}</b> </td> |
|
<td class="LC_left_item"> $old{'generation'} </td> |
|
<td class="LC_left_item"> $generation </td> |
|
</tr> |
|
<tr class="LC_odd_row"> |
|
<td class="LC_left_item"> <b>ID</b> </td> |
|
<td class="LC_left_item"> $old{'id'} </td> |
|
<td class="LC_left_item"> $sid </td> |
|
</tr> |
|
<tr> |
|
<td class="LC_left_item"> <b>$lt{'em'}</b> </td> |
|
<td class="LC_left_item"> $old{'permanentemail'} </td> |
|
<td class="LC_left_item"> $permanentemail </td> |
|
<tr class="LC_odd_row"> |
|
<td> <b>$lt{'sec'}</b> </td> |
|
<td> $old{'section'} </td> |
|
<td> $section</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
</table> |
|
<br /> |
|
<table class="LC_nested_outer"> |
|
<tr> |
|
<th>$lt{'ri'}</th> |
|
</tr> |
|
<tr> |
|
<td> |
|
<table class="LC_nested"> |
|
<tr class="LC_odd_row"> |
|
<td class="LC_left_item"><b>$lt{'st'}:</b></td> |
|
<td class="LC_right_item"> $displayable_starttime </td> |
|
</tr> |
|
<tr> |
|
<td class="LC_left_item"><b>$lt{'et'}:</b></td> |
|
<td class="LC_right_item"> $displayable_endtime </td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
|
</table> |
|
</td> |
|
</tr> |
</table> |
</table> |
<p> |
<p> |
END |
END |
# |
# |
# Send request(s) to modify data (final undef is for 'desiredhost', |
# Send request(s) to modify data (final undef is for 'desiredhost', |
# which is a moot point because the student already has an account. |
# which is a moot point because the student already has an account. |
my $modify_section_results = &modifystudent($sdom,$slogin, |
my $modify_section_results = |
$env{'request.course.id'}, |
&Apache::lonuserutils::modifystudent($sdom,$slogin, |
$section,undef); |
$env{'request.course.id'}, |
|
$section,undef); |
if ($modify_section_results !~ /^ok/) { |
if ($modify_section_results !~ /^ok/) { |
$r->print(&mt('An error occured during the attempt to change the section for this student.')."<br />"); |
$r->print(&mt('An error occurred during the attempt to change the section for this student.')."<br />"); |
} |
} |
my $roleresults = &Apache::lonnet::modifystudent |
my $roleresults = &Apache::lonnet::modifystudent |
($sdom,$slogin,$sid,undef,undef,$firstname,$middlename,$lastname, |
($sdom,$slogin,$sid,undef,undef,$firstname,$middlename,$lastname, |
$generation,$section,$endtime,$starttime,$env{'form.forceid'}); |
$generation,$section,$endtime,$starttime,$env{'form.forceid'}, |
|
undef,$permanentemail); |
|
if ($old{'permanentemail'} ne $permanentemail) { |
|
&Apache::loncommon::flush_email_cache($slogin,$sdom); |
|
} |
if ($roleresults eq 'refused' ) { |
if ($roleresults eq 'refused' ) { |
$r->print(&mt('Your request to change the role information for this student was refused. You do not appear to have sufficient authority to change student information.')); |
$r->print(&mt('Your request to change the role information for this student was refused. You do not appear to have sufficient authority to change student information.')); |
} elsif ($roleresults !~ /ok/) { |
} elsif ($roleresults !~ /ok/) { |
Line 1930 sub get_enrollment_data {
|
Line 2196 sub get_enrollment_data {
|
return ($start,$end,$section); |
return ($start,$end,$section); |
} |
} |
|
|
################################################# |
|
################################################# |
|
|
|
=pod |
=pod |
|
|
=item show_drop_list |
=item show_drop_list() |
|
|
Display a list of students to drop |
Display a list of students to drop |
Inputs: |
Inputs: |
Line 1955 which describes the order elements are s
|
Line 2219 which describes the order elements are s
|
|
|
=cut |
=cut |
|
|
################################################# |
|
################################################# |
|
sub show_drop_list { |
sub show_drop_list { |
my ($r,$classlist,$keylist,$nosort)=@_; |
my ($r,$classlist,$keylist,$nosort)=@_; |
my $cid=$env{'request.course.id'}; |
my $cid=$env{'request.course.id'}; |
Line 2116 END
|
Line 2378 END
|
return; |
return; |
} |
} |
|
|
# |
|
# Print out the initial form to get the courselist file |
=pod |
# |
|
|
=item print_first_courselist_upload_form() |
|
|
|
Print out the initial form to get the courselist file |
|
|
|
=cut |
|
|
sub print_first_courselist_upload_form { |
sub print_first_courselist_upload_form { |
my $r=shift; |
my $r=shift; |
my $str; |
my $str; |
Line 2143 sub print_first_courselist_upload_form {
|
Line 2411 sub print_first_courselist_upload_form {
|
return; |
return; |
} |
} |
|
|
# ================================================= Drop/Add from uploaded file |
|
|
=pod |
|
|
|
=item upfile_drop_add() |
|
|
|
Drop/Add from uploaded file |
|
|
|
=cut |
|
|
sub upfile_drop_add { |
sub upfile_drop_add { |
my $r=shift; |
my $r=shift; |
&Apache::loncommon::load_tmp_file($r); |
&Apache::loncommon::load_tmp_file($r); |
Line 2320 sub upfile_drop_add {
|
Line 2596 sub upfile_drop_add {
|
$$_ =~ s/(\s+$|^\s+)//g; |
$$_ =~ s/(\s+$|^\s+)//g; |
} |
} |
if ($password || $env{'form.login'} eq 'loc') { |
if ($password || $env{'form.login'} eq 'loc') { |
&modifystudent($domain,$username,$cid,$sec, |
&Apache::lonuserutils::modifystudent($domain, |
$desiredhost); |
$username,$cid, |
|
$sec,$desiredhost); |
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, |
Line 2348 sub upfile_drop_add {
|
Line 2625 sub upfile_drop_add {
|
} |
} |
} |
} |
} # end of foreach (@studentdata) |
} # end of foreach (@studentdata) |
$r->print("</p>\n<p>\n".&mt('Processed [_1] student(s).',$count). |
$r->print("</p>\n<p>\n".&mt('Processed [quant,_1,student].',$count). |
"</p>\n"); |
"</p>\n"); |
$r->print("<p>\n". |
$r->print("<p>\n". |
&mt('If active, the new role will be available when the '. |
&mt('If active, the new role will be available when the '. |
Line 2388 sub drop_student_list {
|
Line 2665 sub drop_student_list {
|
foreach (@droplist) { |
foreach (@droplist) { |
my ($uname,$udom)=split(/\:/,$_); |
my ($uname,$udom)=split(/\:/,$_); |
# drop student |
# drop student |
my $result = &modifystudent($udom,$uname,$env{'request.course.id'}); |
my $result = &Apache::lonuserutils::modifystudent($udom,$uname, |
|
$env{'request.course.id'}); |
if ($result eq 'ok' || $result eq 'ok:') { |
if ($result eq 'ok' || $result eq 'ok:') { |
$r->print(&mt('Dropped [_1]',$uname.'@'.$udom).'<br>'); |
$r->print(&mt('Dropped [_1]',$uname.'@'.$udom).'<br>'); |
$count++; |
$count++; |
Line 2398 sub drop_student_list {
|
Line 2676 sub drop_student_list {
|
'<br />'); |
'<br />'); |
} |
} |
} |
} |
$r->print('<p><b>'.&mt('Dropped [_1] student(s).',$count).'</b></p>'); |
$r->print('<p><b>'.&mt('Dropped [quant,_1,student].',$count).'</b></p>'); |
$r->print('<p>'.&mt('Re-enrollment will re-activate data.')) if ($count); |
$r->print('<p>'.&mt('Re-enrollment will re-activate data.')) if ($count); |
} |
} |
|
|
Line 2433 sub get_permission {
|
Line 2711 sub get_permission {
|
my %permission; |
my %permission; |
$permission{'view'} = |
$permission{'view'} = |
&Apache::lonnet::allowed('vcl',$env{'request.course.id'}); |
&Apache::lonnet::allowed('vcl',$env{'request.course.id'}); |
&Apache::lonnet::logthis(" vcl 1 ".$permission{'view'}); |
|
if (!$permission{'view'}) { |
if (!$permission{'view'}) { |
my $scope = $env{'request.course.id'}.'/'.$env{'request.course.sec'}; |
my $scope = $env{'request.course.id'}.'/'.$env{'request.course.sec'}; |
$permission{'view'} = &Apache::lonnet::allowed('vcl',$scope); |
$permission{'view'} = &Apache::lonnet::allowed('vcl',$scope); |
&Apache::lonnet::logthis(" vcl 2 ".$permission{'view'}); |
|
if ($permission{'view'}) { |
if ($permission{'view'}) { |
$permission{'view_section'} = $env{'request.course.sec'}; |
$permission{'view_section'} = $env{'request.course.sec'}; |
&Apache::lonnet::logthis(" vcl 3 ".$permission{'view'}); |
|
} |
} |
} |
} |
|
|
Line 2455 sub get_permission {
|
Line 2730 sub get_permission {
|
foreach my $perm (values(%permission)) { |
foreach my $perm (values(%permission)) { |
if ($perm) { $allowed=1; last; } |
if ($perm) { $allowed=1; last; } |
} |
} |
&Apache::lonnet::logthis(" allowed ".$allowed); |
|
return (\%permission,$allowed); |
return (\%permission,$allowed); |
} |
} |
|
|
################################################################### |
|
################################################################### |
|
|
|
=pod |
=pod |
|
|
=item &handler |
=item &handler() |
|
|
The typical handler you see in all these modules. Takes $r, the |
The typical handler you see in all these modules. Takes $r, the |
http request, as an argument. |
http request, as an argument. |
Line 2491 The response to the request is governed
|
Line 2762 The response to the request is governed
|
|
|
=cut |
=cut |
|
|
################################################################### |
|
################################################################### |
|
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
if ($r->header_only) { |
if ($r->header_only) { |
Line 2533 sub handler {
|
Line 2802 sub handler {
|
# Start page |
# Start page |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
$r->print(&header()); |
|
# |
# |
# Main switch on form.action and form.state, as appropriate |
# Main switch on form.action and form.state, as appropriate |
if (! exists($env{'form.action'})) { |
if (! exists($env{'form.action'})) { |
|
$r->print(&header()); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enrollment Manager')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enrollment Manager')); |
my $action = &print_main_menu($r,$permission); |
my $action = &print_main_menu($r,$permission); |
} elsif ($env{'form.action'} eq 'upload' && $permission->{'enrl'}) { |
} elsif ($env{'form.action'} eq 'upload' && $permission->{'enrl'}) { |
|
$r->print(&header()); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>'/adm/dropadd?action=upload&state=', |
({href=>'/adm/dropadd?action=upload&state=', |
text=>"Upload Classlist"}); |
text=>"Upload Classlist"}); |
Line 2559 sub handler {
|
Line 2829 sub handler {
|
&print_first_courselist_upload_form($r); |
&print_first_courselist_upload_form($r); |
} |
} |
} elsif ($env{'form.action'} eq 'drop' && $permission->{'enrl'}) { |
} elsif ($env{'form.action'} eq 'drop' && $permission->{'enrl'}) { |
|
$r->print(&header()); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>'/adm/dropadd?action=drop', |
({href=>'/adm/dropadd?action=drop', |
text=>"Drop Students"}); |
text=>"Drop Students"}); |
Line 2572 sub handler {
|
Line 2843 sub handler {
|
&print_drop_menu($r); |
&print_drop_menu($r); |
} |
} |
} elsif ($env{'form.action'} eq 'enrollstudent' && $permission->{'enrl'}) { |
} elsif ($env{'form.action'} eq 'enrollstudent' && $permission->{'enrl'}) { |
&Apache::lonhtmlcommon::add_breadcrumb |
my @search = ('srchterm','srchby','srchin','srchtype','srchdomain'); |
({href=>'/adm/dropadd?action=enrollstudent', |
my ($jsback,$elements) = &Apache::loncreateuser::crumb_utilities(); |
text=>"Enroll Student"}); |
my $jscript = '<script type="text/javascript">'.$jsback.'</script>'; |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enroll Student', |
&Apache::loncreateuser::restore_prev_selections(); |
'Course_Add_Student')); |
my $srch; |
if (! exists($env{'form.state'})) { |
foreach my $item (@search) { |
&get_student_username_domain_form($r); |
$srch->{$item} = $env{'form.'.$item}; |
} elsif ($env{'form.state'} eq 'gotusername') { |
} |
&print_enroll_single_student_form($r); |
|
|
if ($env{'form.state'} eq 'gotusername') { |
|
if ($env{'form.phase'} eq 'get_user_info') { |
|
my ($currstate,$response,$forcenewuser,$results) = |
|
&Apache::loncreateuser::user_search_result($srch); |
|
if ($env{'form.currstate'} eq 'modify') { |
|
$currstate = $env{'form.currstate'}; |
|
} |
|
if ($currstate eq 'select') { |
|
$r->print(&header()); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:backPage(document.usersrchform,'','')", |
|
text=>"Single user search"}, |
|
{href=>"javascript:backPage(document.usersrchform,'get_user_info','select')", |
|
text=>"Select User",}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enroll Student', |
|
'Course_Add_Student')); |
|
&Apache::loncreateuser::print_user_selection_page($r, |
|
$response,$srch,$results,'enrollstudent',\@search); |
|
} elsif ($currstate eq 'modify') { |
|
my ($ccuname,$ccdomain); |
|
if (($srch->{'srchby'} eq 'uname') && |
|
($srch->{'srchtype'} eq 'exact')) { |
|
$ccuname = $srch->{'srchterm'}; |
|
$ccdomain= $srch->{'srchdomain'}; |
|
} else { |
|
my @matchedunames = keys(%{$results}); |
|
($ccuname,$ccdomain) = split(/:/,$matchedunames[0]); |
|
} |
|
$ccuname =&LONCAPA::clean_username($ccuname); |
|
$ccdomain=&LONCAPA::clean_domain($ccdomain); |
|
&print_enroll_single_student_form($r,$jscript,$ccuname, |
|
$ccdomain,$srch,$response); |
|
} elsif ($currstate eq 'query') { |
|
$r->print(&header($jscript)); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:backPage(document.studentform,'','')", |
|
text=>"Single user search"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enroll Student', |
|
'Course_Add_Student')); |
|
&Apache::loncreateuser::print_user_query_page($r,'enrollstudent'); |
|
} else { |
|
&get_student_username_domain_form($r,$elements,$response, |
|
$srch,$forcenewuser); |
|
} |
|
} elsif ($env{'form.phase'} eq 'userpicked') { |
|
my $ccuname = &LONCAPA::clean_username($env{'form.seluname'}); |
|
my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'}); |
|
&print_enroll_single_student_form($r,$jscript,$ccuname, |
|
$ccdomain,$srch); |
|
} else { |
|
&get_student_username_domain_form($r,$elements,undef,$srch); |
|
} |
} elsif ($env{'form.state'} eq 'enrolling') { |
} elsif ($env{'form.state'} eq 'enrolling') { |
&enroll_single_student($r); |
$r->print(&header($jscript)); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:backPage(document.studentform,'','')", |
|
text=>"Single user search"}); |
|
if ($env{'form.prevphase'} eq 'userpicked') { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:backPage(document.studentform,'get_user_info','select')", |
|
text=>"Select user",}); |
|
} |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:backPage(document.studentform,'$env{'form.prevphase'}','modify')", |
|
text=>"Set enrollment",}, |
|
{href=>"javascript:backPage(document.studentform,$env{'form.phase'},'')", |
|
text=>"Result",}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enroll Student', |
|
'Course_Add_Student')); |
|
&enroll_single_student($r,\@search); |
} else { |
} else { |
&get_student_username_domain_form($r); |
&get_student_username_domain_form($r,$elements,undef,$srch); |
} |
} |
} elsif ($env{'form.action'} eq 'classlist' && $permission->{'view'}) { |
} elsif ($env{'form.action'} eq 'classlist' && $permission->{'view'}) { |
|
$r->print(&header()); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>'/adm/dropadd?action=classlist', |
({href=>'/adm/dropadd?action=classlist', |
text=>"View Classlist"}); |
text=>"View Classlist"}); |
Line 2602 sub handler {
|
Line 2942 sub handler {
|
&print_html_classlist($r,undef,$permission); |
&print_html_classlist($r,undef,$permission); |
} |
} |
} elsif ($env{'form.action'} eq 'modifystudent' && $permission->{'enrl'}) { |
} elsif ($env{'form.action'} eq 'modifystudent' && $permission->{'enrl'}) { |
|
$r->print(&header()); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>'/adm/dropadd?action=modifystudent', |
({href=>'/adm/dropadd?action=modifystudent', |
text=>"Modify Student Data"}); |
text=>"Modify Student Data"}); |
Line 2621 sub handler {
|
Line 2962 sub handler {
|
&Apache::lonnet::logthis("Undetermined state in londropadd.pm. ". |
&Apache::lonnet::logthis("Undetermined state in londropadd.pm. ". |
"form.action = ".$env{'form.action'}. |
"form.action = ".$env{'form.action'}. |
"Someone should fix this."); |
"Someone should fix this."); |
|
$r->print(&header()); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enrollment Manager')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Enrollment Manager')); |
&print_main_menu($r,$permission); |
&print_main_menu($r,$permission); |
} |
} |
Line 2630 sub handler {
|
Line 2972 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
################################################################### |
|
################################################################### |
|
|
|
1; |
1; |
__END__ |
__END__ |
|
|
|
=pod |
|
|
|
=back |
|
|
|
=cut |