[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm

raeburn raeburn at source.lon-capa.org
Mon Sep 25 18:36:29 EDT 2023


raeburn		Mon Sep 25 22:36:29 2023 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  - Bug 2689
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1411 loncom/interface/loncommon.pm:1.1412
--- loncom/interface/loncommon.pm:1.1411	Sun Sep 10 18:12:54 2023
+++ loncom/interface/loncommon.pm	Mon Sep 25 22:36:29 2023
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1411 2023/09/10 18:12:54 raeburn Exp $
+# $Id: loncommon.pm,v 1.1412 2023/09/25 22:36:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -17054,6 +17054,7 @@
         $cenv{'internal.defaultcredits'} = $args->{'defaultcredits'};
     }
     my @badclasses = (); # Used to accumulate sections/crosslistings that did not pass classlist access check for course owner.
+    my @oklcsecs = (); # Used to accumulate LON-CAPA sections for validated institutional sections.
     if ($args->{'crssections'}) {
         $cenv{'internal.sectionnums'} = '';
         if ($args->{'crssections'} =~ m/,/) {
@@ -17067,7 +17068,11 @@
                 my $class = $args->{'crscode'}.$sec;
                 my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$class,$cenv{'internal.courseowner'});
                 $cenv{'internal.sectionnums'} .= $item.',';
-                unless ($addcheck eq 'ok') {
+                if ($addcheck eq 'ok') {
+                    unless (grep(/^\Q$gp\E$/, at oklcsecs)) {
+                        push(@oklcsecs,$gp);
+                    }
+                } else {
                     push(@badclasses,$class);
                 }
             }
@@ -17095,7 +17100,11 @@
                 my ($xl,$gp) = split/:/,$item;
                 my $addcheck =  &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$xl,$cenv{'internal.courseowner'});
                 $cenv{'internal.crosslistings'} .= $item.',';
-                unless ($addcheck eq 'ok') {
+                if ($addcheck eq 'ok') {
+                    unless (grep(/^\Q$gp\E$/, at oklcsecs)) {
+                        push(@oklcsecs,$gp);
+                    }
+                } else {
                     push(@badclasses,$xl);
                 }
             }
@@ -17158,6 +17167,36 @@
     if ($args->{'no_end_date'}) {
         $args->{'endaccess'} = 0;
     }
+#  If an official course with institutional sections is created by cloning 
+#  an existing course, section-specific hiding of course totals in student's
+#  view of grades as copied from cloned course, will be checked for valid 
+#  sections.
+    if (($can_clone && $cloneid) &&
+        ($cenv{'internal.coursecode'} ne '') &&
+        ($cenv{'grading'} eq 'standard') &&
+        ($cenv{'hidetotals'} ne '') &&
+        ($cenv{'hidetotals'} ne 'all')) {
+        my @hidesecs;
+        my $deletehidetotals;
+        if (@oklcsecs) {
+            foreach my $sec (split(/,/,$cenv{'hidetotals'})) {
+                if (grep(/^\Q$sec$/, at oklcsecs)) {
+                    push(@hidesecs,$sec);
+                }
+            }
+            if (@hidesecs) {
+                $cenv{'hidetotals'} = join(',', at hidesecs);
+            } else {
+                $deletehidetotals = 1;
+            }
+        } else {
+            $deletehidetotals = 1;
+        }
+        if ($deletehidetotals) {
+            delete($cenv{'hidetotals'});
+            &Apache::lonnet::del('environment',['hidetotals'],$$crsudom,$$crsunum);
+        }
+    }
     $cenv{'internal.autostart'}=$args->{'enrollstart'};
     $cenv{'internal.autoend'}=$args->{'enrollend'};
     $cenv{'default_enrollment_start_date'}=$args->{'startaccess'};




More information about the LON-CAPA-cvs mailing list