--- loncom/interface/Attic/londropadd.pm 2003/12/12 18:04:38 1.94
+++ loncom/interface/Attic/londropadd.pm 2005/06/03 16:27:26 1.130
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.94 2003/12/12 18:04:38 sakharuk Exp $
+# $Id: londropadd.pm,v 1.130 2005/06/03 16:27:26 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,11 +25,6 @@
#
# http://www.lon-capa.org/
#
-# (Handler to set parameters for assessments
-#
-# (Handler to resolve ambiguous file locations
-#
-# (TeX Content Handler
#
###############################################################
##############################################################
@@ -37,20 +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;
###############################################################
###############################################################
sub header {
+ my $html=&Apache::lonxml::xmlbegin();
my $bodytag=&Apache::loncommon::bodytag('Enrollment Manager');
my $title = &mt('LON-CAPA Enrollment Manager');
return(<
- - $Text{'enrollone'} - -
- - $Text{'modify'} - -
- - $Text{'view'} - -
- - $Text{'drop'} - -
- - $Text{'populate'} - -END + my ($r,$enrl_permission,$view_permission)=@_; + # + my ($cdom,$cnum) = split/_/,$env{'request.course.id'}; + my @menu = + ( + { text => 'Upload a class list', + help => 'Course_Create_Class_List', + action => 'upload', + permission => $enrl_permission, + }, + { text => 'Enroll a single student', + help => 'Course_Add_Student', + action => 'enrollstudent', + permission => $enrl_permission, + }, + { text => 'Modify student data', + help => 'Course_Modify_Student_Data', + action => 'modifystudent', + permission => $enrl_permission, + }, + { text => 'View Class List', + help => 'Course_View_Class_List', + action => 'classlist', + permission => $view_permission, + }, + { text => 'Drop Students', + help => 'Course_Drop_Student', + action => 'drop', + permission => $enrl_permission, + }, + { text => 'Automated Enrollment Manager', + permission => &Apache::lonnet::auto_run($cnum,$cdom), + url => '/adm/populate', + }, + ); + my $menu_html = ''; + foreach my $menu_item (@menu) { + next if (! $menu_item->{'permission'}); + $menu_html.='
'; + $menu_html.=''; + if (exists($menu_item->{'url'})) { + $menu_html.=qq{}; + } else { + $menu_html.= + qq{}; + } + $menu_html.= &mt($menu_item->{'text'}).''; + if (exists($menu_item->{'help'})) { + $menu_html.= + &Apache::loncommon::help_open_topic($menu_item->{'help'}); + } + $menu_html.='
'.$/; + } + $r->print($menu_html); + return; } ############################################################### @@ -187,23 +204,37 @@ sub hidden_input { sub print_upload_manager_header { my ($r,$datatoken,$distotal,$krbdefdom)=@_; my $javascript; - if (! exists($ENV{'form.upfile_associate'})) { - $ENV{'form.upfile_associate'} = 'forward'; + # + if (! exists($env{'form.upfile_associate'})) { + $env{'form.upfile_associate'} = 'forward'; } - if ($ENV{'form.associate'} eq 'Reverse Association') { - if ( $ENV{'form.upfile_associate'} ne 'reverse' ) { - $ENV{'form.upfile_associate'} = 'reverse'; + if ($env{'form.associate'} eq 'Reverse Association') { + if ( $env{'form.upfile_associate'} ne 'reverse' ) { + $env{'form.upfile_associate'} = 'reverse'; } else { - $ENV{'form.upfile_associate'} = 'forward'; + $env{'form.upfile_associate'} = 'forward'; } } - if ($ENV{'form.upfile_associate'} eq 'reverse') { + if ($env{'form.upfile_associate'} eq 'reverse') { $javascript=&upload_manager_javascript_reverse_associate(); } else { $javascript=&upload_manager_javascript_forward_associate(); } - my $javascript_validations=&javascript_validations('auth',$krbdefdom); - my $checked=(($ENV{'form.noFirstLine'})?' checked="1"':''); + # + # Deal with restored settings + my $password_choice = ''; + if (exists($env{'form.ipwd_choice'}) && + $env{'form.ipwd_choice'} ne '') { + # If a column was specified for password, assume it is for an + # internal password. This is a bug waiting to be filed (could be + # local or krb auth instead of internal) but I do not have the + # time to mess around with this now. + $password_choice = 'int'; + } + # + my $javascript_validations=&javascript_validations('auth',$krbdefdom, + $password_choice); + my $checked=(($env{'form.noFirstLine'})?' checked="1"':''); $r->print('\n". &mt('Note: this will not take effect if the user already exists'). + &Apache::loncommon::help_open_topic('Auth_Options'). "
\n"; $Str .= $krbform."\n
\n". $intform."\n
\n". @@ -543,7 +626,7 @@ sub print_upload_manager_footer { 'of Conflicting IDs (only do if you know what you are doing)'). "\n
\n";
$Str .= ''."
\n";
+ 'value="Update Class List" />'."
\n";
$Str .= &mt('Note: for large courses, this operation may be time '.
'consuming');
$r->print($Str);
@@ -554,40 +637,59 @@ sub print_upload_manager_footer {
###############################################################
sub print_upload_manager_form {
my $r=shift;
+
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;
my $distotal=$total+1;
my $today=time;
my $halfyear=$today+15552000;
- my $defdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+ #
+ # Restore memorized settings
+ &Apache::loncommon::restore_course_settings
+ ('enrollment_upload',{ 'username_choice' => 'scalar', # column settings
+ 'names_choice' => 'scalar',
+ 'fname_choice' => 'scalar',
+ 'mname_choice' => 'scalar',
+ 'lname_choice' => 'scalar',
+ 'gen_choice' => 'scalar',
+ 'id_choice' => 'scalar',
+ 'sec_choice' => 'scalar',
+ 'ipwd_choice' => 'scalar',
+ 'email_choice' => 'scalar',
+ });
+ #
+ # Determine kerberos parameters as appropriate
+ 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);
my $i;
my $keyfields;
if ($total>=0) {
- my @field=(['username',&mt('Username')],
- ['names',&mt('Last Name, First Names')],
- ['fname',&mt('First Name')],
- ['mname',&mt('Middle Names/Initials')],
- ['lname',&mt('Last Name')],
- ['gen',&mt('Generation')],
- ['id',&mt('ID/Student Number')],
- ['sec',&mt('Group/Section')],
- ['ipwd',&mt('Initial Password')],
- ['email',&mt('EMail Address')]);
- if ($ENV{'form.upfile_associate'} eq 'reverse') {
+ 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') {
&Apache::loncommon::csv_print_samples($r,\@records);
$i=&Apache::loncommon::csv_print_select_table($r,\@records,
\@field);
@@ -611,25 +713,25 @@ 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 seperate 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
# 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').' '.$env{'form.cuname'}." \@ ". + $env{'form.lcdomain'}.'
'); + if (($env{'form.cuname'})&&($env{'form.cuname'}!~/\W/)&& + ($env{'form.lcdomain'})&&($env{'form.lcdomain'}!~/\W/)) { # 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 { @@ -644,33 +746,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.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.')."
"); @@ -684,7 +786,7 @@ 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')); @@ -695,10 +797,10 @@ sub setup_date_selectors { my ($starttime,$endtime,$mode) = @_; if (! defined($starttime)) { $starttime = time; - unless ($mode eq 'createcourse') { - if (exists($ENV{'course.'.$ENV{'request.course.id'}. + unless ($mode eq 'create_enrolldates' || $mode eq 'create_defaultdates') { + 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'}; } } @@ -706,9 +808,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'}; } } @@ -719,12 +821,20 @@ sub setup_date_selectors { my $enddateform = &Apache::lonhtmlcommon::date_setter('studentform', 'enddate', $endtime); - if ($mode eq 'createcourse') { + if ($mode eq 'create_enrolldates') { $startdateform = &Apache::lonhtmlcommon::date_setter('ccrs', - 'startdate', + 'startenroll', $starttime); $enddateform = &Apache::lonhtmlcommon::date_setter('ccrs', - 'enddate', + 'endenroll', + $endtime); + } + if ($mode eq 'create_defaultdates') { + $startdateform = &Apache::lonhtmlcommon::date_setter('ccrs', + 'startaccess', + $starttime); + $enddateform = &Apache::lonhtmlcommon::date_setter('ccrs', + 'endaccess', $endtime); } return ($startdateform,$enddateform); @@ -733,7 +843,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); @@ -745,7 +855,7 @@ sub date_setting_table { my $dateDefault = ''.&mt('Starting Date').' | '. @@ -768,8 +881,8 @@ sub date_setting_table { sub make_dates_default { my ($startdate,$enddate) = @_; my $result = ''; - my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; - my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'}; + my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; my $put_result = &Apache::lonnet::put('environment', {'default_enrollment_start_date'=>$startdate, 'default_enrollment_end_date' =>$enddate},$dom,$crs); @@ -777,7 +890,7 @@ sub make_dates_default { $result .= "Set default start and end dates for course
$lt{'hs'}: | $homeserver_form |
---|---|
$lt{'mail'}: | +
+ | |
$lt{'mail'}: | ++ + |
---|
-$CCL
-
-END
- if ($ENV{'form.action'} ne 'modifystudent') {
- my %lt=&Apache::lonlocal::texthash(
- 'ef' => "Excel format",
- 'ss' => "Student Status",
- );
- $r->print(< \n");
+ if ($env{'form.action'} ne 'modifystudent') {
+ my %lt=&Apache::lonlocal::texthash('csv' => "CSV",
+ 'excel' => "Excel",
+ 'html' => 'HTML');
+ my $output_selector = '';
+ $r->print(&mt('Output Format: [_1]',$output_selector).(' 'x3));
}
- $r->print($status_select."');
+ foreach my $role (sort keys %coursepersonnel) {
+ next if ($role =~ /^\s*$/);
+ $r->print('
');
+ #
+ # Interface output
+ $r->print('');
+ $r->print(" ');
+ }
+ $r->print(''.$role.' ');
+ foreach my $user (split(',',$coursepersonnel{$role})) {
+ my ($puname,$pudom)=split(':',$user);
+ $r->print(' '.&Apache::loncommon::aboutmewrapper(
+ &Apache::loncommon::plainname($puname,
+ $pudom),
+ $puname,$pudom));
+ }
+ $r->print('
+ | |||||||||
---|---|---|---|---|---|---|---|---|---|
$lt{'type'} | + "); + } else { + $r->print(" +Count | + "); + } + $r->print(<$lt{'dom'} @@ -1120,37 +1290,57 @@ sub show_class_list { $lt{'sn'} | $lt{'sec'} + | + $lt{'start'} + | + $lt{'end'} | -||||
\n "); + if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') { + if (! defined($start) || $start == 0) { + $start = &mt('none'); + } else { + $start = &Apache::lonlocal::locallocaltime($start); + } + if (! defined($end) || $end == 0) { + $end = &mt('none'); + } else { + $end = &Apache::lonlocal::locallocaltime($end); + } + $r->print(" | |||||||||
'.&mt('manual').' | |
'. &mt('Your Excel spreadsheet').' '.&mt('is ready for download').'.
'."\n"); + } elsif ($mode eq 'csv') { + close($CSVfile); + $r->print(''. + &mt('Your CSV file').' is ready for download.'. + "\n"); + $r->rflush(); + } + if ($mode eq 'autoenroll') { + return ($studentcount,$autocount,$manualcount,$lockcount,$unlockcount); } + return; } @@ -1237,9 +1501,9 @@ sub print_modify_student_form { my $r = shift(); &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['sdom','sname']); - my $sname = $ENV{'form.sname'}; - my $sdom = $ENV{'form.sdom'}; - my $sortby = $ENV{'form.sortby'}; + my $sname = $env{'form.sname'}; + my $sdom = $env{'form.sdom'}; + my $sortby = $env{'form.sortby'}; # determine the students name information my %info=&Apache::lonnet::get('environment', ['firstname','middlename', @@ -1261,12 +1525,33 @@ sub print_modify_student_form { $r->print(''.$starttime.'
'); return; } + # # Deal with date forms + my $current_date_description = ''; + my $textdate = ''; + + if (! defined($starttime) || $starttime == 0) { + $current_date_description = &mt('Current Starting Date: not set'). + '@@ -1313,8 +1597,9 @@ $info{'lastname'} $info{'generation'}, $ $lt{'disn'}
-$lt{'sec'}: +$lt{'sec'}:
+$current_date_description
$date_table