app/models/activities/accountability_report.rb
# Accumulates the raw data from each source and dumps it into the results file.
Accumulates the raw data from each source and dumps it into the results file.
Accumulates the raw data from each source and dumps it into the results file .
def accumulate_raw_data(force = false)
    puts "Accumulating: ActivityCourse... ", true
    for quarter in @quarters
      activity_courses = ActivityCourse.of_type(@activity_type).for_quarter(quarter)
      print "  #{quarter.abbrev}: #{activity_courses.size.to_s.ljust(4)} "
      for activity_course in activity_courses
        for registrant in activity_course.registrants
          if !registrant.failed? && !registrant.credits.zero?
            add_result(registrant.system_key, quarter, activity_course, registrant)
          end
        end
        print "."
      end
      print "\n"
    end
    puts "\n#{@results.size} unique students."
    puts "Saved results output to #{dump_results!(:raw)}"
    puts "Accumulating: ActivityProject... ", true
    activity_projects = ActivityProject.of_type(@activity_type).for_quarter(@quarters)
    for activity_project in activity_projects
      print "|"
      for activity_quarter in activity_project.quarters
        if @quarters.include?(activity_quarter.quarter)
          add_result(activity_project.system_key, activity_quarter.quarter, activity_project, activity_quarter)
          print "."
        end
      end
    end
    print "\n"
    puts "\n#{@results.size} unique students."
    puts "Saved results output to #{dump_results!(:raw)}"
    puts "Accumulating: ServiceLearningPlacement... ", true
    if @activity_type.abbreviation == SERVICE_LEARNING_ACTIVITY_TYPE_ABBREVIATION
      for quarter in @quarters
        print "  #{quarter.abbrev}: "
        placements = quarter.service_learning_placements.select(&:filled?)
        print "#{placements.size.to_s.ljust(4)} "
        for placement in placements
          system_key = placement.person.is_a?(Student) ? placement.person.system_key : nil
          if system_key
            add_result(system_key, quarter, placement, placement)
            print "."
          else
            print "X"
          end
        end
        print "\n"
      end
    else
      print "  (skipping)"
    end
    print "\n"
    puts "\n#{@results.size} unique students."
    puts "Saved results output to #{dump_results!(:raw)}"
    puts "Accumulating: ApplicationForOfferings... ", true
    for quarter in @quarters
      print "  #{quarter.abbrev}: "
      offerings_by_quarter = Offering.find_all_by_activity_type_id_and_quarter_offered_id(@activity_type, quarter)
      offerings_by_acc_quarter = Offering.find_all_by_activity_type_id_and_accountability_quarter_id(@activity_type, quarter)
      offerings = (offerings_by_quarter + offerings_by_acc_quarter).flatten
      puts "#{offerings.size.to_s.ljust(4)}"
      for offering in offerings
        print "    #{offering.title.ljust(40)}: "
        if offering.count_method_for_accountability.blank?
          puts "No count method defined" 
          next
        end
        apps = offering.accountability_objects
        print "#{apps.size}\n      "
        for app in apps
          print "|"
          system_key = app.respond_to?(:person) ? app.person.try(:system_key) : app.system_key
          if system_key.nil?
            print "?"
            next 
          end
          if offering.accountability_quarter
            add_result(system_key, quarter, offering, app)
            print "."
          else
            for award in app.awards.valid
              if @quarters.include?(award.requested_quarter)
                add_result(system_key, award.requested_quarter, offering, award)
                print "#{award.number_of_hours.to_s}/"
              else
                print "X/"
              end
            end
          end
        end
        print "\n"
      end
    end
    print "\n"
    puts "\n#{@results.size} unique students."
    puts "Saved results output to #{dump_results!(:raw)}"
  end
def accumulate_raw_data ( force = false ) puts "Accumulating: ActivityCourse... " , true for quarter in @quarters activity_courses = ActivityCourse . of_type ( @activity_type ) . for_quarter ( quarter ) print "  #{quarter.abbrev}: #{activity_courses.size.to_s.ljust(4)} " for activity_course in activity_courses for registrant in activity_course . registrants if ! registrant . failed? && ! registrant . credits . zero? add_result ( registrant . system_key , quarter , activity_course , registrant ) end end print "." end print "\n" end puts "\n#{@results.size} unique students." puts "Saved results output to #{dump_results!(:raw)}" puts "Accumulating: ActivityProject... " , true activity_projects = ActivityProject . of_type ( @activity_type ) . for_quarter ( @quarters ) for activity_project in activity_projects print "|" for activity_quarter in activity_project . quarters if @quarters . include? ( activity_quarter . quarter ) add_result ( activity_project . system_key , activity_quarter . quarter , activity_project , activity_quarter ) print "." end end end print "\n" puts "\n#{@results.size} unique students." puts "Saved results output to #{dump_results!(:raw)}" puts "Accumulating: ServiceLearningPlacement... " , true if @activity_type . abbreviation == SERVICE_LEARNING_ACTIVITY_TYPE_ABBREVIATION for quarter in @quarters print "  #{quarter.abbrev}: " placements = quarter . service_learning_placements . select ( & :filled? ) print "#{placements.size.to_s.ljust(4)} " for placement in placements system_key = placement . person . is_a? ( Student ) ? placement . person . system_key : nil if system_key add_result ( system_key , quarter , placement , placement ) print "." else print "X" end end print "\n" end else print "  (skipping)" end print "\n" puts "\n#{@results.size} unique students." puts "Saved results output to #{dump_results!(:raw)}" puts "Accumulating: ApplicationForOfferings... " , true for quarter in @quarters print "  #{quarter.abbrev}: " offerings_by_quarter = Offering . find_all_by_activity_type_id_and_quarter_offered_id ( @activity_type , quarter ) offerings_by_acc_quarter = Offering . find_all_by_activity_type_id_and_accountability_quarter_id ( @activity_type , quarter ) offerings = ( offerings_by_quarter + offerings_by_acc_quarter ) . flatten puts "#{offerings.size.to_s.ljust(4)}" for offering in offerings print "    #{offering.title.ljust(40)}: " if offering . count_method_for_accountability . blank? puts "No count method defined" next end apps = offering . accountability_objects print "#{apps.size}\n      " for app in apps print "|" system_key = app . respond_to? ( :person ) ? app . person . try ( :system_key ) : app . system_key if system_key . nil? print "?" next end if offering . accountability_quarter add_result ( system_key , quarter , offering , app ) print "." else for award in app . awards . valid if @quarters . include? ( award . requested_quarter ) add_result ( system_key , award . requested_quarter , offering , award ) print "#{award.number_of_hours.to_s}/" else print "X/" end end end end print "\n" end end print "\n" puts "\n#{@results.size} unique students." puts "Saved results output to #{dump_results!(:raw)}" end
Accumulates the raw data from each source and dumps it into the results file.
Accumulates the raw data from each source and dumps it into the results file .
force