--- loncom/interface/Attic/londropadd.pm 2003/06/20 18:34:52 1.67
+++ loncom/interface/Attic/londropadd.pm 2003/11/06 20:04:06 1.88
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.67 2003/06/20 18:34:52 matthew Exp $
+# $Id: londropadd.pm,v 1.88 2003/11/06 20:04:06 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -32,7 +32,7 @@
# (TeX Content Handler
#
###############################################################
-###############################################################
+##############################################################
package Apache::londropadd;
@@ -42,15 +42,17 @@ use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::Constants qw(:common :http REDIRECT);
use Spreadsheet::WriteExcel;
+use Apache::lonlocal;
###############################################################
###############################################################
sub header {
my $bodytag=&Apache::loncommon::bodytag('Enrollment Manager');
+ my $title = &mt('LON-CAPA Enrollment Manager');
return(<
- Enroll a single student + $Text{'enrollone'}
- Modify student data + $Text{'modify'}
- View Classlist + $Text{'view'}
- Drop Students + $Text{'drop'}
END @@ -182,11 +194,15 @@ sub print_upload_manager_header { $javascript=&upload_manager_javascript_forward_associate(); } my $javascript_validations=&javascript_validations($krbdefdom); + my $checked=(($ENV{'form.noFirstLine'})?' checked="1"':''); + $r->print('\n". + &mt('Total number of records found in file: [_1].',$distotal). + "\n". + "
Note: this will not take effect if the user already exists
@@ -484,18 +501,9 @@ $locform
+
+$date_table +
@@ -511,7 +519,7 @@ ENDPICK # ======================================================= Menu Phase Two Upload sub print_upload_manager_form { my $r=shift; - + my $firstLine; my $datatoken; if (!$ENV{'form.datatoken'}) { $datatoken=&Apache::loncommon::upfile_store($r); @@ -520,11 +528,12 @@ sub print_upload_manager_form { &Apache::loncommon::load_tmp_file($r); } my @records=&Apache::loncommon::upfile_record_sep(); + if($ENV{'form.noFirstLine'}){$firstLine=shift(@records);} my $total=$#records; my $distotal=$total+1; my $today=time; my $halfyear=$today+15552000; - my $defdom=$r->dir_config('lonDefDomain'); + my $defdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; my ($krbdef,$krbdefdom) = &Apache::loncommon::get_kerberos_defaults($defdom); &print_upload_manager_header($r,$datatoken,$distotal,$krbdefdom); @@ -539,7 +548,8 @@ sub print_upload_manager_form { ['gen','Generation'], ['id','ID/Student Number'], ['sec','Group/Section'], - ['ipwd','Initial Password']); + ['ipwd','Initial Password'], + ['email','EMail Address']); if ($ENV{'form.upfile_associate'} eq 'reverse') { &Apache::loncommon::csv_print_samples($r,\@records); $i=&Apache::loncommon::csv_print_select_table($r,\@records,\@d); @@ -558,6 +568,18 @@ sub print_upload_manager_form { # ======================================================= Enroll single student sub enroll_single_student { my $r=shift; + # Remove non alphanumeric values from section + $ENV{'form.csec'}=~s/\W//g; + # + # We do the dates first because the action of making them the defaul + # in the course is entirely seperate from the action of enrolling the + # student. Also, a failure in setting the dates as default is not fatal + # to the process of enrolling / modifying a student. + my ($startdate,$enddate) = &get_dates_from_form(); + if ($ENV{'form.makedatesdefault'}) { + $r->print(&make_dates_default($startdate,$enddate)); + } + $r->print('
Enrolling '.$ENV{'form.cuname'}." \@ ". $ENV{'form.lcdomain'}.'
'); @@ -599,12 +621,6 @@ sub enroll_single_student { &modifystudent($ENV{'form.lcdomain'},$ENV{'form.cuname'}, $ENV{'request.course.id'},$ENV{'form.csec'}, $desiredhost); - my $startdate = - &Apache::lonhtmlcommon::get_date_from_form('startdate'); - my $enddate = - &Apache::lonhtmlcommon::get_date_from_form('enddate'); - &Apache::lonnet::logthis('startdate = '.$startdate); - &Apache::lonnet::logthis('enddate = '.$enddate); my $login_result = &Apache::lonnet::modifystudent ($ENV{'form.lcdomain'},$ENV{'form.cuname'}, $ENV{'form.cstid'},$amode,$genpwd, @@ -621,46 +637,36 @@ sub enroll_single_student { $r->print("unable to enroll: ".$login_result); } } else { - $r->print('ERROR '. - 'Invalid login mode or password. '. - 'Unable to enroll '.$ENV{'form.cuname'}.'.
'); - } + $r->print('ERROR '); + if ($amode =~ /^krb/) { + $r->print('Missing Kerberos domain information. '); + } else { + $r->print('Invalid login mode or password. '); + } + $r->print('Unable to enroll '.$ENV{'form.cuname'}.'.
'); + } } else { $r->print('Invalid username or domain'); } } -# ======================================================= Menu Phase Two Enroll -sub print_enroll_single_student_form { - my $r=shift; - $r->print("Starting Date | '. + ''.$startform.' | '. + ''.$dateDefault.' | '."
Ending Date | '. + ''.$endform.' | '. + ''.$perpetual.' | '."
Username: | +|
---|---|
Domain: | +$domform |
+ | + + |
First Name: | +|
---|---|
Middle Name: | +|
Last Name: | +|
Generation: | +|
Home Server: | +$homeserver_form |
First Name: | ++ + |
---|---|
Middle Name: | ++ + |
Last Name: | ++ + |
Generation: | ++ + |
First Name: | |
Middle Name: | |
Last Name: | |
Generation: |
Username:
-Domain: $domform
-Note: login settings below will not take effect if the user already exists -
-$krbform -
-$intform -
-$locform -
+$user_data_html
Group/Section:
- - - - - - -
-
Starting Date | $startdateform |
Ending Date | $enddateform |
@@ -789,7 +943,7 @@ sub print_html_classlist {
-Current Classlist +Current Class List END if ($ENV{'form.action'} ne 'modifystudent') { @@ -894,7 +1048,7 @@ END $excel_workbook->set_tempdir('/home/httpd/perl/tmp'); $excel_sheet = $excel_workbook->addworksheet('classlist'); # - my $description = 'Classlist for '. + my $description = 'Class List for '. $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; $excel_sheet->write($row++,0,$description); # @@ -1006,13 +1160,13 @@ sub print_modify_student_form { } # determine the students starting and ending times and section my ($starttime,$endtime,$section) = &get_enrollment_data($sname,$sdom); + if ($starttime =~ /^error/) { + $r->print('
'.$starttime.'
'); + return; + } # Deal with date forms - my $startdateform = &Apache::lonhtmlcommon::date_setter('studentform', - 'startdate', - $starttime); - my $enddateform = &Apache::lonhtmlcommon::date_setter('studentform', - 'enddate', - $endtime); + my $date_table = &date_setting_table($starttime,$endtime); # if (! exists($ENV{'form.Status'}) || $ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) { @@ -1052,12 +1206,8 @@ Disable ID/Student Number Safeguard and (only do if you know what you are doing)Section: -
-
Starting Date: | $startdateform |
Ending Date: | $enddateform |
$date_table