Diff
Modified: branches/packs/app/controllers/packs_controller.rb (3720 => 3721)
--- branches/packs/app/controllers/packs_controller.rb 2013-09-25 15:40:44 UTC (rev 3720)
+++ branches/packs/app/controllers/packs_controller.rb 2013-09-26 02:03:03 UTC (rev 3721)
@@ -487,6 +487,25 @@
@results = scrape_checklist_results(open(checklist_uri))
@context = @pack
+ clr = @pack.research_object.checklist_results.find_by_minim_url_and_purpose(
+ entry["minim"], entry["purpose"])
+
+ if clr.nil?
+ clr = @context.research_object.checklist_results.create(
+ :minim_url => entry["minim"],
+ :purpose => entry["purpose"])
+ end
+
+ clr.update_attributes(
+ :score => @results[:score],
+ :max_score => @results[:max_score])
+
+ clr.checklist_item_results.delete_all
+
+ @results[:sub_results].each do |sr|
+ clr.checklist_item_results.build(:colour => sr[:colour].to_s, :text => sr[:text]).save
+ end
+
render "research_objects/checklist"
end
Modified: branches/packs/app/models/research_object.rb (3720 => 3721)
--- branches/packs/app/models/research_object.rb 2013-09-25 15:40:44 UTC (rev 3720)
+++ branches/packs/app/models/research_object.rb 2013-09-26 02:03:03 UTC (rev 3721)
@@ -27,6 +27,8 @@
belongs_to :context, :polymorphic => true
+ has_many :checklist_results, :dependent => :destroy
+
validates_presence_of :slug
def uri
Modified: branches/packs/app/views/packs/_checklist.html.erb (3720 => 3721)
--- branches/packs/app/views/packs/_checklist.html.erb 2013-09-25 15:40:44 UTC (rev 3720)
+++ branches/packs/app/views/packs/_checklist.html.erb 2013-09-26 02:03:03 UTC (rev 3721)
@@ -1,9 +1,27 @@
<div class="contribution_section_box">
<p class="heading">
- <%= info_icon_with_tooltip("These are the results from checklists that measure the health of this pack") %>
- Checklist evaluation
+ <%= info_icon_with_tooltip("These are the results from checklists that measure the progress of this pack") %>
+ Progress
</p>
+ <% Conf.research_object_checklists.each do |label, checklist| %>
+ <% clr = @pack.research_object.checklist_results.find(:first, :conditions => { :minim_url => checklist["minim"], :purpose => checklist["purpose"] } ) %>
+ <% if clr %>
+ <% score_percent = 100 * clr.score / clr.max_score %>
+ <div class="checklist">
+ <div class="label">
+ <%=h label -%>
+ </div>
+ <div class="bar">
+ <div class="score" style="width: <%= score_percent -%>%">
+ </div>
+ </div>
+ </div>
+ <% end %>
+
+
+ <% end %>
+
<% if Authorization.check('view', @pack, current_user) %>
<p>
<% form_tag(update_checklist_pack_path(@pack), :method => :post) do -%>
Added: branches/packs/db/migrate/20130924164435_add_checklist_tables.rb (0 => 3721)
--- branches/packs/db/migrate/20130924164435_add_checklist_tables.rb (rev 0)
+++ branches/packs/db/migrate/20130924164435_add_checklist_tables.rb 2013-09-26 02:03:03 UTC (rev 3721)
@@ -0,0 +1,29 @@
+# myExperiment: db/migrate/20130924164435_add_checklist_tables.rb
+#
+# Copyright (c) 2007-2013 The University of Manchester, the University of
+# Oxford, and the University of Southampton. See license.txt for details.
+
+class AddChecklistTables < ActiveRecord::Migration
+ def self.up
+ create_table "checklist_results", :force => true do |t|
+ t.integer "research_object_id"
+ t.integer "score"
+ t.integer "max_score"
+ t.string "minim_url"
+ t.string "purpose"
+
+ t.timestamps
+ end
+
+ create_table "checklist_item_results", :force => true do |t|
+ t.integer "checklist_result_id"
+ t.string "colour"
+ t.string "text"
+ end
+ end
+
+ def self.down
+ drop_table :checklist_item_results
+ drop_table :checklist_results
+ end
+end
Modified: branches/packs/public/stylesheets/styles.css (3720 => 3721)
--- branches/packs/public/stylesheets/styles.css 2013-09-25 15:40:44 UTC (rev 3720)
+++ branches/packs/public/stylesheets/styles.css 2013-09-26 02:03:03 UTC (rev 3721)
@@ -2713,3 +2713,26 @@
TABLE.checklist {
margin: 32px auto;
}
+
+DIV.checklist {
+ padding: 8px;
+ margin: auto;
+}
+
+DIV.checklist DIV.label {
+ text-align: left;
+ padding-bottom: 2px;
+}
+
+DIV.checklist DIV.bar {
+ width: 204px;
+ height: 12px;
+ background: #aaa;
+ border: 1px solid #666;
+}
+
+DIV.checklist DIV.bar DIV.score {
+ height: 12px;
+ background: #ada;
+}
+