--- loncom/interface/lonmodifycourse.pm	2016/11/10 21:57:10	1.79.2.4
+++ loncom/interface/lonmodifycourse.pm	2016/11/09 14:04:41	1.88
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # handler for DC-only modifiable course settings
 #
-# $Id: lonmodifycourse.pm,v 1.79.2.4 2016/11/10 21:57:10 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.88 2016/11/09 14:04:41 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -72,6 +72,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');
@@ -167,6 +174,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>');
     }
@@ -177,6 +186,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:');
     }
@@ -184,6 +195,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);
@@ -197,6 +211,9 @@ sub print_course_search_page {
                 if ($type eq 'Community') {
                     $roleoption = &mt('Enter the community with one of the available ad hoc roles: [_1].',
                                   join(', ',@adhoc));
+                } elsif ($type eq 'Placement') {
+                    $roleoption = &mt('Enter the placement test with one of the available ad hoc roles: [_1].',
+                                  join(', ',@adhoc));
                 } else {
                     $roleoption = &mt('Enter the course with one of the available ad hoc roles: [_1].',
                                   join(', ',@adhoc));
@@ -204,6 +221,8 @@ sub print_course_search_page {
             } else {
                 if ($type eq 'Community') {
                     $roleoption = &mt('Enter the community with the ad hoc role of: [_1]',$adhoc[0]);
+                } elsif ($type eq 'Placement') {
+                    $roleoption = &mt('Enter the placement test with the ad hoc role of: [_1]',$adhoc[0]);
                 } else {
                     $roleoption = &mt('Enter the course with the ad hoc role of: [_1]',$adhoc[0]);
                 }
@@ -211,6 +230,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);
         }
@@ -296,7 +317,7 @@ sub print_modification_menu {
                     );
     }
     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{'catsettings'} = 'View/Modify catalog settings for community';
@@ -306,7 +327,7 @@ sub print_modification_menu {
             $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';
@@ -391,13 +412,13 @@ 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 => ''
             },
             {
-                linktext => $linktext{'selfenroll'},
+                linktext => $linktext{'selfenroll'},,
                 icon => 'self_enroll.png',
                 #help => 'Course_Self_Enrollment',
                 url => &phaseurl('selfenroll'),
@@ -433,7 +454,7 @@ sub print_modification_menu {
     } else {
         $menu_html .=  '<li>'.&mt('Course owner (permitted to assign Course Coordinator roles in the course).').'</li>'."\n".
                        '<li>'.&mt("Institutional code and default authentication (both required for auto-enrollment of students from institutional datafeeds).").'</li>'."\n";
-        if (&showcredits($dom)) {
+        if (($type ne 'Placement') && &showcredits($dom)) {
             $menu_html .= '<li>'.&mt('Default credits earned by student on course completion.').'</li>'."\n";
         }
         $menu_html .= ' <li>'.&mt('Override defaults for who configures self-enrollment for this specific course.').'</li>'."\n";
@@ -674,7 +695,7 @@ sub print_set_anonsurvey_threshold {
     my $hidden_elements = &hidden_form_elements();
     my ($disabled,$submit);
     if ($readonly) {
-        $disabled = ' disabled="disabled"';
+        $disabled = ' disabled="disabled"'; 
     } else {
         $submit = '<input type="submit" value="'.$lt{'modi'}.'" />';
     }
@@ -749,7 +770,7 @@ sub print_postsubmit_config {
 $helpitem $lt{'disa'}: 
 <label><input type="radio" name="postsubmit" $checkedon onclick="togglePostsubmit('studentsubmission');" value="1" $disabled />
 $lt{'yes'}</label>&nbsp;&nbsp;
-<label><input type="radio" name="postsubmit" $checkedoff onclick="togglePostsubmit('studentsubmission');" value="0" $disabled />
+<label><input type="radio" name="postsubmit" $checkedoff onclick="togglePostsubmit('studentsubmission');" value="0" $disabled/>
 $lt{'no'}</label>
 <div id="studentsubmission" style="display: $display">
 $lt{'nums'} <input type="text" name="postsubtimeout" value="$postsubtimeout" $disabled /><br />
@@ -768,7 +789,7 @@ sub domain_postsubtimeout {
     my ($cdom,$type,$settings) = @_;
     return unless (ref($settings) eq 'HASH'); 
     my $lctype = lc($type);
-    unless ($type eq 'Community') {
+    unless (($type eq 'Community') || ($type eq 'Placement')) {
         $lctype = 'unofficial';
         if ($settings->{'internal.coursecode'}) {
             $lctype = 'official';
@@ -831,6 +852,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><br /><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."));
+            } 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."));
             } 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").':<ul>'.
                           '<li>'.&mt('Auto-cataloging is enabled and the course is assigned an institutional code.').'</li>'.
@@ -852,7 +875,7 @@ sub print_catsettings {
             } else {
                 $r->print(&mt('No categories defined for this domain'));
             }
-            unless ($type eq 'Community') { 
+            unless (($type eq 'Community') || ($type eq 'Placement')) { 
                 $r->print('<p>'.&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).').'</p>');
             }
         }
@@ -894,7 +917,8 @@ sub print_course_modification_page {
     my %enrollvar = &get_enrollment_settings($cdom,$cnum);
     my %settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook',
                                                        'internal.selfenrollmgrdc','internal.selfenrollmgrcc',
-                                                       'internal.mysqltables'],$cdom,$cnum);
+                                                       'internal.mysqltables'],
+                                        $cdom,$cnum);
     my $type = &Apache::lonuserutils::get_extended_type($cdom,$cnum,$crstype,\%settings);
     my @specific_managebydc = split(/,/,$settings{'internal.selfenrollmgrdc'});
     my @specific_managebycc = split(/,/,$settings{'internal.selfenrollmgrcc'});
@@ -951,7 +975,7 @@ sub print_course_modification_page {
         foreach my $cc (@local_ccs) {
             $ownertable .= &Apache::loncommon::start_data_table_row()."\n";
             if ($cc eq $enrollvar{'courseowner'}) {
-                  $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked"'.$disabled.' /></td>'."\n";
+                $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked"'.$disabled.' /></td>'."\n";
             } else {
                 $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'"'.$disabled.' /></td>'."\n";
             }
@@ -978,9 +1002,9 @@ sub print_course_modification_page {
         $r->print(&Apache::lonhtmlcommon::row_title(
                       &Apache::loncommon::help_open_topic('Modify_Course_Instcode').
                       '&nbsp;'.&mt('Course Code'))."\n".
-                  '<input type="text" size="15" name="coursecode" value="'.$enrollvar{'coursecode'}.'"'.$disabled.' />'.
+                  '<input type="text" size="15" name="coursecode" value="'.$enrollvar{'coursecode'}.'"'.$disabled.'/>'.
                   &Apache::lonhtmlcommon::row_closure());
-        if (&showcredits($cdom)) {
+        if (($crstype eq 'Course') && (&showcredits($cdom))) {
             $r->print(&Apache::lonhtmlcommon::row_title(
                           &Apache::loncommon::help_open_topic('Modify_Course_Credithours').
                       '&nbsp;'.&mt('Credits (students)'))."\n".
@@ -1178,7 +1202,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)) {  
@@ -1251,7 +1275,7 @@ sub modify_course {
             $newattr{'mysqltables'} = $env{'form.mysqltables'};
             $newattr{'mysqltables'} =~ s/\D+//g;
         }
-        if (&showcredits($cdom) && exists($env{'form.defaultcredits'})) {
+        if (($type ne 'Placement') && (&showcredits($cdom) && exists($env{'form.defaultcredits'}))) {
             $newattr{'defaultcredits'}=$env{'form.defaultcredits'};
             $newattr{'defaultcredits'} =~ s/[^\d\.]//g;
         }
@@ -1363,7 +1387,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.'));
@@ -2202,6 +2226,8 @@ ENDSCRIPT
     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';
     }
@@ -2376,6 +2402,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";
             } 
@@ -2392,6 +2420,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';
                     }
@@ -2414,17 +2444,17 @@ sub handler {
                         my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
                         my ($readonly,$linktext);
                         if ($permission->{$phase} eq 'view') {
-                           $readonly = 1;
+                           $readonly = 1; 
                         }
                         if (($phase eq 'setquota') && ($permission->{'setquota'})) {
                             if ($permission->{'setquota'} eq 'view') {
-                                $linktext = 'Set quota';
+                                $linktext = 'Set quota'; 
                             } else {
                                 $linktext = 'Display quota';
                             }
                             &Apache::lonhtmlcommon::add_breadcrumb
                             ({href=>"javascript:changePage(document.$phase,'$phase')",
-                              text=>$linktext});
+                              text=>"$linktext"});
                             &print_setquota($r,$cdom,$cnum,$cdesc,$type,$readonly);
                         } elsif (($phase eq 'processquota') && ($permission->{'processquota'})) { 
                             &Apache::lonhtmlcommon::add_breadcrumb
@@ -2455,7 +2485,7 @@ sub handler {
                             }
                             &Apache::lonhtmlcommon::add_breadcrumb
                             ({href=>"javascript:changePage(document.$phase,'$phase')",
-                              text=>$linktext});
+                              text=>"Configure submit button behavior post-submission"});
                             &print_postsubmit_config($r,$cdom,$cnum,$cdesc,$type,$readonly);
                         } elsif (($phase eq 'processpostsubmit') && ($permission->{'processpostsubmit'})) {
                             &Apache::lonhtmlcommon::add_breadcrumb
@@ -2475,7 +2505,7 @@ sub handler {
                             }
                             &Apache::lonhtmlcommon::add_breadcrumb
                             ({href=>"javascript:changePage(document.$phase,'$phase')",
-                              text=>$linktext});
+                              text=>"$linktext"});
                             &print_course_modification_page($r,$cdom,$cnum,$cdesc,$type,$readonly);
                         } elsif (($phase eq 'processparms') && ($permission->{'processparms'})) {
                             &Apache::lonhtmlcommon::add_breadcrumb
@@ -2516,6 +2546,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'));
                     }