--- loncom/interface/lonuserutils.pm 2008/09/11 19:42:28 1.65
+++ loncom/interface/lonuserutils.pm 2008/09/26 08:38:11 1.70
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.65 2008/09/11 19:42:28 droeschl Exp $
+# $Id: lonuserutils.pm,v 1.70 2008/09/26 08:38:11 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1009,7 +1009,7 @@ sub date_setting_table {
}
my $perpetual = '';
if ($mode eq 'create_enrolldates') {
@@ -1295,9 +1295,13 @@ sub print_userlist {
$output_selector .= "\n".$option;
}
$output_selector .= '';
- $r->print(''.(' 'x3));
- }
- $r->print(''.(' 'x3)."\n");
+ $r->print(''.(' 'x3));
+ }
+ $r->print(''.(' 'x3)."\n");
my $roleselected = '';
if ($env{'form.showrole'} eq 'Any') {
$roleselected = ' selected="selected" ';
@@ -1337,7 +1341,9 @@ sub print_userlist {
if ($context eq 'course') {
if (($env{'form.showrole'} eq 'st') || ($env{'form.showrole'} eq 'Any')) {
my $classlist = &Apache::loncoursedata::get_classlist();
- %userlist = %{$classlist};
+ if (ref($classlist) eq 'HASH') {
+ %userlist = %{$classlist};
+ }
}
if ($env{'form.showrole'} ne 'st') {
my $showroles;
@@ -1488,7 +1494,9 @@ sub role_filter {
my ($role_select);
if ($context eq 'domain') {
$role_select = &domain_roles_select();
- $output = '';
+ $output = '';
} else {
$role_select = '';
- $output = '';
+ $output = '';
}
return $output;
}
@@ -2044,6 +2054,7 @@ END
'aboutme' => "Display a user's personal page",
'owin' => "Open in a new window",
'modify' => "Modify a user's information",
+ 'clicker' => "Clicker-ID",
);
if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
$lt{'extent'} = &mt('Course(s): description, section(s), status');
@@ -2241,18 +2252,20 @@ END
time.'_'.rand(1000000000).'.csv';
unless ($CSVfile = Apache::File->new('>/home/httpd'.$CSVfilename)) {
$r->log_error("Couldn't open $CSVfilename for output $!");
- $r->print(&mt('Problems occurred in writing the csv file. '
+ $r->print(&mt('Problems occurred in writing the CSV file. '
.'This error has been logged. '
.'Please alert your LON-CAPA administrator.'));
$CSVfile = undef;
}
#
+ push @cols,'clicker';
# Write headers and data to file
print $CSVfile '"'.$results_description.'"'."\n";
print $CSVfile '"'.join('","',map {
&Apache::loncommon::csv_translate($lt{$_})
- } (@cols)).'"'."\n";
+ } (@cols))."\"\n";
} elsif ($mode eq 'excel') {
+ push @cols,'clicker';
# Create the excel spreadsheet
($excel_workbook,$excel_filename,$format) =
&Apache::loncommon::create_workbook($r);
@@ -2261,6 +2274,7 @@ END
$excel_sheet->write($row++,0,$results_description,$format->{'h2'});
#
my @colnames = map {$lt{$_}} (@cols);
+
$excel_sheet->write($row++,0,\@colnames,$format->{'bold'});
}
@@ -2412,7 +2426,10 @@ END
foreach my $item (@{$keylist}) {
$in{$item} = $sdata->[$index{$item}];
}
- my $role = $in{'role'};
+ my $clickers = (&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1];
+ if ($clickers!~/\w/) { $clickers='-'; }
+ $in{'clicker'} = $clickers;
+ my $role = $in{'role'};
$in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}]);
if (! defined($in{'start'}) || $in{'start'} == 0) {
$in{'start'} = &mt('none');
@@ -2532,7 +2549,7 @@ END
foreach my $item (@cols) {
push @line,&Apache::loncommon::csv_translate($in{$item});
}
- print $CSVfile '"'.join('","',@line).'"'."\n";
+ print $CSVfile '"'.join('","',@line)."\"\n";
} elsif ($mode eq 'excel') {
my $col = 0;
foreach my $item (@cols) {
@@ -2555,12 +2572,10 @@ END
$r->print(&Apache::loncommon::end_data_table().'
');
} elsif ($mode eq 'excel') {
$excel_workbook->close();
- $r->print('
'. - &mt('Your Excel spreadsheet').' '.&mt('is ready for download').'.
'."\n"); + $r->print(&mt('[_1]Your Excel spreadsheet[_2] is ready for download.', '','')."
\n"); } elsif ($mode eq 'csv') { close($CSVfile); - $r->print(''. - &mt('Your CSV file').' '.&mt('is ready for download').'.
'."\n"); + $r->print(&mt('[_1]Your CSV file[_2] is ready for download.', '','')."
\n"); $r->rflush(); } if ($mode eq 'autoenroll') { @@ -3507,7 +3522,9 @@ sub upfile_drop_add { if ($context eq 'course') { my ($cnum,$cdom) = &get_course_identity(); my $roster = &Apache::loncoursedata::get_classlist(); - %userlist = %{$roster}; + if (ref($roster) eq 'HASH') { + %userlist = %{$roster}; + } my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef, \@statuses,\@poss_roles); &gather_userinfo($context,'view',\%userlist,$indexhash,\%info, @@ -3898,7 +3915,7 @@ sub upfile_drop_add { ''. &mt('There are no students with current/future access to the course.'). ''."\n"); - } else { + } elsif (ref($classlist) eq 'HASH') { # Remove the students we just added from the list of students. foreach my $line (@userdata) { my %entries=&Apache::loncommon::record_sep($line);