app/models/campus_oracle/user_courses/base.rb
# This is done in a separate step so that all secondary sections
# are ordered after explicitly assigned primary sections.
This is done in a separate step so that all secondary sections
are ordered after explicitly assigned primary sections.
This is done in a separate step so that all secondary sections are ordered after explicitly assigned primary sections .
def merge_nested_instructing(campus_classes)
        campus_classes.values.each do |semester|
          semester.each do |course|
            if course[:role] == 'Instructor'
              primaries = course[:sections].select { |s| s[:is_primary_section] }
              if primaries.present? && Berkeley::CourseOptions::MAPPING[course[:course_option]]
                secondaries = CampusOracle::UserCourses::SecondarySections.new({user_id: @uid}).get_all_secondary_sections(course)
                if secondaries.present?
                  explicit_secondaries = course[:sections].select { |s| !s[:is_primary_section] }.collect { |s| s[:ccn] }
                  nested_secondaries = {}
                  primaries.each do |prim|
                    secondaries.each do |sec|
                      if explicit_secondaries.include?(sec['course_cntl_num']) ||
                        Berkeley::CourseOptions.nested?(course[:course_option], prim[:section_number], sec['section_num'], sec['instruction_format'])
                        nested_secondaries[sec['course_cntl_num']] = row_to_section_data(sec)
                      end
                    end
                  end
                  course[:sections] = primaries.concat(nested_secondaries.values) unless nested_secondaries.empty?
                end
              end
            end
          end
        end
      end
def merge_nested_instructing ( campus_classes ) campus_classes . values . each do | semester | semester . each do | course | if course [ :role ] == 'Instructor' primaries = course [ :sections ] . select { | s | s [ :is_primary_section ] } if primaries . present? && Berkeley :: CourseOptions :: MAPPING [ course [ :course_option ] ] secondaries = CampusOracle :: UserCourses :: SecondarySections . new ( { user_id : @uid } ) . get_all_secondary_sections ( course ) if secondaries . present? explicit_secondaries = course [ :sections ] . select { | s | ! s [ :is_primary_section ] } . collect { | s | s [ :ccn ] } nested_secondaries = { } primaries . each do | prim | secondaries . each do | sec | if explicit_secondaries . include? ( sec [ 'course_cntl_num' ] ) || Berkeley :: CourseOptions . nested? ( course [ :course_option ] , prim [ :section_number ] , sec [ 'section_num' ] , sec [ 'instruction_format' ] ) nested_secondaries [ sec [ 'course_cntl_num' ] ] = row_to_section_data ( sec ) end end end course [ :sections ] = primaries . concat ( nested_secondaries . values ) unless nested_secondaries . empty? end end end end end end
This is done in a separate step so that all secondary sections
are ordered after explicitly assigned primary sections.
This is done in a separate step so that all secondary sections are ordered after explicitly assigned primary sections .
# Remember any explicit assignments to avoid duplicates and maintain ordering. # Use a hash to avoid duplicates when an instructor is assigned more than one primary.
campus_classes
<not_specific>