2016-08-01 15:16:20 -05:00
|
|
|
|
<%
|
2016-09-07 17:45:22 -05:00
|
|
|
|
content_for_javascript_once 'live-coder' do
|
|
|
|
|
javascript_include_tag "live-coder"
|
|
|
|
|
end
|
|
|
|
|
|
2016-08-01 15:16:20 -05:00
|
|
|
|
option_id = "#{question.question_id}_finish-later"
|
|
|
|
|
checkbox_html = {class: 'checkbox',
|
|
|
|
|
id: "answer_#{option_id}",
|
2016-08-04 21:20:01 -05:00
|
|
|
|
name: "answer[#{question.input_type}][later]",
|
2016-08-01 15:16:20 -05:00
|
|
|
|
checked: Array(question.answer).include?('finish-later')
|
|
|
|
|
}
|
2016-08-23 21:54:53 -05:00
|
|
|
|
|
|
|
|
|
answers = answer.try(:answer) || answer
|
|
|
|
|
value_text = answers['text'] || question.input_options['text']
|
|
|
|
|
value_html = answers['html'] || question.input_options['html']
|
|
|
|
|
value_css = answers['css'] || question.input_options['css']
|
|
|
|
|
value_js = answers['js'] || question.input_options['js']
|
2016-08-01 15:16:20 -05:00
|
|
|
|
%>
|
2016-07-27 22:16:12 -05:00
|
|
|
|
|
2016-08-08 17:08:20 -05:00
|
|
|
|
<%= render partial: "quiz/answer_errors", locals: {question: question, answer: answer} %>
|
2016-08-05 13:10:10 -05:00
|
|
|
|
|
2016-08-08 17:08:20 -05:00
|
|
|
|
<div id="nojs<%= question.question_id %>" data-id="live-coder-finish-later">
|
2016-08-11 17:20:08 -05:00
|
|
|
|
<noscript>
|
|
|
|
|
<p class="warning">
|
2016-08-12 14:32:09 -05:00
|
|
|
|
<% unless params[:action] == 'summary' %>
|
|
|
|
|
This is a question where you will be
|
|
|
|
|
<% else %>
|
|
|
|
|
This is a question where you were
|
|
|
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
asked to write code, and it utilizes a JavaScript-enabled
|
2016-08-11 17:20:08 -05:00
|
|
|
|
environment. It looks like JavaScript is not loaded.
|
2016-08-12 15:07:51 -05:00
|
|
|
|
|
2016-08-11 17:20:08 -05:00
|
|
|
|
<% unless params[:action] == 'summary' %>
|
|
|
|
|
Please check the box below to acknowledge that you agree to come back at a later time to finish
|
|
|
|
|
answering this question before you can submit the test.
|
|
|
|
|
<% else %>
|
|
|
|
|
You will need to enable JavaScript and answer this question before you can submit the test.
|
|
|
|
|
<% end %>
|
|
|
|
|
</p>
|
2016-08-04 22:28:20 -05:00
|
|
|
|
<% unless params[:action] == 'summary' %>
|
2016-08-11 17:20:08 -05:00
|
|
|
|
<%= form.check_box(:answer, checkbox_html, true, '') %>
|
|
|
|
|
<%= form.label(option_id, 'I will come back later to finish this code question') %>
|
2016-08-04 22:28:20 -05:00
|
|
|
|
<% end %>
|
2016-08-11 17:20:08 -05:00
|
|
|
|
</noscript>
|
2016-08-04 22:28:20 -05:00
|
|
|
|
</div>
|
2016-07-27 22:16:12 -05:00
|
|
|
|
|
2016-11-16 23:31:35 -06:00
|
|
|
|
<div class="accordion" id="accordion<%= question.question_id %>" style="display: none;">
|
|
|
|
|
<input type="checkbox" class="accordion__toggle" id="accordion-toggle-live-coder" />
|
|
|
|
|
<label class="accordion__label" for="accordion-toggle-live-coder">How to use the live coder</label>
|
|
|
|
|
<p class="accordion__copy">
|
|
|
|
|
This is our own nifty creation, and it works similarly to CodePen. To use: type any HTML, CSS,
|
|
|
|
|
or JS inside their corresponding boxes, and watch the Results window below the boxes update
|
|
|
|
|
with your changes. Once you’re happy with your code and how it renders in the Results window,
|
|
|
|
|
move on to the next question!
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
2016-08-08 17:08:20 -05:00
|
|
|
|
<div id="answer<%= question.question_id %>" data-id="live-coder-answer" style="display: none;">
|
2016-09-02 17:51:35 -05:00
|
|
|
|
<label for="answer_answer_hash_text">Enter answer here</label>
|
|
|
|
|
<%= text_area_tag 'answer[answer_hash][text]', value_text, { disabled: true, data: {last: answers['text']}} %>
|
2016-08-11 17:44:30 -05:00
|
|
|
|
|
2016-08-08 17:08:20 -05:00
|
|
|
|
<div class="code-input">
|
2016-11-15 11:43:39 -06:00
|
|
|
|
<label for="answer_answer_hash_html">index.html</label>
|
2016-09-02 17:51:35 -05:00
|
|
|
|
<%= text_area_tag 'answer[answer_hash][html]', value_html, { disabled: true, data: {id: 'code-html', last: answers['html']}, class: 'code-answer code-html' } %>
|
2016-08-08 17:08:20 -05:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="code-input">
|
2016-11-15 11:43:39 -06:00
|
|
|
|
<label for="answer_answer_hash_css">styles.css</label>
|
2016-09-02 17:51:35 -05:00
|
|
|
|
<%= text_area_tag 'answer[answer_hash][css]', value_css, { disabled: true, data: {id: 'code-css', last: answers['css']}, class: 'code-answer code-css' } %>
|
2016-08-08 17:08:20 -05:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="code-input">
|
2016-11-15 11:43:39 -06:00
|
|
|
|
<label for="answer_answer_hash_js">main.js</label>
|
2016-09-02 17:51:35 -05:00
|
|
|
|
<%= text_area_tag 'answer[answer_hash][js]', value_js, { disabled: true, data: {id: 'code-js', last: answers['js']}, class: 'code-answer code-js' } %>
|
2016-08-08 17:08:20 -05:00
|
|
|
|
</div>
|
|
|
|
|
|
2016-11-16 23:31:35 -06:00
|
|
|
|
<label class="code-results">Results</label>
|
2016-08-08 17:08:20 -05:00
|
|
|
|
<div class="results" data-id="results"></div>
|
2016-07-27 22:16:12 -05:00
|
|
|
|
</div>
|
2016-08-08 17:08:20 -05:00
|
|
|
|
|
|
|
|
|
<script>
|
2016-08-12 11:22:59 -05:00
|
|
|
|
<% # removes the no-js message %>
|
2016-08-08 17:08:20 -05:00
|
|
|
|
document.getElementById("nojs<%= question.question_id %>").style.display = "none";
|
|
|
|
|
document.getElementById("answer<%= question.question_id %>").style.display = "";
|
2016-11-16 23:31:35 -06:00
|
|
|
|
document.getElementById("accordion<%= question.question_id %>").style.display = "";
|
2016-08-12 11:22:59 -05:00
|
|
|
|
|
|
|
|
|
<% # we want the coders disabled until JS is confirmed, so form post is easier to validate %>
|
|
|
|
|
var coders = document.querySelectorAll("[data-id=live-coder-answer] textarea");
|
2016-08-12 15:07:51 -05:00
|
|
|
|
for(i=0; i<coders.length; i++){ coders[i].disabled = false; }
|
2016-08-08 17:08:20 -05:00
|
|
|
|
</script>
|