--- loncom/interface/lonpopulate.pm 2009/03/25 15:49:47 1.58 +++ loncom/interface/lonpopulate.pm 2013/01/23 16:00:46 1.73 @@ -1,5 +1,5 @@ # automated enrollment configuration handler -# $Id: lonpopulate.pm,v 1.58 2009/03/25 15:49:47 bisitz Exp $ +# $Id: lonpopulate.pm,v 1.73 2013/01/23 16:00:46 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -217,26 +217,28 @@ sub print_mainbox { } elsif ($action eq "newsections") { $action = "sections"; } - $page .= "-> ".$$tasklongref{$action}." -> result"; + $page .= "» ".$$tasklongref{$action}." » result"; } else { - $page .= " -> ".$$tasklongref{$action}.""; + $page .= " » ".$$tasklongref{$action}.""; } } my $usrmang = &mt('User Management'); my $autenrl = &mt('Automated Enrollment Manager'); + #LC_pick_box is used in the following. This is only a temporary solution to adapt the site to the design. $r->print(< - - $realm -> $usrmang -> $page
+ + $realm » $usrmang » $page
- - $autenrl  + + $autenrl  - - +
+
+ ENDTHIS } @@ -247,9 +249,7 @@ sub print_navmenu { $action = $env{'form.action'}; } $r->print(<  - - - - @@ -429,7 +427,7 @@ Note: Any students added manually by cou } my $dateshow; if ( ($oldendshow eq '') && ($oldstartshow eq '') ) { - $dateshow = "
Warning. Currently NO first enrollment or last enrollment dates are set. You must use this menu to set a start date and an end date if you plan to utilise automated adds and/or drops in this course.\n"; + $dateshow = "
Warning. Currently NO first enrollment or last enrollment dates are set. You must use this menu to set a start date and an end date if you plan to utilise automated adds and/or drops in this course.\n"; } else { $dateshow = "Currently: First enrollment: $oldstartshow, Last enrollment: $oldendshow\n"; } @@ -508,8 +506,7 @@ ENDTWO } elsif ($action eq "notify") { my $notifycount = 0; my @notified = split(/,/,$enrollvar{notifylist}); - my @domcoord; - my @showdom; + my (@domcoord,@showdom,@olddomcoord,@futuredomcoord); for (my $i=0; $i<@notified; $i++) { if ($notified[$i] !~ /:/) { $notified[$i] =~ s/\@/:/; @@ -522,12 +519,26 @@ ENDTWO } else { $noteset = "OFF"; } + my $now = time; my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc']); foreach my $server (keys(%dompersonnel)) { foreach my $user (sort(keys(%{$dompersonnel{$server}}))) { my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user); - if (!grep(/^$uname:$udom$/,@domcoord)) { - push(@domcoord,$uname.':'.$udom); + my ($end,$start) = split(':',$dompersonnel{$server}{$user}); + if (($end eq '') || ($end == 0) || ($end > $now)) { + if ($start > $now) { + if (!grep(/^\Q$uname\E:\Q$udom\E$/,@futuredomcoord)) { + push(@futuredomcoord,$uname.':'.$udom); + } + } else { + if (!grep(/^\Q$uname\E:\Q$udom\E$/,@domcoord)) { + push(@domcoord,$uname.':'.$udom); + } + } + } else { + if (!grep(/^\Q$uname\E:\Q$udom\E$/,@olddomcoord)) { + push(@olddomcoord,$uname.':'.$udom); + } } } } @@ -547,13 +558,13 @@ ENDTWO "); if ($notifycount) { $r->print(" - + "); } else { $r->print(" - + "); } $r->print(" @@ -565,7 +576,6 @@ ENDTWO my %pname; my %notifystate; my %status; - my $now = time; foreach my $person (sort(keys(%coursepersonnel))) { my $match = 0; my ($role,$user,$usec) = ($person =~ /^([^:]+):([^:]+:[^:]+):([^:]*)/); @@ -601,6 +611,7 @@ ENDTWO usnm => 'username:domain', coac => 'Course Access', curn => 'Current notification status', + doms => 'Domain Coordinator status', notf => 'Notification?', ntac => 'Notification active', ntin => 'Notification inactive', @@ -630,7 +641,7 @@ ENDTWO if (grep(/^$viewer$/,@domcoord)) { $showalldc = 1; } - foreach my $dc (@domcoord) { + foreach my $dc (@domcoord,@futuredomcoord) { if (!grep(/^$dc$/,@ccs)) { if (grep(/^$dc$/,@notified)) { $notifystate{$dc} = 1; @@ -645,6 +656,16 @@ ENDTWO push(@showdom,$dc); } } + foreach my $olddc (@olddomcoord) { + if (grep(/^$olddc$/,@notified)) { + if (!grep(/^\Q$olddc\E$/,@ccs)) { + $notifystate{$olddc} = 1; + my ($dcname,$dcdom) = split(/:/,$olddc); + $pname{$olddc} = &Apache::loncommon::plainname($dcname,$dcdom); + push(@showdom,$olddc); + } + } + } my $showdomnum = scalar(@showdom); if ($showdomnum) { $r->print(" @@ -662,8 +683,8 @@ ENDTWO "); @@ -671,10 +692,10 @@ ENDTWO if (@ccs > 0 || @showdom > 0) { $r->print(" + - + "); $r->print(&Apache::loncommon::end_data_table_row()); } @@ -825,7 +846,7 @@ ENDTWO $r->print("Enrollment inactive"); } if ($shrflag) { - $r->print(""); + $r->print(""); } else { $r->print(""); } @@ -874,7 +895,7 @@ ENDTWO my $colflag = $j%2; $r->print(&Apache::loncommon::start_data_table_row()); $r->print(" - + "); @@ -931,13 +952,13 @@ ENDTWO "); if ($enrollvar{showphoto}) { $r->print(" - + "); } else { $r->print(" - + "); } $r->print(' @@ -1088,14 +1109,14 @@ Note: Any students previously added manu if ($update) { $r->print('
'.$commentary.'

- - - + +'); } else { $r->print(&mt('Update of photos via the Automated 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'}.''); @@ -1132,7 +1153,8 @@ onclick="javascript:document.photoupdate 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(); + my $crstype =&Apache::loncommon::course_type(); + my ($permission,$allowed) = &Apache::lonuserutils::get_permission('course',$crstype); foreach my $student (keys(%{$classlist})) { if (exists($permission->{'view_section'})) { if ($classlist->{$student}[$secidx] ne $permission->{'view_section'}) { @@ -1168,14 +1190,14 @@ onclick="javascript:document.photoupdate if ($autocount > 0) { $cellcount ++; $r->print(<
 Change auto   +
END } if ($manualcount > 0) { $cellcount ++; $r->print(<
 Change manual   +
END } @@ -1185,7 +1207,7 @@ END } $cellcount ++; $r->print(<
 Lock manual   +
END } @@ -1195,7 +1217,7 @@ END } $cellcount ++; $r->print(<
 Unlock manual   +
END } @@ -1230,12 +1252,15 @@ END } sub notifier_tables { - my ($role,$lt,$users,$status,$notifystate,$pname,$notifyshow) = @_; + my ($role,$lt,$users,$status,$notifystate,$pname,$notifyshow,$olddomcoord, + $futuredomcoord) = @_; my $output = &Apache::loncommon::start_data_table(); $output .= &Apache::loncommon::start_data_table_header_row(); $output .= ""; - if ($role eq 'cc') { + if ($role eq 'dc') { + $output .= ""; + } elsif ($role eq 'cc') { $output .= ""; } $output .= " @@ -1246,7 +1271,19 @@ sub notifier_tables { $output .= ''. ''; - if ($role eq 'cc') { + if ($role eq 'dc') { + $output .= ''; + } elsif ($role eq 'cc') { $output .= ''; } $output .= '
-
+
ENDONE foreach my $task (@{$tasksref}) { if ($task eq $action) { @@ -272,9 +272,7 @@ ENDONE $r->print("

 

  "); + "); } ############################################################### @@ -370,13 +368,13 @@ ENDONE ENDTWO if ($enrollvar{autoadds}) { $r->print(" - + "); } else { $r->print(" - + "); } $r->print(" @@ -387,12 +385,12 @@ ENDTWO Removals based on classlist changes:  "); if ($enrollvar{autodrops}) { $r->print(" - + "); } else { $r->print(" - "); + "); } $r->print("
"); - $r->print(¬ifier_tables('dc',\%lt,\@showdom,\%status,\%notifystate, - \%pname,\$notifyshow)); + $r->print(¬ifier_tables('dc',\%lt,\@showdom,\%status,\%notifystate,\%pname, + \$notifyshow,\@olddomcoord,\@futuredomcoord)); $r->print("
 
"); if ($notifycount) { - $r->print(&mt("Uncheck the checkbox(es) to terminate notification for people currently informed of roster changes from the nightly enrollment update.
")); + $r->print(&mt('Uncheck the checkbox(es) to terminate notification for people currently informed of roster changes from the nightly enrollment update.').'
'); } if ((@ccs + @showdom) > $notifycount) { - $r->print(&mt("Check the checkbox(es) to initiate notification for people not currently informed of roster changes from the nightly enrollment update.
")); + $r->print(&mt('Check the checkbox(es) to initiate notification for people not currently informed of roster changes from the nightly enrollment update.').'
'); } $r->print(&mt("Click 'Go' to save your changes.")."
@@ -734,9 +755,9 @@ ENDTWO my $colflag = $i%2; $r->print(&Apache::loncommon::start_data_table_row()); $r->print(" -
$xl $currsections[$j]
Change auto  
Change manual  
Lock manual  
Unlock manual  
$$lt{name} $$lt{usnm}$$lt{doms}$$lt{coac}$$lt{curn}'.$$pname{$$users[$i]}.''.$$users[$i].''; + if ((ref($olddomcoord) eq 'ARRAY') && (ref($futuredomcoord) eq 'ARRAY')) { + if (grep(/^\Q$users->[$i]\E$/,@{$olddomcoord})) { + $output .= &mt('expired'); + } elsif (grep(/^\Q$users->[$i]\E$/,@{$futuredomcoord})) { + $output .= &mt('future'); + } else { + $output .= &mt('active'); + } + } + $output .= ''.$$status{$$users[$i]}.''; @@ -1290,12 +1327,12 @@ 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).', - '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".', ); + $lt{'ncds'} = &mt('changing default start and end access dates will affect [_1]future enrollments[_2] and also [_1]currently inactive[_2] students (i.e., those for whom access will begin in the future).','',''); + $lt{'tcha'} = &mt('To change access dates for [_1]currently active[_2] students, use User Management -> "Manage Course 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 '') ) { - $dateshow = "
".&mt('Warning').". ".$lt{'cuno'}." "; + $dateshow = "
".&mt('Warning').". ".$lt{'cuno'}." "; if ($action eq 'setaccess') { $dateshow .= $lt{'ifyo'}."\n"; } elsif ($action eq 'updatenow') { @@ -1475,7 +1512,7 @@ sub print_chgsettings_response { } if ($autoadds || $autodrops) { $warning = &warning_message($dom,$crs,$action); - $warn_prefix = "
Warning. Although you indicated that nightly "; + $warn_prefix = "
Warning. Although you indicated that nightly "; $warn_suffix = " should be enabled, additional action is required.
"; } if ($autoadds) { @@ -1573,7 +1610,7 @@ sub print_setdates_response { } } $warning = &warning_message($dom,$crs,$action); - $warn_prefix = "
Warning. Although you set a start and end date for auto-enrollment, additional action is required.
"; + $warn_prefix = "
Warning. Although you set a start and end date for auto-enrollment, additional action is required.
"; unless ($warning eq '') { $response .= $warn_prefix.$warning; } @@ -1623,7 +1660,7 @@ start and end access dates for this cour } else { $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".').'
'; + $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 -> "Manage 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. @@ -1672,7 +1709,7 @@ start and end access dates for this cour } } $warning = &warning_message($dom,$crs,$action); - $warn_prefix = "
Warning. Although you have set default first and last access dates for students who are added via automatic enrollment, additional action is required.
"; + $warn_prefix = "
Warning. Although you have set default first and last access dates for students who are added via automatic enrollment, additional action is required.
"; unless ($warning eq '') { $response .= $warn_prefix.$warning; } @@ -1745,7 +1782,7 @@ sub print_notify_response { } $response .= "\n"; } else { - $response = &mt('Notification of enrollment changes was not enabled as no [_1]s were selected as recipients.
',&Apache::lonnet::plaintext('cc')); + $response = &mt('Notification of enrollment changes was [_1]not enabled[_2] as no [_3]s were selected as recipients.','','',&Apache::lonnet::plaintext('cc')).'
'; } } else { if ($currcount) { @@ -1857,7 +1894,7 @@ sub print_crosslistings_menu () { sub print_crosslistings_response () { my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_; - my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode','internal.courseowner'],$dom,$crs); + my %settings = &Apache::lonnet::get('environment',['internal.crosslistings','internal.coursecode','internal.courseowner','internal.co-owners'],$dom,$crs); my @currxlists = (); my @xlists = (); my @allxlists = (); @@ -1869,6 +1906,7 @@ sub print_crosslistings_response () { my $xliststr = $settings{'internal.crosslistings'}; my $coursecode = $settings{'internal.coursecode'}; my $owner = $settings{'internal.courseowner'}; + my $coowners = $settings{'internal.co-owners'}; my $response = ''; my $warning = ''; my $warn_prefix = ''; @@ -1902,7 +1940,7 @@ sub print_crosslistings_response () { $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$env{"form.$xl"}); if ($coursecheck eq 'ok') { my $addcheck = ''; - $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$env{"form.$xl"},$owner); + $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$env{"form.$xl"},$owner,$coowners); if ($addcheck eq 'ok') { push @xlists,$env{"form.$xl"}.":".$env{"form.$lc_sec"}; } else { @@ -1980,7 +2018,7 @@ sub print_crosslistings_response () { if (@allxlists > 0) { $warning = &warning_message($dom,$crs,$action); - $warn_prefix = "
Warning. Although you have selected crosslisted courses to contribute enrollment to this course, additional action is required.
"; + $warn_prefix = "
Warning. Although you have selected crosslisted courses to contribute enrollment to this course, additional action is required.
"; unless ($warning eq '') { $response .= $warn_prefix.$warning; } @@ -1992,7 +2030,7 @@ sub print_crosslistings_response () { sub print_sections_menu () { my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_; - my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs); + my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner','internal.co-owners'],$dom,$crs); my @currsections = (); my @sections = (); my @badowner = (); @@ -2006,6 +2044,7 @@ sub print_sections_menu () { my $warn_prefix = ""; my $coursecode = $settings{'internal.coursecode'}; my $owner = $settings{'internal.courseowner'}; + my $coowners = $settings{'internal.co-owners'}; if ($settings{'internal.sectionnums'} ne '') { @currsections = split(/,/,$settings{'internal.sectionnums'}); } @@ -2030,7 +2069,7 @@ sub print_sections_menu () { my $newsec = $coursecode.$env{"form.$secnum"}; my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec); if ($coursecheck eq 'ok') { - my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner); + my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner,$coowners); if ($addcheck eq 'ok') { push @sections,$env{"form.$secnum"}.":".$env{"form.$lc_sec"}; $seccount ++; @@ -2118,7 +2157,7 @@ sections which contribute to enrollment if ($seccount > 0) { $warning = &warning_message($dom,$crs,$action); - $warn_prefix = "
Warning. Although you have selected sections to contribute enrollment to this course, additional action is required.
"; + $warn_prefix = "
Warning. Although you have selected sections to contribute enrollment to this course, additional action is required.
"; unless ($warning eq '') { $response .= $warn_prefix.$warning; } @@ -2174,7 +2213,7 @@ sections which contribute to enrollment sub print_sections_response () { my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_; - my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner'],$dom,$crs); + my %settings = &Apache::lonnet::get('environment',['internal.sectionnums','internal.coursecode','internal.courseowner','internal.co-owners'],$dom,$crs); my @currsections = (); my @sections = (); my @allsections = (); @@ -2186,6 +2225,7 @@ sub print_sections_response () { my $secstr = $settings{'internal.sectionnums'}; my $coursecode = $settings{'internal.coursecode'}; my $owner = $settings{'internal.courseowner'}; + my $coowners = $settings{'internal.co-owners'}; my $response = ''; my $putreply = ''; my $warning = ''; @@ -2216,7 +2256,7 @@ sub print_sections_response () { my $newsec = $coursecode.$env{"form.$sec"}; my $coursecheck = &Apache::lonnet::auto_validate_courseID($crs,$dom,$newsec); if ($coursecheck eq 'ok') { - my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner); + my $addcheck = &Apache::lonnet::auto_new_course($crs,$dom,$newsec,$owner,$coowners); if ($addcheck eq 'ok') { push @sections,$env{"form.$sec"}.":".$env{"form.$lc_sec"}; } else { @@ -2289,7 +2329,7 @@ sub print_sections_response () { if (@allsections > 0) { $warning = &warning_message($dom,$crs,$action); - $warn_prefix = "
Warning. Although you have selected sections to contribute enrollment to this course, additional action is required.
"; + $warn_prefix = "
Warning. Although you have selected sections to contribute enrollment to this course, additional action is required.
"; unless ($warning eq '') { $response .= $warn_prefix.$warning; } @@ -2413,10 +2453,10 @@ function agreement_result(caller) {
- - - - + + + + '; } else { @@ -2471,10 +2511,10 @@ sub print_photos_response { if ($update) { $response .= '
'.$commentary.'

- - - + +
'; } }