- question.input_options.each do | option |
+ <% question.input_options.each do | option |
option_id = "#{option.parameterize}_#{question.to_i}"
checkbox_html = {class: "", id: option_id, data: { last: answers.include?(option) ? 'checked' : '' } }
%>
-
+
<%= check_box_tag('answer[answer_hash][options][]', option, answers.include?(option), checkbox_html) %>
<%= label_tag(option_id, option) %>
<%
end %>
-
+
<%
option_id = "other_#{question.to_i}"
checkbox_html = {class: "", id: option_id, data: { last: answers.include?('other') ? 'checked' : '' } }
@@ -21,7 +24,8 @@
%>
<%= check_box_tag('answer[answer_hash][options][]', 'other', answers.include?('other'), checkbox_html) %>
<%= label_tag(option_id, 'Other') %>
- <%= text_field_tag 'answer[answer_hash][other]', other_value, text_html %>
+ <%= text_field_tag 'answer[answer_hash][other]', other_value, text_html.merge(id: "#{option_id}_value") %>
+
<%= render partial: "quiz/answer_errors", locals: {question: question, answer: answer} %>
diff --git a/app/views/quiz/_live_code.html.erb b/app/views/quiz/_live_code.html.erb
index cce5495..219923d 100644
--- a/app/views/quiz/_live_code.html.erb
+++ b/app/views/quiz/_live_code.html.erb
@@ -46,8 +46,8 @@
-
Enter answer here
- <%= text_area_tag 'answer[answer_hash][text]', value_text, { disabled: true, data: {last: answers['text']}} %>
+
Enter answer here
+ <%= text_area_tag 'answer[answer_hash][text]', value_text, { disabled: true, data: {last: answers['text']}, id: "answer_answer_hash_text_#{question.question_id}"} %>
- index.html
- <%= text_area_tag 'answer[answer_hash][html]', value_html, { disabled: true, data: {id: 'code-html', last: answers['html']}, class: 'code-answer code-html' } %>
+ index.html
+ <%= text_area_tag 'answer[answer_hash][html]', value_html, { disabled: true, data: {id: 'code-html', last: answers['html']}, class: 'code-answer code-html', id: "answer_answer_hash_html_#{question.question_id}"} %>
- styles.css
- <%= text_area_tag 'answer[answer_hash][css]', value_css, { disabled: true, data: {id: 'code-css', last: answers['css']}, class: 'code-answer code-css' } %>
+ styles.css
+ <%= text_area_tag 'answer[answer_hash][css]', value_css, { disabled: true, data: {id: 'code-css', last: answers['css']}, class: 'code-answer code-css', id: "answer_answer_hash_css_#{question.question_id}" } %>
- main.js
- <%= text_area_tag 'answer[answer_hash][js]', value_js, { disabled: true, data: {id: 'code-js', last: answers['js']}, class: 'code-answer code-js' } %>
+ main.js
+ <%= text_area_tag 'answer[answer_hash][js]', value_js, { disabled: true, data: {id: 'code-js', last: answers['js']}, class: 'code-answer code-js', id: "answer_answer_hash_js_#{question.question_id}" } %>
Results
-
+