'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'
';
}
}
if (($type ne 'Community') && ($changed{'code'} || $changed{'owner'})) {
@@ -842,6 +1107,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) {
@@ -850,7 +1117,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).' ');
@@ -867,7 +1134,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));
}
@@ -883,7 +1150,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));
}
@@ -895,7 +1162,15 @@ sub modify_course {
}
} else {
foreach my $attr (@modifiable_params) {
- $nochgresponse .= '
'.$longtype{$attr}.' '.&mt('still set to').' "'.$currattr{$attr}.'".
';
+ $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'));
@@ -1037,7 +1330,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);
@@ -1086,58 +1379,104 @@ 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:').
- ' '.$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'}));
+ '
'.$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 {
- my %cenv = (
- 'internal.coursequota' => $env{'form.coursequota'},
- );
- my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
- $cnum);
- if (($oldsettings{'internal.coursequota'} eq '') &&
- ($env{'form.coursequota'} == $defaultquota)) {
+ 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 group portfolio files in this community is the default quota for this domain: [_1] Mb.',$defaultquota));
+ $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 group portfolio files in this course is the default quota for this domain: [_1] Mb.',$defaultquota));
+ $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 ($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('
');
- }
+ } 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('An error occurred storing the quota for group portfolio files: ').
- $putreply);
+ $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('The new quota requested contained invalid characters, so the quota is unchanged.'));
+ $r->print(&mt('An error occurred storing the quota(s) for group portfolio files and/or uploaded content: ').
+ $putreply);
}
}
$r->print('
'.
@@ -1179,6 +1518,12 @@ sub modify_anonsurvey_threshold {
);
my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
$cnum);
+ 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));
@@ -1289,6 +1634,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') {
@@ -1340,7 +1692,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') {
my $invalid = &mt('The quota you entered contained invalid characters.');
my $alert = &mt('You must enter a number');
my $regexp = '/^\s*(\d+\.?\d*|\.\d+)\s*$/';
$js .= <<"ENDSCRIPT";
-
+
ENDSCRIPT
} elsif ($phase eq 'setanon') {
my $invalid = &mt('The responder threshold you entered is invalid.');
my $alert = &mt('You must enter a positive integer.');
my $regexp = ' /^\s*\d+\s*$/';
$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';
@@ -1434,38 +1795,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 {
@@ -1473,8 +1831,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(
@@ -1492,6 +1852,10 @@ 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',
+ 'selfenrollmgrdc' => "Course-specific self-enrollment configuration by Domain Coordinator",
+ 'selfenrollmgrcc' => "Course-specific self-enrollment configuration by Course personnel",
+
);
}
return %longtype;
@@ -1502,11 +1866,20 @@ sub hidden_form_elements {
&Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
- 'threshold'])."\n".
+ 'threshold','defaultcredits','uploadquota','selfenrollmgrdc','selfenrollmgrcc',
+ 'action','state','currsec_st','sections','newsec'],['^selfenrollmgr_'])."\n".
'';
return $hidden_elements;
}
+sub showcredits {
+ my ($dom) = @_;
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbokcredits'}) {
+ return 1;
+ }
+}
+
sub handler {
my $r = shift;
if ($r->header_only) {
@@ -1514,8 +1887,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;
@@ -1554,7 +1929,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') {
@@ -1566,7 +1941,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')",
@@ -1635,14 +2011,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)");
}