version 1.56, 2002/10/15 14:41:31
|
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 752 sub print_drop_menu {
|
Line 754 sub print_drop_menu {
|
# ============================================== view classlist |
# ============================================== view classlist |
sub print_html_classlist { |
sub print_html_classlist { |
my $r=shift; |
my $r=shift; |
|
if (! exists($ENV{'form.sortby'})) { |
|
$ENV{'form.sortby'} = 'username'; |
|
} |
|
if ($ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) { |
|
$ENV{'form.Status'} = 'Active'; |
|
} |
|
my $status_select = &Apache::lonhtmlcommon::StatusOptions |
|
($ENV{'form.Status'},'studentform'); |
$r->print(<<END); |
$r->print(<<END); |
|
<input type="hidden" name="action" value="$ENV{'form.action'}" /> |
|
<input type="hidden" name="state" value="" /> |
<p> |
<p> |
<font size="+1">Current Classlist</font> |
<font size="+1">Current Classlist</font> |
<font size="+1"><a href="/adm/dropadd?action=classlist&state=csv">CSV format</a></font> |
|
</p> |
|
END |
END |
|
if ($ENV{'form.action'} ne 'modifystudent') { |
|
$r->print(<<END); |
|
<font size="+1"> |
|
<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> |
|
|
|
Student Status: |
|
END |
|
} |
|
$r->print($status_select."</p>\n"); |
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)) { |
Line 766 END
|
Line 789 END
|
# Print out the available choices |
# Print out the available choices |
if ($ENV{'form.action'} eq 'modifystudent') { |
if ($ENV{'form.action'} eq 'modifystudent') { |
&show_class_list($r,'view','modify','modifystudent', |
&show_class_list($r,'view','modify','modifystudent', |
'Active',$classlist,$keylist); |
$ENV{'form.Status'},$classlist,$keylist); |
} else { |
} else { |
&show_class_list($r,'view','aboutme','classlist', |
&show_class_list($r,'view','aboutme','classlist', |
'Active',$classlist,$keylist); |
$ENV{'form.Status'},$classlist,$keylist); |
} |
} |
} |
} |
} |
} |
|
|
# ============================================== 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', |
'Active',$classlist,$keylist); |
$ENV{'form.Status'},$classlist,$keylist); |
} |
} |
} |
} |
|
|
Line 791 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 805 sub show_class_list {
|
Line 831 sub show_class_list {
|
$r->print('Select a user name to modify the students information'); |
$r->print('Select a user name to modify the students information'); |
} |
} |
$r->print(<<END); |
$r->print(<<END); |
|
|
<input type="hidden" name="sortby" value="$sortby" /> |
<input type="hidden" name="sortby" value="$sortby" /> |
|
<input type="hidden" name="sname" value="" /> |
|
<input type="hidden" name="sdom" value="" /> |
<p> |
<p> |
<table border=2> |
<table border=2> |
<tr><th> |
<tr><th> |
<a href="/adm/dropadd?action=$action&sortby=username">username</a> |
<a href="javascript:document.studentform.sortby.value='username';document.studentform.submit();">username</a> |
</th><th> |
</th><th> |
<a href="/adm/dropadd?action=$action&sortby=domain">domain</a> |
<a href="javascript:document.studentform.sortby.value='domain';document.studentform.submit();">domain</a> |
</th><th> |
</th><th> |
<a href="/adm/dropadd?action=$action&sortby=id">ID</a> |
<a href="javascript:document.studentform.sortby.value='id';document.studentform.submit();">ID</a> |
</th><th> |
</th><th> |
<a href="/adm/dropadd?action=$action&sortby=fullname">student name</a> |
<a href="javascript:document.studentform.sortby.value='fullname';document.studentform.submit();">student name</a> |
</th><th> |
</th><th> |
<a href="/adm/dropadd?action=$action&sortby=section">section</a> |
<a href="javascript:document.studentform.sortby.value='section';document.studentform.submit();">section</a> |
</th> |
</th> |
</tr> |
</tr> |
END |
END |
} elsif ($mode eq 'csv') { |
} elsif ($mode eq 'csv') { |
$r->print('"'.join('","',("username","domain","ID","student name", |
if($statusmode eq 'Expired') { |
"section")).'"'."\n"); |
$r->print('"Students with expired roles"'); |
|
} |
|
if ($statusmode eq 'Any') { |
|
$r->print('"'.join('","',("username","domain","ID","student name", |
|
"section","status")).'"'."\n"); |
|
} else { |
|
$r->print('"'.join('","',("username","domain","ID","student name", |
|
"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 849 END
|
Line 902 END
|
my $name = $classlist->{$student}->[$index{'fullname'}]; |
my $name = $classlist->{$student}->[$index{'fullname'}]; |
my $id = $classlist->{$student}->[$index{'id'}]; |
my $id = $classlist->{$student}->[$index{'id'}]; |
my $status = $classlist->{$student}->[$index{'status'}]; |
my $status = $classlist->{$student}->[$index{'status'}]; |
next if (($statusmode ne 'any') && ($status ne $statusmode)); |
next if (($statusmode ne 'Any') && ($status ne $statusmode)); |
if ($mode eq 'view') { |
if ($mode eq 'view') { |
$r->print("<tr>\n <td>\n "); |
$r->print("<tr>\n <td>\n "); |
if ($linkto eq 'nothing') { |
if ($linkto eq 'nothing') { |
Line 859 END
|
Line 912 END
|
$username, |
$username, |
$domain)); |
$domain)); |
} elsif ($linkto eq 'modify') { |
} elsif ($linkto eq 'modify') { |
$r->print('<a href="/adm/dropadd?action=modifystudent'. |
$r->print('<a href="'. |
'&state=selected'.'&sname='.$username. |
"javascript:document.studentform.sname.value='". |
'&sdom='.$domain.'&sortby='.$sortby.'">'. |
$username. |
|
"';document.studentform.sdom.value='".$domain. |
|
"';document.studentform.state.value='selected". |
|
"';document.studentform.submit();".'">'. |
$username."</a>\n"); |
$username."</a>\n"); |
} |
} |
$r->print(<<"END"); |
$r->print(<<"END"); |
Line 878 END
|
Line 934 END
|
foreach ($username,$domain,$id,$name,$section) { |
foreach ($username,$domain,$id,$name,$section) { |
push @line,&Apache::loncommon::csv_translate($_); |
push @line,&Apache::loncommon::csv_translate($_); |
} |
} |
|
if ($statusmode eq 'Any') { |
|
push @line,&Apache::loncommon::csv_translate($status); |
|
} |
my $tmp = $"; |
my $tmp = $"; |
$" = '","'; |
$" = '","'; |
$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 894 END
|
Line 962 END
|
sub print_modify_student_form { |
sub print_modify_student_form { |
my $r = shift(); |
my $r = shift(); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
['sdom','sname','sortby']); |
['sdom','sname']); |
my $sname = $ENV{'form.sname'}; |
my $sname = $ENV{'form.sname'}; |
my $sdom = $ENV{'form.sdom'}; |
my $sdom = $ENV{'form.sdom'}; |
my $sortby = $ENV{'form.sortby'}; |
my $sortby = $ENV{'form.sortby'}; |
Line 922 sub print_modify_student_form {
|
Line 990 sub print_modify_student_form {
|
my $enddateform = &Apache::lonhtmlcommon::date_setter('studentform', |
my $enddateform = &Apache::lonhtmlcommon::date_setter('studentform', |
'enddate', |
'enddate', |
$endtime); |
$endtime); |
|
# |
|
if (! exists($ENV{'form.Status'}) || |
|
$ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) { |
|
$ENV{'form.Status'} = 'crap'; |
|
} |
# Make sure student is enrolled in course |
# Make sure student is enrolled in course |
$r->print(<<END); |
$r->print(<<END); |
<p> |
<p> |
Line 934 Only domain coordinators can change a us
|
Line 1007 Only domain coordinators can change a us
|
<input type="hidden" name="action" value="modifystudent" /> |
<input type="hidden" name="action" value="modifystudent" /> |
<input type="hidden" name="state" value="done" /> |
<input type="hidden" name="state" value="done" /> |
<input type="hidden" name="sortby" value="$sortby" /> |
<input type="hidden" name="sortby" value="$sortby" /> |
|
<input type="hidden" name="Status" value="$ENV{'form.Status'}" /> |
|
|
<h2>Modify Enrollment for $info{'firstname'} $info{'middlename'} |
<h2>Modify Enrollment for $info{'firstname'} $info{'middlename'} |
$info{'lastname'} $info{'generation'}, $sname\@$sdom</h2> |
$info{'lastname'} $info{'generation'}, $sname\@$sdom</h2> |
<p> |
<p> |
Line 971 END
|
Line 1046 END
|
# |
# |
sub modify_single_student { |
sub modify_single_student { |
my $r = shift; |
my $r = shift; |
# Get the 'sortby' variable so the user does not need to re-sort |
# Get the 'sortby' and 'Status' variables so the user goes back to their |
|
# previous screen |
my $sortby = $ENV{'form.sortby'}; |
my $sortby = $ENV{'form.sortby'}; |
|
my $status = $ENV{'form.Status'}; |
# |
# |
# We always need this information |
# We always need this information |
my $slogin = $ENV{'form.slogin'}; |
my $slogin = $ENV{'form.slogin'}; |
Line 983 sub modify_single_student {
|
Line 1060 sub modify_single_student {
|
['firstname','middlename', |
['firstname','middlename', |
'lastname','generation','id'], |
'lastname','generation','id'], |
$sdom, $slogin); |
$sdom, $slogin); |
|
$old{'section'} = &Apache::lonnet::getsection($sdom,$slogin, |
|
$ENV{'request.course.id'}); |
my ($tmp) = keys(%old); |
my ($tmp) = keys(%old); |
if ($tmp =~ /^(con_lost|error|no_such_host)/i) { |
if ($tmp =~ /^(con_lost|error|no_such_host)/i) { |
$r->print("There was an error determining the environment values ". |
$r->print("There was an error determining the environment values ". |
Line 1007 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 1044 sub modify_single_student {
|
Line 1124 sub modify_single_student {
|
<td> <b>ID</b> </td> |
<td> <b>ID</b> </td> |
<td> $old{'id'} </td> |
<td> $old{'id'} </td> |
<td> $sid </td> |
<td> $sid </td> |
|
</tr><tr> |
|
<td> <b>Section</b> </td> |
|
<td> $old{'section'} </td> |
|
<td> $section</td> |
</tr> |
</tr> |
</table> |
</table> |
<h3>Role Information</h3> |
<h3>Role Information</h3> |
<table> |
<table> |
<tr><td>Section </td><td> $section </td></tr> |
|
<tr><td>Start Time </td><td> $displayable_starttime </td></tr> |
<tr><td>Start Time </td><td> $displayable_starttime </td></tr> |
<tr><td>End Time </td><td> $displayable_endtime </td></tr> |
<tr><td>End Time </td><td> $displayable_endtime </td></tr> |
</table> |
</table> |
<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 1079 END
|
Line 1170 END
|
} |
} |
$r->print(<<END); |
$r->print(<<END); |
</p><p> |
</p><p> |
<a href="/adm/dropadd?action=modifystudent&sortby=$sortby">Modify another students data</a> |
<input type="hidden" name="action" value="modifystudent" /> |
|
<input type="hidden" name="sortby" value="$sortby" /> |
|
<input type="hidden" name="Status" value="$status" /> |
|
<a href="javascript:document.studentform.submit();">Modify another students data</a> |
</body></html> |
</body></html> |
END |
END |
return; |
return; |
Line 1148 which describes the order elements are s
|
Line 1242 which describes the order elements are s
|
sub show_drop_list { |
sub show_drop_list { |
my ($r,$classlist,$keylist,$nosort)=@_; |
my ($r,$classlist,$keylist,$nosort)=@_; |
my $cid=$ENV{'request.course.id'}; |
my $cid=$ENV{'request.course.id'}; |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
if (! exists($ENV{'form.sortby'})) { |
['sortby']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['sortby']); |
|
} |
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 1475 sub drop_student_list {
|
Line 1571 sub drop_student_list {
|
my $result = &modifystudent($udom,$uname,$ENV{'request.course.id'}); |
my $result = &modifystudent($udom,$uname,$ENV{'request.course.id'}); |
if ($result eq 'ok' || $result eq 'ok:') { |
if ($result eq 'ok' || $result eq 'ok:') { |
$r->print('Dropped '.$uname.' @ '.$udom.'<br>'); |
$r->print('Dropped '.$uname.' @ '.$udom.'<br>'); |
|
$count++; |
} else { |
} else { |
$r->print('Error dropping '.$uname.' @ '.$udom.': '.$result. |
$r->print('Error dropping '.$uname.' @ '.$udom.': '.$result. |
'<br />'); |
'<br />'); |
} |
} |
$count++; |
|
} |
} |
$r->print('<p><b>Dropped '.$count.' student(s).</b>'); |
$r->print('<p><b>Dropped '.$count.' student(s).</b>'); |
$r->print('<p>Re-enrollment will re-activate data.'); |
$r->print('<p>Re-enrollment will re-activate data.') if ($count); |
} |
} |
|
|
################################################################### |
################################################################### |
Line 1584 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); |
} |
} |