--- loncom/interface/Attic/londropadd.pm 2007/07/26 23:56:35 1.165
+++ loncom/interface/Attic/londropadd.pm 2008/09/11 14:47:21 1.174
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.165 2007/07/26 23:56:35 albertel Exp $
+# $Id: londropadd.pm,v 1.174 2008/09/11 14:47:21 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -45,7 +45,13 @@ use LONCAPA();
###############################################################
###############################################################
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(< 'Create a new group',
help => 'Course_Create_Group',
permission => $permission->{'grp_manage'},
- url => '/adm/coursegroups?refpage=enrl&action=create',
+ url => '/adm/coursegroups?refpage=enrl&action=create',
},
{ text => 'Modify an existing group',
help => 'Course_Modify_Group',
permission => $permission->{'grp_manage'},
- url => '/adm/coursegroups?refpage=enrl&action=modify',
+ url => '/adm/coursegroups?refpage=enrl&action=modify',
},
{ text => 'Delete an existing group',
help => 'Course_Delete_Group',
permission => $permission->{'grp_manage'},
- url => '/adm/coursegroups?refpage=enrl&action=delete',
+ url => '/adm/coursegroups?refpage=enrl&action=delete',
},
{ text => 'Re-enable a deleted group',
help => 'Course_Reenable_Group',
permission => $permission->{'grp_manage'},
- url => '/adm/coursegroups?refpage=enrl&action=reenable',
+ url => '/adm/coursegroups?refpage=enrl&action=reenable',
},
{ text => 'Enter an existing group',
help => 'Course_Display_Group',
permission => $permission->{'grp_view'},
- url => '/adm/coursegroups?refpage=enrl&action=view',
+ url => '/adm/coursegroups?refpage=enrl&action=view',
},
);
my $menu_html = '';
@@ -256,8 +262,9 @@ sub print_upload_manager_header {
$password_choice = 'int';
}
#
- my $javascript_validations=&javascript_validations('auth',$krbdefdom,
- $password_choice);
+ my $javascript_validations =
+ &javascript_validations('auth',$krbdefdom,$password_choice,undef,
+ $env{'request.role.domain'});
my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':'');
$r->print('
'.&mt('Uploading Class List')."
\n".
"\n".
@@ -287,7 +294,7 @@ sub print_upload_manager_header {
###############################################################
###############################################################
sub javascript_validations {
- my ($mode,$krbdefdom,$curr_authtype,$curr_authfield)=@_;
+ my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain)=@_;
my $authheader;
if ($mode eq 'auth') {
my %param = ( formname => 'studentform',
@@ -296,7 +303,7 @@ sub javascript_validations {
$authheader = &Apache::loncommon::authform_header(%param);
} elsif ($mode eq 'createcourse') {
my %param = ( formname => 'ccrs',
- kerb_def_dom => $krbdefdom,
+ kerb_def_dom => $krbdefdom,
curr_authtype => $curr_authtype );
$authheader = &Apache::loncommon::authform_header(%param);
} elsif ($mode eq 'modifycourse') {
@@ -325,6 +332,7 @@ sub javascript_validations {
my $function_name =(< 1) {
+ $auth_checks .= (<".&mt("Enroll another student")."
");
+ if (ref($srcharray) eq 'ARRAY') {
+ foreach my $item (@{$srcharray},'ccuname','ccdomain') {
+ $r->print(''."\n");
+ }
+ }
+ foreach my $item ('sortby','seluname','seludom') {
+ if (exists($env{'form.'.$item})) {
+ $r->print(''."\n");
+ }
+ }
+ $r->print(''."\n".
+ ''."\n".
+ ''."\n".
+ ''."\n".
+ '');
}
sub setup_date_selectors {
@@ -936,9 +965,23 @@ sub make_dates_default {
## Single student enrollment routines (some of them)
##
sub get_student_username_domain_form {
- my $r = shift;
- my $domform = &Apache::loncommon::select_dom_form
- ($env{'course.'.$env{'request.course.id'}.'.domain'},'cudomain',0);
+ my ($r,$elements,$response,$srch,$forcenewuser) = @_;
+ my $loaditems = {
+ '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".
+ ''."\n";
+
my %lt=&Apache::lonlocal::texthash(
'eos' => "Enroll One Student",
'usr' => "Username",
@@ -946,34 +989,49 @@ sub get_student_username_domain_form {
'been' => "Begin Enrollment",
);
$r->print(<
-
+$jscript
$lt{'eos'}
-
-
:
-
-
:
-
$domform
-
-
-
-
-
-
END
+ $r->print($response);
+ $r->print(&single_user_entry_form($defdom,$srch,$forcenewuser));
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";
+
+
+
+$userpicker
+
+ENDDOCUMENT
+ return $output;
+}
+
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("
".&mt('Enroll One Student')."
");
#
- my $username = &LONCAPA::clean_username($env{'form.cuname'});
- my $domain = &LONCAPA::clean_domain($env{'form.cudomain'});
- my $home = &Apache::lonnet::homeserver($username,$domain);
+ my $home = &Apache::lonnet::homeserver($ccuname,$ccdomain);
# $new_user flags whether we are creating a new user or using an old one
my $new_user = 1;
if ($home ne 'no_host') {
@@ -983,11 +1041,34 @@ sub print_enroll_single_student_form {
my $user_data_html = '';
my $javascript_validations = '';
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'};
# Set up authentication forms
my ($krbdef,$krbdefdom) =
- &Apache::loncommon::get_kerberos_defaults($domain);
- $javascript_validations=&javascript_validations('auth',$krbdefdom);
+ &Apache::loncommon::get_kerberos_defaults($ccdomain);
+ $javascript_validations =
+ &Apache::lonuserutils::javascript_validations('auth',$krbdefdom,
+ undef,undef,$ccdomain);
my %param = ( formname => 'document.studentform',
kerb_def_dom => $krbdefdom,
kerb_def_auth => $krbdef
@@ -998,7 +1079,7 @@ sub print_enroll_single_student_form {
#
# Set up domain selection form
my $homeserver_form = '';
- my %servers = &Apache::lonnet::get_servers($domain,'library');
+ my %servers = &Apache::lonnet::get_servers($ccdomain,'library');
$homeserver_form = '