app/models/my_academics/canvas_sites.rb
# Returns the list (if any) of campus classes which include this Canvas course site.
# This is then referred to for any Canvas group sites associated with the course site.
Returns the list (if any) of campus classes which include this Canvas course site.
This is then referred to for any Canvas group sites associated with the course site.
Returns the list ( if any ) of campus classes which include this Canvas course site . This is then referred to for any Canvas group sites associated with the course site .
def course_site_merge(data, course_site)
      merged_courses = nil
      if (term_yr = course_site[:term_yr]) && (term_cd = course_site[:term_cd]) &&
        (term_slug = Berkeley::TermCodes.to_slug(term_yr, term_cd))
        if (site_sections = course_site[:sections])
          [:semesters, :teachingSemesters].each do |role_key|
            campus_terms = data[role_key]
            if campus_terms.present? && (matching_term = campus_terms.find { |t| t[:slug] == term_slug })
              site_ccns = site_sections.collect {|s| s[:ccn].to_i}
              campus_courses = matching_term[:classes]
              campus_courses.each do |course|
                linked_ccns = []
                course[:sections].each do |s|
                  if site_ccns.include? s[:ccn].to_i
                    linked_ccns << {ccn: s[:ccn]}
                    if course[:multiplePrimaries]
                      primary_to_associate = s[:is_primary_section] ? s : course[:sections].find { |prim| prim[:slug] == s[:associatedWithPrimary] }
                      if primary_to_associate
                        primary_to_associate[:siteIds] ||= []
                        primary_to_associate[:siteIds] << course_site[:id]
                      end
                    end
                  end
                end
                if linked_ccns.present?
                  course[:class_sites] ||= []
                  site_entry = course_site_entry(course_site)
                  site_entry[:sections] = linked_ccns if role_key == :teachingSemesters
                  course[:class_sites] << site_entry
                  merged_courses ||= {
                    term_slug: matching_term[:slug],
                    source: course_site[:name],
                    role_and_slugs: []
                  }
                  merged_courses[:role_and_slugs] << {role_key: role_key, slug: course[:slug]}
                end
              end
            end
          end
        end
        if merged_courses.blank?
          add_other_site_membership(data, course_site)
        end
      end
      merged_courses
    end
def course_site_merge ( data , course_site ) merged_courses = nil if ( term_yr = course_site [ :term_yr ] ) && ( term_cd = course_site [ :term_cd ] ) && ( term_slug = Berkeley :: TermCodes . to_slug ( term_yr , term_cd ) ) if ( site_sections = course_site [ :sections ] ) [ :semesters , :teachingSemesters ] . each do | role_key | campus_terms = data [ role_key ] if campus_terms . present? && ( matching_term = campus_terms . find { | t | t [ :slug ] == term_slug } ) site_ccns = site_sections . collect { | s | s [ :ccn ] . to_i } campus_courses = matching_term [ :classes ] campus_courses . each do | course | linked_ccns = [ ] course [ :sections ] . each do | s | if site_ccns . include? s [ :ccn ] . to_i linked_ccns << { ccn : s [ :ccn ] } if course [ :multiplePrimaries ] primary_to_associate = s [ :is_primary_section ] ? s : course [ :sections ] . find { | prim | prim [ :slug ] == s [ :associatedWithPrimary ] } if primary_to_associate primary_to_associate [ :siteIds ] ||= [ ] primary_to_associate [ :siteIds ] << course_site [ :id ] end end end end if linked_ccns . present? course [ :class_sites ] ||= [ ] site_entry = course_site_entry ( course_site ) site_entry [ :sections ] = linked_ccns if role_key == :teachingSemesters course [ :class_sites ] << site_entry merged_courses ||= { term_slug : matching_term [ :slug ] , source : course_site [ :name ] , role_and_slugs : [ ] } merged_courses [ :role_and_slugs ] << { role_key : role_key , slug : course [ :slug ] } end end end end end if merged_courses . blank? add_other_site_membership ( data , course_site ) end end merged_courses end
Returns the list (if any) of campus classes which include this Canvas course site.
Returns the list ( if any ) of campus classes which include this Canvas course site .
# Compare CCNs as parsed integers to avoid mismatches on prefixed zeroes. # In the case of multiple primaries, expose the minimum data needed to make a section association. # Do not expose course site integrations to students, since Canvas does not expose # section IDs. # This course site has a legitimate academic term but the current user is not officially # connected to a linked class section.
data
<not_specific>
course_site
<not_specific>