--- loncom/interface/lonpopulate.pm 2013/02/11 02:39:11 1.74 +++ loncom/interface/lonpopulate.pm 2021/12/28 02:04:35 1.90 @@ -1,5 +1,5 @@ # automated enrollment configuration handler -# $Id: lonpopulate.pm,v 1.74 2013/02/11 02:39:11 raeburn Exp $ +# $Id: lonpopulate.pm,v 1.90 2021/12/28 02:04:35 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,11 +37,12 @@ use Apache::lonuserutils; use Apache::Constants qw(:common :http REDIRECT); use Time::Local; use LONCAPA::Enrollment; +use LONCAPA qw(:DEFAULT :match); ############################################################### sub header { - my ($action) = @_; - my $args = &make_crumbs($action); + my ($action,$permref) = @_; + my $args = &make_crumbs($action,$permref); return &Apache::loncommon::start_page('Classlist Manager',undef,$args); } @@ -49,9 +50,10 @@ sub header { ############################################################### sub choose_header { - my ($action) = @_; + my ($action,$permref,$dom) = @_; my $notify_check = '/^note_[0-9]+$/'; - my %lt = + my $additems; + my %js_lt = &Apache::lonlocal::texthash( adds => 'You must select either "Enable" or "Disable" for nightly additions based on classlist changes', drop => 'You must select either "Enable" or "Disable" for nightly removals based on classlist changes', @@ -60,13 +62,25 @@ sub choose_header { eras => 'Click "OK" to erase all recipients, or "Cancel".', ynot => 'You have indicated that you want notification of roster changes messages to be sent, but you have not selected any recipients.', atle => 'You must check at least one checkbox, before proceeding to the next page', + noed => 'You do not have rights to modify automated enrollment settings', ); - $lt{'both'} = &mt('You have selected "No" for both addition and removal of students[_1] in the institutional classlist but not in your LON-CAPA course.[_1]','\\n'); - $lt{'nnot'} = &mt('You have indicated that you do not want notification of roster changes messages to be sent, but [_1] have been checked as recipients.[_2]',"'+totalnote+'",'\\n'); - - my $scripttag = <{'edit'})) { + $scripttag .= < 0) { if (formName.notify[1].checked == true) { - if (confirm('$lt{'nnot'}$lt{'eras'}')) { + if (confirm('$js_lt{'nnot'}$js_lt{'eras'}')) { checker = 1; } else { checker = 0; @@ -149,7 +163,7 @@ function process(calling,numauto,nummanu } } else { if (formName.notify[0].checked == true) { - alert('$lt{'ynot'}'); + alert('$js_lt{'ynot'}'); checker = 0; } } @@ -177,7 +191,7 @@ function process(calling,numauto,nummanu document.forms.studentform.state.value = "process"; } if (totcheck == 0) { - alert('$lt{'atle'}') + alert('$js_lt{'atle'}') checker = 0; } } @@ -186,6 +200,7 @@ function process(calling,numauto,nummanu } } ENDJSONE + } if ($action eq 'viewclass') { $scripttag .= &Apache::loncommon::check_uncheck_jscript(); $scripttag .= <{'failsafe'} eq 'off') { + $includedom = 0; + } + } + $scripttag .= < "toggleFailsafe(document.enter);" }; } $scripttag .= < ENDJS - my $args = &make_crumbs($action); + my $args = &make_crumbs($action,$permref,$additems); return &Apache::loncommon::start_page('Classlist Manager', $scripttag,$args); } sub make_crumbs { - my ($action) = @_; - my ($tasklong,$tasktitle) = &get_task_text(); + my ($action,$permref,$additems) = @_; + my ($tasklong,$tasktitle) = &get_task_text($permref); my $brcrum = [{href=>"/adm/createuser", text=>"User Management",}, {href=>"/adm/populate", @@ -230,7 +285,6 @@ sub make_crumbs { } elsif ($action eq 'newsections') { $action = 'sections'; } - my ($tasklong,$tasktitle) = &get_task_text(); my $text; if (ref($tasklong) eq 'HASH') { $text = $tasklong->{$action}; @@ -242,7 +296,8 @@ sub make_crumbs { ); } return {bread_crumbs => $brcrum, - bread_crumbs_component => 'Automated Management'}; + bread_crumbs_component => 'Automated Management', + add_entries => $additems}; } sub print_navmenu { @@ -254,7 +309,6 @@ sub print_navmenu { '); - print STDERR "action is ||$action|| and state is ||$state||\n"; foreach my $task (@{$tasksref}) { if (($task eq $action) && ($state eq 'choose')) { $r->print(' @@ -282,16 +336,21 @@ sub print_navmenu { ############################################################### sub print_main_frame { - my ($r,$realm,$dom,$crs,$tasktitleref) = @_; + my ($r,$realm,$dom,$crs,$tasktitleref,$permref) = @_; my $action = "information"; if (exists($env{'form.action'}) ) { $action = $env{'form.action'}; } + my ($disabled,$readonly); + unless ($permref->{'edit'}) { + $disabled = ' disabled="disabled"'; + $readonly = 1; + } # Get course settings my %enrollvar; my %settings = &Apache::lonnet::dump('environment',$dom,$crs); - foreach my $item (keys %settings) { + foreach my $item (keys(%settings)) { if ($item =~ m/^internal\.(.+)$/) { $enrollvar{$1} = $settings{$item}; } elsif ($item =~ /^default_enrollment_(start|end)_date$/) { @@ -305,7 +364,9 @@ sub print_main_frame {   '.&mt('Use the menu on the left to choose an enrollment management task.').'

- + '); + if ($permref->{'edit'}) { + $r->print('   '.&mt('Use [_1]Automated adds/drops[_2] to enable or disable automatic nightly adds or drops in your LON-CAPA course based on institutional enrollment information.','"','"').' @@ -350,6 +411,57 @@ sub print_main_frame { '.&mt('Use [_1]View students and change type[_2] to display the current course roster, and (optionally) change enrollment type for selected students from "auto" to "manual" and vice versa.','"','"').' +   + '.&mt('Use [_1]View/change enrollment failsafe[_2] to (a) set number of drops from existing enrollments in an institutional section above which no automated drops will occur (e.g., when section enrollment retrieved from institutional data is incomplete) and (b) set whether this only applies when retrieved data contains zero records for the institutional section.','"','"').' + '); + } else { + if (($permref->{'view'}) || ($permref->{'view_section'} ne '')) { + $r->print(' + +   + '.&mt('Use [_1]Automated adds/drops[_2] to display status of automatic nightly adds or drops based on institutional enrollment information.','"','"').' + + +   + '.&mt('Use [_1]Enrollment dates[_2] to display the date of first automated enrollment and last automated enrollment for registered students.','"','"').' + + +   + '.&mt('Use [_1]Access dates[_2] to display the default start and/or end dates for student roles created by automated enrollment.','"','"').' + + +   + '.&mt('Use [_1]Notification of changes[_2] to display which course coordinators (if any) receive notification of enrollment changes.','"','"').' + + +   + '.&mt('Use [_1]Crosslisting[_2] to display enrollment settings for crosslisted classes.', + '"','"').' + + +   + '.&mt('Use [_1]Section settings[_2] to display sections included for enrollment.', + '"','"').' + + +   + '.&mt('Use [_1]Student photo settings[_2] to display settings for automatic import of photos for registered students.', + '"','"').' + + +   + '.&mt('Use [_1]Enrollment failsafe[_2] to display (a) number of drops from existing enrollments in an institutional section above which no automated drops occur (e.g., when section enrollment retrieved from institutional data is incomplete), and (b) whether this only applies when retrieved data contains zero records for the institutional section.','"','"').' + '); + } + if (($permref->{'show'}) || ($permref->{'show_section'} ne '')) { + $r->print(' + +   + '.&mt('Use [_1]View students and enrollment type[_2] to display the current course roster and enrollment type ("auto" or "manual").','"','"').' + '); + } + $r->print(' +   @@ -357,6 +469,7 @@ sub print_main_frame { '.&mt('Note: if automated adds and/or drops are enabled, the nightly enrollment update will ONLY occur once the first enrollment date has been reached.').' '); + } } elsif ($action eq 'chgsettings') { my @autosets = (&mt('OFF'),&mt('ON')); $r->print(' @@ -374,15 +487,15 @@ sub print_main_frame { '.&mt('Additions based on classlist changes:').'  '); if ($enrollvar{autoadds}) { $r->print(' -