app/models/people/student.rb
# Returns an array of the Courses that this student is enrolled in for the given quarter. 
# (Returns actual Course objects, not StudentRegsitrationCourse records)
# To include courses where this student is force-enrolled as a CourseExtraEnrollee, specify
# :include_extra_enrollees option as true.
Returns an array of the Courses that this student is enrolled in for the given quarter.
(Returns actual Course objects, not StudentRegsitrationCourse records)
To include courses where this student is force-enrolled as a CourseExtraEnrollee, specify
:include_extra_enrollees option as true.
Returns an array of the Courses that this student is enrolled in for the given quarter . ( Returns actual Course objects not StudentRegsitrationCourse records ) To include courses where this student is force - enrolled as a CourseExtraEnrollee specify : include_extra_enrollees option as true .
def enrolled_courses(quarter = Quarter.current_quarter, options = {})
    @registrations ||= {}; @enrolled_courses ||= {}
    @registrations[quarter] ||= sdb.registrations.for(quarter)
    if @registrations[quarter].nil? && !options[:include_extra_enrollees]
      return [] 
    elsif !@registrations[quarter].nil?
      @enrolled_courses[quarter] ||= @registrations[quarter].courses.includes(:course).where("request_status IN ('A','C','R')").collect(&:course)
    end
    if options[:include_extra_enrollees]
      if @enrolled_courses[quarter] && options[:remove_old_extra_enrollees]
        for cee in course_extra_enrollees.for(quarter)
          if @enrolled_courses[quarter].include?(cee.course)
            cee.destroy
          end
        end
      end
      course = course_extra_enrollees.for(quarter).collect(&:course)
      if @enrolled_courses[quarter]
        @enrolled_courses[quarter] << course
      else
        @enrolled_courses[quarter] = course
      end
      @enrolled_courses[quarter] = @enrolled_courses[quarter].flatten.uniq
    end
    @enrolled_courses[quarter]
  end
def enrolled_courses ( quarter = Quarter . current_quarter , options = { } ) @registrations ||= { } ; @enrolled_courses ||= { } @registrations [ quarter ] ||= sdb . registrations . for ( quarter ) if @registrations [ quarter ] . nil? && ! options [ :include_extra_enrollees ] return [ ] elsif ! @registrations [ quarter ] . nil? @enrolled_courses [ quarter ] ||= @registrations [ quarter ] . courses . includes ( :course ) . where ( "request_status IN ('A','C','R')" ) . collect ( & :course ) end if options [ :include_extra_enrollees ] if @enrolled_courses [ quarter ] && options [ :remove_old_extra_enrollees ] for cee in course_extra_enrollees . for ( quarter ) if @enrolled_courses [ quarter ] . include? ( cee . course ) cee . destroy end end end course = course_extra_enrollees . for ( quarter ) . collect ( & :course ) if @enrolled_courses [ quarter ] @enrolled_courses [ quarter ] << course else @enrolled_courses [ quarter ] = course end @enrolled_courses [ quarter ] = @enrolled_courses [ quarter ] . flatten . uniq end @enrolled_courses [ quarter ] end
Returns an array of the Courses that this student is enrolled in for the given quarter.
Returns an array of the Courses that this student is enrolled in for the given quarter .
# @enrolled_courses ||= r.courses.enrolled.collect(&:course)
quarter
current_quarter
options