--- loncom/interface/Attic/londropadd.pm 2003/12/08 21:01:03 1.92
+++ loncom/interface/Attic/londropadd.pm 2005/03/10 17:33:57 1.126
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.92 2003/12/08 21:01:03 sakharuk Exp $
+# $Id: londropadd.pm,v 1.126 2005/03/10 17:33:57 matthew 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
#
###############################################################
##############################################################
@@ -42,15 +37,17 @@ 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,6 +204,7 @@ 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'; } @@ -202,7 +220,20 @@ sub print_upload_manager_header { } else { $javascript=&upload_manager_javascript_forward_associate(); } - my $javascript_validations=&javascript_validations('auth',$krbdefdom); + # + # 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";
$Str .= ''."
\n";
+ 'value="Update Class List" />'."
\n";
$Str .= &mt('Note: for large courses, this operation may be time '.
'consuming');
$r->print($Str);
@@ -557,6 +636,7 @@ sub print_upload_manager_footer {
###############################################################
sub print_upload_manager_form {
my $r=shift;
+
my $firstLine;
my $datatoken;
if (!$ENV{'form.datatoken'}) {
@@ -573,23 +653,41 @@ sub print_upload_manager_form {
my $distotal=$total+1;
my $today=time;
my $halfyear=$today+15552000;
+ #
+ # 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')]);
+ 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,
@@ -617,7 +715,7 @@ sub enroll_single_student {
$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();
@@ -625,8 +723,8 @@ sub enroll_single_student {
$r->print(&make_dates_default($startdate,$enddate));
}
- $r->print('
Enrolling '.$ENV{'form.cuname'}." \@ ". + $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/)) { @@ -638,12 +736,12 @@ sub enroll_single_student { } else { my %home_servers =&Apache::loncommon::get_library_servers($domain); if (! exists($home_servers{$desiredhost})) { - $r->print('Error:'. - 'Invalid home server specified'); + $r->print(''.&mt('Error').':'. + &mt('Invalid home server specified')); return; } } - $r->print(" with server $desiredhost :") if (defined($desiredhost)); + $r->print(" ".&mt('with server')." $desiredhost :") if (defined($desiredhost)); # End of home server selection logic my $amode=''; my $genpwd=''; @@ -673,25 +771,24 @@ sub enroll_single_student { $ENV{'form.clast'},$ENV{'form.cgen'}, $ENV{'form.csec'},$enddate, $startdate,$ENV{'form.forceid'}, - $desiredhost); + $desiredhost,$ENV{'form.emailaddress'}); if ($login_result =~ /^ok/) { $r->print($login_result); - $r->print("If active, the new role will be available ". - "when the student next logs in to LON-CAPA.
"); + $r->print("".&mt('If active, the new role will be available when the student next logs in to LON-CAPA.')."
"); } else { - $r->print("unable to enroll: ".$login_result); + $r->print(&mt('unable to enroll').": ".$login_result); } } else { - $r->print('ERROR '); + $r->print('
'.&mt('ERROR').' '); if ($amode =~ /^krb/) { - $r->print('Missing Kerberos domain information. '); + $r->print(&mt('Missing Kerberos domain information.').' '); } else { - $r->print('Invalid login mode or password. '); + $r->print(&mt('Invalid login mode or password.').' '); } - $r->print('Unable to enroll '.$ENV{'form.cuname'}.'.
'); + $r->print(''.&mt('Unable to enroll').' '.$ENV{'form.cuname'}.'.'); } } else { - $r->print('Invalid username or domain'); + $r->print(&mt('Invalid username or domain')); } } @@ -699,7 +796,7 @@ sub setup_date_selectors { my ($starttime,$endtime,$mode) = @_; if (! defined($starttime)) { $starttime = time; - unless ($mode eq 'createcourse') { + 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'}. @@ -723,12 +820,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); @@ -747,22 +852,25 @@ sub date_setting_table { my ($starttime,$endtime,$mode) = @_; my ($startform,$endform)=&setup_date_selectors($starttime,$endtime,$mode); my $dateDefault = 'Starting Date | '. + $result .= '||
'.&mt('Starting Date').' | '. ''.$startform.' | '. ''.$dateDefault.' | '."
Ending Date | '. + $result .= '||
'.&mt('Ending Date').' | '. ''.$endform.' | '. ''.$perpetual.' | '."
Username: | +|
---|---|
$lt{'usr'}: | |
Domain: | +|
$lt{'dom'}: | $domform |
- + |
First Name: | +|
---|---|
$lt{'fn'}: | |
Middle Name: | +|
$lt{'mn'}: | |
Last Name: | +|
$lt{'ln'}: | |
Generation: | +|
$lt{'gen'}: | |
Home Server: | +|
$lt{'hs'}: | $homeserver_form |
$lt{'mail'}: | +
First Name: | +|
---|---|
$lt{'fn'}: | |
Middle Name: | +|
$lt{'mn'}: | |
Last Name: | +|
$lt{'ln'}: | |
Generation: | +|
$lt{'gen'}: | |
$lt{'mail'}: | ++ + |
Group/Section: +
$lt{'gs'}:
$date_table
--ID/Student Number: +$lt{'idsn'}:
-Disable ID/Student Number Safeguard and Force Change of Conflicting IDs -(only do if you know what you are doing) +$lt{'disn'}
- +
END return; @@ -980,7 +1131,7 @@ sub print_drop_menu { my $cid=$ENV{'request.course.id'}; my ($classlist,$keylist) = &Apache::loncoursedata::get_classlist(); if (! defined($classlist)) { - $r->print("There are no students currently enrolled.\n"); + $r->print(&mt('There are no students currently enrolled.')."\n"); return; } # Print out the available choices @@ -990,7 +1141,7 @@ sub print_drop_menu { # ============================================== view classlist sub print_html_classlist { - my $r=shift; + my ($r,$mode) = @_; if (! exists($ENV{'form.sortby'})) { $ENV{'form.sortby'} = 'username'; } @@ -998,122 +1149,196 @@ sub print_html_classlist { $ENV{'form.Status'} = 'Active'; } my $status_select = &Apache::lonhtmlcommon::StatusOptions - ($ENV{'form.Status'},'studentform'); - $r->print(<
-Current Class List
-
-END
+ ($ENV{'form.Status'});
+ my $cid=$ENV{'request.course.id'};
+ my $cdom=$ENV{'course.'.$cid.'.domain'};
+ my $cnum=$ENV{'course.'.$cid.'.num'};
+ #
+ # List course personnel
+ my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum);
+ #
+ if (! defined($ENV{'form.output'}) ||
+ $ENV{'form.output'} !~ /^(csv|excel|html)$/ ) {
+ $ENV{'form.output'} = 'html';
+ }
+ #
+ $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(' |
\n");
if ($ENV{'form.action'} ne 'modifystudent') {
- $r->print(<
- username + | |||||||||
---|---|---|---|---|---|---|---|---|---|
$lt{'type'} | + "); + } else { + $r->print(" +Count | + "); + } + $r->print(<- domain + $lt{'dom'} | ID | - student name + $lt{'sn'} + | + $lt{'sec'} | - section + $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').' | |
'. - 'Your Excel spreadsheet is ready for download.
'."\n"); + &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; } @@ -1210,33 +1505,66 @@ sub print_modify_student_form { $sdom, $sname); my ($tmp) = keys(%info); if ($tmp =~ /^(con_lost|error|no_such_host)/i) { - $r->print('Error'. + $r->print(''.&mt('Error').''. ''. - 'Unable to retrieve environment data for '.$sname. - 'in domain '.$sdom.'
'. - 'Please contact your LON-CAPA administrator '. - 'regarding this situation.