--- loncom/interface/lonpopulate.pm 2007/05/02 01:33:49 1.50 +++ loncom/interface/lonpopulate.pm 2008/04/30 23:54:59 1.55 @@ -1,5 +1,5 @@ # automated enrollment configuration handler -# $Id: lonpopulate.pm,v 1.50 2007/05/02 01:33:49 albertel Exp $ +# $Id: lonpopulate.pm,v 1.55 2008/04/30 23:54:59 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,6 +33,7 @@ use Apache::lonhtmlcommon; use Apache::lonlocal; use Apache::loncoursedata; use Apache::longroup; +use Apache::lonuserutils; use Apache::Constants qw(:common :http REDIRECT); use Time::Local; use LONCAPA::Enrollment; @@ -207,9 +208,9 @@ sub print_mainbox { } my $page = ''; if ($action eq "information") { - $page = "Automated Enrollment"; + $page = "Automated Student Enrollment"; } else { - $page = 'Automated Enrollment'; + $page = 'Automated Student Enrollment'; if ($reply) { if ($action eq "newcross") { $action = "crosslist"; @@ -225,10 +226,10 @@ sub print_mainbox {
- $realm -> Enrollment Manager -> $page
+ $realm -> User Management -> $page
- Automated Enrollment Manager  + Automated Student Enrollment Manager 
@@ -397,7 +398,7 @@ ENDTWO -Note: Any students added manually by course coordinators using the Enrollment Manager will be unaffected by the nightly removal process if you choose to enable it. +Note: Any students added manually by course coordinators using the User Manager will be unaffected by the nightly removal process if you choose to enable it. @@ -1000,7 +1001,7 @@ ENDTWO $r->print(' '. -&mt('The policies of your institution ([_1]) require that the course owner ([_2]) must indicate acceptance of the conditions of use of digital photos of registered students, before they may be made available for use in a course.',$institution,$ownername).'

'.&mt('Please direct the course owner [_1] to visit the "Student photos" page in the Automated Enrollment Manager to indicate acceptance of these conditions of use.',$emailstr).'

+&mt('The policies of your institution ([_1]) require that the course owner ([_2]) must indicate acceptance of the conditions of use of digital photos of registered students, before they may be made available for use in a course.',$institution,$ownername).'

'.&mt('Please direct the course owner [_1] to visit the "Student photos" page in the Automated Student Enrollment Manager to indicate acceptance of these conditions of use.',$emailstr).'

@@ -1088,7 +1089,7 @@ onclick="javascript:document.photoupdate '); } else { - $r->print(&mt('Update of photos via the Automated Enrollment Manager is unavailable in this domain.').'

'); + $r->print(&mt('Update of photos via the Automated Student Enrollment Manager is unavailable in this domain.').'

'); } } else { $r->print('Update of photos is unavailable, as import of student photos is currently disabled.
Enable this first via: '.$$tasktitleref{'photos'}.''); @@ -1121,16 +1122,34 @@ onclick="javascript:document.photoupdate } my $status_select = &Apache::lonhtmlcommon::StatusOptions($env{'form.Status'}); # Get current classlist - my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist(); + my %userlist; + my ($indexhash,$keylist) = &Apache::lonuserutils::make_keylist_array(); + my $classlist = &Apache::loncoursedata::get_classlist(); + my $secidx = &Apache::loncoursedata::CL_SECTION(); + my ($permission,$allowed) = &Apache::lonuserutils::get_permission(); + foreach my $student (keys(%{$classlist})) { + if (exists($permission->{'view_section'})) { + if ($classlist->{$student}[$secidx] ne $permission->{'view_section'}) { + next; + } else { + $userlist{$student} = $classlist->{$student}; + } + } else { + $userlist{$student} = $classlist->{$student}; + } + } + if (! defined($classlist)) { - $r->print(&mt('There are no students either currently or previously enrolled.'). - "\n"); + $r->print(&mt('There are no students either currently or previously enrolled.')." + + \n"); } else { $r->print(&mt('Student Status: [_1]',$status_select)."\n"); $r->print(''. "\n

\n"); - - my ($studentcount,$autocount,$manualcount,$lockcount,$unlockcount) = &Apache::londropadd::show_class_list($r,'autoenroll','nothing',$env{'form.Status'},$classlist,$keylist); + my $context = 'course'; + my $mode = 'autoenroll'; + my ($studentcount,$autocount,$manualcount,$lockcount,$unlockcount) = &Apache::lonuserutils::show_users_list($r,$context,$mode,$permission,$env{'form.Status'},\%userlist,$keylist); $r->print(" @@ -1185,6 +1204,14 @@ END "); + } else { + $r->print(' + +
+ '.&mt('There are no students with the selected status.').' + + + '); } $r->print(" @@ -1257,8 +1284,8 @@ sub print_accessdate_table { 'freg' => 'for registered students added via automated enrollment', 'fnew' => 'for new students added when you update the class roster', 'ifad' => 'If automated adds are enabled, then when students are added their student roles will become active on the date set here for first access, and their roles will become inactive on the date set here for last access. These default access dates will be overridden for specific students if the institutional classlist data supplied to the automatic enrollment process includes entries for the startdate and enddate fields for those students.', - 'ncds' => 'changing default start and end access dates will affect future enrollments and ALSO currently inactive students (i.e., those for whom access will begin in the future). To change access dates for currently active students, you should change the access dates via this screen, then use Enrollment manager -> Drop Students to drop the students, and then use Automated Enrollment Manager -> Update roster now to re-enroll them with the new access dates.' - + 'ncds' => 'changing default start and end access dates will affect future enrollments and also currently inactive students (i.e., those for whom access will begin in the future).', + 'tcha' => 'To change access dates for currently active students, use User Management -> "Display Class Lists and Manage Multiple Users" to display currently active students, then use the dropdown menu for "Action to take for selected users:" to choose "Change starting/ending dates", select the students to change, and click "Proceed".', ); my $dateshow; if ( ($oldendshow eq '') && ($oldstartshow eq '') ) { @@ -1341,7 +1368,7 @@ ENDFOUR   - ".&mt('Note').": ".$lt{'ncds'}." + ".&mt('Note').": ".$lt{'ncds'}.' '.$lt{'tcha'}." "); @@ -1581,17 +1608,16 @@ start and end access dates for this cour $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.
"; } else { if ($currstart == $startaccess) { - $response = "The first access date for students added via automated enrollment has been left unchanged as $showstart.
"; + $response = "The first access date for students being added via automated enrollment has been left unchanged as $showstart.
"; } else { - $response = "The first access date for students added via automated enrollment has been changed to -$showstart.
"; + $response = "The first access date for students being added via automated enrollment has been changed to $showstart.
"; } if ($currend == $endaccess) { - $response .= "The last access date for students added via automated enrollment has been left unchanged as $showend.
"; + $response .= "The last access date for students being added via automated enrollment has been left unchanged as $showend.
"; } else { - $response .= "The last access date for students automated enrollment has been changed to -$showend.
"; + $response .= "The last access date for students being added via automated enrollment has been changed to $showend.
"; } + $response .= '
'.&mt('Any change in access dates will only apply to students who are not currently active, i.e., those who currently have access start dates in the future, and to those added by future automated enrollment.').'

'.&mt('To change access dates for any currently active students, use User Management -> "Display Class Lists and Manage Multiple Users" to display currently active students, then use the dropdown menu for "Action to take for selected users:" to choose "Change starting/ending dates", select the students to change, and click "Proceed".').'
'; # Generate message in case where old first access date was later than today, but new first access date is now today or earlier. @@ -2393,7 +2419,7 @@ function agreement_result(caller) { if ($owneremail) { $emailstr = "(e-mail: $owneremail)"; } - $response = &mt('The policies of your institution [_1] require that the course owner [_2] must indicate acceptance of the conditions of use of digital photos of registered students, before they may be made available for use in a course.',$institution,$ownername).'

'.&mt('Please direct the course owner [_1] to visit the "Student photos" page in the Automated Enrollment Manager to indicate acceptance of these conditions of use',$emailstr); + $response = &mt('The policies of your institution [_1] require that the course owner [_2] must indicate acceptance of the conditions of use of digital photos of registered students, before they may be made available for use in a course.',$institution,$ownername).'

'.&mt('Please direct the course owner [_1] to visit the "Student photos" page in the Automated Student Enrollment Manager to indicate acceptance of these conditions of use',$emailstr); } &print_reply($r,$response,$$tasktitleref{$action}); } @@ -2459,7 +2485,7 @@ onclick="javascript:document.photoupdate } } if (keys(%newenv) > 0) { - &Apache::lonnet::appenv(%newenv); + &Apache::lonnet::appenv(\%newenv); } &print_reply($r,$response,$$tasktitleref{$action}); return; @@ -2479,7 +2505,7 @@ sub print_photoupdate_response { my %LC_code; my %affiliates; my $outcome; - &get_institutional_codes(\%settings,,\@allcourses,\%LC_code); + &Apache::loncommon::get_institutional_codes(\%settings,\@allcourses,\%LC_code); if (@allcourses > 0) { @{$affiliates{$crs}} = @allcourses; $outcome = &Apache::lonnet::auto_photoupdate(\%affiliates,$dom,$crs,\%changes); @@ -2583,7 +2609,7 @@ sub print_update_result () { } elsif ($coursecode eq '') { $response = "There was a problem retrieving the course code for this LON-CAPA course. An update of the class roster has not been carried out, and enrollment remains unchanged"; } else { - &get_institutional_codes(\%settings,\@allcourses,\%LC_code); + &Apache::loncommon::get_institutional_codes(\%settings,\@allcourses,\%LC_code); if (@allcourses > 0) { @{$affiliates{$crs}} = @allcourses; my $outcome = &Apache::lonnet::fetch_enrollment_query('updatenow',\%affiliates,\%reply,$dom,$crs); @@ -2617,48 +2643,6 @@ sub print_update_result () { return; } -sub get_institutional_codes { - my ($settings,$allcourses,$LC_code) = @_; -# Get complete list of course sections to update - my @currsections = (); - my @currxlists = (); - my $coursecode = $$settings{'internal.coursecode'}; - - if ($$settings{'internal.sectionnums'} ne '') { - @currsections = split(/,/,$$settings{'internal.sectionnums'}); - } - - if ($$settings{'internal.crosslistings'} ne '') { - @currxlists = split(/,/,$$settings{'internal.crosslistings'}); - } - - if (@currxlists > 0) { - foreach (@currxlists) { - if (m/^([^:]+):(\w*)$/) { - unless (grep/^$1$/,@{$allcourses}) { - push @{$allcourses},$1; - $$LC_code{$1} = $2; - } - } - } - } - - if (@currsections > 0) { - foreach (@currsections) { - if (m/^(\w+):(\w*)$/) { - my $sec = $coursecode.$1; - my $lc_sec = $2; - unless (grep/^$sec$/,@{$allcourses}) { - push @{$allcourses},$sec; - $$LC_code{$sec} = $lc_sec; - } - } - } - } - return; -} - - sub print_viewclass_response { my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_; my $response; @@ -2689,7 +2673,7 @@ sub print_viewclass_response { &Apache::loncommon::get_env_multiple('form.unlockchg')); foreach my $student (sort @typechglist) { - my ($uname,$udom) = split/:/,$student; + my ($uname,$udom) = split(/:/,$student); my $sdata = $classlist->{$student}; my $section = $sdata->[$secidx]; my $uid = $sdata->[$ididx]; @@ -2713,7 +2697,7 @@ sub print_viewclass_response { } elsif ($newtype eq '') { $newlock = '1'; } - my $modreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$newtype,$newlock,$cid); + my $modreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$newtype,$newlock,$cid,'','chgtype'); if ($modreply eq 'ok') { $chgok ++; $chg{$student} = "Changed to $change"; @@ -2727,7 +2711,7 @@ sub print_viewclass_response { } } foreach my $student (@lockchglist) { - my ($uname,$udom) = split/:/,$student; + my ($uname,$udom) = split(/:/,$student); my $sdata = $classlist->{$student}; my $section = $sdata->[$secidx]; my $uid = $sdata->[$ididx]; @@ -2745,7 +2729,7 @@ sub print_viewclass_response { $newlockname = &mt('unlocked'); $oldlockname = &mt('locked'); } - my $lockreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$type,$newlock,$cid); + my $lockreply = &Apache::lonnet::modify_student_enrollment($udom,$uname,$uid,'','','','',$section,$end,$start,$type,$newlock,$cid,'','chgtype'); if ($lockreply eq 'ok') { $lockok ++; $lockchg{$student} = 'Changed to '.$newlockname; @@ -2756,31 +2740,31 @@ sub print_viewclass_response { } } if ($chgtotal > 0) { - $response = "You requested a change in enrollment type for $chgtotal students.

\n"; + $response = &mt('You requested a change in enrollment type for [quant,_1,student].',$chgtotal).'

'."\n"; $classlist = &Apache::loncoursedata::get_classlist($dom,$crs); if ($chgok > 0) { - $response .= "The following $chgok changes were successful:
"; + $response .= &mt('The following [quant,_1,change was,changes were] successful;',$chgtotal).':

'; $response .= &enrolltype_result(\%chg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx); } if ($chgfail > 0) { - $response .= "The following $chgfail students were not modified successfully: 
"; + $response .= &mt('The following [quant,_1,student was,students were] not modified successfully',$chgfail).': 
'; $response .= &enrolltype_result(\%nochg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx); } if ($othdom > 0) { - $response .= "The following $othdom students were not modified because students must be in the same LON-CAPA domain as the course, in order to be set to an enrollment type of 'auto':
"; + $response .= &mt("The following [quant,_1,student was,students were] not modified because students must be in the same LON-CAPA domain as the course, in order to be set to an enrollment type of 'auto'",$othdom).':
'; $response .= &enrolltype_result(\%otherdom,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx); } $response .= "

"; } if ($locktotal > 0) { - $response .= "You requested locking/unlocking for $locktotal manually enrolled students.

\n"; + $response .= &mt('You requested locking/unlocking for [quant,_1,manually enrolled student]',$locktotal).'

'."\n"; $classlist = &Apache::loncoursedata::get_classlist($dom,$crs); if ($lockok > 0) { - $response .= "The following $lockok changes were successful:
"; + $response .= &mt('The following [quant,_1,change was,changes were] successful',$lockok).':

'; $response .= &enrolltype_result(\%lockchg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx); } if ($lockfail > 0) { - $response .= "The following $lockfail students were not modified successfully: 
"; + $response .= &mt('The following [quant,_1,student was,students were] not modified successfully',$lockfail).': 
'; $response .= &enrolltype_result(\%nolockchg,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx); } } @@ -2790,9 +2774,8 @@ sub print_viewclass_response { sub enrolltype_result { my ($changes,$classlist,$endidx,$startidx,$ididx,$secidx,$typeidx,$lockedidx) = @_; - my $reply = " - - + my $reply = &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row().' @@ -2800,11 +2783,11 @@ sub enrolltype_result { - - "; - foreach (sort keys %{$changes}) { - my $sdata = $classlist->{$_}; - my ($uname,$udom) = split/:/,$_; + '."\n". + &Apache::loncommon::end_data_table_header_row(); + foreach my $chg (sort keys %{$changes}) { + my $sdata = $classlist->{$chg}; + my ($uname,$udom) = split(/:/,$chg); my $section = $sdata->[$secidx]; my $uid = $sdata->[$ididx]; my $start = $sdata->[$startidx]; @@ -2821,24 +2804,23 @@ sub enrolltype_result { $end = &Apache::lonlocal::locallocaltime($end); } if (!defined($section) || ($section eq '')) { - $section eq ' '; + $section = ' '; } if (!defined($uid) || ($uid eq '')) { - $uid = ' '; + $uid = ' '; } - $reply .= " - - - - - - - - - - "; + $reply .= &Apache::loncommon::start_data_table_row().' + + + + + + + + '."\n". + &Apache::loncommon::end_data_table_row(); } - $reply .= "
username domain IDsection start date end dateenrollment change
enrollment change
$uname$udom$uid".&Apache::loncommon::plainname($uname,$udom)."$section$start$end$$changes{$_}
'.$uname.''.$udom.''.$uid.''.&Apache::loncommon::plainname($uname,$udom).''.$section.''.$start.''.$end.''.$$changes{$chg}.'
"; + $reply .= &Apache::loncommon::end_data_table(); return $reply; }