--- loncom/interface/Attic/londropadd.pm 2003/12/22 22:50:37 1.95
+++ loncom/interface/Attic/londropadd.pm 2006/02/07 16:21:26 1.135
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.95 2003/12/22 22:50:37 albertel Exp $
+# $Id: londropadd.pm,v 1.135 2006/02/07 16:21:26 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -32,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,$grp_manage_permission, + $grp_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', + }, +# { text => 'Create a new group', +# help => 'Course_Create_Group', +# permission => $grp_manage_permission, +# url => '/adm/coursegroups?refpage=enrl&action=create', +# }, +# { text => 'Modify an existing group', +# help => 'Course_Modify_Group', +# permission => $grp_manage_permission, +# url => '/adm/coursegroups?refpage=enrl&action=modify', +# }, +# { text => 'Delete an existing group', +# help => 'Course_Delete_Group', +# permission => $grp_manage_permission, +# url => '/adm/coursegroups?refpage=enrl&action=delete', +# }, +# { text => 'Enter an existing group', +# help => 'Course_Display_Group', +# permission => $grp_view_permission, +# url => '/adm/coursegroups?refpage=enrl&action=view', +# }, + ); + 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; } ############################################################### @@ -182,23 +225,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". @@ -529,14 +638,14 @@ sub print_upload_manager_footer { $Str .= "
\n".$date_table."
\n"; $Str .= "\n".''; + $Str .= "
\n".'
\n"; + "\n
\n";
$Str .= ''."
\n";
$Str .= &mt('Note: for large courses, this operation may be time '.
@@ -549,40 +658,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);
@@ -606,25 +734,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 { @@ -639,33 +767,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.')."
"); @@ -679,7 +807,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')); @@ -690,10 +818,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'}; } } @@ -701,9 +829,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'}; } } @@ -714,12 +842,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); @@ -728,7 +864,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); @@ -738,16 +874,19 @@ sub date_setting_table { my ($starttime,$endtime,$mode) = @_; my ($startform,$endform)=&setup_date_selectors($starttime,$endtime,$mode); my $dateDefault = ''.&mt('Starting Date').' | '. @@ -763,8 +902,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); @@ -772,7 +911,7 @@ sub make_dates_default { $result .= "Set default start and end dates for course
$lt{'hs'}: | $homeserver_form |
---|---|
$lt{'mail'}: | +
+ | |
$lt{'mail'}: | ++ + |
---|
$lt{'idsn'}:
+
@@ -997,7 +1153,7 @@ END sub print_drop_menu { my $r=shift; $r->print("
-$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(&mt('Student Status: [_1]',$status_select)."\n");
+ $r->print(''.
+ "\n
'.
&mt('Your Excel spreadsheet').' '.&mt('is ready for download').'. '.$starttime.'
@@ -1305,11 +1665,14 @@ $info{'lastname'} $info{'generation'}, $
$lt{'sid'}:
+
-$lt{'sec'}:
+$lt{'sec'}:
$current_date_description $date_table');
+ foreach my $role (sort keys %coursepersonnel) {
+ next if ($role =~ /^\s*$/);
+ $r->print('
');
+ #
+ # Interface output
+ $r->print('');
+ $r->print(" ');
}
- $r->print($status_select."\n");
- my $cid=$ENV{'request.course.id'};
+ $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(' '.&mt('Current Class List').'
');
my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
if (! defined($classlist)) {
$r->print(&mt('There are no students currently enrolled.')."\n");
} else {
# Print out the available choices
- if ($ENV{'form.action'} eq 'modifystudent') {
- &show_class_list($r,'view','modify','modifystudent',
- $ENV{'form.Status'},$classlist,$keylist);
+ if ($env{'form.action'} eq 'modifystudent') {
+ &show_class_list($r,'view','modify',
+ $env{'form.Status'},$classlist,$keylist);
} else {
- &show_class_list($r,'view','aboutme','classlist',
- $ENV{'form.Status'},$classlist,$keylist);
+ &show_class_list($r,$env{'form.output'},'aboutme',
+ $env{'form.Status'},$classlist,$keylist);
}
}
}
-# ============================================== view classlist
-sub print_formatted_classlist {
- my $r=shift;
- my $mode = shift;
- my $cid=$ENV{'request.course.id'};
- my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
- if (! defined($classlist)) {
- $r->print(&mt('There are no students currently enrolled.')."\n");
- } else {
- &show_class_list($r,$mode,'nolink','csv',
- $ENV{'form.Status'},$classlist,$keylist);
- }
-}
-
# =================================================== Show student list to drop
sub show_class_list {
- my ($r,$mode,$linkto,$action,$statusmode,$classlist,$keylist)=@_;
- my $cid=$ENV{'request.course.id'};
+ my ($r,$mode,$linkto,$statusmode,$classlist,$keylist)=@_;
+ my $cid=$env{'request.course.id'};
#
# Variables for excel output
- my ($excel_workbook, $excel_sheet, $excel_filename,$row);
+ my ($excel_workbook, $excel_sheet, $excel_filename,$row,$format);
+ #
+ # Variables for csv output
+ my ($CSVfile,$CSVfilename);
#
- my $sortby = $ENV{'form.sortby'};
- if ($sortby !~ /^(username|domain|section|fullname|id)$/) {
+ my $sortby = $env{'form.sortby'};
+ if ($sortby !~ /^(username|domain|section|fullname|id|start|end|type)$/) {
$sortby = 'username';
}
+ if (! exists($env{'form.displayphotos'})) {
+ $env{'form.displayphotos'} = 'off';
+ }
+ my $displayphotos = $env{'form.displayphotos'};
+
# Print out header
- if ($mode eq 'view') {
+ unless ($mode eq 'autoenroll') {
+ $r->print(<
-
+
+ ");
+ if ($mode eq 'autoenroll') {
+ $r->print("
+
END
+ if ($env{'course.'.$env{'request.course.id'}.'.internal.showphotos'}) {
+ my %photo_options = &Apache::lonlocal::texthash(
+ 'on' => 'Show',
+ 'off' => 'Hide',
+ );
+ my $photochg = 'on';
+ if ($displayphotos eq 'on') {
+ $photochg = 'off';
+ }
+ $r->print(' $lt{'type'}
+ ");
+ } else {
+ $r->print("
+Count
+ ");
+ }
+ $r->print(<
$lt{'dom'}
@@ -1115,37 +1333,72 @@ sub show_class_list {
$lt{'sn'}
$lt{'sec'}
+
+ $lt{'start'}
+
+ $lt{'end'}
-'."\n".' '.
+ ''.
+ $photo_options{$photochg}.' '.$lt{'photo'}."\n".
+ ' '."\n");
+ }
+ $r->print(" \n");
} elsif ($mode eq 'csv') {
+ #
+ # Open a file
+ $CSVfilename = '/prtspool/'.
+ $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
+ time.'_'.rand(1000000000).'.csv';
+ unless ($CSVfile = Apache::File->new('>/home/httpd'.$CSVfilename)) {
+ $r->log_error("Couldn't open $CSVfilename for output $!");
+ $r->print("Problems occured in writing the csv file. ".
+ "This error has been logged. ".
+ "Please alert your LON-CAPA administrator.");
+ $CSVfile = undef;
+ }
+ #
+ # Write headers and data to file
if($statusmode eq 'Expired') {
- $r->print(&mt('Students with expired roles'));
+ print $CSVfile '"'.&mt('Students with expired roles').'"'."\n";
}
if ($statusmode eq 'Any') {
- $r->print('"'.join('","',(&mt("username"),&mt("domain"),"ID",
- &mt("student name"),&mt("section"),&mt("status"))).
- '"'."\n");
+ print $CSVfile '"'.join('","',map {
+ &Apache::loncommon::csv_translate(&mt($_))
+ } ("username","domain","ID","student name",
+ "section","start date","end date","status")).'"'."\n";
} else {
- $r->print('"'.join('","',(&mt("username"),&mt("domain"),"ID",
- &mt("student name"),&mt("section"))).'"'."\n");
+ print $CSVfile '"'.join('","',map {
+ &Apache::loncommon::csv_translate(&mt($_))
+ } ("username","domain","ID","student name",
+ "section","start date","end date")).'"'."\n";
}
} elsif ($mode eq 'excel') {
# Create the excel spreadsheet
- $excel_filename = '/prtspool/'.
- $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
- time.'_'.rand(1000000000).'.xls';
- $excel_workbook = Spreadsheet::WriteExcel->new('/home/httpd'.
- $excel_filename);
- $excel_workbook->set_tempdir('/home/httpd/perl/tmp');
+ ($excel_workbook,$excel_filename,$format) =
+ &Apache::loncommon::create_workbook($r);
+ return if (! defined($excel_workbook));
$excel_sheet = $excel_workbook->addworksheet('classlist');
#
my $description = 'Class List for '.
- $ENV{'course.'.$ENV{'request.course.id'}.'.description'};
- $excel_sheet->write($row++,0,$description);
+ $env{'course.'.$env{'request.course.id'}.'.description'};
+ $excel_sheet->write($row++,0,$description,$format->{'h1'});
#
$excel_sheet->write($row++,0,["username","domain","ID",
- "student name","section","status"]);
+ "student name","section",
+ "start date","end date","status"],
+ $format->{'bold'});
}
#
# Sort the students
@@ -1164,16 +1417,58 @@ END
||
lc($classlist->{$a}->[$third]) cmp lc($classlist->{$b}->[$third])
} (keys(%$classlist));
+ my $studentcount = 0;
+ my $autocount = 0;
+ my $manualcount = 0;
+ my $unlockcount = 0;
+ my $lockcount = 0;
foreach my $student (@Sorted_Students) {
- my $username = $classlist->{$student}->[$index{'username'}];
- my $domain = $classlist->{$student}->[$index{'domain'}];
- my $section = $classlist->{$student}->[$index{'section'}];
- my $name = $classlist->{$student}->[$index{'fullname'}];
- my $id = $classlist->{$student}->[$index{'id'}];
- my $status = $classlist->{$student}->[$index{'status'}];
+ my $sdata = $classlist->{$student};
+ my $username = $sdata->[$index{'username'}];
+ my $domain = $sdata->[$index{'domain'}];
+ my $section = $sdata->[$index{'section'}];
+ my $name = $sdata->[$index{'fullname'}];
+ my $id = $sdata->[$index{'id'}];
+ my $status = $sdata->[$index{'status'}];
+ my $start = $sdata->[$index{'start'}];
+ my $end = $sdata->[$index{'end'}];
+ my $type = $sdata->[$index{'type'}];
next if (($statusmode ne 'Any') && ($status ne $statusmode));
- if ($mode eq 'view') {
- $r->print("\n \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(" \n ");
+ if ($mode eq 'autoenroll') {
+ my $lockedtype = $sdata->[$index{'lockedtype'}];
+ $studentcount++;
+ my $cellentry;
+ if ($type eq 'auto') {
+ $cellentry = ''.&mt('auto').' ';
+ $autocount ++;
+ } else {
+ $cellentry = '
+
';
+ }
+ $r->print("'.&mt('manual').' $cellentry \n ");
+ } else {
+ $r->print(" ".(++$studentcount)." \n ");
+ }
if ($linkto eq 'nothing') {
$r->print($username);
} elsif ($linkto eq 'aboutme') {
@@ -1195,33 +1490,78 @@ END
$id
$name
$section
-$start
+ $end
END
+ if ($env{'course.'.$env{'request.course.id'}.
+ '.internal.showphotos'}) {
+ if ($displayphotos eq 'on') {
+ my $imgurl =
+ &Apache::lonnet::retrievestudentphoto($domain,
+ $username,'gif',
+ 'thumbnail');
+
+ $r->print(' ');
+ } else {
+ $r->print(' ');
+ }
+ }
+ $r->print(' ');
} elsif ($mode eq 'csv') {
+ next if (! defined($CSVfile));
# no need to bother with $linkto
+ 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);
+ }
my @line = ();
- foreach ($username,$domain,$id,$name,$section) {
+ foreach ($username,$domain,$id,$name,$section,$start,$end) {
push @line,&Apache::loncommon::csv_translate($_);
}
if ($statusmode eq 'Any') {
push @line,&Apache::loncommon::csv_translate($status);
}
- my $tmp = $";
- $" = '","';
- $r->print("\"@line\"\n");
- $" = $tmp;
+ print $CSVfile '"'.join('","',@line).'"'."\n";
} elsif ($mode eq 'excel') {
- $excel_sheet->write($row++,0,[$username,$domain,$id,
- $name,$section,$status]);
+ $excel_sheet->write($row,0,[$username,$domain,$id,
+ $name,$section]);
+ my $col = 5;
+ foreach my $time ($start,$end) {
+ if (defined($time) && $time != 0) {
+ $excel_sheet->write($row,$col++,
+ &Apache::lonstathelpers::calc_serial($time),
+ $format->{'date'});
+ } else {
+ $excel_sheet->write($row,$col++,'none');
+ }
+ }
+ $excel_sheet->write($row,$col++,$status);
+ $row++;
}
}
- if ($mode eq 'view') {
+ if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') {
$r->print('
');
} elsif ($mode eq 'excel') {
$excel_workbook->close();
$r->print('
';
+ } else {
+ $current_date_description =
+ &mt('Current Starting Date: [_1]',
+ &Apache::lonlocal::locallocaltime($starttime)).'
';
+ }
+ if (! defined($endtime) || $endtime == 0) {
+ $current_date_description.= &mt('Current Ending Date: not set').
+ '
';
+ } else {
+ $current_date_description.=
+ &mt('Current Ending Date: [_1]',
+ &Apache::lonlocal::locallocaltime($endtime)).'
';
+
+ }
my $date_table = &date_setting_table($starttime,$endtime);
#
- if (! exists($ENV{'form.Status'}) ||
- $ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
- $ENV{'form.Status'} = 'crap';
+ if (! exists($env{'form.Status'}) ||
+ $env{'form.Status'} !~ /^(Any|Expired|Active)$/) {
+ $env{'form.Status'} = 'crap';
}
# Make sure student is enrolled in course
my %lt=&Apache::lonlocal::texthash(
@@ -1288,8 +1649,7 @@ $lt{'odcc'}
-
-
+
$lt{'mef'} $info{'firstname'} $info{'middlename'}
$info{'lastname'} $info{'generation'}, $sname\@$sdom