--- loncom/interface/Attic/londropadd.pm 2006/11/23 00:17:01 1.149 +++ loncom/interface/Attic/londropadd.pm 2007/07/17 21:24:17 1.163 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to drop and add students in courses # -# $Id: londropadd.pm,v 1.149 2006/11/23 00:17:01 albertel Exp $ +# $Id: londropadd.pm,v 1.163 2007/07/17 21:24:17 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -40,6 +40,7 @@ use Spreadsheet::WriteExcel; use Apache::lonstathelpers(); use Apache::lonlocal; use Apache::longroup; +use LONCAPA(); ############################################################### ############################################################### @@ -60,8 +61,8 @@ sub modifystudent { # 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 course and add them to section $csec - $courseid=~s/\_/\//g; - $courseid=~s/^(\w)/\/$1/; + my $cdom = $env{'course.'.$courseid.'.domain'}; + my $cnum = $env{'course.'.$courseid.'.num'}; my %roles = &Apache::lonnet::dump('roles',$udom,$unam); my ($tmp) = keys(%roles); # Bail out if we were unable to get the students roles @@ -69,10 +70,10 @@ sub modifystudent { # Go through the roles looking for enrollment in this course my $result = ''; 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 my $section=$1; - $section='' if ($course eq $courseid.'_st'); + $section='' if ($course eq "/$cdom/$cnum".'_st'); if (defined($csec) && $section eq $csec) { $result .= 'ok:'; } elsif ( ((!$section) && (!$csec)) || ($section ne $csec) ) { @@ -105,7 +106,7 @@ sub domain_form { # Set up domain and server selection forms # # Get the domains - my @domains = &Apache::loncommon::get_domains(); + my @domains = &Apache::lonnet::all_domains(); # build up the menu information to be passed to # &Apache::loncommon::linked_select_forms my %select_menus; @@ -116,7 +117,7 @@ sub domain_form { $select_menus{$dom}->{'default'}= 'default'; $select_menus{$dom}->{'select2'}->{'default'} = 'default'; # Now build up the other items in the second menu - my %servers = &Apache::loncommon::get_library_servers($dom); + my %servers = &Apache::lonnet::get_servers($dom,'library'); foreach my $server (keys(%servers)) { $select_menus{$dom}->{'select2'}->{$server} = "$server $servers{$server}"; @@ -135,7 +136,9 @@ sub print_main_menu { my ($r,$enrl_permission,$view_permission,$grp_manage_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 = ( { text => 'Upload a class list', @@ -177,11 +180,16 @@ sub print_main_menu { permission => $grp_manage_permission, url => '/adm/coursegroups?refpage=enrl&action=modify', }, -# { text => 'Delete an existing group', -# help => 'Course_Delete_Group', -# permission => $grp_manage_permission, -# url => '/adm/coursegroups?refpage=enrl&action=delete', -# }, + { text => 'Delete an existing group', + help => 'Course_Delete_Group', + permission => $grp_manage_permission, + 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', help => 'Course_Display_Group', permission => $grp_view_permission, @@ -744,17 +752,21 @@ sub enroll_single_student { } $r->print('
'.&mt('Enrolling').' '.$env{'form.cuname'}." \@ ". - $env{'form.lcdomain'}.'
'); - if (($env{'form.cuname'})&&($env{'form.cuname'}!~/\W/)&& - ($env{'form.lcdomain'})&&($env{'form.lcdomain'}!~/\W/)) { + $r->print(''.&mt('Enrolling [_1] : [_2]',$env{'form.cuname'}, + $env{'form.lcdomain'}).'
'); + if (($env{'form.cuname'}) + && ($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 my $domain=$env{'form.lcdomain'}; my $desiredhost = $env{'form.lcserver'}; if (lc($desiredhost) eq 'default') { $desiredhost = undef; } else { - my %home_servers =&Apache::loncommon::get_library_servers($domain); + my %home_servers =&Apache::lonnet::get_servers($domain,'library'); if (! exists($home_servers{$desiredhost})) { $r->print(''.&mt('Error').':'. &mt('Invalid home server specified')); @@ -810,6 +822,7 @@ sub enroll_single_student { } else { $r->print(&mt('Invalid username or domain')); } + $r->print("".&mt("Enroll another student")."
"); } sub setup_date_selectors { @@ -873,7 +886,8 @@ sub date_setting_table { my ($startform,$endform)=&setup_date_selectors($starttime,$endtime,$mode); my $dateDefault = '$lt{'usr'}: | +|
---|---|
: | |
$lt{'dom'}: | +|
: | $domform |
+ | |
$lt{'grp'} + | + $lt{'email'} | END if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { @@ -1390,13 +1394,15 @@ END print $CSVfile '"'.join('","',map { &Apache::loncommon::csv_translate(&mt($_)) } ("username","domain","ID","student name", - "section","start date","end date","status","active groups")) + "section","start date","end date","status", + "active groups","email address")) .'"'."\n"; } else { print $CSVfile '"'.join('","',map { &Apache::loncommon::csv_translate(&mt($_)) } ("username","domain","ID","student name", - "section","start date","end date","active groups")).'"'."\n"; + "section","start date","end date", + "active groups","email address")).'"'."\n"; } } elsif ($mode eq 'excel') { # Create the excel spreadsheet @@ -1412,7 +1418,7 @@ END $excel_sheet->write($row++,0,["username","domain","ID", "student name","section", "start date","end date","status", - "active groups"], + "active groups","email address"], $format->{'bold'}); } # @@ -1451,10 +1457,21 @@ END my $name = $sdata->[$index{'fullname'}]; my $id = $sdata->[$index{'id'}]; my $status = $sdata->[$index{'status'}]; + next if (($statusmode ne 'Any') && ($status ne $statusmode)); my $start = $sdata->[$index{'start'}]; my $end = $sdata->[$index{'end'}]; my $type = $sdata->[$index{'type'}]; - next if (($statusmode ne 'Any') && ($status ne $statusmode)); + + my %emails = &Apache::loncommon::getemails($username,$domain); + my $email; + foreach my $type ('critnotification', 'permanentemail', + 'notification') { + if ($emails{$type} =~ /\S/) { + $email = $emails{$type}; + last; + } + } + if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll') { if (! defined($start) || $start == 0) { $start = &mt('none'); @@ -1514,6 +1531,7 @@ END$start | $end | $active_groups | +
-$lt{'sid'}: +$lt{'sid'}:
-$lt{'sec'}: +$lt{'sec'}:
$current_date_description
$date_table
@@ -1748,7 +1768,7 @@ sub modify_single_student { $env{'request.course.id'}); my ($tmp) = keys(%old); if ($tmp =~ /^(con_lost|error|no_such_host)/i) { - $r->print(&mt('There was an error determining the environment values for')." $slogin \@ $sdom."); + $r->print(&mt('There was an error determining the environment values for')." $slogin : $sdom."); return; } undef $tmp; @@ -1788,7 +1808,7 @@ sub modify_single_student { 'et' => "End Time", ); $r->print(<