From 34a54abc5c1cd002fef7200a93d6d6752d1f580e Mon Sep 17 00:00:00 2001 From: Ryan Souza Date: Mon, 19 Mar 2012 16:28:43 -0700 Subject: [PATCH] Added Offering Summary --- app/models/offering.rb | 10 +++++++ app/views/offerings/_summary.html.erb | 11 +++++++ app/views/offerings/content/_summary.html.erb | 13 ++++++++- app/views/offerings/details/_summary.html.erb | 24 +++++++++++++-- app/views/offerings/importing/edit.html.erb | 7 ++++- app/views/offerings/objectives/_summary.html | 29 ++++++++++++++++++- app/views/offerings/show.html.erb | 11 ++----- 7 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 app/views/offerings/_summary.html.erb diff --git a/app/models/offering.rb b/app/models/offering.rb index d410312..c7dbd5c 100644 --- a/app/models/offering.rb +++ b/app/models/offering.rb @@ -238,4 +238,14 @@ def self.content_to_outcome_mapping_row_total 10 end + + def summed_mappings + outcomes.map do |outcome| + objectives. + includes(:mappings). + where(mappings: {outcome_id: outcome, value: 1}).count + end + end + + end diff --git a/app/views/offerings/_summary.html.erb b/app/views/offerings/_summary.html.erb new file mode 100644 index 0000000..789bf40 --- /dev/null +++ b/app/views/offerings/_summary.html.erb @@ -0,0 +1,11 @@ +
+ <% if offering.is_complete? :details %> + <%= render partial: 'offerings/details/summary', locals: {offering: offering} %> + <% end %> + <% if offering.is_complete? :objectives %> + <%= render partial: 'offerings/objectives/summary', locals: {offering: offering} %> + <% end %> + <% if offering.is_complete? :content %> + <%= render partial: 'offerings/content/summary', locals: {offering: offering} %> + <% end %> +
diff --git a/app/views/offerings/content/_summary.html.erb b/app/views/offerings/content/_summary.html.erb index 86ef0cb..3ef7ed2 100644 --- a/app/views/offerings/content/_summary.html.erb +++ b/app/views/offerings/content/_summary.html.erb @@ -1 +1,12 @@ -Nothing here but us words +
+
+

Content

+
+
+
    + <% offering.content_groups.each do |cg| %> +
  • <%= cg.content.count %>
    <%= cg.name %>
  • + <% end %> +
+
+ diff --git a/app/views/offerings/details/_summary.html.erb b/app/views/offerings/details/_summary.html.erb index 4c3b450..d3f44ce 100644 --- a/app/views/offerings/details/_summary.html.erb +++ b/app/views/offerings/details/_summary.html.erb @@ -1,2 +1,22 @@ -Nothing here but us words - +
+
+
+
CRN #
+
<%= offering.crn %>
+
Section(s)
+
<%= offering.section %>
+
Credits
+
<%= offering.credits %>
+
Location
+
<%= offering.location %>
+ +
+
+
+
Description
+
<%= offering.description %>
+
Primary Textbook
+
<%= offering.textbook %>
+
+
+
diff --git a/app/views/offerings/importing/edit.html.erb b/app/views/offerings/importing/edit.html.erb index 3f5442a..68b5e2b 100644 --- a/app/views/offerings/importing/edit.html.erb +++ b/app/views/offerings/importing/edit.html.erb @@ -43,7 +43,12 @@


-

Offering summary goes here

+ +
+
+ <%= render partial: 'offerings/summary', locals: {offering: @recent_offering_choice} %> +
+
<% end %> diff --git a/app/views/offerings/objectives/_summary.html b/app/views/offerings/objectives/_summary.html index 4c3b450..718e0df 100644 --- a/app/views/offerings/objectives/_summary.html +++ b/app/views/offerings/objectives/_summary.html @@ -1,2 +1,29 @@ -Nothing here but us words +
+
+

Objectives

+
+
+ + + + + + + <% offering.outcomes.each do |outcome| %> + + <% end %> + + + + + <% offering.summed_mappings.each do |value| %> + + <% end %> + + +
+ <%= offering.objectives.count %> objectives meeting outcomes +
<%= outcome.key %>
<%= value %>
+
+
diff --git a/app/views/offerings/show.html.erb b/app/views/offerings/show.html.erb index 5107ad0..7929bc6 100644 --- a/app/views/offerings/show.html.erb +++ b/app/views/offerings/show.html.erb @@ -2,15 +2,8 @@
- <% if @offering.is_complete? :details %> - <%= render 'offerings/details/summary' %> - <% end %> - <% if @offering.is_complete? :objectives %> - <%= render 'offerings/objectives/summary' %> - <% end %> - <% if @offering.is_complete? :content %> - <%= render 'offerings/content/summary' %> - <% end %> + <%= render partial: 'summary', locals: {offering: @offering} %> +