--- loncom/interface/Attic/londropadd.pm 2005/03/10 17:33:57 1.126
+++ loncom/interface/Attic/londropadd.pm 2007/07/26 23:56:35 1.165
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.126 2005/03/10 17:33:57 matthew Exp $
+# $Id: londropadd.pm,v 1.165 2007/07/26 23:56:35 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -32,26 +32,22 @@
package Apache::londropadd;
use strict;
-use Apache::lonnet();
+use Apache::lonnet;
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::Constants qw(:common :http REDIRECT);
use Spreadsheet::WriteExcel;
use Apache::lonstathelpers();
use Apache::lonlocal;
+use Apache::longroup;
+use LONCAPA();
###############################################################
###############################################################
sub header {
- my $html=&Apache::lonxml::xmlbegin();
- my $bodytag=&Apache::loncommon::bodytag('Enrollment Manager');
- my $title = &mt('LON-CAPA Enrollment Manager');
+ my $start_page=&Apache::loncommon::start_page('Enrollment Manager');
return(<
\n".''; + $Str .= "
\n".'
\n"; - $Str .= '\n
\n";
+ $Str .= ''."
\n";
$Str .= &mt('Note: for large courses, this operation may be time '.
'consuming');
@@ -639,14 +667,14 @@ sub print_upload_manager_form {
my $firstLine;
my $datatoken;
- if (!$ENV{'form.datatoken'}) {
+ if (!$env{'form.datatoken'}) {
$datatoken=&Apache::loncommon::upfile_store($r);
} else {
- $datatoken=$ENV{'form.datatoken'};
+ $datatoken=$env{'form.datatoken'};
&Apache::loncommon::load_tmp_file($r);
}
my @records=&Apache::loncommon::upfile_record_sep();
- if($ENV{'form.noFirstLine'}){
+ if($env{'form.noFirstLine'}){
$firstLine=shift(@records);
}
my $total=$#records;
@@ -669,7 +697,7 @@ sub print_upload_manager_form {
});
#
# Determine kerberos parameters as appropriate
- my $defdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+ my $defdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
my ($krbdef,$krbdefdom) =
&Apache::loncommon::get_kerberos_defaults($defdom);
#
@@ -678,17 +706,17 @@ sub print_upload_manager_form {
my $keyfields;
if ($total>=0) {
my @field=
- (['username',&mt('Username'), $ENV{'form.username_choice'}],
- ['names',&mt('Last Name, First Names'),$ENV{'form.names_choice'}],
- ['fname',&mt('First Name'), $ENV{'form.fname_choice'}],
- ['mname',&mt('Middle Names/Initials'),$ENV{'form.mname_choice'}],
- ['lname',&mt('Last Name'), $ENV{'form.lname_choice'}],
- ['gen', &mt('Generation'), $ENV{'form.gen_choice'}],
- ['id', &mt('ID/Student Number'),$ENV{'form.id_choice'}],
- ['sec', &mt('Group/Section'), $ENV{'form.sec_choice'}],
- ['ipwd', &mt('Initial Password'),$ENV{'form.ipwd_choice'}],
- ['email',&mt('EMail Address'), $ENV{'form.email_choice'}]);
- if ($ENV{'form.upfile_associate'} eq 'reverse') {
+ (['username',&mt('Username'), $env{'form.username_choice'}],
+ ['names',&mt('Last Name, First Names'),$env{'form.names_choice'}],
+ ['fname',&mt('First Name'), $env{'form.fname_choice'}],
+ ['mname',&mt('Middle Names/Initials'),$env{'form.mname_choice'}],
+ ['lname',&mt('Last Name'), $env{'form.lname_choice'}],
+ ['gen', &mt('Generation'), $env{'form.gen_choice'}],
+ ['id', &mt('ID/Student Number'),$env{'form.id_choice'}],
+ ['sec', &mt('Section'), $env{'form.sec_choice'}],
+ ['ipwd', &mt('Initial Password'),$env{'form.ipwd_choice'}],
+ ['email',&mt('EMail Address'), $env{'form.email_choice'}]);
+ if ($env{'form.upfile_associate'} eq 'reverse') {
&Apache::loncommon::csv_print_samples($r,\@records);
$i=&Apache::loncommon::csv_print_select_table($r,\@records,
\@field);
@@ -712,29 +740,33 @@ sub print_upload_manager_form {
sub enroll_single_student {
my $r=shift;
# Remove non alphanumeric values from section
- $ENV{'form.csec'}=~s/\W//g;
+ $env{'form.csec'}=~s/\W//g;
#
# We do the dates first because the action of making them the defaul
# 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
# to the process of enrolling / modifying a student.
my ($startdate,$enddate) = &get_dates_from_form();
- if ($ENV{'form.makedatesdefault'}) {
+ if ($env{'form.makedatesdefault'}) {
$r->print(&make_dates_default($startdate,$enddate));
}
$r->print('
'.&mt('Enrolling').' '.$ENV{'form.cuname'}." \@ ". - $ENV{'form.lcdomain'}.'
'); - if (($ENV{'form.cuname'})&&($ENV{'form.cuname'}!~/\W/)&& - ($ENV{'form.lcdomain'})&&($ENV{'form.lcdomain'}!~/\W/)) { + $r->print(''.&mt('Enrolling [_1] : [_2]',$env{'form.cuname'}, + $env{'form.lcdomain'}).'
'); + if (($env{'form.cuname'}) + && ($env{'form.cuname'} + eq &LONCAPA::clean_username($env{'form.cuname'})) + && ($env{'form.lcdomain'}) + && ($env{'form.lcdomain'} + eq &LONCAPA::clean_domain($env{'form.lcdomain'}))) { # Deal with home server selection - my $domain=$ENV{'form.lcdomain'}; - my $desiredhost = $ENV{'form.lcserver'}; + my $domain=$env{'form.lcdomain'}; + my $desiredhost = $env{'form.lcserver'}; if (lc($desiredhost) eq 'default') { $desiredhost = undef; } else { - my %home_servers =&Apache::loncommon::get_library_servers($domain); + my %home_servers =&Apache::lonnet::get_servers($domain,'library'); if (! exists($home_servers{$desiredhost})) { $r->print(''.&mt('Error').':'. &mt('Invalid home server specified')); @@ -745,33 +777,33 @@ sub enroll_single_student { # End of home server selection logic my $amode=''; my $genpwd=''; - if ($ENV{'form.login'} eq 'krb') { + if ($env{'form.login'} eq 'krb') { $amode='krb'; - $amode.=$ENV{'form.krbver'}; - $genpwd=$ENV{'form.krbarg'}; - } elsif ($ENV{'form.login'} eq 'int') { + $amode.=$env{'form.krbver'}; + $genpwd=$env{'form.krbarg'}; + } elsif ($env{'form.login'} eq 'int') { $amode='internal'; - $genpwd=$ENV{'form.intarg'}; - } elsif ($ENV{'form.login'} eq 'loc') { + $genpwd=$env{'form.intarg'}; + } elsif ($env{'form.login'} eq 'loc') { $amode='localauth'; - $genpwd=$ENV{'form.locarg'}; + $genpwd=$env{'form.locarg'}; if (!$genpwd) { $genpwd=" "; } } - my $home = &Apache::lonnet::homeserver($ENV{'form.cuname'}, - $ENV{'form.lcdomain'}); + my $home = &Apache::lonnet::homeserver($env{'form.cuname'}, + $env{'form.lcdomain'}); if ((($amode) && ($genpwd)) || ($home ne 'no_host')) { # Clean out any old roles the student has in this class. - &modifystudent($ENV{'form.lcdomain'},$ENV{'form.cuname'}, - $ENV{'request.course.id'},$ENV{'form.csec'}, + &modifystudent($env{'form.lcdomain'},$env{'form.cuname'}, + $env{'request.course.id'},$env{'form.csec'}, $desiredhost); my $login_result = &Apache::lonnet::modifystudent - ($ENV{'form.lcdomain'},$ENV{'form.cuname'}, - $ENV{'form.cstid'},$amode,$genpwd, - $ENV{'form.cfirst'},$ENV{'form.cmiddle'}, - $ENV{'form.clast'},$ENV{'form.cgen'}, - $ENV{'form.csec'},$enddate, - $startdate,$ENV{'form.forceid'}, - $desiredhost,$ENV{'form.emailaddress'}); + ($env{'form.lcdomain'},$env{'form.cuname'}, + $env{'form.cstid'},$amode,$genpwd, + $env{'form.cfirst'},$env{'form.cmiddle'}, + $env{'form.clast'},$env{'form.cgen'}, + $env{'form.csec'},$enddate, + $startdate,$env{'form.forceid'}, + $desiredhost,$env{'form.emailaddress'}); if ($login_result =~ /^ok/) { $r->print($login_result); $r->print("".&mt('If active, the new role will be available when the student next logs in to LON-CAPA.')."
"); @@ -785,11 +817,12 @@ sub enroll_single_student { } else { $r->print(&mt('Invalid login mode or password.').' '); } - $r->print(''.&mt('Unable to enroll').' '.$ENV{'form.cuname'}.'.'); + $r->print(''.&mt('Unable to enroll').' '.$env{'form.cuname'}.'.'); } } else { $r->print(&mt('Invalid username or domain')); } + $r->print("".&mt("Enroll another student")."
"); } sub setup_date_selectors { @@ -797,9 +830,9 @@ sub setup_date_selectors { if (! defined($starttime)) { $starttime = time; unless ($mode eq 'create_enrolldates' || $mode eq 'create_defaultdates') { - if (exists($ENV{'course.'.$ENV{'request.course.id'}. + if (exists($env{'course.'.$env{'request.course.id'}. '.default_enrollment_start_date'})) { - $starttime = $ENV{'course.'.$ENV{'request.course.id'}. + $starttime = $env{'course.'.$env{'request.course.id'}. '.default_enrollment_start_date'}; } } @@ -807,9 +840,9 @@ sub setup_date_selectors { if (! defined($endtime)) { $endtime = time+(6*30*24*60*60); # 6 months from now, approx unless ($mode eq 'createcourse') { - if (exists($ENV{'course.'.$ENV{'request.course.id'}. + if (exists($env{'course.'.$env{'request.course.id'}. '.default_enrollment_end_date'})) { - $endtime = $ENV{'course.'.$ENV{'request.course.id'}. + $endtime = $env{'course.'.$env{'request.course.id'}. '.default_enrollment_end_date'}; } } @@ -842,7 +875,7 @@ sub setup_date_selectors { sub get_dates_from_form { my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate'); my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate'); - if ($ENV{'form.no_end_date'}) { + if ($env{'form.no_end_date'}) { $enddate = 0; } return ($startdate,$enddate); @@ -852,16 +885,17 @@ sub date_setting_table { my ($starttime,$endtime,$mode) = @_; my ($startform,$endform)=&setup_date_selectors($starttime,$endtime,$mode); my $dateDefault = '$lt{'usr'}: | +|
---|---|
: | |
$lt{'dom'}: | +|
: | $domform |
+ | |