Skip to content

Instantly share code, notes, and snippets.

@samuels410
Created November 14, 2018 09:00
Show Gist options
  • Save samuels410/631f5c219d9f1c9002bc0b9400de57a9 to your computer and use it in GitHub Desktop.
Save samuels410/631f5c219d9f1c9002bc0b9400de57a9 to your computer and use it in GitHub Desktop.
get_completed_student_data
include StudentDashboardHelper
headers = ['Batch name', 'ID', 'Student email', 'Progress state']
document_root = "#{Rails.root}"
csv_file_name = "completed_batch_students.csv"
csv_document = "#{document_root}/#{csv_file_name}"
CSV.open(csv_document, "w") do |csv|
csv << headers
programs = Program.where(code: ['PGPBA-BI', 'PGP-BDML'])
programs.each do |program|
program_group_details = ProgramGroupDetail.where("program_id = ? and ends_at < ?", program.id, Date.today)
program_group_details.each do |program_group_detail|
program_group = ProgramGroup.find(program_group_detail.program_group_id)
pg_name = program_group.name
view = StudentDashboard.compute_program_view(program_group_detail.program_group_id)
program_view_dashboard = view[:dashboard]
program_view_dashboard.each do |student_id, course_details|
status = ApplicationController.helpers.pg_completion_state(course_details, view[:re_enrolled_records], student_id)
unless status == 'Incomplete'
profile = User.profile(student_id)
csv << [pg_name, profile.id, profile.primary_email, status]
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment