# automated enrollment configuration handler
# $Id: lonpopulate.pm,v 1.85 2016/11/09 00:48:52 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
package Apache::lonpopulate;
use strict;
use lib qw(/home/httpd/lib/perl);
use Apache::lonnet;
use Apache::loncommon;
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;
###############################################################
sub header {
my ($action,$permref) = @_;
my $args = &make_crumbs($action,$permref);
return
&Apache::loncommon::start_page('Classlist Manager',undef,$args);
}
###############################################################
sub choose_header {
my ($action,$permref) = @_;
my $notify_check = '/^note_[0-9]+$/';
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',
noup => 'Hence there is no update to carry out',
ysno => 'You must select either "Yes" or "No" for immediate removal of unregistered students from the roster',
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',
);
$js_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");
$js_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");
&js_escape(\%js_lt);
my $scripttag = '
ENDJS
my $args = &make_crumbs($action,$permref);
return &Apache::loncommon::start_page('Classlist Manager',
$scripttag,$args);
}
sub make_crumbs {
my ($action,$permref) = @_;
my ($tasklong,$tasktitle) = &get_task_text($permref);
my $brcrum = [{href=>"/adm/createuser",
text=>"User Management",},
{href=>"/adm/populate",
text=>"Automated Enrollment",
help=>'Course_Automated_Enrollment'},
];
if ($action eq 'newcross') {
$action = 'crosslist';
} elsif ($action eq 'newsections') {
$action = 'sections';
}
my $text;
if (ref($tasklong) eq 'HASH') {
$text = $tasklong->{$action};
}
unless ($action eq 'information') {
push(@{$brcrum},
{href => "javascript:backPage(document.crtuser)",
text => $text}
);
}
return {bread_crumbs => $brcrum,
bread_crumbs_component => 'Automated Management'};
}
sub print_navmenu {
my ($r,$tasksref,$tasklongref,$action,$state) = @_;
#LC_pick_box is used in the following. This is only a temporary solution to adapt the site to the design.
$r->print('
');
foreach my $task (@{$tasksref}) {
if (($task eq $action) && ($state eq 'choose')) {
$r->print('
'.$tasklongref->{$task}.'
|
');
}
###############################################################
sub print_main_frame {
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)) {
if ($item =~ m/^internal\.(.+)$/) {
$enrollvar{$1} = $settings{$item};
} elsif ($item =~ /^default_enrollment_(start|end)_date$/) {
$enrollvar{$item} = $settings{$item};
}
}
if ($action eq 'information') {
$r->print('
'.&mt('Warning.').' '.&mt('Currently [_1]NO[_2] first enrollment or last enrollment dates are set.','','').' '. &mt('You [_1]must[_2] 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 = &mt('Currently: First enrollment[_1] Last enrollment[_2]', " -- $oldstartshow"," -- $oldendshow")."\n"; } $r->print(' '); } elsif ($action eq 'setaccess') { &print_accessdate_table($r,\%enrollvar,$tasktitleref,$action,$readonly); $r->print(' |
'.&mt('Add new crosslistings.').' '. &mt('Number of new crosslistings to add:[_1]',' ').' |
'.$tasktitleref->{$action}.' |
');
if ($enrollvar{'showphoto'}) {
my ($update,$commentary) = &Apache::lonnet::auto_photochoice($crs,
$dom);
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(&mt('Update of photos is unavailable, as import of student photos is currently disabled.').' '. &mt('Enable this first via: [_1]',''.$tasktitleref->{'photos'}.'')); } $r->print(' |
'.$caller.' - '.&mt('result').'
'.$response.' |
'.&mt('Starting Date').' | '. ''.$startform.' | '. ''." |
'.&mt('Ending Date').' | '. ''.$endform.' | '. ''.$perpetual.' | '."