diff --git a/Gemfile b/Gemfile index 007dfedf8..d1fa886ed 100644 --- a/Gemfile +++ b/Gemfile @@ -53,6 +53,7 @@ group :development do gem 'rack-mini-profiler' gem 'listen' gem 'timecop' + gem 'wicked_pdf' end group :test, :development do diff --git a/Gemfile.lock b/Gemfile.lock index d304cab50..a2248ecd1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -507,6 +507,8 @@ GEM websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + wicked_pdf (2.7.0) + activesupport xpath (3.2.0) nokogiri (~> 1.8) zeitwerk (2.6.12) @@ -589,6 +591,7 @@ DEPENDENCIES validate_url vcr webmock + wicked_pdf RUBY VERSION ruby 3.2.2p53 diff --git a/app/views/transcripts/_transcript.html.erb b/app/views/transcripts/_transcript.html.erb new file mode 100644 index 000000000..6933b1c67 --- /dev/null +++ b/app/views/transcripts/_transcript.html.erb @@ -0,0 +1,40 @@ +
+
+

Transcript for Epicodus

+

+ <%= student.cohort.try(:description).try('include?', 'Data Engineering') ? 'Data Engineering' : 'Web and Mobile Development' %> +

+

400 SW 6th Ave, Suite 800, Portland OR 97204

+

Student: <%= student.name %>

+

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') %>

+ +

Courses: (does not include courses in progress)

+
    + <% completed_courses.each do |course| %> +
  • + <%= course.description %> +
      + <% course.code_reviews.where(journal: nil).or(course.code_reviews.where(journal: false)).each do |code_review| %> +
    • + <%= code_review.title %> + <%= code_review.status(student) %> +
    • + <% end %> +
    +
  • + <% end %> +
+ + <% if completed_courses.non_internship_courses.any? %> + <% if student.days_since_start_of_program.any? && student.total_attendance_score >= 90.0 %> +

Epicodus requires students to attend class at least 90% of the time. This student met that requirement.

+ <% end %> + <% end %> + +

<%= image_tag "signature.png" %>

+

Michael Kaiser-Nyman, President

+

Date: <%= completed_courses.last.end_date.strftime('%B %d, %Y') %>

+
+

Epicodus maintains student transcripts for 50 years.

+
+
diff --git a/app/views/transcripts/show.html.erb b/app/views/transcripts/show.html.erb index cca2bac9a..28fcac276 100644 --- a/app/views/transcripts/show.html.erb +++ b/app/views/transcripts/show.html.erb @@ -1,40 +1 @@ -
-
-

Transcript for Epicodus

-

- <%= @student.cohort.try(:description).try('include?', 'Data Engineering') ? 'Data Engineering' : 'Web and Mobile Development' %> -

-

400 SW 6th Ave, Suite 800, Portland OR 97204

-

Student: <%= @student.name %>

-

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') %>

- -

Courses: (does not include courses in progress)

-
    - <% @completed_courses.each do |course| %> -
  • - <%= course.description %> -
      - <% course.code_reviews.where(journal: nil).or(course.code_reviews.where(journal: false)).each do |code_review| %> -
    • - <%= code_review.title %> - <%= code_review.status(@student) %> -
    • - <% end %> -
    -
  • - <% end %> -
- - <% if @completed_courses.non_internship_courses.any? %> - <% if @student.total_attendance_score >= 90.0 %> -

Epicodus requires students to attend class at least 90% of the time. This student met that requirement.

- <% end %> - <% end %> - -

<%= image_tag "signature.png" %>

-

Michael Kaiser-Nyman, President

-

Date: <%= @completed_courses.last.end_date.strftime('%B %d, %Y') %>

-
-

Epicodus maintains student transcripts for 50 years.

-
-
+<%= render partial: 'transcript', locals: {student: @student, completed_courses: @completed_courses} %> diff --git a/lib/tasks/save_all_transcripts.rake b/lib/tasks/save_all_transcripts.rake new file mode 100644 index 000000000..5c2d97891 --- /dev/null +++ b/lib/tasks/save_all_transcripts.rake @@ -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