version 1.27, 2006/01/12 01:30:44
|
version 1.32, 2006/08/11 21:55:15
|
Line 27 package LONCAPA::Enrollment;
|
Line 27 package LONCAPA::Enrollment;
|
|
|
use Apache::loncoursedata; |
use Apache::loncoursedata; |
use Apache::lonnet; |
use Apache::lonnet; |
|
use Apache::loncommon(); |
use Apache::lonmsg; |
use Apache::lonmsg; |
|
use Apache::lonlocal; |
use HTML::Entities; |
use HTML::Entities; |
use LONCAPA::Configuration; |
use LONCAPA::Configuration; |
use Time::Local; |
use Time::Local; |
Line 36 use lib '/home/httpd/lib/perl';
|
Line 38 use lib '/home/httpd/lib/perl';
|
use strict; |
use strict; |
|
|
sub update_LC { |
sub update_LC { |
my ($dom,$crs,$adds,$drops,$startdate,$enddate,$authtype,$autharg,$classesref,$groupref,$logmsg,$newusermsg,$context) = @_; |
my ($dom,$crs,$adds,$drops,$startdate,$enddate,$authtype,$autharg,$classesref,$groupref,$logmsg,$newusermsg,$context,$phototypes) = @_; |
# Get institutional code and title of this class |
# Get institutional code and title of this class |
my %courseinfo = (); |
my %courseinfo = (); |
&get_courseinfo($dom,$crs,\%courseinfo); |
&get_courseinfo($dom,$crs,\%courseinfo); |
Line 75 sub update_LC {
|
Line 77 sub update_LC {
|
my $addresult = ''; |
my $addresult = ''; |
my $dropresult = ''; |
my $dropresult = ''; |
my $switchresult = ''; |
my $switchresult = ''; |
|
my $photoresult = ''; |
if ($context eq "updatenow") { |
if ($context eq "updatenow") { |
$linefeed = "</li>\n<li>"; |
$linefeed = "</li>\n<li>"; |
} elsif ($context eq "automated") { |
} elsif ($context eq "automated") { |
Line 192 sub update_LC {
|
Line 195 sub update_LC {
|
@{$unameFromINid{$stuID}} = $uname; |
@{$unameFromINid{$stuID}} = $uname; |
} |
} |
} |
} |
|
|
# Explicitly allow access to creation/modification of students if called as an automated process. |
# Explicitly allow access to creation/modification of students if called as an automated process. |
if ($context eq 'automated') { |
if ($context eq 'automated') { |
$env{'allowed.cst'}='F'; |
$env{'allowed.cst'}='F'; |
Line 323 sub update_LC {
|
Line 327 sub update_LC {
|
} else { |
} else { |
&execute_add($context,'newstudent',$uname,$dom,$auth,$authparam,$first,$middle,$last,$gene,$pid,$usec,$end,$start,$emailenc,$cid,\$addresult,\$enrollcount,$linefeed,$logmsg); |
&execute_add($context,'newstudent',$uname,$dom,$auth,$authparam,$first,$middle,$last,$gene,$pid,$usec,$end,$start,$emailenc,$cid,\$addresult,\$enrollcount,$linefeed,$logmsg); |
} |
} |
|
if ($courseinfo{'showphoto'}) { |
|
my ($result,$resulttype) = |
|
&Apache::lonnet::auto_checkphotos($uname,$dom,$pid); |
|
if ($resulttype) { |
|
push(@{$$phototypes{$resulttype}},$uname); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($courseinfo{'showphoto'}) { |
|
if (keys(%{$phototypes})>0) { |
|
my %lt = &photo_response_types(); |
|
foreach my $type (sort(keys(%{$phototypes}))) { |
|
my $numphoto = @{$$phototypes{$type}}; |
|
if ($numphoto > 0) { |
|
if ($context eq 'updatenow') { |
|
$photoresult .= '<br /><b>'. |
|
&mt('For [_1] students, photos ',$numphoto). |
|
$lt{$type}.'</b><ul><li>'; |
|
} else { |
|
$photoresult .= "\nFor $numphoto students, photos ". |
|
$lt{$type}."\n"; |
|
} |
|
foreach my $user (@{$$phototypes{$type}}) { |
|
$photoresult .= $user.$linefeed; |
|
} |
|
if ($context eq 'updatenow') { |
|
$photoresult = substr($photoresult,0, |
|
rindex($photoresult,"<li>")); |
|
$photoresult .= '</ul><br />'; |
|
} else { |
|
$photoresult .= "\n"; |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
|
|
# Do drops |
# Do drops |
if ( ($drops == 1) && (@reg_students > 0) ) { |
if ( ($drops == 1) && (@reg_students > 0) ) { |
foreach my $uname (@localstudents) { |
foreach my $uname (@localstudents) { |
Line 402 sub update_LC {
|
Line 442 sub update_LC {
|
} |
} |
} |
} |
my $changecount = $enrollcount + $dropcount + $switchcount; |
my $changecount = $enrollcount + $dropcount + $switchcount; |
return ($changecount,$addresult.$dropresult.$switchresult); |
return ($changecount,$addresult.$photoresult.$dropresult.$switchresult); |
} |
} |
|
|
sub create_newuser { |
sub create_newuser { |
Line 463 sub create_newuser {
|
Line 503 sub create_newuser {
|
if ($context eq 'createowner' || $context eq 'createcourse') { |
if ($context eq 'createowner' || $context eq 'createcourse') { |
my $result = &Apache::lonnet::modifyuser($udom,$uname,$pid,$auth,$authparam,$first,$middle,$last,$gene,'1',undef,$emailaddr); |
my $result = &Apache::lonnet::modifyuser($udom,$uname,$pid,$auth,$authparam,$first,$middle,$last,$gene,'1',undef,$emailaddr); |
if ($result eq 'ok' && $context eq 'createcourse') { |
if ($result eq 'ok' && $context eq 'createcourse') { |
$outcome = &Apache::loncreateuser::commit_standardrole($udom,$uname,$userurl,$role,$start,$end,$cdom,$crs,$usec); |
$outcome = &Apache::loncommon::commit_standardrole($udom,$uname,$userurl,$role,$start,$end,$cdom,$crs,$usec); |
unless ($outcome =~ /^Error:/) { |
unless ($outcome =~ /^Error:/) { |
$outcome = 'ok'; |
$outcome = 'ok'; |
} |
} |
Line 787 sub get_courseinfo {
|
Line 827 sub get_courseinfo {
|
my ($dom,$crs,$courseinfo) = @_; |
my ($dom,$crs,$courseinfo) = @_; |
my $owner; |
my $owner; |
if (defined($dom) && defined($crs)) { |
if (defined($dom) && defined($crs)) { |
my %settings = &Apache::lonnet::get('environment',['internal.coursecode','description'],$dom,$crs); |
my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.showphoto','description'],$dom,$crs); |
if ( defined($settings{'internal.coursecode'}) ) { |
if ( defined($settings{'internal.coursecode'}) ) { |
$$courseinfo{'inst_code'} = $settings{'internal.coursecode'}; |
$$courseinfo{'inst_code'} = $settings{'internal.coursecode'}; |
|
|
} |
} |
if ( defined($settings{'description'}) ) { |
if ( defined($settings{'description'}) ) { |
$$courseinfo{'description'} = $settings{'description'}; |
$$courseinfo{'description'} = $settings{'description'}; |
} |
} |
|
if ( defined($settings{'internal.showphoto'}) ) { |
|
$$courseinfo{'showphoto'} = $settings{'internal.showphoto'}; |
|
} |
} |
} |
return; |
return; |
} |
} |
Line 811 sub CL_middlename { return 8;}
|
Line 853 sub CL_middlename { return 8;}
|
sub CL_startdate { return 9; } |
sub CL_startdate { return 9; } |
sub CL_studentID { return 10; } |
sub CL_studentID { return 10; } |
|
|
|
sub photo_response_types { |
|
my %lt = &Apache::lonlocal::texthash( |
|
'same' => 'remained unchanged', |
|
'update' => 'were updated', |
|
'new' => 'were added', |
|
'missing' => 'were missing', |
|
'error' => 'were not imported because an error occurred', |
|
'nouser' => 'were for users without accounts', |
|
'noid' => 'were for users without student IDs', |
|
); |
|
return %lt; |
|
} |
|
|
|
|
1; |
1; |