Navigation Menu

Skip to content

Commit

Permalink
Refactored assessment question partial.
Browse files Browse the repository at this point in the history
We had a lot of duplicate code, because the "not applicable" version had
a full questionnaire in case you reconsider. In the current
implementation, reconsidering reloads the page, so we don't really need
that questionnaire. But we're about to change that.

https://www.pivotaltracker.com/story/show/27396213
  • Loading branch information
eostrom committed Apr 4, 2012
1 parent bcfd17e commit c7e5d7e
Showing 1 changed file with 7 additions and 59 deletions.
66 changes: 7 additions & 59 deletions app/views/assessments/_assessment_question.html.erb
Expand Up @@ -7,77 +7,26 @@
</div> </div>
<h3 class="prompt plain"><%= answer.question_description %></h3> <h3 class="prompt plain"><%= answer.question_description %></h3>
</div> </div>
<% elsif answer.was_skipped? %> <% else %>
<div class="question not-applicable"> <div class="question <%= 'not-applicable' if answer.was_skipped? %>">
<div class="response"> <div class="response">
<div class="answers"> <div class="answers">
</div> </div>
<% if answer.was_skipped? %>
<%= form_for(answer, :url => reconsider_answer_path(answer), :html => {:method => :put}) do |a| %> <%= form_for(answer, :url => reconsider_answer_path(answer), :html => {:method => :put}) do |a| %>
<%= a.hidden_field :was_skipped, :value => false %> <%= a.hidden_field :was_skipped, :value => false %>
<%= link_to 'reconsider', '#', :class => 'does-not-apply reconsider-question', :style => 'color:#666;text-decoration:underline;', :onclick => "this.submit()"%> <%= link_to 'reconsider', '#', :class => 'does-not-apply reconsider-question', :style => 'color:#666;text-decoration:underline;', :onclick => "this.submit()"%>
<% end %> <% end %>
</div> <% else %>
<h3 class="prompt plain"><%= answer.question_description %></h3>
<div class="answer" style="display:none;">
<%= form_for answer do |a| %>
<table>
<tr>
<td>
<strong>Preparedness: *</strong>
</td>
<td>
<label><%= a.radio_button :preparedness, 'not ready' %> not ready</label>
</td>
<td>
<label><%= a.radio_button :preparedness, 'needs work' %> needs work</label>
</td>
<td>
<label><%= a.radio_button :preparedness, 'ready' %> ready</label>
</td>
<td>
<label><%= a.radio_button :preparedness, 'unknown' %> unknown</label>
</td>
</tr>
<tr>
<td>
<strong>Priority: *</strong>
</td>
<td>
<label><%= a.radio_button :priority, 'critical' %> critical</label>
</td>
<td>
<label><%= a.radio_button :priority, 'non-critical' %> non-critical</label>
</td>
</tr>
</table>
<%= a.submit 'Save answer', :class => 'button blue save-response' %>
<% end %>
</div>
<div class="explain" style="display:none">
<p>Please rate the priority and preparedness of this topic for your organization.</p>
<div class="info-bubble">
<%= link_to 'Learn more about this topic', '', :class => 'button weak info-bubble-trigger' %>
<div class="info-bubble-text-disabled">
<%= RedCloth.new(answer.question.help).to_html.html_safe if answer.question.help %>
<br /><br />
</div>
</div>
</div>
<div style="clear: both;"></div>
</div>
<% else %>
<div class="question">
<div class="response">
<div class="answers">
</div>
&nbsp; <%= link_to 'answer', "", :class => 'button respond', :style => 'margin-bottom:10px;', :onclick => "$('.answer-#{answer.id}').toggle();$('.explain-#{answer.id}').toggle();"%><br /> &nbsp; <%= link_to 'answer', "", :class => 'button respond', :style => 'margin-bottom:10px;', :onclick => "$('.answer-#{answer.id}').toggle();$('.explain-#{answer.id}').toggle();"%><br />
<%= form_for(answer, :url => skip_answer_path(answer), :html => {:method => :put}) do |a| %> <%= form_for(answer, :url => skip_answer_path(answer), :html => {:method => :put}) do |a| %>
<%= a.hidden_field :was_skipped, :value => true %> <%= a.hidden_field :was_skipped, :value => true %>
<%= link_to 'not applicable', '#', :class => 'does-not-apply skip-question', :style => 'color:#666;text-decoration:underline;' %> <%= link_to 'not applicable', '#', :class => 'does-not-apply skip-question', :style => 'color:#666;text-decoration:underline;' %>
<% end %> <% end %>
<% end %>
</div> </div>
<h3 class="prompt plain"><%= answer.question_description %></h3> <h3 class="prompt plain"><%= answer.question_description %></h3>
<div class="answer answer-<%= answer.id %>" style="display:none;"> <div class="answer <%= dom_id(answer) %>" style="display:none;">
<%= form_for answer do |a| %> <%= form_for answer do |a| %>
<table> <table>
<tr> <tr>
Expand Down Expand Up @@ -112,7 +61,7 @@
<%= a.submit 'save answer', :class => 'button blue save-response' %> <%= a.submit 'save answer', :class => 'button blue save-response' %>
<% end %> <% end %>
</div> </div>
<div class="explain explain-<%= answer.id %>" style="display:none;"> <div class="explain <%= "explain_#{answer.id}" if answer.id %>" style="display:none;">
<p>Please rate the priority and preparedness of this topic for your organization.</p> <p>Please rate the priority and preparedness of this topic for your organization.</p>
<% unless answer.question.help.blank? %> <% unless answer.question.help.blank? %>
<div class="info-bubble"> <div class="info-bubble">
Expand All @@ -126,5 +75,4 @@
</div> </div>
<div style="clear: both;"></div> <div style="clear: both;"></div>
</div> </div>

<% end %> <% end %>

0 comments on commit c7e5d7e

Please sign in to comment.