version 1.142, 2006/05/11 20:09:47
|
version 1.155, 2007/01/10 21:37:50
|
Line 39 use Apache::Constants qw(:common :http R
|
Line 39 use Apache::Constants qw(:common :http R
|
use Spreadsheet::WriteExcel; |
use Spreadsheet::WriteExcel; |
use Apache::lonstathelpers(); |
use Apache::lonstathelpers(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use Apache::longroup; |
|
use LONCAPA(); |
|
|
############################################################### |
############################################################### |
############################################################### |
############################################################### |
Line 59 sub modifystudent {
|
Line 61 sub modifystudent {
|
# if $csec is undefined, drop the student from all the courses matching |
# if $csec is undefined, drop the student from all the courses matching |
# this one. If $csec is defined, drop them from all other sections of |
# this one. If $csec is defined, drop them from all other sections of |
# this course and add them to section $csec |
# this course and add them to section $csec |
$courseid=~s/\_/\//g; |
my $cdom = $env{'course.'.$courseid.'.domain'}; |
$courseid=~s/^(\w)/\/$1/; |
my $cnum = $env{'course.'.$courseid.'.num'}; |
my %roles = &Apache::lonnet::dump('roles',$udom,$unam); |
my %roles = &Apache::lonnet::dump('roles',$udom,$unam); |
my ($tmp) = keys(%roles); |
my ($tmp) = keys(%roles); |
# Bail out if we were unable to get the students roles |
# Bail out if we were unable to get the students roles |
Line 68 sub modifystudent {
|
Line 70 sub modifystudent {
|
# Go through the roles looking for enrollment in this course |
# Go through the roles looking for enrollment in this course |
my $result = ''; |
my $result = ''; |
foreach my $course (keys(%roles)) { |
foreach my $course (keys(%roles)) { |
if ($course=~/^$courseid(?:\/)*(?:\s+)*(\w+)*\_st$/) { |
if ($course=~m{^/\Q$cdom\E/\Q$cnum\E(?:\/)*(?:\s+)*(\w+)*\_st$}) { |
# We are in this course |
# We are in this course |
my $section=$1; |
my $section=$1; |
$section='' if ($course eq $courseid.'_st'); |
$section='' if ($course eq "/$cdom/$cnum".'_st'); |
if (defined($csec) && $section eq $csec) { |
if (defined($csec) && $section eq $csec) { |
$result .= 'ok:'; |
$result .= 'ok:'; |
} elsif ( ((!$section) && (!$csec)) || ($section ne $csec) ) { |
} elsif ( ((!$section) && (!$csec)) || ($section ne $csec) ) { |
my (undef,$end,$start)=split(/\_/,$roles{$course}); |
my (undef,$end,$start)=split(/\_/,$roles{$course}); |
my $now=time; |
my $now=time; |
# if this is an active role |
# if this is an active role |
if (!($start && ($now<$start)) || !($end && ($now>$end))) { |
if (!($start && ($now<$start)) || !($end && ($now>$end))) { |
my $reply=&Apache::lonnet::modifystudent |
my $reply=&Apache::lonnet::modifystudent |
# dom name id mode pass f m l g |
# dom name id mode pass f m l g |
Line 134 sub print_main_menu {
|
Line 136 sub print_main_menu {
|
my ($r,$enrl_permission,$view_permission,$grp_manage_permission, |
my ($r,$enrl_permission,$view_permission,$grp_manage_permission, |
$grp_view_permission)=@_; |
$grp_view_permission)=@_; |
# |
# |
my ($cdom,$cnum) = split/_/,$env{'request.course.id'}; |
my $cid =$env{'request.course.id'}; |
|
my $cdom=$env{'course.'.$cid.'.domain'}; |
|
my $cnum=$env{'course.'.$cid.'.num'}; |
my @menu = |
my @menu = |
( |
( |
{ text => 'Upload a class list', |
{ text => 'Upload a class list', |
Line 181 sub print_main_menu {
|
Line 185 sub print_main_menu {
|
permission => $grp_manage_permission, |
permission => $grp_manage_permission, |
url => '/adm/coursegroups?refpage=enrl&action=delete', |
url => '/adm/coursegroups?refpage=enrl&action=delete', |
}, |
}, |
|
{ text => 'Re-enable a deleted group', |
|
help => 'Course_Reenable_Group', |
|
permission => $grp_manage_permission, |
|
url => '/adm/coursegroups?refpage=enrl&action=reenable', |
|
}, |
{ text => 'Enter an existing group', |
{ text => 'Enter an existing group', |
help => 'Course_Display_Group', |
help => 'Course_Display_Group', |
permission => $grp_view_permission, |
permission => $grp_view_permission, |
Line 249 sub print_upload_manager_header {
|
Line 258 sub print_upload_manager_header {
|
# |
# |
my $javascript_validations=&javascript_validations('auth',$krbdefdom, |
my $javascript_validations=&javascript_validations('auth',$krbdefdom, |
$password_choice); |
$password_choice); |
my $checked=(($env{'form.noFirstLine'})?' checked="1"':''); |
my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':''); |
$r->print('<h3>'.&mt('Uploading Class List')."</h3>\n". |
$r->print('<h3>'.&mt('Uploading Class List')."</h3>\n". |
"<hr>\n". |
"<hr>\n". |
'<h3>'.&mt('Identify fields')."</h3>\n"); |
'<h3>'.&mt('Identify fields')."</h3>\n"); |
Line 268 sub print_upload_manager_header {
|
Line 277 sub print_upload_manager_header {
|
$r->print('<input type="button" value="Reverse Association" '. |
$r->print('<input type="button" value="Reverse Association" '. |
'name="'.&mt('Reverse Association').'" '. |
'name="'.&mt('Reverse Association').'" '. |
'onClick="javascript:this.form.associate.value=\'Reverse Association\';submit(this.form);" />'); |
'onClick="javascript:this.form.associate.value=\'Reverse Association\';submit(this.form);" />'); |
$r->print('<label><input type="checkbox" name="noFirstLine" $checked />'. |
$r->print('<label><input type="checkbox" name="noFirstLine"'.$checked.'/>'. |
&mt('Ignore First Line').'</label>'); |
&mt('Ignore First Line').'</label>'); |
$r->print("<hr />\n". |
$r->print("<hr />\n". |
'<script type="text/javascript" language="Javascript">'."\n". |
'<script type="text/javascript" language="Javascript">'."\n". |
Line 745 sub enroll_single_student {
|
Line 754 sub enroll_single_student {
|
$r->print('<h3>'.&mt('Enrolling Student').'</h3>'); |
$r->print('<h3>'.&mt('Enrolling Student').'</h3>'); |
$r->print('<p>'.&mt('Enrolling').' '.$env{'form.cuname'}." \@ ". |
$r->print('<p>'.&mt('Enrolling').' '.$env{'form.cuname'}." \@ ". |
$env{'form.lcdomain'}.'</p>'); |
$env{'form.lcdomain'}.'</p>'); |
if (($env{'form.cuname'})&&($env{'form.cuname'}!~/\W/)&& |
if (($env{'form.cuname'}) |
($env{'form.lcdomain'})&&($env{'form.lcdomain'}!~/\W/)) { |
&& ($env{'form.cuname'} |
|
eq &LONCAPA::clean_username($env{'form.cuname'})) |
|
&& ($env{'form.lcdomain'}) |
|
&& ($env{'form.lcdomain'} |
|
eq &LONCAPA::clean_domain($env{'form.lcdomain'}))) { |
# Deal with home server selection |
# Deal with home server selection |
my $domain=$env{'form.lcdomain'}; |
my $domain=$env{'form.lcdomain'}; |
my $desiredhost = $env{'form.lcserver'}; |
my $desiredhost = $env{'form.lcserver'}; |
Line 809 sub enroll_single_student {
|
Line 822 sub enroll_single_student {
|
} else { |
} else { |
$r->print(&mt('Invalid username or domain')); |
$r->print(&mt('Invalid username or domain')); |
} |
} |
|
$r->print("<p><a href='/adm/dropadd?action=enrollstudent'>".&mt("Enroll another student")."</a></p>"); |
} |
} |
|
|
sub setup_date_selectors { |
sub setup_date_selectors { |
Line 956 sub print_enroll_single_student_form {
|
Line 970 sub print_enroll_single_student_form {
|
my $r=shift; |
my $r=shift; |
$r->print("<h3>".&mt('Enroll One Student')."</h3>"); |
$r->print("<h3>".&mt('Enroll One Student')."</h3>"); |
# |
# |
my $username = $env{'form.cuname'}; |
my $username = &LONCAPA::clean_username($env{'form.cuname'}); |
my $domain = $env{'form.cudomain'}; |
my $domain = &LONCAPA::clean_domain($env{'form.cudomain'}); |
$username=~s/\W//gs; |
|
$domain=~s/\W//gs; |
|
my $home = &Apache::lonnet::homeserver($username,$domain); |
my $home = &Apache::lonnet::homeserver($username,$domain); |
# $new_user flags whether we are creating a new user or using an old one |
# $new_user flags whether we are creating a new user or using an old one |
my $new_user = 1; |
my $new_user = 1; |
Line 1171 sub print_html_classlist {
|
Line 1183 sub print_html_classlist {
|
if (! exists($env{'form.sortby'})) { |
if (! exists($env{'form.sortby'})) { |
$env{'form.sortby'} = 'username'; |
$env{'form.sortby'} = 'username'; |
} |
} |
if ($env{'form.Status'} !~ /^(Any|Expired|Active)$/) { |
if ($env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) { |
$env{'form.Status'} = 'Active'; |
$env{'form.Status'} = 'Active'; |
} |
} |
my $status_select = &Apache::lonhtmlcommon::StatusOptions |
my $status_select = &Apache::lonhtmlcommon::StatusOptions |
($env{'form.Status'}); |
($env{'form.Status'}); |
my $cid=$env{'request.course.id'}; |
my $cid =$env{'request.course.id'}; |
my $cdom=$env{'course.'.$cid.'.domain'}; |
my $cdom=$env{'course.'.$cid.'.domain'}; |
my $cnum=$env{'course.'.$cid.'.num'}; |
my $cnum=$env{'course.'.$cid.'.num'}; |
# |
# |
Line 1382 END
|
Line 1394 END
|
if($statusmode eq 'Expired') { |
if($statusmode eq 'Expired') { |
print $CSVfile '"'.&mt('Students with expired roles').'"'."\n"; |
print $CSVfile '"'.&mt('Students with expired roles').'"'."\n"; |
} |
} |
|
if($statusmode eq 'Future') { |
|
print $CSVfile '"'.&mt('Students with future roles').'"'."\n"; |
|
} |
if ($statusmode eq 'Any') { |
if ($statusmode eq 'Any') { |
print $CSVfile '"'.join('","',map { |
print $CSVfile '"'.join('","',map { |
&Apache::loncommon::csv_translate(&mt($_)) |
&Apache::loncommon::csv_translate(&mt($_)) |
Line 1641 sub print_modify_student_form {
|
Line 1656 sub print_modify_student_form {
|
my $date_table = &date_setting_table($starttime,$endtime); |
my $date_table = &date_setting_table($starttime,$endtime); |
# |
# |
if (! exists($env{'form.Status'}) || |
if (! exists($env{'form.Status'}) || |
$env{'form.Status'} !~ /^(Any|Expired|Active)$/) { |
$env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) { |
$env{'form.Status'} = 'crap'; |
$env{'form.Status'} = 'crap'; |
} |
} |
# Make sure student is enrolled in course |
# Make sure student is enrolled in course |
Line 1866 END
|
Line 1881 END
|
sub get_enrollment_data { |
sub get_enrollment_data { |
my ($sname,$sdomain) = @_; |
my ($sname,$sdomain) = @_; |
my $courseid = $env{'request.course.id'}; |
my $courseid = $env{'request.course.id'}; |
$courseid =~ s:_:/:g; |
my $cdom = $env{'course.'.$courseid.'.domain'}; |
|
my $cnum = $env{'course.'.$courseid.'.num'}; |
my %roles = &Apache::lonnet::dump('roles',$sdomain,$sname); |
my %roles = &Apache::lonnet::dump('roles',$sdomain,$sname); |
my ($tmp) = keys(%roles); |
my ($tmp) = keys(%roles); |
# Bail out if we were unable to get the students roles |
# Bail out if we were unable to get the students roles |
Line 1876 sub get_enrollment_data {
|
Line 1892 sub get_enrollment_data {
|
my $section = ''; |
my $section = ''; |
my $count = scalar(keys(%roles)); |
my $count = scalar(keys(%roles)); |
while (my ($course,$role) = each(%roles)) { |
while (my ($course,$role) = each(%roles)) { |
if ($course=~ /^\/$courseid\/*\s*(\w+)*_st$/ ) { |
if ($course=~m{^/\Q$cdom\E/\Q$cnum\E/*\s*(\w+)*_st$} ) { |
# |
# |
# Get active role |
# Get active role |
$section=$1; |
$section=$1; |
Line 1936 sub show_drop_list {
|
Line 1952 sub show_drop_list {
|
my $cdom = $env{'course.'.$cid.'.domain'}; |
my $cdom = $env{'course.'.$cid.'.domain'}; |
my $cnum = $env{'course.'.$cid,'.num'}; |
my $cnum = $env{'course.'.$cid,'.num'}; |
my ($classgroups) = &Apache::loncoursedata::get_group_memberships( |
my ($classgroups) = &Apache::loncoursedata::get_group_memberships( |
$classlist,$cdom,$cnum); |
$classlist,$keylist,$cdom,$cnum); |
# |
# |
my $action = "drop"; |
my $action = "drop"; |
$r->print(<<END); |
$r->print(<<END); |
Line 2189 sub upfile_drop_add {
|
Line 2205 sub upfile_drop_add {
|
$amode = ''; # This causes the loop below to be skipped |
$amode = ''; # This causes the loop below to be skipped |
} |
} |
} |
} |
unless (($domain=~/\W/) || ($amode eq '')) { |
if ( $domain eq &LONCAPA::clean_domain($domain) |
|
&& ($amode ne '')) { |
####################################### |
####################################### |
## Enroll Students ## |
## Enroll Students ## |
####################################### |
####################################### |
Line 2198 sub upfile_drop_add {
|
Line 2215 sub upfile_drop_add {
|
my $flushc=0; |
my $flushc=0; |
my %student=(); |
my %student=(); |
# Get information about course groups |
# Get information about course groups |
my %curr_groups = &Apache::loncommon::coursegroups(); |
my %curr_groups = &Apache::longroup::coursegroups(); |
# Get new classlist |
# Get new classlist |
foreach (@studentdata) { |
foreach (@studentdata) { |
my %entries=&Apache::loncommon::record_sep($_); |
my %entries=&Apache::loncommon::record_sep($_); |
Line 2223 sub upfile_drop_add {
|
Line 2240 sub upfile_drop_add {
|
$gen=$entries{$fields{'gen'}}; |
$gen=$entries{$fields{'gen'}}; |
} |
} |
} |
} |
if ($entries{$fields{'username'}}=~/\W/) { |
if ($entries{$fields{'username'}} |
|
ne &LONCAPA::clean_username($entries{$fields{'username'}})) { |
$r->print('<br />'. |
$r->print('<br />'. |
&mt('<b>[_1]</b>: Unacceptable username for user [_2] [_3] [_4] [_5]', |
&mt('<b>[_1]</b>: Unacceptable username for user [_2] [_3] [_4] [_5]', |
$entries{$fields{'username'}},$fname,$mname,$lname,$gen). |
$entries{$fields{'username'}},$fname,$mname,$lname,$gen). |
Line 2367 sub drop_student_list {
|
Line 2385 sub drop_student_list {
|
|
|
sub section_check_js { |
sub section_check_js { |
my $groupslist; |
my $groupslist; |
my %curr_groups = &Apache::loncommon::coursegroups(); |
my %curr_groups = &Apache::longroup::coursegroups(); |
if (%curr_groups) { |
if (%curr_groups) { |
$groupslist = join('","',sort(keys(%curr_groups))); |
$groupslist = join('","',sort(keys(%curr_groups))); |
} |
} |