--- loncom/enrollment/Enrollment.pm 2006/01/12 01:30:44 1.27 +++ loncom/enrollment/Enrollment.pm 2006/02/07 05:08:21 1.28 @@ -1,5 +1,5 @@ # Automated Enrollment manager -# $Id: Enrollment.pm,v 1.27 2006/01/12 01:30:44 raeburn Exp $ +# $Id: Enrollment.pm,v 1.28 2006/02/07 05:08:21 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -28,6 +28,7 @@ package LONCAPA::Enrollment; use Apache::loncoursedata; use Apache::lonnet; use Apache::lonmsg; +use Apache::lonlocal; use HTML::Entities; use LONCAPA::Configuration; use Time::Local; @@ -36,7 +37,7 @@ use lib '/home/httpd/lib/perl'; use strict; 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 my %courseinfo = (); &get_courseinfo($dom,$crs,\%courseinfo); @@ -75,6 +76,7 @@ sub update_LC { my $addresult = ''; my $dropresult = ''; my $switchresult = ''; + my $photoresult = ''; if ($context eq "updatenow") { $linefeed = "\n
  • "; } elsif ($context eq "automated") { @@ -192,6 +194,7 @@ sub update_LC { @{$unameFromINid{$stuID}} = $uname; } } + # Explicitly allow access to creation/modification of students if called as an automated process. if ($context eq 'automated') { $env{'allowed.cst'}='F'; @@ -323,10 +326,46 @@ sub update_LC { } else { &execute_add($context,'newstudent',$uname,$dom,$auth,$authparam,$first,$middle,$last,$gene,$pid,$usec,$end,$start,$emailenc,$cid,\$addresult,\$enrollcount,$linefeed,$logmsg); } + if ($courseinfo{'showphotos'}) { + my ($result,$resulttype) = + &Apache::lonnet::auto_checkphotos($uname,$dom,$pid); + if ($resulttype) { + push(@{$$phototypes{$resulttype}},$uname); + } + } } } } } + if ($courseinfo{'showphotos'}) { + 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 .= '
    '. + &mt('For [_1] students, photos ',$numphoto). + $lt{$type}.'
    '; + } else { + $photoresult .= "\n"; + } + } + } + } + } + # Do drops if ( ($drops == 1) && (@reg_students > 0) ) { foreach my $uname (@localstudents) { @@ -365,6 +404,9 @@ sub update_LC { if ($context eq "updatenow") { $addresult = substr($addresult,0,rindex($addresult,"
  • ")); $addresult = "The following $enrollcount student(s) was/were added to this LON-CAPA course:


    "; + if ($courseinfo{'showphotos'}) { + + } } else { $addresult = "The following $enrollcount student(s) was/were added to this LON-CAPA course:\n\n".$addresult."\n\n"; } @@ -402,7 +444,7 @@ sub update_LC { } } my $changecount = $enrollcount + $dropcount + $switchcount; - return ($changecount,$addresult.$dropresult.$switchresult); + return ($changecount,$addresult.$photoresult.$dropresult.$switchresult); } sub create_newuser { @@ -787,14 +829,16 @@ sub get_courseinfo { my ($dom,$crs,$courseinfo) = @_; my $owner; 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.showphotos','description'],$dom,$crs); if ( defined($settings{'internal.coursecode'}) ) { $$courseinfo{'inst_code'} = $settings{'internal.coursecode'}; - } if ( defined($settings{'description'}) ) { $$courseinfo{'description'} = $settings{'description'}; } + if ( defined($settings{'internal.showphotos'}) ) { + $$courseinfo{'showphotos'} = $settings{'internal.showphotos'}; + } } return; } @@ -811,4 +855,18 @@ sub CL_middlename { return 8;} sub CL_startdate { return 9; } 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;