diff --git a/app/assets/javascripts/live-coder.js b/app/assets/javascripts/live-coder.js index ee256c6..2616bd4 100644 --- a/app/assets/javascripts/live-coder.js +++ b/app/assets/javascripts/live-coder.js @@ -113,7 +113,8 @@ $(function(){ }); // 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 $("[data-id='live-coder-finish-later']").addClass("hidden"); $('.js-error').addClass('hidden'); diff --git a/app/controllers/candidate_controller.rb b/app/controllers/candidate_controller.rb index 336405a..fd3d445 100644 --- a/app/controllers/candidate_controller.rb +++ b/app/controllers/candidate_controller.rb @@ -35,6 +35,12 @@ class CandidateController < ApplicationController redirect_to :question end + def live_coder + @question = Question.find(params[:question_id]) + @answer = @question.answers.order("RAND()").first.answer + render layout: false + end + # private # # def question_params diff --git a/app/views/candidate/_live-coder.html.erb b/app/views/candidate/_live-coder.html.erb index bd96518..7f1d1ea 100644 --- a/app/views/candidate/_live-coder.html.erb +++ b/app/views/candidate/_live-coder.html.erb @@ -14,28 +14,7 @@
- <% - # answers inserted dynamically via jQuery .load() - # to check for JS capability/enabled + <% # answers inserted dynamically via jQuery .load() + # to check for JS capability/enabled %> - -
- - -
- -
- - -
- -
- - -
- - -- MOVE TO FLASH HASH -- -
You must write code in one of the above textareas to progress.
- -
diff --git a/app/views/candidate/live_coder.html.erb b/app/views/candidate/live_coder.html.erb new file mode 100644 index 0000000..adc3806 --- /dev/null +++ b/app/views/candidate/live_coder.html.erb @@ -0,0 +1,19 @@ +
+ + +
+ +
+ + +
+ +
+ + +
+ +-- MOVE TO FLASH HASH -- +
You must write code in one of the above textareas to progress.
+ +
diff --git a/config/routes.rb b/config/routes.rb index d88e093..b503f26 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,6 +8,9 @@ Rails.application.routes.draw do get "/question", to: "candidate#question", as: :question 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" # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end