answer inserts
This commit is contained in:
@ -1,17 +1,19 @@
|
||||
<%
|
||||
question.input_options.each do | option |
|
||||
option_id = "#{option.parameterize}_#{question.to_i}"
|
||||
question.input_options.each_with_index do | option, i |
|
||||
option_id = "#{question.question_id}_#{i}"
|
||||
|
||||
checkbox_html = {class: 'checkbox',
|
||||
id: "answer_#{option_id}",
|
||||
name: "answer[checkbox][]",
|
||||
checked: Array(question.answer).include?(option)
|
||||
}
|
||||
%>
|
||||
<div class="form-group-multiples">
|
||||
<input type="checkbox" class="checkbox"
|
||||
name="input_checkbox_<%= question.to_i %>[]"
|
||||
id="check_<%= option_id %>"
|
||||
value="<%= option %>"
|
||||
<%= "checked=\"checked\"" if Array(question.answer).include?(option) %>
|
||||
>
|
||||
<label for="check_<%= option_id %>"><%= option %></label>
|
||||
<%= form.check_box(:answer, checkbox_html, option, '') %>
|
||||
<%= form.label(option_id, option) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
-- MOVE TO FLASH HASH --
|
||||
<div class="error">Please select or enter an answer.</div>
|
||||
<% if flash[:error].try(:include?, question.to_i) %>
|
||||
<div class="error">Please select an answer.</div>
|
||||
<% end %>
|
||||
|
@ -1,17 +1,14 @@
|
||||
<%
|
||||
question.input_options.each do | option |
|
||||
option_id = "#{option.parameterize}_#{question.to_i}"
|
||||
radio_html = {class: 'radio', id: option_id}
|
||||
%>
|
||||
<div class="form-group-multiples">
|
||||
<input type="radio" class="radio"
|
||||
name="input_radio_<%= question.to_i %>"
|
||||
id="radio_<%= option_id %>"
|
||||
value="<%= option %>"
|
||||
<%= "checked=\"checked\"" if question.answer == option %>
|
||||
>
|
||||
<label for="radio_<%= option_id %>"><%= option %></label>
|
||||
<%= radio_button_tag('answer[radio]', option, (question.answer == option), radio_html) %>
|
||||
<%= label_tag(option_id, option) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
-- MOVE TO FLASH HASH --
|
||||
<div class="error">Please select or enter an answer. (The character limit for a textarea answer is 1000)</div>
|
||||
<% if flash[:error].try(:include?, question.to_i) %>
|
||||
<div class="error">Please select an answer.</div>
|
||||
<% end %>
|
||||
|
@ -1,7 +1,8 @@
|
||||
<label for="textArea">Enter answer here</label>
|
||||
<textarea id="textArea" name="textarea" rows="10"><%= question.answer %></textarea>
|
||||
<label for="answer_text">Enter answer here</label>
|
||||
<textarea id="answer_text" name="answer[text]" rows="10"><%= question.answer %></textarea>
|
||||
|
||||
<div class="chars">Characters remaining: <span></span></div>
|
||||
|
||||
-- MOVE TO FLASH HASH --
|
||||
<div class="error">Please select or enter an answer. (The character limit for a textarea answer is 1000)</div>
|
||||
<% if flash[:error].try(:include?, question.to_i) %>
|
||||
<div class="error">Please select or enter an answer. (The character limit for a textarea answer is 1000)</div>
|
||||
<% end %>
|
||||
|
@ -13,7 +13,8 @@
|
||||
<textarea data-id="code-js" name="code-js" class="code-answer code-js"><%= @answer['js'] unless @answer.nil? %></textarea>
|
||||
</div>
|
||||
|
||||
-- MOVE TO FLASH HASH --
|
||||
<div class="error">You must write code in one of the above textareas to progress.</div>
|
||||
<% if flash[:error].try(:include?, @question.to_i) %>
|
||||
<div class="error">You must write code in one of the above textareas to progress.</div>
|
||||
<% end %>
|
||||
|
||||
<div class="results" data-id="results"></div>
|
||||
|
@ -5,12 +5,14 @@
|
||||
content_for :footer_title, "Skills Assessment"
|
||||
%>
|
||||
|
||||
<%= form_tag post_question_path, id: 'answer-form', data: {qid: @question.question_id} do %>
|
||||
<%= form_for(@answer, url: post_answer_path(@answer.id), html:{id: 'answer-form', data: {qid: @question.question_id}}) do |form| %>
|
||||
<main class="questions_tpl">
|
||||
<h2 class="question-text"><%= @question.question %></h2>
|
||||
|
||||
<div class="content-well">
|
||||
<%= render partial: @question.input_type, locals: {question: @question} %>
|
||||
<%= hidden_field_tag 'answer[question_id]', @question.question_id %>
|
||||
<%= hidden_field_tag 'answer[answer_id]', @question.answer_id %>
|
||||
<%= render partial: @question.input_type, locals: {question: @question, form: form} %>
|
||||
</div>
|
||||
|
||||
<% if @status.on_summary %>
|
||||
|
@ -5,8 +5,8 @@
|
||||
Once you're done, hit the button at the bottom of the page to submit your answers.
|
||||
</p>
|
||||
|
||||
<%= form_tag(post_summary_path) do %>
|
||||
<% @quiz.each do |question| %>
|
||||
<% @quiz.each do |question| %>
|
||||
<%= form_for(:answer, url: post_summary_path, html:{id: 'summary-form'}) do |form| %>
|
||||
<article class="answer-sec <%= question.input_type %>-type" data-qid="<%= question.question_id %>">
|
||||
<div class="question-heading">
|
||||
<div class="question-title">
|
||||
@ -21,20 +21,21 @@
|
||||
|
||||
<div class="answer-container">
|
||||
<fieldset disabled class="answer-block">
|
||||
<%= render partial: question.input_type, locals: {question: question} %>
|
||||
<%= hidden_field_tag 'answer[question_id]', question.question_id %>
|
||||
<%= render partial: question.input_type, locals: {question: question, form: form} %>
|
||||
</fieldset>
|
||||
</div>
|
||||
</article>
|
||||
<% end #questions loop %>
|
||||
|
||||
<% if @status.can_submit %>
|
||||
<div class="btn-container-right">
|
||||
<input type="submit" class="submit-button" value="Submit all answers" name="submit" />
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="error">Sorry, you must answer all questions before you can submit.</div>
|
||||
<% end %>
|
||||
|
||||
<% end #form_tag %>
|
||||
|
||||
<% if @status.can_submit %>
|
||||
<div class="btn-container-right">
|
||||
<input type="submit" class="submit-button" value="Submit all answers" name="submit" />
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="error">Sorry, you must answer all questions before you can submit.</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
</main>
|
||||
|
Reference in New Issue
Block a user