--- loncom/interface/Attic/londropadd.pm 2004/02/27 14:59:19 1.104
+++ loncom/interface/Attic/londropadd.pm 2004/05/13 21:03:16 1.110
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.104 2004/02/27 14:59:19 matthew Exp $
+# $Id: londropadd.pm,v 1.110 2004/05/13 21:03:16 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -37,6 +37,7 @@ use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::Constants qw(:common :http REDIRECT);
use Spreadsheet::WriteExcel;
+use Apache::lonstathelpers();
use Apache::lonlocal;
###############################################################
@@ -699,7 +700,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();
@@ -1115,21 +1116,28 @@ sub print_html_classlist {
#
# 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('
');
- foreach (sort keys %coursepersonnel) {
- $r->print(''.$_.' ');
- foreach (split(/\,/,$coursepersonnel{$_})) {
- my ($puname,$pudom)=split(/\:/,$_);
+ foreach my $role (sort keys %coursepersonnel) {
+ next if ($role =~ /^\s*$/);
+ $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));
+ &Apache::loncommon::plainname($puname,
+ $pudom),
+ $puname,$pudom));
}
$r->print(' ');
}
$r->print('
');
#
# Interface output
- my $CCL=&mt('Current Class List');
$r->print(' ');
$r->print("\n");
@@ -1137,14 +1145,10 @@ sub print_html_classlist {
my %lt=&Apache::lonlocal::texthash('csv' => "CSV",
'excel' => "Excel",
'html' => 'HTML');
- $r->print('');
- my $output_selector = '';
- if ($ENV{'form.state'} !~ /^(csv|excel|html)$/ ) {
- $ENV{'form.state'} = 'html';
- }
+ my $output_selector = '';
foreach my $outputformat ('html','csv','excel') {
my $option = '';
@@ -1154,8 +1158,8 @@ sub print_html_classlist {
$r->print(&mt('Output Format: [_1]',$output_selector).(' 'x3));
}
$r->print(&mt('Student Status: [_1]',$status_select)."\n");
- $r->print(' '."\n
\n");
-
+ $r->print(' '.
+ "\n\n");
#
# Print the classlist
$r->print(''.&mt('Current Class List').' ');
@@ -1165,13 +1169,12 @@ sub print_html_classlist {
} else {
# Print out the available choices
if ($ENV{'form.action'} eq 'modifystudent') {
- &show_class_list($r,'view','modify','modifystudent',
- $ENV{'form.Status'},$classlist,$keylist);
- } elsif (! defined($mode) || $mode eq '') {
- &show_class_list($r,'view','aboutme','classlist',
+ &show_class_list($r,'view','modify',
$ENV{'form.Status'},$classlist,$keylist);
- } elsif ($mode eq 'csv' || $mode eq 'excel') {
- &show_class_list($r,$mode,'nolink','csv',
+ } else {
+ &Apache::lonnet::logthis('showing class list '.$ENV{'form.output'});
+
+ &show_class_list($r,$ENV{'form.output'},'aboutme',
$ENV{'form.Status'},$classlist,$keylist);
}
}
@@ -1179,7 +1182,7 @@ sub print_html_classlist {
# =================================================== Show student list to drop
sub show_class_list {
- my ($r,$mode,$linkto,$action,$statusmode,$classlist,$keylist)=@_;
+ my ($r,$mode,$linkto,$statusmode,$classlist,$keylist)=@_;
my $cid=$ENV{'request.course.id'};
#
# Variables for excel output
@@ -1189,35 +1192,36 @@ sub show_class_list {
my ($CSVfile,$CSVfilename);
#
my $sortby = $ENV{'form.sortby'};
- if ($sortby !~ /^(username|domain|section|fullname|id)$/) {
+ if ($sortby !~ /^(username|domain|section|fullname|id|start|end)$/) {
$sortby = 'username';
}
# Print out header
$r->print(<
-
-
END
- if ($mode eq 'view') {
+ if ($mode eq 'html' || $mode eq 'view') {
if ($linkto eq 'aboutme') {
$r->print(&mt('Select a user name to view the users personal page.'));
} elsif ($linkto eq 'modify') {
$r->print(&mt('Select a user name to modify the students information'));
}
my %lt=&Apache::lonlocal::texthash(
- 'usrn' => "username",
- 'dom' => "domain",
- 'sn' => "student name",
- 'sec' => "section",
+ 'usrn' => "username",
+ 'dom' => "domain",
+ 'sn' => "student name",
+ 'sec' => "section",
+ 'start' => "start date",
+ 'end' => "end date",
);
$r->print(<
-
+ Count
+
$lt{'usrn'}
$lt{'dom'}
@@ -1227,6 +1231,10 @@ END
$lt{'sn'}
$lt{'sec'}
+
+ $lt{'start'}
+
+ $lt{'end'}
END
@@ -1252,12 +1260,12 @@ END
print $CSVfile '"'.join('","',map {
&Apache::loncommon::csv_translate(&mt($_))
} ("username","domain","ID","student name",
- "section","status")).'"'."\n";
+ "section","start date","end date","status")).'"'."\n";
} else {
print $CSVfile '"'.join('","',map {
&Apache::loncommon::csv_translate(&mt($_))
} ("username","domain","ID","student name",
- "section")).'"'."\n";
+ "section","start date","end date")).'"'."\n";
}
} elsif ($mode eq 'excel') {
# Create the excel spreadsheet
@@ -1276,7 +1284,9 @@ END
$excel_sheet->write($row++,0,$description,$format->{'h1'});
#
$excel_sheet->write($row++,0,["username","domain","ID",
- "student name","section","status"],$format->{'bold'});
+ "student name","section",
+ "start date","end date","status"],
+ $format->{'bold'});
}
#
# Sort the students
@@ -1295,16 +1305,22 @@ END
||
lc($classlist->{$a}->[$third]) cmp lc($classlist->{$b}->[$third])
} (keys(%$classlist));
+ my $studentcount = 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'}];
next if (($statusmode ne 'Any') && ($status ne $statusmode));
- if ($mode eq 'view') {
- $r->print("\n \n ");
+ if ($mode eq 'view' || $mode eq 'html') {
+ $start = &Apache::lonlocal::locallocaltime($start);
+ $end = &Apache::lonlocal::locallocaltime($end);
+ $r->print(" \n ".(++$studentcount)." \n ");
if ($linkto eq 'nothing') {
$r->print($username);
} elsif ($linkto eq 'aboutme') {
@@ -1326,13 +1342,17 @@ END
$id
$name
$section
+ $start
+ $end
END
} elsif ($mode eq 'csv') {
next if (! defined($CSVfile));
# no need to bother with $linkto
+ $start = &Apache::lonlocal::locallocaltime($start);
+ $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') {
@@ -1340,11 +1360,19 @@ END
}
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) {
+ $excel_sheet->write($row,$col++,
+ &Apache::lonstathelpers::calc_serial($time),
+ $format->{'date'});
+ }
+ $excel_sheet->write($row,$col++,$status);
+ $row++;
}
}
- if ($mode eq 'view') {
+ if ($mode eq 'view' || $mode eq 'html') {
$r->print('
');
} elsif ($mode eq 'excel') {
$excel_workbook->close();
@@ -1691,7 +1719,7 @@ sub show_drop_list {
['sortby']);
}
my $sortby = $ENV{'form.sortby'};
- if ($sortby !~ /^(username|domain|section|fullname|id)$/) {
+ if ($sortby !~ /^(username|domain|section|fullname|id|start|end)$/) {
$sortby = 'username';
}
#
@@ -1715,13 +1743,14 @@ function uncheckAll(field) {
END
+my %lt=&Apache::lonlocal::texthash('usrn' => "username",
+ 'dom' => "domain",
+ 'sn' => "student name",
+ 'sec' => "section",
+ 'start' => "start date",
+ 'end' => "end date",
+ );
if ($nosort) {
- my %lt=&Apache::lonlocal::texthash(
- 'usrn' => "username",
- 'dom' => "domain",
- 'sn' => "student name",
- 'sec' => "section",
- );
$r->print(<
@@ -1731,16 +1760,12 @@ END
ID
$lt{'sn'}
$lt{'sec'}
+ $lt{'start'}
+ $lt{'end'}
END
} else {
- my %lt=&Apache::lonlocal::texthash(
- 'usrn' => "username",
- 'dom' => "domain",
- 'sn' => "student name",
- 'sec' => "section",
- );
$r->print(<
@@ -1754,6 +1779,10 @@ END
$lt{'sn'}
$lt{'sec'}
+
+ $lt{'start'}
+
+ $lt{'end'}
END
@@ -1777,12 +1806,25 @@ END
} (keys(%$classlist));
foreach my $student (@Sorted_Students) {
my $error;
- 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 $start = $sdata->[$index{'start'}];
+ my $end = $sdata->[$index{'end'}];
+ 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 $status = $sdata->[$index{'status'}];
next if ($status ne 'Active');
#
$r->print(<<"END");
@@ -1793,6 +1835,8 @@ END
$id
$name
$section
+ $start
+ $end
END
}
@@ -2162,8 +2206,7 @@ sub handler {
} elsif ($ENV{'form.action'} eq 'upload') {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/dropadd?action=upload&state=',
- text=>"Upload Classlist",
- faq=>9,bug=>'Instructor Interface',});
+ text=>"Upload Classlist"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs
(undef,'Upload Classlist'));
if (! exists($ENV{'form.state'})) {
@@ -2182,8 +2225,7 @@ sub handler {
} elsif ($ENV{'form.action'} eq 'drop') {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/dropadd?action=drop',
- text=>"Drop Students",
- faq=>9,bug=>'Instructor Interface',});
+ text=>"Drop Students"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs
(undef,'Drop Students'));
if (! exists($ENV{'form.state'})) {
@@ -2196,8 +2238,7 @@ sub handler {
} elsif ($ENV{'form.action'} eq 'enrollstudent') {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/dropadd?action=enrollstudent',
- text=>"Enroll Student",
- faq=>9,bug=>'Instructor Interface',});
+ text=>"Enroll Student"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs
(undef,'Enroll Student'));
if (! exists($ENV{'form.state'})) {
@@ -2212,8 +2253,7 @@ sub handler {
} elsif ($ENV{'form.action'} eq 'classlist') {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/dropadd?action=classlist',
- text=>"View Classlist",
- faq=>9,bug=>'Instructor Interface',});
+ text=>"View Classlist"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs
(undef,'View Classlist'));
if (! exists($ENV{'form.state'})) {
@@ -2228,8 +2268,7 @@ sub handler {
} elsif ($ENV{'form.action'} eq 'modifystudent') {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>'/adm/dropadd?action=modifystudent',
- text=>"Modify Student Data",
- faq=>9,bug=>'Instructor Interface',});
+ text=>"Modify Student Data"});
$r->print(&Apache::lonhtmlcommon::breadcrumbs
(undef,'Modify Student Data'));
if (! exists($ENV{'form.state'})) {