-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create script to download transcripts in bulk
- Loading branch information
Showing
5 changed files
with
66 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<div class="row"> | ||
<div class="col-md-8 col-md-offset-2"> | ||
<h1 class="text-center">Transcript for Epicodus</h1> | ||
<p class="text-center"><em><strong> | ||
<%= student.cohort.try(:description).try('include?', 'Data Engineering') ? 'Data Engineering' : 'Web and Mobile Development' %> | ||
</em></p> | ||
<p class="text-center">400 SW 6th Ave, Suite 800, Portland OR 97204</p> | ||
<p>Student: <strong><%= student.name %></strong></p> | ||
<p>Dates Enrolled: <%= student.courses.order(:start_date).first.start_date.strftime('%B %d, %Y') %> - <%= student.courses.order(:start_date).last.end_date.strftime('%B %d, %Y') %></p> | ||
|
||
<p>Courses: <strong>(does not include courses in progress)</strong></p> | ||
<ul> | ||
<% completed_courses.each do |course| %> | ||
<li> | ||
<%= course.description %> | ||
<ul> | ||
<% course.code_reviews.where(journal: nil).or(course.code_reviews.where(journal: false)).each do |code_review| %> | ||
<li> | ||
<%= code_review.title %> | ||
<span class="pull-right"><em><%= code_review.status(student) %></em></span> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</li> | ||
<% end %> | ||
</ul> | ||
|
||
<% if completed_courses.non_internship_courses.any? %> | ||
<% if student.days_since_start_of_program.any? && student.total_attendance_score >= 90.0 %> | ||
<p>Epicodus requires students to attend class at least 90% of the time. This student met that requirement.</p> | ||
<% end %> | ||
<% end %> | ||
|
||
<p><%= image_tag "signature.png" %></p> | ||
<p><strong>Michael Kaiser-Nyman, President</strong></p> | ||
<p>Date: <%= completed_courses.last.end_date.strftime('%B %d, %Y') %></p> | ||
<br> | ||
<p>Epicodus maintains student transcripts for 50 years.</p> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1 @@ | ||
<div class="row"> | ||
<div class="col-md-8 col-md-offset-2"> | ||
<h1 class="text-center">Transcript for Epicodus</h1> | ||
<p class="text-center"><em><strong> | ||
<%= @student.cohort.try(:description).try('include?', 'Data Engineering') ? 'Data Engineering' : 'Web and Mobile Development' %> | ||
</em></p> | ||
<p class="text-center">400 SW 6th Ave, Suite 800, Portland OR 97204</p> | ||
<p>Student: <strong><%= @student.name %></strong></p> | ||
<p>Dates Enrolled: <%= @student.courses.order(:start_date).first.start_date.strftime('%B %d, %Y') %> - <%= @student.courses.order(:start_date).last.end_date.strftime('%B %d, %Y') %></p> | ||
|
||
<p>Courses: <strong>(does not include courses in progress)</strong></p> | ||
<ul> | ||
<% @completed_courses.each do |course| %> | ||
<li> | ||
<%= course.description %> | ||
<ul> | ||
<% course.code_reviews.where(journal: nil).or(course.code_reviews.where(journal: false)).each do |code_review| %> | ||
<li> | ||
<%= code_review.title %> | ||
<span class="pull-right"><em><%= code_review.status(@student) %></em></span> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</li> | ||
<% end %> | ||
</ul> | ||
|
||
<% if @completed_courses.non_internship_courses.any? %> | ||
<% if @student.total_attendance_score >= 90.0 %> | ||
<p>Epicodus requires students to attend class at least 90% of the time. This student met that requirement.</p> | ||
<% end %> | ||
<% end %> | ||
|
||
<p><%= image_tag "signature.png" %></p> | ||
<p><strong>Michael Kaiser-Nyman, President</strong></p> | ||
<p>Date: <%= @completed_courses.last.end_date.strftime('%B %d, %Y') %></p> | ||
<br> | ||
<p>Epicodus maintains student transcripts for 50 years.</p> | ||
</div> | ||
</div> | ||
<%= render partial: 'transcript', locals: {student: @student, completed_courses: @completed_courses} %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'wicked_pdf' | ||
|
||
task :save_all_transcripts => [:environment] do | ||
students = Student.select {|s| s.courses.any?} | ||
students.each do |student| | ||
@student = student | ||
@completed_courses = student.courses.order(:start_date) | ||
|
||
html = ActionController::Base.new.render_to_string( | ||
template: 'transcripts/_transcript', | ||
locals: { student: @student, completed_courses: @completed_courses } | ||
) | ||
|
||
pdf = WickedPdf.new.pdf_from_string(html) | ||
|
||
file_path = Rails.root.join('transcripts-output', "#{student.name.parameterize}_#{student.email}.pdf") | ||
File.open(file_path, 'wb') do |file| | ||
file << pdf | ||
end | ||
end | ||
end |