live coder load on question template
This commit is contained in:
parent
fc6b56d9b8
commit
1a8d7629ff
@ -113,7 +113,8 @@ $(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
// If JavaScript is enabled, display the livecoder section dynamically
|
// If JavaScript is enabled, display the livecoder section dynamically
|
||||||
$("[data-id='live-coder-answer']").load("live-coder-chunk.php .layout", function(){
|
var qid = 257208768;
|
||||||
|
$("[data-id='live-coder-answer']").load("/live-coder-entry/" + qid, function(){
|
||||||
// if it loads in, and hide "finish later" checkbox
|
// if it loads in, and hide "finish later" checkbox
|
||||||
$("[data-id='live-coder-finish-later']").addClass("hidden");
|
$("[data-id='live-coder-finish-later']").addClass("hidden");
|
||||||
$('.js-error').addClass('hidden');
|
$('.js-error').addClass('hidden');
|
||||||
|
@ -35,6 +35,12 @@ class CandidateController < ApplicationController
|
|||||||
redirect_to :question
|
redirect_to :question
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def live_coder
|
||||||
|
@question = Question.find(params[:question_id])
|
||||||
|
@answer = @question.answers.order("RAND()").first.answer
|
||||||
|
render layout: false
|
||||||
|
end
|
||||||
|
|
||||||
# private
|
# private
|
||||||
#
|
#
|
||||||
# def question_params
|
# def question_params
|
||||||
|
@ -14,28 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div data-id="live-coder-answer">
|
<div data-id="live-coder-answer">
|
||||||
<%
|
<% # answers inserted dynamically via jQuery .load()
|
||||||
# answers inserted dynamically via jQuery .load()
|
|
||||||
# to check for JS capability/enabled
|
# to check for JS capability/enabled
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<div class="code-input">
|
|
||||||
<label for="code-html">HTML</label>
|
|
||||||
<textarea data-id="code-html" name="code-html"><%= question.answer['html'] unless question.answer.nil? %></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="code-input">
|
|
||||||
<label for="code-css">CSS</label>
|
|
||||||
<textarea data-id="code-css" name="code-css"><%= question.answer['css'] unless question.answer.nil? %></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="code-input">
|
|
||||||
<label for="code-js">JS</label>
|
|
||||||
<textarea data-id="code-js" name="code-js"><%= question.answer['js'] unless question.answer.nil? %></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
-- MOVE TO FLASH HASH --
|
|
||||||
<div class="error">You must write code in one of the above textareas to progress.</div>
|
|
||||||
|
|
||||||
<div class="results" data-id="results"></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
19
app/views/candidate/live_coder.html.erb
Normal file
19
app/views/candidate/live_coder.html.erb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<div class="code-input">
|
||||||
|
<label for="code-html">HTML</label>
|
||||||
|
<textarea data-id="code-html" name="code-html"><%= @answer['html'] unless @answer.nil? %></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="code-input">
|
||||||
|
<label for="code-css">CSS</label>
|
||||||
|
<textarea data-id="code-css" name="code-css"><%= @answer['css'] unless @answer.nil? %></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="code-input">
|
||||||
|
<label for="code-js">JS</label>
|
||||||
|
<textarea data-id="code-js" name="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>
|
||||||
|
|
||||||
|
<div class="results" data-id="results"></div>
|
@ -8,6 +8,9 @@ Rails.application.routes.draw do
|
|||||||
get "/question", to: "candidate#question", as: :question
|
get "/question", to: "candidate#question", as: :question
|
||||||
post "/validate", to: "candidate#validate", as: :validate_candidate
|
post "/validate", to: "candidate#validate", as: :validate_candidate
|
||||||
|
|
||||||
|
# live coder partial
|
||||||
|
get "/live-coder-entry/:question_id", to: "candidate#live_coder"
|
||||||
|
|
||||||
root to: "candidate#welcome"
|
root to: "candidate#welcome"
|
||||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user