--- loncom/interface/lonmodifycourse.pm 2010/05/18 16:13:31 1.54
+++ loncom/interface/lonmodifycourse.pm 2016/09/17 16:03:36 1.79.2.2
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# handler for DC-only modifiable course settings
#
-# $Id: lonmodifycourse.pm,v 1.54 2010/05/18 16:13:31 bisitz Exp $
+# $Id: lonmodifycourse.pm,v 1.79.2.2 2016/09/17 16:03:36 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -34,23 +34,29 @@ use Apache::loncommon;
use Apache::lonhtmlcommon;
use Apache::lonlocal;
use Apache::lonuserutils;
+use Apache::loncreateuser;
use Apache::lonpickcourse;
use lib '/home/httpd/lib/perl';
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
sub get_dc_settable {
- my ($type) = @_;
+ my ($type,$cdom) = @_;
if ($type eq 'Community') {
- return ('courseowner');
+ return ('courseowner','selfenrollmgrdc','selfenrollmgrcc');
} else {
- return ('courseowner','coursecode','authtype','autharg');
+ my @items = ('courseowner','coursecode','authtype','autharg','selfenrollmgrdc',
+ 'selfenrollmgrcc','mysqltables');
+ if (&showcredits($cdom)) {
+ push(@items,'defaultcredits');
+ }
+ return @items;
}
}
sub autoenroll_keys {
- my $internals = ['coursecode','courseowner','authtype','autharg','autoadds','autodrops',
- 'autostart','autoend','sectionnums','crosslistings',
- 'co-owners'];
+ my $internals = ['coursecode','courseowner','authtype','autharg','defaultcredits',
+ 'autoadds','autodrops','autostart','autoend','sectionnums',
+ 'crosslistings','co-owners','autodropfailsafe'];
my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date'];
return ($internals,$accessdates);
}
@@ -112,8 +118,13 @@ sub get_enrollment_settings {
$enrollvar{$type} =~ s/,/, /g;
} elsif ($type eq "authtype"
|| $type eq "autharg" || $type eq "coursecode"
- || $type eq "crosslistings") {
+ || $type eq "crosslistings" || $type eq "selfenrollmgr"
++ || $type eq "autodropfailsafe") {
$enrollvar{$type} = $settings{$item};
+ } elsif ($type eq 'defaultcredits') {
+ if (&showcredits($cdom)) {
+ $enrollvar{$type} = $settings{$item};
+ }
} elsif ($type eq 'courseowner') {
if ($settings{$item} =~ /^[^:]+:[^:]+$/) {
$enrollvar{$type} = $settings{$item};
@@ -145,25 +156,23 @@ sub print_course_search_page {
$type = 'Course';
}
&print_header($r,$type);
- my $filterlist = ['descriptfilter',
- 'instcodefilter','ownerfilter',
- 'coursefilter'];
- my $filter = {};
- my ($numtitles,$cctitle,$dctitle);
+ my ($filterlist,$filter) = &get_filters($dom);
+ my ($numtitles,$cctitle,$dctitle,@codetitles);
my $ccrole = 'cc';
if ($type eq 'Community') {
$ccrole = 'co';
}
$cctitle = &Apache::lonnet::plaintext($ccrole,$type);
$dctitle = &Apache::lonnet::plaintext('dc');
- $r->print(&Apache::lonpickcourse::js_changer());
+ $r->print(&Apache::loncommon::js_changer());
if ($type eq 'Community') {
$r->print('
'.&mt('Search for a community in the [_1] domain',$domdesc).' ');
} else {
$r->print(''.&mt('Search for a course in the [_1] domain',$domdesc).' ');
- }
- $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type,
- undef,undef,$filter,$action,\$numtitles,'modifycourse'));
+ }
+ $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
+ \$numtitles,'modifycourse',undef,undef,undef,
+ \@codetitles,$dom));
if ($type eq 'Community') {
$r->print(&mt('Actions available after searching for a community:').''.
''.&mt('Enter the community with the role of [_1]',$cctitle).' '."\n".
@@ -175,6 +184,7 @@ sub print_course_search_page {
''.&mt('View or modify course settings which only a [_1] may modify.',$dctitle).
' '."\n".' ');
}
+ return;
}
sub print_course_selection_page {
@@ -186,49 +196,88 @@ sub print_course_selection_page {
&print_header($r,$type);
# Criteria for course search
- my $filterlist = ['descriptfilter',
- 'instcodefilter','ownerfilter',
- 'ownerdomfilter','coursefilter'];
- my %filter;
+ my ($filterlist,$filter) = &get_filters();
my $action = '/adm/modifycourse';
my $dctitle = &Apache::lonnet::plaintext('dc');
- my $numtitles;
- $r->print(&Apache::lonpickcourse::js_changer());
+ my ($numtitles,@codetitles);
+ $r->print(&Apache::loncommon::js_changer());
$r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.'). ');
- $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type,
- undef,undef,\%filter,$action,\$numtitles));
- $filter{'domainfilter'} = $dom;
- my %courses = &Apache::lonpickcourse::search_courses($r,$type,0,
- \%filter,$numtitles);
+ $r->print(&Apache::loncommon::build_filters($filterlist,$type,undef,undef,$filter,$action,
+ \$numtitles,'modifycourse',undef,undef,undef,
+ \@codetitles,$dom,$env{'form.form'}));
+ my %courses = &Apache::loncommon::search_courses($dom,$type,$filter,$numtitles,
+ undef,undef,undef,\@codetitles);
&Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef,
- %courses);
+ undef,undef,%courses);
return;
}
+sub get_filters {
+ my ($dom) = @_;
+ my @filterlist = ('descriptfilter','instcodefilter','ownerfilter',
+ 'ownerdomfilter','coursefilter','sincefilter');
+ # created filter
+ my $loncaparev = &Apache::lonnet::get_server_loncaparev($dom);
+ if ($loncaparev ne 'unknown_cmd') {
+ push(@filterlist,'createdfilter');
+ }
+ my %filter;
+ foreach my $item (@filterlist) {
+ $filter{$item} = $env{'form.'.$item};
+ }
+ return (\@filterlist,\%filter);
+}
+
sub print_modification_menu {
- my ($r,$cdesc,$domdesc,$dom,$type) = @_;
+ my ($r,$cdesc,$domdesc,$dom,$type,$cid,$coursehash) = @_;
&print_header($r,$type);
- my ($ccrole,$categorytitle,$setquota_text,$setparams_text,$cat_text);
+ my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$setparams_text,$cat_text,
+ $cdom,$cnum);
+ if (ref($coursehash) eq 'HASH') {
+ $cdom = $coursehash->{'domain'};
+ $cnum = $coursehash->{'num'};
+ } else {
+ ($cdom,$cnum) = split(/_/,$cid);
+ }
if ($type eq 'Community') {
$ccrole = 'co';
} else {
$ccrole = 'cc';
- }
+ }
if ($type eq 'Community') {
$categorytitle = 'View/Modify Community Settings';
$setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');
+ $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a community via Content Editor.');
$setparams_text = 'View/Modify community owner';
$cat_text = 'View/Modify catalog settings for community';
} else {
$categorytitle = 'View/Modify Course Settings';
$setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');
- $setparams_text = 'View/Modify course owner, institutional code, and default authentication';
- $cat_text = 'View/Modify catalog settings for course';
+ $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a course via Content Editor.');
+ if (&showcredits($dom)) {
+ $setparams_text = 'View/Modify course owner, institutional code, default authentication, credits, self-enrollment and table lifetime';
+ } else {
+ $setparams_text = 'View/Modify course owner, institutional code, default authentication, self-enrollment and table lifetime';
+ }
+ $cat_text = 'View/Modify catalog settings for course';
}
+ my $anon_text = &mt('Responder threshold required to display anonymous survey submissions.');
+ my $postsubmit_text = &mt('Override defaults for submit button behavior post-submission for this specific course.');
my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
+ sub manage_selfenrollment {
+ my ($cdom,$cnum,$type,$coursehash) = @_;
+ my ($managed_by_cc,$managed_by_dc) = &Apache::lonuserutils::selfenrollment_administration($cdom,$cnum,$type,$coursehash);
+ if (ref($managed_by_dc) eq 'ARRAY') {
+ if (@{$managed_by_dc}) {
+ return 1;
+ }
+ }
+ return 0;
+ }
+
sub phaseurl {
my $phase = shift;
return "javascript:changePage(document.menu,'$phase')"
@@ -241,15 +290,23 @@ sub print_modification_menu {
url => &phaseurl('setparms'),
permission => 1,
#help => '',
- icon => 'mcrs.png',
+ icon => 'crsconf.png',
linktitle => ''
},
{
- linktext => 'View/Modify quota for group portfolio files',
+ linktext => 'View/Modify quotas for group portfolio files, and for uploaded content.',
url => &phaseurl('setquota'),
permission => 1,
#help => '',
- icon => 'mcrs.png',
+ icon => 'groupportfolioquota.png',
+ linktitle => ''
+ },
+ {
+ linktext => 'View/Modify responders threshold for anonymous survey submissions display',
+ url => &phaseurl('setanon'),
+ permission => 1,
+ #help => '',
+ icon => 'anonsurveythreshold.png',
linktitle => ''
},
{
@@ -257,7 +314,7 @@ sub print_modification_menu {
url => &phaseurl('catsettings'),
permission => (@additional_params > 0),
#help => '',
- icon => 'mcrs.png',
+ icon => 'ccatconf.png',
linktitle => ''
},
{
@@ -265,9 +322,25 @@ sub print_modification_menu {
url => &phaseurl('viewparms'),
permission => ($type ne 'Community'),
#help => '',
- icon => 'mcrs.png',
+ icon => 'roles.png',
linktitle => ''
},
+ {
+ linktext => 'View/Modify Self-Enrollment configuration',
+ icon => 'self_enroll.png',
+ #help => 'Course_Self_Enrollment',
+ url => &phaseurl('selfenroll'),
+ permission => &manage_selfenrollment($cdom,$cnum,$type,$coursehash),
+ linktitle => 'Configure user self-enrollment.',
+ },
+ {
+ linktext => 'View/Modify submit button behavior, post-submission',
+ icon => 'emblem-readonly.png',
+ #help => '',
+ url => &phaseurl('setpostsubmit'),
+ permission => 1,
+ linktitle => '',
+ },
]
},
);
@@ -284,12 +357,21 @@ sub print_modification_menu {
}
$menu_html .= ''."\n".'';
if ($type eq 'Community') {
- $menu_html .= ''.&mt('Community owner (permitted to assign Coordinator roles in the community).').' ';
+ $menu_html .= ''.&mt('Community owner (permitted to assign Coordinator roles in the community).').' '."\n".
+ ''.&mt('Override defaults for who configures self-enrollment for this specific community').' '."\n";
} else {
- $menu_html .= ''.&mt('Course owner (permitted to assign Course Coordinator roles in the course).').' '.
- ''.&mt("Institutional code and default authentication (both required for auto-enrollment of students from institutional datafeeds).").' ';
- }
- $menu_html .= ''.$setquota_text.' '."\n";
+ $menu_html .= ''.&mt('Course owner (permitted to assign Course Coordinator roles in the course).').' '."\n".
+ ''.&mt("Institutional code and default authentication (both required for auto-enrollment of students from institutional datafeeds).").' '."\n";
+ if (&showcredits($dom)) {
+ $menu_html .= ''.&mt('Default credits earned by student on course completion.').' '."\n";
+ }
+ $menu_html .= ' '.&mt('Override defaults for who configures self-enrollment for this specific course.').' '."\n";
+ }
+ $menu_html .= ''.$mysqltables_text.' '."\n".
+ ''.$setquota_text.' '."\n".
+ ''.$setuploadquota_text.' '."\n".
+ ''.$anon_text.' '."\n".
+ ''.$postsubmit_text.' '."\n";
foreach my $item (@additional_params) {
if ($type eq 'Community') {
if ($item eq 'togglecats') {
@@ -344,7 +426,7 @@ sub print_settings_display {
}
my $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
my $dctitle = &Apache::lonnet::plaintext('dc');
- my @modifiable_params = &get_dc_settable($type);
+ my @modifiable_params = &get_dc_settable($type,$cdom);
my ($internals,$accessdates) = &autoenroll_keys();
my @items;
if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
@@ -376,9 +458,13 @@ sub print_settings_display {
' '.$cdesc.' '.
'
+ENDDOCUMENT
+ return;
+}
+
+sub domain_postsubtimeout {
+ my ($cdom,$type,$settings) = @_;
+ return unless (ref($settings) eq 'HASH');
+ my $lctype = lc($type);
+ unless ($type eq 'Community') {
+ $lctype = 'unofficial';
+ if ($settings->{'internal.coursecode'}) {
+ $lctype = 'official';
+ } elsif ($settings->{'internal.textbook'}) {
+ $lctype = 'textbook';
+ }
+ }
+ my %domconfig =
+ &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
+ my $postsubtimeout = 60;
+ if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
+ if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') {
+ if (ref($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') {
+ if ($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$lctype} ne '') {
+ $postsubtimeout = $domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}{$lctype};
+ }
+ }
+ }
+ }
+ return $postsubtimeout;
+}
+
sub print_catsettings {
my ($r,$cdom,$cnum,$cdesc,$type) = @_;
&print_header($r,$type);
@@ -498,7 +737,7 @@ sub print_catsettings {
}
sub print_course_modification_page {
- my ($r,$cdom,$cnum,$cdesc,$type) = @_;
+ my ($r,$cdom,$cnum,$cdesc,$crstype) = @_;
my %lt=&Apache::lonlocal::texthash(
'actv' => "Active",
'inac' => "Inactive",
@@ -508,17 +747,28 @@ sub print_course_modification_page {
'stus' => "Status",
'nocc' => 'There is currently no owner set for this course.',
'gobt' => "Save",
+ 'sett' => 'Setting',
+ 'domd' => 'Domain default',
+ 'whom' => 'Who configures',
);
my ($ownertable,$ccrole,$javascript_validations,$authenitems,$ccname);
my %enrollvar = &get_enrollment_settings($cdom,$cnum);
- if ($type eq 'Community') {
+ my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook',
+ 'internal.selfenrollmgrdc','internal.selfenrollmgrcc',
+ 'internal.mysqltables'],$cdom,$cnum);
+ my $type = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype,\%settings);
+ my @specific_managebydc = split(/,/,$settings{'internal.selfenrollmgrdc'});
+ my @specific_managebycc = split(/,/,$settings{'internal.selfenrollmgrcc'});
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
+ my @default_managebydc = split(/,/,$domdefaults{$type.'selfenrolladmdc'});
+ if ($crstype eq 'Community') {
$ccrole = 'co';
$lt{'nocc'} = &mt('There is currently no owner set for this community.');
} else {
$ccrole ='cc';
($javascript_validations,$authenitems) = &gather_authenitems($cdom,\%enrollvar);
}
- $ccname = &Apache::lonnet::plaintext($ccrole,$type);
+ $ccname = &Apache::lonnet::plaintext($ccrole,$crstype);
my %roleshash = &Apache::lonnet::get_my_roles($cnum,$cdom,'','',[$ccrole]);
my (@local_ccs,%cc_status,%pname);
foreach my $item (keys(%roleshash)) {
@@ -571,14 +821,14 @@ sub print_course_modification_page {
}
$ownertable .= &Apache::loncommon::end_data_table();
}
- &print_header($r,$type,$javascript_validations);
+ &print_header($r,$crstype,$javascript_validations);
my $dctitle = &Apache::lonnet::plaintext('dc');
- my $mainheader = &modifiable_only_title($type);
+ my $mainheader = &modifiable_only_title($crstype);
my $hidden_elements = &hidden_form_elements();
$r->print(''."\n".
''.$mainheader.' '.$cdesc.' '.
&Apache::lonhtmlcommon::start_pick_box());
- if ($type eq 'Community') {
+ if ($crstype eq 'Community') {
$r->print(&Apache::lonhtmlcommon::row_title(
&Apache::loncommon::help_open_topic('Modify_Community_Owner').
' '.&mt('Community Owner'))."\n");
@@ -586,29 +836,146 @@ sub print_course_modification_page {
$r->print(&Apache::lonhtmlcommon::row_title(
&Apache::loncommon::help_open_topic('Modify_Course_Instcode').
' '.&mt('Course Code'))."\n".
- ' '.
- &Apache::lonhtmlcommon::row_closure().
- &Apache::lonhtmlcommon::row_title(
- &Apache::loncommon::help_open_topic('Modify_Course_Defaultauth').
- ' '.&mt('Default Authentication method'))."\n".
- $authenitems."\n".
- &Apache::lonhtmlcommon::row_closure().
- &Apache::lonhtmlcommon::row_title(
- &Apache::loncommon::help_open_topic('Modify_Course_Owner').
+ ' '.
+ &Apache::lonhtmlcommon::row_closure());
+ if (&showcredits($cdom)) {
+ $r->print(&Apache::lonhtmlcommon::row_title(
+ &Apache::loncommon::help_open_topic('Modify_Course_Credithours').
+ ' '.&mt('Credits (students)'))."\n".
+ ' '.
+ &Apache::lonhtmlcommon::row_closure());
+ }
+ $r->print(&Apache::lonhtmlcommon::row_title(
+ &Apache::loncommon::help_open_topic('Modify_Course_Defaultauth').
+ ' '.&mt('Default Authentication method'))."\n".
+ $authenitems."\n".
+ &Apache::lonhtmlcommon::row_closure().
+ &Apache::lonhtmlcommon::row_title(
+ &Apache::loncommon::help_open_topic('Modify_Course_Owner').
' '.&mt('Course Owner'))."\n");
}
- $r->print($ownertable."\n".&Apache::lonhtmlcommon::row_closure(1).
+ my ($cctitle,$rolename,$currmanages,$ccchecked,$dcchecked,$defaultchecked);
+ my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
+ if ($type eq 'Community') {
+ $cctitle = &mt('Community personnel');
+ } else {
+ $cctitle = &mt('Course personnel');
+ }
+
+ $r->print($ownertable."\n".&Apache::lonhtmlcommon::row_closure().
+ &Apache::lonhtmlcommon::row_title(
+ &Apache::loncommon::help_open_topic('Modify_Course_Selfenrolladmin').
+ ' '.&mt('Self-enrollment configuration')).
+ &Apache::loncommon::start_data_table()."\n".
+ &Apache::loncommon::start_data_table_header_row()."\n".
+ '
'.$lt{'sett'}.' '.
+ ''.$lt{'domd'}.' '.
+ ''.$lt{'whom'}.' '.
+ &Apache::loncommon::end_data_table_header_row()."\n");
+ my %optionname;
+ $optionname{''} = &mt('Use domain default');
+ $optionname{'0'} = $dctitle;
+ $optionname{'1'} = $cctitle;
+ foreach my $item (@{$selfenrollrows}) {
+ my %checked;
+ my $default = $cctitle;
+ if (grep(/^\Q$item\E$/,@default_managebydc)) {
+ $default = $dctitle;
+ }
+ if (grep(/^\Q$item\E$/,@specific_managebydc)) {
+ $checked{'0'} = ' checked="checked"';
+ } elsif (grep(/^\Q$item\E$/,@specific_managebycc)) {
+ $checked{'1'} = ' checked="checked"';
+ } else {
+ $checked{''} = ' checked="checked"';
+ }
+ $r->print(&Apache::loncommon::start_data_table_row()."\n".
+ ''.$selfenrolltitles->{$item}.' '."\n".
+ ''.&mt('[_1] configures',$default).' '."\n".
+ '');
+ foreach my $option ('','0','1') {
+ $r->print(''.
+ ' '.
+ $optionname{$option}.' ');
+ }
+ $r->print(' '."\n".
+ &Apache::loncommon::end_data_table_row()."\n");
+ }
+ $r->print(&Apache::loncommon::end_data_table()."\n".
+ ' '.&Apache::lonhtmlcommon::row_closure().
+ &Apache::lonhtmlcommon::row_title(
+ &Apache::loncommon::help_open_topic('Modify_Course_Table_Lifetime').
+ ' '.&mt('"Temporary" Tables Lifetime (s)'))."\n".
+ ' '.
+ &Apache::lonhtmlcommon::row_closure(1).
&Apache::lonhtmlcommon::end_pick_box().''.$hidden_elements.
' print('this.form.submit();"');
} else {
$r->print('javascript:verify_message(this.form);"');
}
- $r->print('value="'.$lt{'gobt'}.'" />
');
+ $r->print(' value="'.$lt{'gobt'}.'" />');
+ return;
+}
+
+sub print_selfenrollconfig {
+ my ($r,$type,$cdesc,$coursehash) = @_;
+ return unless(ref($coursehash) eq 'HASH');
+ my $cnum = $coursehash->{'num'};
+ my $cdom = $coursehash->{'domain'};
+ my %currsettings = &get_selfenroll_settings($coursehash);
+ &print_header($r,$type);
+ $r->print(''.&mt('Self-enrollment with a student role in: [_1]',
+ ''.$cdesc.' ').' '."\n");
+ &Apache::loncreateuser::print_selfenroll_menu($r,'domain',$env{'form.pickedcourse'},
+ $cdom,$cnum,\%currsettings,
+ &hidden_form_elements());
return;
}
+sub modify_selfenrollconfig {
+ my ($r,$type,$cdesc,$coursehash) = @_;
+ return unless(ref($coursehash) eq 'HASH');
+ my $cnum = $coursehash->{'num'};
+ my $cdom = $coursehash->{'domain'};
+ my %currsettings = &get_selfenroll_settings($coursehash);
+ &print_header($r,$type);
+ $r->print(''.&mt('Self-enrollment with a student role in: [_1]',
+ ''.$cdesc.' ').' '."\n");
+ $r->print(''."\n".
+ &hidden_form_elements().' ');
+ &Apache::loncreateuser::update_selfenroll_config($r,$env{'form.pickedcourse'},
+ $cdom,$cnum,'domain',$type,\%currsettings);
+ $r->print(' ');
+ return;
+}
+
+sub get_selfenroll_settings {
+ my ($coursehash) = @_;
+ my %currsettings;
+ if (ref($coursehash) eq 'HASH') {
+ %currsettings = (
+ selfenroll_types => $coursehash->{'internal.selfenroll_types'},
+ selfenroll_registered => $coursehash->{'internal.selfenroll_registered'},
+ selfenroll_section => $coursehash->{'internal.selfenroll_section'},
+ selfenroll_notifylist => $coursehash->{'internal.selfenroll_notifylist'},
+ selfenroll_approval => $coursehash->{'internal.selfenroll_approval'},
+ selfenroll_limit => $coursehash->{'internal.selfenroll_limit'},
+ selfenroll_cap => $coursehash->{'internal.selfenroll_cap'},
+ selfenroll_start_date => $coursehash->{'internal.selfenroll_start_date'},
+ selfenroll_end_date => $coursehash->{'internal.selfenroll_end_date'},
+ selfenroll_start_access => $coursehash->{'internal.selfenroll_start_access'},
+ selfenroll_end_access => $coursehash->{'internal.selfenroll_end_access'},
+ default_enrollment_start_date => $coursehash->{'default_enrollment_start_date'},
+ default_enrollment_end_date => $coursehash->{'default_enrollment_end_date'},
+ uniquecode => $coursehash->{'internal.uniquecode'},
+ );
+ }
+ return %currsettings;
+}
+
sub modifiable_only_title {
my ($type) = @_;
my $dctitle = &Apache::lonnet::plaintext('dc');
@@ -662,16 +1029,21 @@ sub modify_course {
my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
my %longtype = &course_settings_descrip($type);
my @items = ('internal.courseowner','description','internal.co-owners',
- 'internal.pendingco-owners');
+ 'internal.pendingco-owners','internal.selfenrollmgrdc',
+ 'internal.selfenrollmgrcc','internal.mysqltables');
+ my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
unless ($type eq 'Community') {
push(@items,('internal.coursecode','internal.authtype','internal.autharg',
'internal.sectionnums','internal.crosslistings'));
+ if (&showcredits($cdom)) {
+ push(@items,'internal.defaultcredits');
+ }
}
my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
my $description = $settings{'description'};
- my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,%cenv,%changed,
- @changes,@nochanges,@sections,@xlists,@warnings);
- my @modifiable_params = &get_dc_settable($type);
+ my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,
+ %cenv,%changed,@changes,@nochanges,@sections,@xlists,@warnings);
+ my @modifiable_params = &get_dc_settable($type,$cdom);
foreach my $param (@modifiable_params) {
$currattr{$param} = $settings{'internal.'.$param};
}
@@ -690,7 +1062,7 @@ sub modify_course {
$sections[0] = $settings{'internal.sectionnums'};
}
}
- unless ($settings{'internal.crosslistings'} eq'') {
+ unless ($settings{'internal.crosslistings'} eq '') {
if ($settings{'internal.crosslistings'} =~ m/,/) {
@xlists = split/,/,$settings{'internal.crosslistings'};
} else {
@@ -729,8 +1101,40 @@ sub modify_course {
$changed{'code'} = 1;
}
}
+ if ( exists($env{'form.mysqltables'}) ) {
+ $newattr{'mysqltables'} = $env{'form.mysqltables'};
+ $newattr{'mysqltables'} =~ s/\D+//g;
+ }
+ if (&showcredits($cdom) && exists($env{'form.defaultcredits'})) {
+ $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
+ $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
+ }
+ }
+
+ my @newmgrdc = ();
+ my @newmgrcc = ();
+ my @currmgrdc = split(/,/,$currattr{'selfenrollmgrdc'});
+ my @currmgrcc = split(/,/,$currattr{'selfenrollmgrcc'});
+
+ foreach my $item (@{$selfenrollrows}) {
+ if ($env{'form.selfenrollmgr_'.$item} eq '0') {
+ push(@newmgrdc,$item);
+ } elsif ($env{'form.selfenrollmgr_'.$item} eq '1') {
+ push(@newmgrcc,$item);
+ }
}
+ $newattr{'selfenrollmgrdc'}=join(',',@newmgrdc);
+ $newattr{'selfenrollmgrcc'}=join(',',@newmgrcc);
+
+ my $cctitle;
+ if ($type eq 'Community') {
+ $cctitle = &mt('Community personnel');
+ } else {
+ $cctitle = &mt('Course personnel');
+ }
+ my $dctitle = &Apache::lonnet::plaintext('dc');
+
if ( exists($env{'form.courseowner'}) ) {
$newattr{'courseowner'}=$env{'form.courseowner'};
unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
@@ -764,10 +1168,10 @@ sub modify_course {
}
}
if (@changes > 0) {
- $chgresponse = &mt("The following settings have been changed:");
+ $chgresponse = &mt('The following settings have been changed:').'';
}
if (@nochanges > 0) {
- $nochgresponse = &mt("The following settings remain unchanged:");
+ $nochgresponse = &mt('The following settings remain unchanged:').'';
}
if (@changes > 0) {
my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
@@ -781,11 +1185,36 @@ sub modify_course {
}
$response .= ' '.&mt('Error: ').$putreply.'';
} else {
+ if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
+ my %newenv;
+ map { $newenv{'course.'.$cdom.'_'.$cnum.'.internal.'.$_} = $newattr{$_}; } @changes;
+ &Apache::lonnet::appenv(\%newenv);
+ }
foreach my $attr (@modifiable_params) {
if (grep/^\Q$attr\E$/,@changes) {
- $chgresponse .= ''.$longtype{$attr}.' '.&mt('now set to:').' "'.$newattr{$attr}.'". ';
+ my $shown = $newattr{$attr};
+ if ($attr eq 'selfenrollmgrdc') {
+ $shown = &selfenroll_config_status(\@newmgrdc,$selfenrolltitles);
+ } elsif ($attr eq 'selfenrollmgrcc') {
+ $shown = &selfenroll_config_status(\@newmgrcc,$selfenrolltitles);
+ } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
+ $shown = &mt('None');
+ } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
+ $shown = &mt('domain default');
+ }
+ $chgresponse .= ''.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).' ';
} else {
- $nochgresponse .= ''.$longtype{$attr}.' '.&mt('still set to:').' "'.$currattr{$attr}.'". ';
+ my $shown = $currattr{$attr};
+ if ($attr eq 'selfenrollmgrdc') {
+ $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
+ } elsif ($attr eq 'selfenrollmgrcc') {
+ $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
+ } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
+ $shown = &mt('None');
+ } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
+ $shown = &mt('domain default');
+ }
+ $nochgresponse .= ''.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).' ';
}
}
if (($type ne 'Community') && ($changed{'code'} || $changed{'owner'})) {
@@ -793,6 +1222,8 @@ sub modify_course {
push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
' '.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
} else {
+ my %crsenv = &Apache::lonnet::get('environment',['internal.co-owners'],$cdom,$cnum);
+ my $coowners = $crsenv{'internal.co-owners'};
if (@sections > 0) {
if ($changed{'code'}) {
foreach my $sec (@sections) {
@@ -801,7 +1232,7 @@ sub modify_course {
my $inst_course_id = $newattr{'coursecode'}.$1;
my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
if ($course_check eq 'ok') {
- my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
+ my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
unless ($outcome eq 'ok') {
push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome).' ');
@@ -818,7 +1249,7 @@ sub modify_course {
if ($sec =~ m/^(.+):/) {
my $instsec = $1;
my $inst_course_id = $newattr{'coursecode'}.$instsec;
- my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
+ my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'},$coowners);
unless ($outcome eq 'ok') {
push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome));
}
@@ -834,7 +1265,7 @@ sub modify_course {
foreach my $xlist (@xlists) {
if ($xlist =~ m/^(.+):/) {
my $instxlist = $1;
- my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'});
+ my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'},$coowners);
unless ($outcome eq 'ok') {
push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for crosslisted class "[_2]" for the following reason: "[_3]".',$description,$instxlist,$outcome));
}
@@ -846,7 +1277,17 @@ sub modify_course {
}
} else {
foreach my $attr (@modifiable_params) {
- $nochgresponse .= ''.$longtype{$attr}.' '.&mt('still set to').' "'.$currattr{$attr}.'". ';
+ my $shown = $currattr{$attr};
+ if ($attr eq 'selfenrollmgrdc') {
+ $shown = &selfenroll_config_status(\@currmgrdc,$selfenrolltitles);
+ } elsif ($attr eq 'selfenrollmgrcc') {
+ $shown = &selfenroll_config_status(\@currmgrcc,$selfenrolltitles);
+ } elsif (($attr eq 'defaultcredits') && ($shown eq '')) {
+ $shown = &mt('None');
+ } elsif (($attr eq 'mysqltables') && ($shown eq '')) {
+ $shown = &mt('domain default');
+ }
+ $nochgresponse .= ''.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).' ';
}
}
@@ -875,22 +1316,40 @@ sub modify_course {
$reply = ''.$mainheader.' '.$cdesc.' '."\n".
''.$reply.'
'."\n".
' '.
- &hidden_form_elements().
- ''.
- &mt('Pick another action').' ';
+ &hidden_form_elements();
+ my @actions =
+ (''.
+ &mt('Pick another action').' ');
if ($numwarnings) {
my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
'=1&destinationurl=/adm/populate','&<>"');
- $reply .= ''.
- &mt('Go to Automated Enrollment Manager for course').' ';
+ push(@actions, ''.
+ &mt('Go to Automated Enrollment Manager for course').' ');
}
- $reply .= ' ';
+ $reply .= &Apache::lonhtmlcommon::actionbox(\@actions).'';
$r->print($reply);
return;
}
+sub selfenroll_config_status {
+ my ($items,$selfenrolltitles) = @_;
+ my $shown;
+ if ((ref($items) eq 'ARRAY') && (ref($selfenrolltitles) eq 'HASH')) {
+ if (@{$items} > 0) {
+ $shown = '';
+ foreach my $item (@{$items}) {
+ $shown .= ''.$selfenrolltitles->{$item}.' ';
+ }
+ $shown .= ' ';
+ } else {
+ $shown = &mt('None');
+ }
+ }
+ return $shown;
+}
+
sub update_coowners {
my ($cdom,$cnum,$chome,$settings,$newattr) = @_;
return unless ((ref($settings) eq 'HASH') && (ref($newattr) eq 'HASH'));
@@ -988,7 +1447,7 @@ sub update_coowners {
if ($designhash{$cdom.'.autoassign.co-owners'}) {
my @newcoowners = ();
if ($settings->{'internal.co-owners'}) {
- my @currcoown = split(',',$settings->{'internal.coowners'});
+ my @currcoown = split(',',$settings->{'internal.co-owners'});
my ($updatecoowners,$delcoowners);
foreach my $person (@currcoown) {
my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person);
@@ -1037,63 +1496,247 @@ sub update_coowners {
sub modify_quota {
my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
&print_header($r,$type);
+ my $lctype = lc($type);
+ my $headline = &mt("Disk space quotas for $lctype: [_1]",
+ ''.$cdesc.' ');
$r->print(''."\n".
- ''.&mt('Disk space for storage of group portfolio files for:').
+ ''.$headline.' ');
+ my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
+ my %staticdefaults = (
+ coursequota => 20,
+ uploadquota => 500,
+ );
+ my %default;
+ $default{'coursequota'} = $staticdefaults{'coursequota'};
+ my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
+ $default{'uploadquota'} = $domdefs{'uploadquota'};
+ if ($default{'uploadquota'} eq '') {
+ $default{'uploadquota'} = $staticdefaults{'uploadquota'};
+ }
+ my (%cenv,%showresult);
+ foreach my $item ('coursequota','uploadquota') {
+ if ($env{'form.'.$item} ne '') {
+ my $newquota = $env{'form.'.$item};
+ if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
+ $newquota = $1;
+ if ($oldsettings{'internal.'.$item} == $newquota) {
+ if ($item eq 'coursequota') {
+ $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] MB.',$newquota).' ');
+ } else {
+ $r->print(&mt('The disk space allocated for files uploaded via the Content Editor remains unchanged as [_1] MB.',$newquota).' ');
+ }
+ } else {
+ $cenv{'internal.'.$item} = $newquota;
+ $showresult{$item} = 1;
+ }
+ } else {
+ if ($item eq 'coursequota') {
+ $r->print(&mt('The proposed group portfolio quota contained invalid characters, so the quota is unchanged.').' ');
+ } else {
+ $r->print(&mt('The proposed quota for content uploaded via the Content Editor contained invalid characters, so the quota is unchanged.').' ');
+
+ }
+ }
+ }
+ }
+ if (keys(%cenv)) {
+ my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
+ $cnum);
+ foreach my $key (sort(keys(%showresult))) {
+ if (($oldsettings{'internal.'.$key} eq '') &&
+ ($env{'form.'.$key} == $default{$key})) {
+ if ($key eq 'uploadquota') {
+ if ($type eq 'Community') {
+ $r->print(&mt('The disk space allocated for files uploaded to this community via the Content Editor is the default quota for this domain: [_1] MB.',
+ $default{$key}).' ');
+ } else {
+ $r->print(&mt('The disk space allocated for files uploaded to this course via the Content Editor is the default quota for this domain: [_1] MB.',
+ $default{$key}).' ');
+ }
+ } else {
+ if ($type eq 'Community') {
+ $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] MB.',
+ $default{$key}).' ');
+ } else {
+ $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] MB.',
+ $default{$key}).' ');
+ }
+ }
+ delete($showresult{$key});
+ }
+ }
+ if ($putreply eq 'ok') {
+ my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota'],$cdom,$cnum);
+ if ($showresult{'coursequota'}) {
+ $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] MB.',
+ ''.$updatedsettings{'internal.coursequota'}.' ').' ');
+ my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
+ if ($usage >= $updatedsettings{'internal.coursequota'}) {
+ my $newoverquota;
+ if ($usage < $oldsettings{'internal.coursequota'}) {
+ $newoverquota = 'now';
+ }
+ $r->print(' ');
+ if ($type eq 'Community') {
+ $r->print(&mt("Disk usage $newoverquota exceeds the quota for this community.").' '.
+ &mt('Upload of new portfolio files and assignment of a non-zero MB quota to new groups in the community will not be possible until some files have been deleted, and total usage is below community quota.'));
+ } else {
+ $r->print(&mt("Disk usage $newoverquota exceeds the quota for this course.").' '.
+ &mt('Upload of new portfolio files and assignment of a non-zero MB quota to new groups in the course will not be possible until some files have been deleted, and total usage is below course quota.'));
+ }
+ $r->print('
');
+ }
+ }
+ if ($showresult{'uploadquota'}) {
+ $r->print(&mt('The disk space allocated for content uploaded directly via the Content Editor is now: [_1] MB.',
+ ''.$updatedsettings{'internal.uploadquota'}.' ').' ');
+ }
+ } else {
+ $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content: ').
+ $putreply);
+ }
+ }
+ $r->print(''.
+ ''.
+ &mt('Pick another action').' ');
+ $r->print(&hidden_form_elements().'
');
+ return;
+}
+
+sub modify_anonsurvey_threshold {
+ my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
+ &print_header($r,$type);
+ $r->print(''."\n".
+ ''.&mt('Responder threshold required for display of anonymous survey submissions:').
' '.$cdesc.' ');
- my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
- my $defaultquota = 20;
- if ($env{'form.coursequota'} ne '') {
- my $newquota = $env{'form.coursequota'};
- if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
- $newquota = $1;
- if ($oldsettings{'internal.coursequota'} eq $env{'form.coursequota'}) {
- $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] Mb.',$env{'form.coursequota'}));
+ my %oldsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
+ my %domconfig =
+ &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
+ my $defaultthreshold;
+ if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
+ $defaultthreshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
+ if ($defaultthreshold eq '') {
+ $defaultthreshold = 10;
+ }
+ } else {
+ $defaultthreshold = 10;
+ }
+ if ($env{'form.threshold'} eq '') {
+ $r->print(&mt('The proposed responder threshold for display of anonymous survey submissions was blank, so the threshold is unchanged.'));
+ } else {
+ my $newthreshold = $env{'form.threshold'};
+ if ($newthreshold =~ /^\s*(\d+)\s*$/) {
+ $newthreshold = $1;
+ if ($oldsettings{'internal.anonsurvey_threshold'} eq $env{'form.threshold'}) {
+ $r->print(&mt('Responder threshold for anonymous survey submissions display remains unchanged: [_1].',$env{'form.threshold'}));
} else {
my %cenv = (
- 'internal.coursequota' => $env{'form.coursequota'},
+ 'internal.anonsurvey_threshold' => $env{'form.threshold'},
);
my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
$cnum);
- if (($oldsettings{'internal.coursequota'} eq '') &&
- ($env{'form.coursequota'} == $defaultquota)) {
- if ($type eq 'Community') {
- $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] Mb.',$defaultquota));
- } else {
- $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] Mb.',$defaultquota));
+ if ($putreply eq 'ok') {
+ if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
+ &Apache::lonnet::appenv(
+ {'course.'.$cdom.'_'.$cnum.'.internal.anonsurvey_threshold' => $env{'form.threshold'}});
}
+ }
+ if (($oldsettings{'internal.anonsurvey_threshold'} eq '') &&
+ ($env{'form.threshold'} == $defaultthreshold)) {
+ $r->print(&mt('The responder threshold for display of anonymous survey submissions is the default for this domain: [_1].',$defaultthreshold));
} else {
if ($putreply eq 'ok') {
- my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
- $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] Mb.',$updatedsettings{'internal.coursequota'}));
- my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
- if ($usage >= $updatedsettings{'internal.coursequota'}) {
- my $newoverquota;
- if ($usage < $oldsettings{'internal.coursequota'}) {
- $newoverquota = 'now';
- }
- $r->print('');
- if ($type eq 'Community') {
- $r->print(&mt('Disk usage [_1] exceeds the quota for this community.',$newoverquota).' '.
- &mt('Upload of new portfolio files and assignment of a non-zero Mb quota to new groups in the community will not be possible until some files have been deleted, and total usage is below community quota.'));
- } else {
- $r->print(&mt('Disk usage [_1] exceeds the quota for this course.',$newoverquota).' '.
- &mt('Upload of new portfolio files and assignment of a non-zero Mb quota to new groups in the course will not be possible until some files have been deleted, and total usage is below course quota.'));
- }
- $r->print('
');
- }
+ my %updatedsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
+ $r->print(&mt('The responder threshold for display of anonymous survey submissions is now: [_1].',''.$updatedsettings{'internal.anonsurvey_threshold'}.' '));
} else {
- $r->print(&mt('An error occurred storing the quota for group portfolio files: ').
+ $r->print(&mt('An error occurred storing the responder threshold for anonymous submissions display: ').
$putreply);
}
}
}
} else {
- $r->print(&mt('The new quota requested contained invalid characters, so the quota is unchanged.'));
+ $r->print(&mt('The proposed responder threshold for display of anonymous submissions contained invalid characters, so the threshold is unchanged.'));
}
}
$r->print(''.
- ''.
- &mt('Pick another action').' ');
+ ''.
+ &mt('Pick another action').'
');
+ $r->print(&hidden_form_elements().' ');
+ return;
+}
+
+sub modify_postsubmit_config {
+ my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
+ &print_header($r,$type);
+ my %lt = &Apache::lonlocal::texthash(
+ subb => 'Submit button behavior after student makes a submission:',
+ unch => 'Post submission behavior of the Submit button is unchanged.',
+ erro => 'An error occurred when saving your proposed changes.',
+ inva => 'An invalid response was recorded.',
+ pick => 'Pick another action',
+ );
+ $r->print(''."\n".
+ ''.$lt{'subb'}.' ('.$cdesc.') ');
+ my %oldsettings =
+ &Apache::lonnet::get('environment',['internal.postsubmit','internal.postsubtimeout','internal.coursecode','internal.textbook'],$cdom,$cnum);
+ my $postsubmit = $env{'form.postsubmit'};
+ if ($postsubmit eq '1') {
+ my $postsubtimeout = $env{'form.postsubtimeout'};
+ $postsubtimeout =~ s/[^\d\.]+//g;
+ if (($oldsettings{'internal.postsubmit'} eq $postsubmit) && ($oldsettings{'internal.postsubtimeout'} eq $postsubtimeout)) {
+ $r->print($lt{'unch'});
+ } else {
+ my %cenv = (
+ 'internal.postsubmit' => $postsubmit,
+ );
+ if ($postsubtimeout eq '') {
+ my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
+ if ($putreply eq 'ok') {
+ my $defaulttimeout = &domain_postsubtimeout($cdom,$type,\%oldsettings);
+ $r->print(&mt('The proposed duration for disabling the Submit button post-submission was blank, so the domain default of [quant,_1,second] will be used.',$defaulttimeout));
+ if (exists($oldsettings{'internal.postsubtimeout'})) {
+ &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
+ }
+ } else {
+ $r->print($lt{'erro'});
+ }
+ } else {
+ $cenv{'internal.postsubtimeout'} = $postsubtimeout;
+ my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
+ if ($putreply eq 'ok') {
+ if ($postsubtimeout eq '0') {
+ $r->print(&mt('Submit button will be disabled after student submission until page is reloaded.'));
+ } else {
+ $r->print(&mt('Submit button will be disabled after student submission for [quant,_1,second].',$postsubtimeout));
+ }
+ } else {
+ $r->print($lt{'erro'});
+ }
+ }
+ }
+ } elsif ($postsubmit eq '0') {
+ if ($oldsettings{'internal.postsubmit'} eq $postsubmit) {
+ $r->print($lt{'unch'});
+ } else {
+ if (exists($oldsettings{'internal.postsubtimeout'})) {
+ &Apache::lonnet::del('environment',['internal.postsubtimeout'],$cdom,$cnum);
+ }
+ my %cenv = (
+ 'internal.postsubmit' => $postsubmit,
+ );
+ my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
+ if ($putreply eq 'ok') {
+ $r->print(&mt('Submit button will not be disabled after student submission'));
+ } else {
+ $r->print($lt{'erro'});
+ }
+ }
+ } else {
+ $r->print($lt{'inva'}.' '.$lt{'unch'});
+ }
+ $r->print(''.
+ ''.
+ &mt('Pick another action').'
');
$r->print(&hidden_form_elements().' ');
return;
}
@@ -1184,6 +1827,13 @@ sub modify_catsettings {
if (@changes > 0) {
my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
if ($putreply eq 'ok') {
+ if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') {
+ my %newenvhash;
+ foreach my $item (@changes) {
+ $newenvhash{'course.'.$cdom.'_'.$cnum.'.'.$item} = $cenv{$item};
+ }
+ &Apache::lonnet::appenv(\%newenvhash);
+ }
my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
$cnum,undef,undef,'.');
if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
@@ -1235,7 +1885,7 @@ sub print_header {
$phase = $env{'form.phase'};
}
my $js = qq|
-
+
|;
if ($phase eq 'setparms') {
- $js .= qq|
-
-|;
+ $js .= $javascript_validations;
} elsif ($phase eq 'courselist') {
$js .= qq|
-
+
+function hide_searching() {
+ if (document.getElementById('searching')) {
+ document.getElementById('searching').style.display = 'none';
+ }
+ return;
+}
+
|;
} elsif ($phase eq 'setquota') {
- $js .= <<'ENDSCRIPT';
-
+
ENDSCRIPT
+
}
my $starthash;
if ($env{'form.phase'} eq 'ccrole') {
$starthash = {
add_entries => {'onload' => "javascript:document.ccrole.submit();"},
};
+ } elsif ($phase eq 'courselist') {
+ $starthash = {
+ add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},
+ };
}
$r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
- $js,$starthash));
+ &Apache::lonhtmlcommon::scripttag($js),
+ $starthash));
my $bread_text = "View/Modify Courses/Communities";
if ($type eq 'Community') {
$bread_text = 'Community Settings';
@@ -1301,38 +2070,35 @@ sub print_footer {
}
sub check_course {
- my ($r,$dom,$domdesc) = @_;
- my ($ok_course,$description,$instcode,$owner);
- my %args = (
- one_time => 1,
- );
- my %coursehash =
- &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
- my $cnum = $coursehash{'num'};
- my $cdom = $coursehash{'domain'};
- if ($cdom eq $dom) {
- my $description;
- my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
- $cnum,undef,undef,'.');
- if (keys(%courseIDs) > 0) {
- $ok_course = 'ok';
- my ($instcode,$owner);
- if (ref($courseIDs{$cdom.'_'.$cnum}) eq 'HASH') {
- $description = $courseIDs{$cdom.'_'.$cnum}{'description'};
- $instcode = $courseIDs{$cdom.'_'.$cnum}{'inst_code'};
- $owner = $courseIDs{$cdom.'_'.$cnum}{'owner'};
- } else {
- ($description,$instcode,$owner) =
- split(/:/,$courseIDs{$cdom.'_'.$cnum});
- }
- $description = &unescape($description);
- $instcode = &unescape($instcode);
- if ($instcode) {
- $description .= " ($instcode)";
+ my ($dom,$domdesc) = @_;
+ my ($ok_course,$description,$instcode);
+ my %coursehash;
+ if ($env{'form.pickedcourse'} =~ /^$match_domain\_$match_courseid$/) {
+ my %args;
+ unless ($env{'course.'.$env{'form.pickedcourse'}.'.description'}) {
+ %args = (
+ 'one_time' => 1,
+ 'freshen_cache' => 1,
+ );
+ }
+ %coursehash =
+ &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
+ my $cnum = $coursehash{'num'};
+ my $cdom = $coursehash{'domain'};
+ $description = $coursehash{'description'};
+ $instcode = $coursehash{'internal.coursecode'};
+ if ($instcode) {
+ $description .= " ($instcode)";
+ }
+ if (($cdom eq $dom) && ($cnum =~ /^$match_courseid$/)) {
+ my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
+ $cnum,undef,undef,'.');
+ if ($courseIDs{$cdom.'_'.$cnum}) {
+ $ok_course = 'ok';
}
- return ($ok_course,$description);
}
}
+ return ($ok_course,$description,\%coursehash);
}
sub course_settings_descrip {
@@ -1340,8 +2106,10 @@ sub course_settings_descrip {
my %longtype;
if ($type eq 'Community') {
%longtype = &Apache::lonlocal::texthash(
- 'courseowner' => "Username:domain of community owner",
- 'co-owners' => "Username:domain of each co-owner",
+ 'courseowner' => "Username:domain of community owner",
+ 'co-owners' => "Username:domain of each co-owner",
+ 'selfenrollmgrdc' => "Community-specific self-enrollment configuration by Domain Coordinator",
+ 'selfenrollmgrcc' => "Community-specific self-enrollment configuration by Community personnel",
);
} else {
%longtype = &Apache::lonlocal::texthash(
@@ -1359,6 +2127,12 @@ sub course_settings_descrip {
'notifylist' => 'Course Coordinators to be notified of enrollment changes',
'sectionnums' => 'Course section number:LON-CAPA section',
'crosslistings' => 'Crosslisted class:LON-CAPA section',
+ 'defaultcredits' => 'Credits',
+ 'autodropfailsafe' => "Failsafe section enrollment count",
+ 'selfenrollmgrdc' => "Course-specific self-enrollment configuration by Domain Coordinator",
+ 'selfenrollmgrcc' => "Course-specific self-enrollment configuration by Course personnel",
+ 'mysqltables' => '"Temporary" student performance tables lifetime (seconds)',
+
);
}
return %longtype;
@@ -1368,11 +2142,22 @@ sub hidden_form_elements {
my $hidden_elements =
&Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
- 'locarg','krbarg','krbver','counter','hidefromcat','usecategory'])."\n".
+ 'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
+ 'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
+ 'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
+ 'sections','newsec','mysqltables'],['^selfenrollmgr_','^selfenroll_'])."\n".
' ';
return $hidden_elements;
}
+sub showcredits {
+ my ($dom) = @_;
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) {
+ return 1;
+ }
+}
+
sub handler {
my $r = shift;
if ($r->header_only) {
@@ -1380,8 +2165,10 @@ sub handler {
$r->send_http_header;
return OK;
}
+
my $dom = $env{'request.role.domain'};
my $domdesc = &Apache::lonnet::domain($dom,'description');
+
if (&Apache::lonnet::allowed('ccc',$dom)) {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
@@ -1420,7 +2207,7 @@ sub handler {
if ($phase eq 'courselist') {
&print_course_selection_page($r,$dom,$domdesc);
} else {
- my ($checked,$cdesc) = &check_course($r,$dom,$domdesc);
+ my ($checked,$cdesc,$coursehash) = &check_course($dom,$domdesc);
if ($checked eq 'ok') {
my $enter_text;
if ($type eq 'Community') {
@@ -1432,7 +2219,8 @@ sub handler {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'menu')",
text=>"Pick action"});
- &print_modification_menu($r,$cdesc,$domdesc,$dom,$type);
+ &print_modification_menu($r,$cdesc,$domdesc,$dom,$type,
+ $env{'form.pickedcourse'},$coursehash);
} elsif ($phase eq 'ccrole') {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'ccrole')",
@@ -1456,7 +2244,30 @@ sub handler {
({href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Result"});
&modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
- } elsif ($phase eq 'viewparms') {
+ } elsif ($phase eq 'setanon') {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:changePage(document.$phase,'$phase')",
+ text=>"Threshold for anonymous submissions display"});
+ &print_set_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$type);
+ } elsif ($phase eq 'processthreshold') {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:changePage(document.$phase,'setanon')",
+ text=>"Threshold for anonymous submissions display"});
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:changePage(document.$phase,'$phase')",
+ text=>"Result"});
+ &modify_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$domdesc,$type);
+ } elsif ($phase eq 'setpostsubmit') {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:changePage(document.$phase,'$phase')",
+ text=>"Configure submit button behavior post-submission"});
+ &print_postsubmit_config($r,$cdom,$cnum,$cdesc,$type);
+ } elsif ($phase eq 'processpostsubmit') {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:changePage(document.$phase,'$phase')",
+ text=>"Result"});
+ &modify_postsubmit_config($r,$cdom,$cnum,$cdesc,$domdesc,$type);
+ } elsif ($phase eq 'viewparms') {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"javascript:changePage(document.$phase,'viewparms')",
text=>"Display settings"});
@@ -1487,14 +2298,26 @@ sub handler {
({href=>"javascript:changePage(document.$phase,'$phase')",
text=>"Result"});
&modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
+ } elsif ($phase eq 'selfenroll') {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href => "javascript:changePage(document.$phase,'$phase')",
+ text => "Self-enrollment settings"});
+ if (!exists($env{'form.state'})) {
+ &print_selfenrollconfig($r,$type,$cdesc,$coursehash);
+ } elsif ($env{'form.state'} eq 'done') {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"javascript:changePage(document.$phase,'$phase')",
+ text=>"Result"});
+ &modify_selfenrollconfig($r,$type,$cdesc,$coursehash);
+ }
}
}
} else {
$r->print('');
if ($type eq 'Community') {
- $r->print(&mt('The course you selected is not a valid course in this domain'));
- } else {
$r->print(&mt('The community you selected is not a valid community in this domain'));
+ } else {
+ $r->print(&mt('The course you selected is not a valid course in this domain'));
}
$r->print(" ($domdesc) ");
}