--- loncom/interface/lonmodifycourse.pm	2024/08/21 03:24:07	1.79.2.9.2.6
+++ loncom/interface/lonmodifycourse.pm	2024/08/21 03:11:41	1.106
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # handler for DC-only modifiable course settings
 #
-# $Id: lonmodifycourse.pm,v 1.79.2.9.2.6 2024/08/21 03:24:07 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.106 2024/08/21 03:11:41 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -79,6 +79,13 @@ sub catalog_settable {
             if ($confhash->{'categorizecomm'} ne 'comm') {
                 push(@settable,'categorize');
             }
+        } elsif ($type eq 'Placement') {
+            if ($confhash->{'togglecatsplace'} ne 'place') {
+                push(@settable,'togglecats');
+            }
+            if ($confhash->{'categorizeplace'} ne 'place') {
+                push(@settable,'categorize');
+            }
         } else {
             if ($confhash->{'togglecats'} ne 'crs') {
                 push(@settable,'togglecats');
@@ -175,6 +182,8 @@ sub print_course_search_page {
     $r->print(&Apache::loncommon::js_changer());
     if ($type eq 'Community') {
         $r->print('<h3>'.&mt('Search for a community in the [_1] domain',$domdesc).'</h3>');
+    } elsif ($type eq 'Placement') {
+        $r->print('<h3>'.&mt('Search for a placement test in the [_1] domain',$domdesc).'</h3>');
     } else {
         $r->print('<h3>'.&mt('Search for a course in the [_1] domain',$domdesc).'</h3>');
     }
@@ -185,6 +194,8 @@ sub print_course_search_page {
     my ($actiontext,$roleoption,$settingsoption);
     if ($type eq 'Community') {
         $actiontext = &mt('Actions available after searching for a community:');
+    } elsif ($type eq 'Placement') {
+        $actiontext = &mt('Actions available after searching for a placement test:')
     } else {
         $actiontext = &mt('Actions available after searching for a course:');
     }
@@ -192,6 +203,9 @@ sub print_course_search_page {
        if ($type eq 'Community') {
            $roleoption = &mt('Enter the community with the role of [_1]',$cctitle);
            $settingsoption = &mt('View or modify community settings which only a [_1] may modify.',$dctitle);
+       } elsif ($type eq 'Placement') {
+           $roleoption = &mt('Enter the placement test with the role of [_1]',$cctitle);
+           $settingsoption = &mt('View or modify placement test settings which only a [_1] may modify.',$dctitle);
        } else {
            $roleoption = &mt('Enter the course with the role of [_1]',$cctitle);
            $settingsoption = &mt('View or modify course settings which only a [_1] may modify.',$dctitle);
@@ -202,6 +216,8 @@ sub print_course_search_page {
             if (@{$roles_by_num} > 1) {
                 if ($type eq 'Community') {
                     $roleoption = &mt('Enter the community with one of the available ad hoc roles');
+                } elsif ($type eq 'Placement') {
+                    $roleoption = &mt('Enter the placement test with one of the available ad hoc roles.');
                 } else {
                     $roleoption = &mt('Enter the course with one of the available ad hoc roles.');
                 }
@@ -209,6 +225,8 @@ sub print_course_search_page {
                 my $rolename = $description->{$roles_by_num->[0]};
                 if ($type eq 'Community') {
                     $roleoption = &mt('Enter the community with the ad hoc role of: [_1]',$rolename);
+                } elsif ($type eq 'Placement') {
+                    $roleoption = &mt('Enter the placement test with the ad hoc role of: [_1]',$rolename);
                 } else {
                     $roleoption = &mt('Enter the course with the ad hoc role of: [_1]',$rolename);
                 }
@@ -216,6 +234,8 @@ sub print_course_search_page {
         }
         if ($type eq 'Community') {
             $settingsoption = &mt('View community settings which only a [_1] may modify.',$dctitle);
+        } elsif ($type eq 'Placement') {
+            $settingsoption = &mt('View placement test settings which only a [_1] may modify.',$dctitle);
         } else {
             $settingsoption = &mt('View course settings which only a [_1] may modify.',$dctitle);
         }
@@ -413,6 +433,7 @@ 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 {
@@ -423,6 +444,7 @@ 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',
                     );
     }
@@ -527,7 +549,7 @@ sub print_modification_menu {
             {
                 linktext => $linktext{'viewparms'},
                 url => &phaseurl('viewparms'),
-                permission => ($permission->{'viewparms'} && ($type ne 'Community')),
+                permission => ($permission->{'viewparms'} && ($type ne 'Community') && ($type ne 'Placement')),
                 #help => '',
                 icon => 'roles.png',
                 linktitle => ''
@@ -565,6 +587,14 @@ sub print_modification_menu {
                 linktitle => '',
             },
             {
+                linktext => $linktext{'setcrsauthor'},
+                icon => 'crsauthor.png',
+                #help => '',
+                url => &phaseurl('setcrsauthor'),
+                permission => $permission->{'setcrsauthor'},
+                linktitle => '',
+            },
+            {
                 linktext => $linktext{'setcrseditors'},
                 icon => 'crseditors.png',
                 #help => '',
@@ -943,7 +973,7 @@ sub domain_postsubtimeout {
 sub get_lctype {
     my ($type,$settings) = @_;
     my $lctype = lc($type);
-    unless ($type eq 'Community') {
+    unless (($type eq 'Community') || ($type eq 'Placement')) {
         $lctype = 'unofficial';
         if (ref($settings) eq 'HASH') {
             if ($settings->{'internal.coursecode'}) {
@@ -998,6 +1028,8 @@ sub print_catsettings {
                       '&nbsp;<label><input name="hidefromcat" type="radio" value="yes" '.$excludeon.$disabled.' />'.&mt('Yes').'</label>&nbsp;&nbsp;&nbsp;<label><input name="hidefromcat" type="radio" value="" '.$excludeoff.$disabled.' />'.&mt('No').'</label></p><p>');
             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.").'</p>');
+            } 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.").'</p>');
             } 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").':</p><ul>'.
                           '<li>'.&mt('Auto-cataloging is enabled and the course is assigned an institutional code.').'</li>'.
@@ -1030,7 +1062,7 @@ sub print_catsettings {
                           '<p>'.&mt('No categories defined for this domain.'));
                 $shownsave = 1;
             }
-            if ($type eq 'Community') {
+            if (($type eq 'Community') || ($type eq 'Placement')) {
                 $r->print('</p>');
             } elsif ($shownsave) {
                 $r->print('<br />'.&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.').'</p>');
@@ -1633,7 +1665,7 @@ sub modify_course {
                  'internal.pendingco-owners','internal.selfenrollmgrdc',
                  'internal.selfenrollmgrcc','internal.mysqltables');
     my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles();
-    unless ($type eq 'Community') {
+    unless (($type eq 'Community') || ($type eq 'Placement')) {
         push(@items,('internal.coursecode','internal.authtype','internal.autharg',
                      'internal.sectionnums','internal.crosslistings'));
         if (&showcredits($cdom)) {
@@ -1868,7 +1900,7 @@ sub modify_course {
                     $nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>';
                 }
             }
-            if (($type ne 'Community') && ($changed{'code'} || $changed{'owner'})) {
+            if (($type ne 'Community') && ($type ne 'Placement') && ($changed{'code'} || $changed{'owner'})) {
                 if ( $newattr{'courseowner'} eq '') {
 	            push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
                                    '<br />'.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
@@ -2813,7 +2845,7 @@ function togglePostsubmit(caller) {
 ENDSCRIPT
 
     } elsif (($phase eq 'setltiauth') || ($phase eq 'setexttool') ||
-             ($phase eq 'setcrseditors')) {
+             ($phase eq 'setcrsauthor') || ($phase eq 'setcrseditors')) {
         $js .= <<"ENDJS";
 function toggleOptions(form,phase) {
     var radioname;
@@ -2864,7 +2896,8 @@ ENDJS
     } elsif ($phase eq 'courselist') {
         $starthash = {
            add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"},
-    } elsif ($env{'form.phase'} =~ /^set(ltiauth|exttool|crseditors)$/) {
+                     };
+    } elsif ($env{'form.phase'} =~ /^set(ltiauth|exttool|crsauthor|crseditors)$/) {
         $starthash = {
            add_entries => {'onload' => "toggleOptions(document.$env{'form.phase'},'$env{'form.phase'}');"},
                      };
@@ -2875,6 +2908,8 @@ ENDJS
     my $bread_text = "View/Modify Courses/Communities";
     if ($type eq 'Community') {
         $bread_text = 'Community Settings';
+    } elsif ($type eq 'Placement') {
+        $bread_text = 'Placement Test Settings';
     } else {
         $bread_text = 'Course Settings';
     }
@@ -2974,7 +3009,7 @@ sub hidden_form_elements {
           'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota',
           'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st',
           'sections','newsec','mysqltables','nopasswdchg','ltiauth','ltiauthset',
-          'exttoolset','exttool','crseditorsset','crseditors'],
+          'exttoolset','exttool','crsauthorset','crsauthor','crseditorsset','crseditors'],
           ['^selfenrollmgr_','^selfenroll_'])."\n".
           '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
     return $hidden_elements;
@@ -3012,6 +3047,8 @@ sub get_permission {
             processltiauth    => 'edit',
             setexttool        => 'edit',
             processexttool    => 'edit',
+            setcrsauthor      => 'edit',
+            processcrsauthor  => 'edit',
             setcrseditors     => 'edit',
             processcrseditors => 'edit',
         );
@@ -3031,6 +3068,7 @@ sub get_permission {
             adhocrole     => 'custom',
             setltiauth    => 'view',
             setexttool    => 'view',
+            setcrsauthor  => 'view',
             setcrseditors => 'view',
         );
         if ($passwdconf{'crsownerchg'}) {
@@ -3097,6 +3135,8 @@ sub handler {
             }
             if ($type eq 'Community') {
                 $choose_text = "Choose a community";
+            } elsif ($type eq 'Placement') {
+                $choose_text = "Choose a placement test";
             } else {
                 $choose_text = "Choose a course";
             }
@@ -3113,6 +3153,8 @@ sub handler {
                     my $enter_text;
                     if ($type eq 'Community') {
                         $enter_text = 'Enter community';
+                    } elsif ($type eq 'Placement') {
+                        $enter_text = 'Enter placement test';
                     } else {
                         $enter_text = 'Enter course';
                     }
@@ -3255,6 +3297,18 @@ sub handler {
                              {href=>"javascript:changePage(document.$phase,'$phase')",
                               text=>"Result"});
                             &modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'exttool');
+                        } elsif (($phase eq 'setcrsauthor') && ($permission->{'setcrsauthor'})) {
+                            &Apache::lonhtmlcommon::add_breadcrumb
+                            ({href=>"javascript:changePage(document.$phase,'$phase')",
+                              text=>"In-course authoring permission"});
+                            &print_default_overrides($r,$cdom,$cnum,$cdesc,$type,$readonly,'crsauthor');
+                        } elsif (($phase eq 'processcrsauthor') && ($permission->{'processcrsauthor'})) {
+                            &Apache::lonhtmlcommon::add_breadcrumb
+                            ({href=>"javascript:changePage(document.$phase,'setcrsauthor')",
+                              text=>"In-course authoring permission"},
+                             {href=>"javascript:changePage(document.$phase,'$phase')",
+                              text=>"Result"});
+                            &modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'crsauthor');
                         } elsif (($phase eq 'setcrseditors') && ($permission->{'setcrseditors'})) {
                             &Apache::lonhtmlcommon::add_breadcrumb
                             ({href=>"javascript:changePage(document.$phase,'$phase')",
@@ -3273,6 +3327,8 @@ sub handler {
                     $r->print('<span class="LC_error">');
                     if ($type eq 'Community') {
                         $r->print(&mt('The community you selected is not a valid community in this domain'));
+                    } elsif ($type eq 'Placement') {
+                        $r->print(&mt('The course you selected is not a valid placement test in this domain'));
                     } else {
                         $r->print(&mt('The course you selected is not a valid course in this domain'));
                     }