version 1.59, 2002/10/16 18:45:10
|
version 1.63, 2002/12/10 00:54:37
|
Line 41 use Apache::lonnet();
|
Line 41 use Apache::lonnet();
|
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonhtmlcommon(); |
use Apache::Constants qw(:common :http REDIRECT); |
use Apache::Constants qw(:common :http REDIRECT); |
|
use Spreadsheet::WriteExcel; |
|
|
############################################################### |
############################################################### |
############################################################### |
############################################################### |
Line 92 sub modifystudent {
|
Line 93 sub modifystudent {
|
} |
} |
} |
} |
if ($result eq '') { |
if ($result eq '') { |
$result eq 'Unable to find section for this student'; |
$result = 'Unable to find section for this student'; |
} else { |
} else { |
$result =~ s/(ok:)+/ok/g; |
$result =~ s/(ok:)+/ok/g; |
} |
} |
Line 220 function verify_message (vf,founduname,f
|
Line 221 function verify_message (vf,founduname,f
|
alert('You need to specify the username field'); |
alert('You need to specify the username field'); |
return; |
return; |
} |
} |
|
// alert('current.radiovalue = '+current.radiovalue); |
if (current.radiovalue == null || current.radiovalue == 'nochange') { |
if (current.radiovalue == null || current.radiovalue == 'nochange') { |
// They did not check any of the login radiobuttons. |
// They did not check any of the login radiobuttons. |
alert('You must choose an authentication type'); |
alert('You must choose an authentication type'); |
Line 771 END
|
Line 773 END
|
$r->print(<<END); |
$r->print(<<END); |
<font size="+1"> |
<font size="+1"> |
<a href="javascript:document.studentform.state.value='csv';document.studentform.submit();">CSV format</a> |
<a href="javascript:document.studentform.state.value='csv';document.studentform.submit();">CSV format</a> |
|
|
|
<a href="javascript:document.studentform.state.value='excel';document.studentform.submit();">Excel format</a> |
</font> |
</font> |
|
|
|
Student Status: |
END |
END |
} |
} |
$r->print($status_select."</p>\n"); |
$r->print($status_select."</p>\n"); |
Line 793 END
|
Line 798 END
|
} |
} |
|
|
# ============================================== view classlist |
# ============================================== view classlist |
sub print_csv_classlist { |
sub print_formatted_classlist { |
my $r=shift; |
my $r=shift; |
|
my $mode = shift; |
my $cid=$ENV{'request.course.id'}; |
my $cid=$ENV{'request.course.id'}; |
my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist(); |
my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist(); |
if (! defined($classlist)) { |
if (! defined($classlist)) { |
$r->print("There are no students currently enrolled.\n"); |
$r->print("There are no students currently enrolled.\n"); |
} else { |
} else { |
&show_class_list($r,'csv','nolink','csv', |
&show_class_list($r,$mode,'nolink','csv', |
$ENV{'form.Status'},$classlist,$keylist); |
$ENV{'form.Status'},$classlist,$keylist); |
} |
} |
} |
} |
Line 809 sub print_csv_classlist {
|
Line 815 sub print_csv_classlist {
|
sub show_class_list { |
sub show_class_list { |
my ($r,$mode,$linkto,$action,$statusmode,$classlist,$keylist)=@_; |
my ($r,$mode,$linkto,$action,$statusmode,$classlist,$keylist)=@_; |
my $cid=$ENV{'request.course.id'}; |
my $cid=$ENV{'request.course.id'}; |
# &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
# |
# ['sortby']); |
# Variables for excel output |
|
my ($excel_workbook, $excel_sheet, $excel_filename,$row); |
|
# |
my $sortby = $ENV{'form.sortby'}; |
my $sortby = $ENV{'form.sortby'}; |
if ($sortby !~ /^(username|domain|section|fullname|id)$/) { |
if ($sortby !~ /^(username|domain|section|fullname|id)$/) { |
$sortby = 'username'; |
$sortby = 'username'; |
Line 853 END
|
Line 861 END
|
$r->print('"'.join('","',("username","domain","ID","student name", |
$r->print('"'.join('","',("username","domain","ID","student name", |
"section")).'"'."\n"); |
"section")).'"'."\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_sheet = $excel_workbook->addworksheet('classlist'); |
|
# |
|
my $description = 'Classlist for '. |
|
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}; |
|
$excel_sheet->write($row++,0,$description); |
|
# |
|
$excel_sheet->write($row++,0,["username","domain","ID", |
|
"student name","section","status"]); |
} |
} |
# |
# |
# Sort the students |
# Sort the students |
Line 917 END
|
Line 941 END
|
$" = '","'; |
$" = '","'; |
$r->print("\"@line\"\n"); |
$r->print("\"@line\"\n"); |
$" = $tmp; |
$" = $tmp; |
|
} elsif ($mode eq 'excel') { |
|
$excel_sheet->write($row++,0,[$username,$domain,$id, |
|
$name,$section,$status]); |
} |
} |
} |
} |
$r->print('</table><br>') if ($mode eq 'view'); |
if ($mode eq 'view') { |
|
$r->print('</table><br>'); |
|
} elsif ($mode eq 'excel') { |
|
$excel_workbook->close(); |
|
$r->print('<p><a href="'.$excel_filename.'">'. |
|
'Your Excel spreadsheet</a> is ready for download.</p>'."\n"); |
|
} |
} |
} |
|
|
|
|
Line 1053 sub modify_single_student {
|
Line 1086 sub modify_single_student {
|
my $displayable_endtime = localtime($endtime); |
my $displayable_endtime = localtime($endtime); |
# |
# |
# check for forceid override |
# check for forceid override |
if (($sid ne $old{'id'}) && (! exists($ENV{'form.forceid'}))) { |
if ((defined($old{'id'})) && ($old{'id'} ne '') && |
|
($sid ne $old{'id'}) && (! exists($ENV{'form.forceid'}))) { |
$r->print("<font color=\"ff0000\">You changed the students id ". |
$r->print("<font color=\"ff0000\">You changed the students id ". |
" but did not disable the ID change safeguard.". |
" but did not disable the ID change safeguard.". |
" The students id will not be changed.</font>"); |
" The students id will not be changed.</font>"); |
Line 1104 sub modify_single_student {
|
Line 1138 sub modify_single_student {
|
<p> |
<p> |
END |
END |
# |
# |
# Send request(s) to modify data |
# Send request(s) to modify data (final undef is for 'desiredhost', |
|
# which is a moot point because the student already has an account. |
|
my $modify_section_results = &modifystudent($sdom,$slogin, |
|
$ENV{'request.course.id'}, |
|
$section,undef); |
|
if ($modify_section_results !~ /^ok/) { |
|
$r->print("An error occured during the attempt to change the ". |
|
"section for this student.<br />"); |
|
} |
my $roleresults = &Apache::lonnet::modifystudent |
my $roleresults = &Apache::lonnet::modifystudent |
($sdom,$slogin,$sid,undef,undef,$firstname,$middlename,$lastname, |
($sdom,$slogin,$sid,undef,undef,$firstname,$middlename,$lastname, |
$generation,$section,$endtime,$starttime,$ENV{'form.forceid'}); |
$generation,$section,$endtime,$starttime,$ENV{'form.forceid'}); |
Line 1638 sub handler {
|
Line 1680 sub handler {
|
if (! exists($ENV{'form.state'})) { |
if (! exists($ENV{'form.state'})) { |
&print_html_classlist($r); |
&print_html_classlist($r); |
} elsif ($ENV{'form.state'} eq 'csv') { |
} elsif ($ENV{'form.state'} eq 'csv') { |
&print_csv_classlist($r); |
&print_formatted_classlist($r,'csv'); |
|
} elsif ($ENV{'form.state'} eq 'excel') { |
|
&print_formatted_classlist($r,'excel'); |
} else { |
} else { |
&print_html_classlist($r); |
&print_html_classlist($r); |
} |
} |