--- loncom/interface/lonmodifycourse.pm 2010/03/29 17:32:28 1.52 +++ loncom/interface/lonmodifycourse.pm 2014/03/13 14:46:46 1.69 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # handler for DC-only modifiable course settings # -# $Id: lonmodifycourse.pm,v 1.52 2010/03/29 17:32:28 raeburn Exp $ +# $Id: lonmodifycourse.pm,v 1.69 2014/03/13 14:46:46 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}; @@ -145,11 +153,8 @@ 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(); + my ($numtitles,$cctitle,$dctitle,@codetitles); my $ccrole = 'cc'; if ($type eq 'Community') { $ccrole = 'co'; @@ -161,9 +166,10 @@ sub print_course_search_page { $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,$filter->{'domainfilter'})); if ($type eq 'Community') { $r->print(&mt('Actions available after searching for a community:').''); } + return; } sub print_course_selection_page { @@ -186,109 +193,170 @@ 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; + 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)); - $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,$filter->{'domainfilter'}, + $env{'form.form'})); + if (ref($filter) eq 'HASH') { + $filter->{'domainfilter'} = $dom; + } + my %courses = &Apache::lonpickcourse::search_courses($r,$type,0,$filter,$numtitles, + undef,undef,undef,\@codetitles); &Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef, %courses); return; } +sub get_filters { + my @filterlist = ('descriptfilter','instcodefilter','ownerfilter', + 'ownerdomfilter','coursefilter','sincefilter'); + # created filter + my $loncaparev = &Apache::lonnet::get_server_loncaparev($env{'form.domainfilter'}); + 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) = @_; &print_header($r,$type); - my ($ccrole,$setquota_text,$setparams_text,$cat_text); + my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$setparams_text,$cat_text); if ($type eq 'Community') { $ccrole = 'co'; } else { $ccrole = 'cc'; - } - my $action = '/adm/modifycourse'; + } 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, 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 @menu = - ( - { text => $setparams_text, - phase => 'setparms', - }, - { text => 'View/Modify quota for group portfolio files', - phase => 'setquota', - } - ); + 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); - if (@additional_params > 0) { - push (@menu, { text => $cat_text, - phase => 'catsettings', - }); + + sub phaseurl { + my $phase = shift; + return "javascript:changePage(document.menu,'$phase')" } - unless ($type eq 'Community') { - push(@menu, - { text => 'Display current settings for automated enrollment', - phase => 'viewparms', - } + my @menu = + ({ categorytitle => $categorytitle, + items => [ + { + linktext => $setparams_text, + url => &phaseurl('setparms'), + permission => 1, + #help => '', + icon => 'crsconf.png', + linktitle => '' + }, + { + linktext => 'View/Modify quotas for group portfolio files, and for uploaded content.', + url => &phaseurl('setquota'), + permission => 1, + #help => '', + icon => 'groupportfolioquota.png', + linktitle => '' + }, + { + linktext => 'View/Modify responders threshold for anonymous survey submissions display', + url => &phaseurl('setanon'), + permission => 1, + #help => '', + icon => 'anonsurveythreshold.png', + linktitle => '' + }, + { + linktext => $cat_text, + url => &phaseurl('catsettings'), + permission => (@additional_params > 0), + #help => '', + icon => 'ccatconf.png', + linktitle => '' + }, + { + linktext => 'Display current settings for automated enrollment', + url => &phaseurl('viewparms'), + permission => ($type ne 'Community'), + #help => '', + icon => 'roles.png', + linktitle => '' + }, + ] + }, ); - } - my $menu_html = '

'.&mt('View/Modify settings for: '). - ' '.$cdesc.'

'."\n"; + + my $menu_html = + '

' + .&mt('View/Modify settings for: [_1]', + ''.$cdesc.'') + .'

'."\n".'

'; if ($type eq 'Community') { $menu_html .= &mt('Although almost all community settings can be modified by a Coordinator, the following may only be set or modified by a Domain Coordinator:'); } else { $menu_html .= &mt('Although almost all course settings can be modified by a Course Coordinator, the following may only be set or modified by a Domain Coordinator:'); } - $menu_html .= '

' + .'' + ."\n" + .&hidden_form_elements(); $r->print($menu_html); + $r->print(&Apache::lonhtmlcommon::generate_menu(@menu)); + $r->print(''); return; } @@ -319,7 +387,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')) { @@ -351,9 +419,13 @@ sub print_settings_display { ' '.$cdesc.''. '
'."\n". '

'.$lt{'cose'}.'

'. + '
  • '.&mt('Settings modifiable by a [_1] via the [_2]Automated Enrollment Manager[_3] in a course.',$cctitle,'','').'
  • '); + if (&showcredits($cdom)) { + $r->print('
  • '.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, and default authentication and credits[_3].',$dctitle,'','')."\n"); + } else { + $r->print('
  • '.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, and default authentication[_3].',$dctitle,'','')."\n"); + } + $r->print('
  • '. '

    '.$lt{'cour'}.'

    '.$disp_table.'

    '. ''.$lt{'back'}.''."\n". &hidden_form_elements(). @@ -363,29 +435,58 @@ sub print_settings_display { sub print_setquota { my ($r,$cdom,$cnum,$cdesc,$type) = @_; + my $lctype = lc($type); + my $headline = &mt("Set disk space quotas for $lctype: [_1]", + ''.$cdesc.''); my %lt = &Apache::lonlocal::texthash( - 'cquo' => 'Disk space for storage of group portfolio files for:', - 'gpqu' => 'Course portfolio files disk space', + 'gpqu' => 'Disk space for storage of group portfolio files', + 'upqu' => 'Disk space for storage of content directly uploaded to course via Content Editor', 'modi' => 'Save', 'back' => 'Pick another action', ); - if ($type eq 'Community') { - $lt{'gpqu'} = &mt('Community portfolio files disk space'); - } - my %settings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum); + my %staticdefaults = ( + coursequota => 20, + uploadquota => 500, + ); + my %settings = &Apache::lonnet::get('environment',['internal.coursequota','internal.uploadquota','internal.coursecode'], + $cdom,$cnum); my $coursequota = $settings{'internal.coursequota'}; + my $uploadquota = $settings{'internal.uploadquota'}; if ($coursequota eq '') { - $coursequota = 20; + $coursequota = $staticdefaults{'coursequota'}; + } + if ($uploadquota eq '') { + my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); + if ($type eq 'Community') { + $uploadquota = $domdefs{$lctype.'quota'}; + } elsif ($settings{'internal.coursecode'}) { + $uploadquota = $domdefs{'officialquota'}; + } elsif ($settings{'internal.textbook'}) { + $uploadquota = $domdefs{'textbookquota'}; + } else { + $uploadquota = $domdefs{'unofficialquota'}; + } + if ($uploadquota eq '') { + $uploadquota = $staticdefaults{'uploadquota'}; + } } &print_header($r,$type); my $hidden_elements = &hidden_form_elements(); - my $helpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota'); + my $porthelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota'); + my $uploadhelpitem = &Apache::loncommon::help_open_topic('Modify_Course_Upload_Quota'); $r->print(< -

    $lt{'cquo'} $cdesc

    + +

    $headline

    +

    +$porthelpitem $lt{'gpqu'}: MB + +
    + +$uploadhelpitem $lt{'upqu'}: MB + +

    -$helpitem $lt{'gpqu'}: Mb      - +

    $hidden_elements $lt{'back'} @@ -394,6 +495,45 @@ ENDDOCUMENT return; } +sub print_set_anonsurvey_threshold { + my ($r,$cdom,$cnum,$cdesc,$type) = @_; + my %lt = &Apache::lonlocal::texthash( + 'resp' => 'Responder threshold for anonymous survey submissions display:', + 'sufa' => 'Anonymous survey submissions displayed when responders exceeds', + 'modi' => 'Save', + 'back' => 'Pick another action', + ); + my %settings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum); + my $threshold = $settings{'internal.anonsurvey_threshold'}; + if ($threshold eq '') { + my %domconfig = + &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom); + if (ref($domconfig{'coursedefaults'}) eq 'HASH') { + $threshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'}; + if ($threshold eq '') { + $threshold = 10; + } + } else { + $threshold = 10; + } + } + &print_header($r,$type); + my $hidden_elements = &hidden_form_elements(); + my $helpitem = &Apache::loncommon::help_open_topic('Modify_Anonsurvey_Threshold'); + $r->print(< +

    $lt{'resp'} $cdesc

    +

    +$helpitem $lt{'sufa'}:      + +

    +$hidden_elements +$lt{'back'} + +ENDDOCUMENT + return; +} + sub print_catsettings { my ($r,$cdom,$cnum,$cdesc,$type) = @_; &print_header($r,$type); @@ -562,14 +702,21 @@ sub print_course_modification_page { &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). @@ -580,7 +727,7 @@ sub print_course_modification_page { } else { $r->print('javascript:verify_message(this.form);"'); } - $r->print('value="'.$lt{'gobt'}.'" />

    '); + $r->print(' value="'.$lt{'gobt'}.'" />

    '); return; } @@ -641,12 +788,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}; } @@ -665,7 +815,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 { @@ -704,6 +854,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'}) ) { @@ -739,10 +895,10 @@ sub modify_course { } } if (@changes > 0) { - $chgresponse = &mt("The following settings have been changed: