--- loncom/interface/lonmodifycourse.pm 2010/05/18 16:13:31 1.54
+++ loncom/interface/lonmodifycourse.pm 2013/03/01 05:01:26 1.60
@@ -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.60 2013/03/01 05:01:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,18 +39,22 @@ use lib '/home/httpd/lib/perl';
use LONCAPA;
sub get_dc_settable {
- my ($type) = @_;
+ my ($type,$cdom) = @_;
if ($type eq 'Community') {
return ('courseowner');
} else {
- return ('courseowner','coursecode','authtype','autharg');
+ my @items = ('courseowner','coursecode','authtype','autharg');
+ 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'];
my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date'];
return ($internals,$accessdates);
}
@@ -114,6 +118,10 @@ sub get_enrollment_settings {
|| $type eq "autharg" || $type eq "coursecode"
|| $type eq "crosslistings") {
$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};
@@ -149,7 +157,7 @@ sub print_course_search_page {
'instcodefilter','ownerfilter',
'coursefilter'];
my $filter = {};
- my ($numtitles,$cctitle,$dctitle);
+ my ($numtitles,$cctitle,$dctitle,@codetitles);
my $ccrole = 'cc';
if ($type eq 'Community') {
$ccrole = 'co';
@@ -163,7 +171,8 @@ sub print_course_search_page {
$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'));
+ undef,undef,$filter,$action,\$numtitles,'modifycourse',
+ undef,undef,undef,\@codetitles));
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".
@@ -192,14 +201,16 @@ sub print_course_selection_page {
my %filter;
my $action = '/adm/modifycourse';
my $dctitle = &Apache::lonnet::plaintext('dc');
- my $numtitles;
+ my ($numtitles,@codetitles);
$r->print(&Apache::lonpickcourse::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));
+ undef,undef,\%filter,$action,\$numtitles,
+ undef,undef,undef,undef,\@codetitles));
$filter{'domainfilter'} = $dom;
my %courses = &Apache::lonpickcourse::search_courses($r,$type,0,
- \%filter,$numtitles);
+ \%filter,$numtitles,undef,
+ undef,undef,\@codetitles);
&Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef,
%courses);
return;
@@ -222,9 +233,14 @@ sub print_modification_menu {
} 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';
+ if (&showcredits($dom)) {
+ $setparams_text = 'View/Modify course owner, institutional code, and default authentication and credits';
+ } else {
+ $setparams_text = 'View/Modify course owner, institutional code, and default authentication';
+ }
+ $cat_text = 'View/Modify catalog settings for course';
}
+ my $anon_text = 'Responder threshold required to display anonymous survey submissions';
my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
@@ -241,7 +257,7 @@ sub print_modification_menu {
url => &phaseurl('setparms'),
permission => 1,
#help => '',
- icon => 'mcrs.png',
+ icon => 'crsconf.png',
linktitle => ''
},
{
@@ -249,7 +265,15 @@ sub print_modification_menu {
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 +281,7 @@ sub print_modification_menu {
url => &phaseurl('catsettings'),
permission => (@additional_params > 0),
#help => '',
- icon => 'mcrs.png',
+ icon => 'ccatconf.png',
linktitle => ''
},
{
@@ -265,7 +289,7 @@ sub print_modification_menu {
url => &phaseurl('viewparms'),
permission => ($type ne 'Community'),
#help => '',
- icon => 'mcrs.png',
+ icon => 'roles.png',
linktitle => ''
},
]
@@ -288,8 +312,12 @@ sub print_modification_menu {
} 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).").'
';
+ if (&showcredits($dom)) {
+ $menu_html .= '
'.&mt('Default credits earned by student on course completion.').'
';
+ }
}
- $menu_html .= '
'.$setquota_text.'
'."\n";
+ $menu_html .= '
'.$setquota_text.'
'.
+ '
'.$anon_text.'
'."\n";
foreach my $item (@additional_params) {
if ($type eq 'Community') {
if ($item eq 'togglecats') {
@@ -344,7 +372,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 +404,13 @@ sub print_settings_display {
' '.$cdesc.''.
'
');
+ $r->print(' value="'.$lt{'gobt'}.'" />');
return;
}
@@ -666,12 +744,15 @@ sub modify_course {
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 +771,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,6 +810,12 @@ sub modify_course {
$changed{'code'} = 1;
}
}
+
+ if (&showcredits($cdom) && exists($env{'form.defaultcredits'})) {
+ $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
+ $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
+ }
+
}
if ( exists($env{'form.courseowner'}) ) {
@@ -793,6 +880,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 +890,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 +907,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 +923,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));
}
@@ -988,7 +1077,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);
@@ -1064,7 +1153,7 @@ sub modify_quota {
} 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'}));
+ $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;
@@ -1098,6 +1187,62 @@ sub modify_quota {
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.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.anonsurvey_threshold' => $env{'form.threshold'},
+ );
+ my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
+ $cnum);
+ 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.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 responder threshold for anonymous submissions display: ').
+ $putreply);
+ }
+ }
+ }
+ } else {
+ $r->print(&mt('The proposed responder threshold for display of anonymous submissions contained invalid characters, so the threshold is unchanged.'));
+ }
+ }
+ $r->print('