--- loncom/interface/lonmodifycourse.pm 2023/04/11 20:35:19 1.99 +++ loncom/interface/lonmodifycourse.pm 2024/04/14 17:12:27 1.105 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # handler for DC-only modifiable course settings # -# $Id: lonmodifycourse.pm,v 1.99 2023/04/11 20:35:19 raeburn Exp $ +# $Id: lonmodifycourse.pm,v 1.105 2024/04/14 17:12:27 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -104,7 +104,7 @@ sub get_enrollment_settings { my ($cdom,$cnum) = @_; my ($internals,$accessdates) = &autoenroll_keys(); my @items; - if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) { + if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) { @items = map { 'internal.'.$_; } (@{$internals}); push(@items,@{$accessdates}); } @@ -411,7 +411,8 @@ sub get_filters { sub print_modification_menu { my ($r,$cdesc,$domdesc,$dom,$type,$cid,$coursehash,$permission) = @_; &print_header($r,$type); - my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$cdom,$cnum); + my ($ccrole,$categorytitle,$setquota_text,$setuploadquota_text,$cdom,$cnum, + $extendedtype); if (ref($coursehash) eq 'HASH') { $cdom = $coursehash->{'domain'}; $cnum = $coursehash->{'num'}; @@ -432,6 +433,8 @@ sub print_modification_menu { 'setpostsubmit' => 'View/Modify submit button behavior, post-submission', 'setltiauth' => 'View/Modify re-authentication requirement for LTI launch of deep-linked item', 'setexttool' => 'View/Modify External Tools permissions', + 'setcrsauthor' => 'View/Modify In-course Authoring permissions', + 'setcrseditors' => 'View/Modify permitted course resource editors', ); } else { %linktext = ( @@ -441,20 +444,22 @@ sub print_modification_menu { 'setpostsubmit' => 'View submit button behavior, post-submission', 'setltiauth' => 'View re-authentication requirement for LTI launch of deep-linked item', 'setexttool' => 'View External Tools permissions', + 'setcrsauthor' => 'View In-course Authoring permissions', + 'setcrseditors' => 'View permitted course resource editors', ); } if ($type eq 'Community') { - if ($permission->{'setparms'} eq 'edit') { + if ($permission->{'setparms'} eq 'edit') { $categorytitle = 'View/Modify Community Settings'; - $linktext{'setparms'} = 'View/Modify community owner'; + $linktext{'setparms'} = 'View/Modify community owner, self-enrollment and table lifetime'; $linktext{'catsettings'} = 'View/Modify catalog settings for community'; } else { $categorytitle = 'View Community Settings'; - $linktext{'setparms'} = 'View community owner'; + $linktext{'setparms'} = 'View community owner, self-enrollment and table lifetime'; $linktext{'catsettings'} = 'View catalog settings for community'; } $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.'); + $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a community via Content Editor.'); } else { if ($permission->{'setparms'} eq 'edit') { $categorytitle = 'View/Modify Course Settings'; @@ -475,9 +480,12 @@ sub print_modification_menu { } $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.'); $setuploadquota_text = &mt('Disk space allocated for storage of content uploaded directly to a course via Content Editor.'); + my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook'], + $cdom,$cnum); + $extendedtype = ucfirst(&Apache::lonuserutils::get_extended_type($cdom,$cnum,$type,\%settings)); } 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 $postsubmit_text = &mt('Override defaults for submit button behavior post-submission for this specific course.'); my $mysqltables_text = &mt('Override default for lifetime of "temporary" MySQL tables containing student performance data.'); my $ltiauth_text = &mt('Override default for requirement for re-authentication for LTI-limited launch of deep-linked item.'); my $exttool_text = &mt('Override default permissions for external tools use for this specific course.'); @@ -578,68 +586,39 @@ sub print_modification_menu { permission => $permission->{'setexttool'}, linktitle => '', }, + { + linktext => $linktext{'setcrsauthor'}, + icon => 'crsauthor.png', + #help => '', + url => &phaseurl('setcrsauthor'), + permission => $permission->{'setcrsauthor'}, + linktitle => '', + }, + { + linktext => $linktext{'setcrseditors'}, + icon => 'crseditors.png', + #help => '', + url => &phaseurl('setcrseditors'), + permission => $permission->{'setcrseditors'}, + linktitle => '', + }, ] }, ); - my $menu_html = + $r->print( '

' - .&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".'' - .'
' + $r->print( + '' ."\n" - .&hidden_form_elements(); - - $r->print($menu_html); - $r->print(&Apache::lonhtmlcommon::generate_menu(@menu)); - $r->print('
'); + .&hidden_form_elements() + .&Apache::lonhtmlcommon::generate_menu(@menu) + .''); return; } @@ -656,9 +635,9 @@ sub print_adhocrole_selected { } $selectrole = 1; } elsif ($permission->{'adhocrole'} eq 'custom') { - my ($okroles,$description) = &Apache::lonnet::get_my_adhocroles($env{'form.pickedcourse'},1); + my ($okroles,$description) = &Apache::lonnet::get_my_adhocroles($env{'form.pickedcourse'},1); if (ref($okroles) eq 'ARRAY') { - my $possrole = $env{'form.adhocrole'}; + my $possrole = $env{'form.adhocrole'}; if (($possrole ne '') && (grep(/^\Q$possrole\E$/,@{$okroles}))) { my $confname = &Apache::lonnet::get_domainconfiguser($cdom); $newrole = "cr/$cdom/$confname/$possrole./$cdom/$cnum"; @@ -757,30 +736,32 @@ sub print_settings_display { $setparms_link_start = ''; $setparms_link_end = ''; } - $r->print('

'.&mt('Current automated enrollment settings for:'). - ' '.$cdesc.'

'. + $r->print('

'.&mt('Current automated enrollment settings').'

'."\n". + '

'.&mt($type).': '.$cdesc.'

'."\n". '
'."\n". - '

'.$lt{'cose'}.'

'. + $lt{'cour'}.'

'.$disp_table.'

'."\n". + &hidden_form_elements().'

'. + ''."\n"); + my @actions = + (''. + $lt{'back'}.''); + $r->print('
'.&Apache::lonhtmlcommon::actionbox(\@actions)); } sub print_setquota { my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_; my $lctype = lc($type); - my $headline = &mt("Set disk space quotas for $lctype: [_1]", - ''.$cdesc.''); + my $headline = '

'.&mt("Set disk space quotas for $lctype").'

'."\n". + '

'.&mt($type).': '.$cdesc.'

'."\n"; my %lt = &Apache::lonlocal::texthash( 'gpqu' => 'Disk space for storage of group portfolio files', 'upqu' => 'Disk space for storage of content directly uploaded to course via Content Editor', @@ -795,15 +776,20 @@ sub print_setquota { $cdom,$cnum); my $coursequota = $settings{'internal.coursequota'}; my $uploadquota = $settings{'internal.uploadquota'}; - if ($coursequota eq '') { - $coursequota = $staticdefaults{'coursequota'}; - } - if ($uploadquota eq '') { + if (($uploadquota eq '') || ($coursequota eq '')) { my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); my $quotatype = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$type,\%settings); - $uploadquota = $domdefs{$quotatype.'quota'}; if ($uploadquota eq '') { - $uploadquota = $staticdefaults{'uploadquota'}; + $uploadquota = $domdefs{$quotatype.'quota'}; + if ($uploadquota eq '') { + $uploadquota = $staticdefaults{'uploadquota'}; + } + } + if ($coursequota eq '') { + $coursequota = $domdefs{$quotatype.'coursequota'}; + if ($coursequota eq '') { + $coursequota = $staticdefaults{'coursequota'}; + } } } &print_header($r,$type); @@ -817,8 +803,8 @@ sub print_setquota { $submit = ''; } $r->print(< -

$headline

$porthelpitem $lt{'gpqu'}: MB @@ -831,9 +817,12 @@ $uploadhelpitem $lt{'upqu'}: $hidden_elements -$lt{'back'} ENDDOCUMENT + my @actions = + (''. + $lt{'back'}.''); + $r->print('
'.&Apache::lonhtmlcommon::actionbox(\@actions)); return; } @@ -848,7 +837,7 @@ sub print_set_anonsurvey_threshold { my %settings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum); my $threshold = $settings{'internal.anonsurvey_threshold'}; if ($threshold eq '') { - my %domconfig = + my %domconfig = &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom); if (ref($domconfig{'coursedefaults'}) eq 'HASH') { $threshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'}; @@ -863,22 +852,26 @@ sub print_set_anonsurvey_threshold { my $hidden_elements = &hidden_form_elements(); my ($disabled,$submit); if ($readonly) { - $disabled = ' disabled="disabled"'; + $disabled = ' disabled="disabled"'; } else { $submit = ''; } my $helpitem = &Apache::loncommon::help_open_topic('Modify_Anonsurvey_Threshold'); + my $showtype = &mt($type); $r->print(<$lt{'resp'} +

$showtype: $cdesc

-

$lt{'resp'} $cdesc

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

$submit -

$hidden_elements -$lt{'back'}
ENDDOCUMENT + my @actions = + (''. + $lt{'back'}.''); + $r->print('

'.&Apache::lonhtmlcommon::actionbox(\@actions)); return; } @@ -899,11 +892,11 @@ sub print_postsubmit_config { if ($postsubmit eq '') { my %domconfig = &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom); - $postsubmit = 1; + $postsubmit = 1; if (ref($domconfig{'coursedefaults'}) eq 'HASH') { if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') { if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'off') { - $postsubmit = 0; + $postsubmit = 0; } } } @@ -931,31 +924,36 @@ sub print_postsubmit_config { $submit = ''; } my $helpitem = &Apache::loncommon::help_open_topic('Modify_Postsubmit_Config'); + my $showtype = &mt($type); $r->print(<$lt{'conf'} +

$showtype: $cdesc

-

$lt{'conf'} ($cdesc)

-$helpitem $lt{'disa'}: +$helpitem $lt{'disa'}:    +$lt{'no'}

$lt{'nums'}
$zero
-
+

$submit

$hidden_elements -$lt{'back'}
ENDDOCUMENT + my @actions = + (''. + $lt{'back'}.''); + $r->print('
'.&Apache::lonhtmlcommon::actionbox(\@actions)); return; } sub domain_postsubtimeout { my ($cdom,$type,$settings) = @_; - return unless (ref($settings) eq 'HASH'); + return unless (ref($settings) eq 'HASH'); my $lctype = &get_lctype($type,$settings); my %domconfig = &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom); @@ -1005,8 +1003,9 @@ sub print_catsettings { $lt{'categ'} = &mt('Categorize Community'); $lt{'assi'} = &mt('Assign one or more subcategories to this community.'); } - $r->print('
'. - '

'.$lt{'catset'}.' '.$cdesc.'

'); + $r->print('

'.$lt{'catset'}.'

'."\n". + '

'.&mt($type).': '.$cdesc.'

'."\n". + ''."\n"); my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom); my @cat_params = &catalog_settable($domconf{'coursecategories'},$type); if (@cat_params > 0) { @@ -1014,50 +1013,65 @@ sub print_catsettings { if ($readonly) { $disabled = ' disabled="disabled"'; } - my %currsettings = + my %currsettings = &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum); if (grep(/^togglecats$/,@cat_params)) { my $excludeon = ''; my $excludeoff = ' checked="checked" '; if ($currsettings{'hidefromcat'} eq 'yes') { $excludeon = $excludeoff; - $excludeoff = ''; + $excludeoff = ''; } $r->print('

'.$lt{'visi'}.'

'. + '

'. $lt{'exclude'}. - '    

'); + '    

'); if ($type eq 'Community') { - $r->print(&mt("If a community has been categorized using at least one of the categories defined for communities in the domain, it will be listed in the domain's publicly accessible Course/Community Catalog, unless excluded.")); + $r->print(&mt("If a community has been categorized using at least one of the categories defined for communities in the domain, it will be listed in the domain's publicly accessible Course/Community Catalog, unless excluded.").'

'); } elsif ($type eq 'Placement') { - $r->print(&mt("If a placement test has been categorized using at least one of the categories defined for placement tests in the domain, it will be listed in the domain's publicly accessible Course/Community Catalog, unless excluded.")); + $r->print(&mt("If a placement test has been categorized using at least one of the categories defined for placement tests in the domain, it will be listed in the domain's publicly accessible Course/Community Catalog, unless excluded.").'

'); } else { - $r->print(&mt("Unless excluded, a course will be listed in the domain's publicly accessible Course/Community Catalog, if at least one of the following applies").':
    '. + $r->print(&mt("Unless excluded, a course will be listed in the domain's publicly accessible Course/Community Catalog, if at least one of the following applies").':

      '. '
    • '.&mt('Auto-cataloging is enabled and the course is assigned an institutional code.').'
    • '. '
    • '.&mt('The course has been categorized using at least one of the course categories defined for the domain.').'
    '); } - $r->print('

'); } + my $savebutton; + unless ($readonly) { + $savebutton = '


'; + } + my $shownsave; if (grep(/^categorize$/,@cat_params)) { - $r->print('

'.$lt{'categ'}.'

'); + my $categheader = '

'.$lt{'categ'}.'

'; if (ref($domconf{'coursecategories'}) eq 'HASH') { my $cathash = $domconf{'coursecategories'}{'cats'}; if (ref($cathash) eq 'HASH') { - $r->print($lt{'assi'}.'

'. + $r->print($categheader. + '

'.$lt{'assi'}.'

'. &Apache::loncommon::assign_categories_table($cathash, $currsettings{'categories'},$type,$disabled)); } else { - $r->print(&mt('No categories defined for this domain')); + $r->print($savebutton.$categheader. + '

'.&mt('No categories defined for this domain.')); + $shownsave = 1; } } else { - $r->print(&mt('No categories defined for this domain')); + $r->print($savebutton.$categheader. + '

'.&mt('No categories defined for this domain.')); + $shownsave = 1; } - unless (($type eq 'Community') || ($type eq 'Placement')) { - $r->print('

'.&mt('If auto-cataloging based on institutional code is enabled in the domain, a course will continue to be listed in the catalog of official courses, in addition to receiving a listing under any manually assigned categor(ies).').'

'); + if (($type eq 'Community') || ($type eq 'Placement')) { + $r->print('

'); + } elsif ($shownsave) { + $r->print('
'.&mt('If auto-cataloging based on institutional code is enabled in the domain, a course will continue to be listed in the catalog of official courses.').'

'); + } else { + $r->print('

'.&mt('If auto-cataloging based on institutional code is enabled in the domain, a course will continue to be listed in the catalog of official courses, in addition to receiving a listing under any manually assigned categor(ies).').'

'); } } - unless ($readonly) { - $r->print('

'); + unless ($readonly || $shownsave) { + $r->print($savebutton); } } else { $r->print(''); @@ -1066,11 +1080,13 @@ sub print_catsettings { } else { $r->print(&mt('Catalog settings in this domain are set in course context via "Course Configuration".')); } - $r->print('

'."\n". - ''. - $lt{'back'}.''); + $r->print(''."\n"); } $r->print(&hidden_form_elements().'
'."\n"); + my @actions = + (''. + $lt{'back'}.''); + $r->print('
'.&Apache::lonhtmlcommon::actionbox(\@actions)); return; } @@ -1087,7 +1103,7 @@ sub print_course_modification_page { 'gobt' => "Save", 'sett' => 'Setting', 'domd' => 'Domain default', - 'whom' => 'Who configures', + 'whom' => 'Who configures', ); my ($ownertable,$ccrole,$javascript_validations,$authenitems,$ccname,$disabled); my %enrollvar = &get_enrollment_settings($cdom,$cnum); @@ -1121,11 +1137,11 @@ sub print_course_modification_page { $cc_status{$uname.':'.$udom} = $lt{'actv'}; } } - if (($enrollvar{'courseowner'} ne '') && + if (($enrollvar{'courseowner'} ne '') && (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs))) { push(@local_ccs,$enrollvar{'courseowner'}); my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'}); - $pname{$enrollvar{'courseowner'}} = + $pname{$enrollvar{'courseowner'}} = &Apache::loncommon::plainname($owneruname,$ownerdom); my $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname, $cdom,$cnum,$ccrole); @@ -1155,7 +1171,7 @@ sub print_course_modification_page { } else { $ownertable .= ''."\n"; } - $ownertable .= + $ownertable .= ''.$pname{$cc}.''."\n". ''.$cc.''."\n". ''.$cc_status{$cc}.' '.$ccname.''."\n". @@ -1165,10 +1181,14 @@ sub print_course_modification_page { } &print_header($r,$crstype,$javascript_validations); my $dctitle = &Apache::lonnet::plaintext('dc'); - my $mainheader = &modifiable_only_title($crstype); my $hidden_elements = &hidden_form_elements(); - $r->print('
'."\n". - '

'.$mainheader.' '.$cdesc.'

'. + my $showtype; + if (($type eq 'official') || ($type eq 'unofficial') || ($type eq 'textbook')) { + $showtype = ' ('.&mt($type).')'; + } + $r->print('

'.&modifiable_only_title($crstype).'

'."\n". + '

'.&mt($crstype).': '.$cdesc.$showtype.'


'."\n". + ''."\n". &Apache::lonhtmlcommon::start_pick_box()); if ($crstype eq 'Community') { $r->print(&Apache::lonhtmlcommon::row_title( @@ -1206,7 +1226,7 @@ sub print_course_modification_page { &Apache::loncommon::help_open_topic('Modify_Course_Chgpasswd'). ' '.&mt('Changing passwords (internal)'))."\n". '