diff --git a/README.md b/README.md index 8de62f4..41f6171 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,11 @@ This application manages quizzes intended to be used as pre-interview skill asse - starts up simple server for viewing/demo sans guard visit http://localhost:3000 + + +---- + +# Question creation + +* attachments: http://dev.perficientxd.com/skill_assets/ + diff --git a/app/views/candidate/question.html.erb b/app/views/candidate/question.html.erb index 3762b96..26e7054 100644 --- a/app/views/candidate/question.html.erb +++ b/app/views/candidate/question.html.erb @@ -9,6 +9,10 @@

<%= @question.question %>

+ <% if @question.attachment.present? %> + <%= image_tag @question.attachment %> + <% end %> +
<%= hidden_field_tag 'answer[question_id]', @question.question_id %> <%= hidden_field_tag 'answer[answer_id]', @question.answer_id %> diff --git a/app/workers/candidate_quiz.rb b/app/workers/candidate_quiz.rb index 4329ef0..6b7b738 100644 --- a/app/workers/candidate_quiz.rb +++ b/app/workers/candidate_quiz.rb @@ -1,8 +1,8 @@ class CandidateQuiz attr_reader :candidate_id - def initialize candidate_id - @candidate_id = candidate_id + def initialize candidate + @candidate_id = candidate.to_i end def fetch_question qid @@ -18,7 +18,7 @@ class CandidateQuiz def raw_quiz qid = nil question = qid.nil? ? "" : " and q.id = #{qid} " sql = "select c.id candidate_id, q.quiz_id, q.id question_id, a.id answer_id, q.sort - , q.question, q.category, q.input_type, q.input_options, a.answer + , q.question, q.attachment, q.category, q.input_type, q.input_options, a.answer , ifnull(a.saved, false) saved, ifnull(a.submitted, false) submitted , a.updated_at from candidates c inner join questions q on q.quiz_id = c.quiz_id diff --git a/app/workers/candidate_quiz_question.rb b/app/workers/candidate_quiz_question.rb index a1839db..70220e8 100644 --- a/app/workers/candidate_quiz_question.rb +++ b/app/workers/candidate_quiz_question.rb @@ -26,6 +26,10 @@ class CandidateQuizQuestion row["question"] end + def attachment + row['attachment'] + end + def category row["category"] end diff --git a/db/migrate/20160803003932_add_attachments_to_questions.rb b/db/migrate/20160803003932_add_attachments_to_questions.rb new file mode 100644 index 0000000..88333da --- /dev/null +++ b/db/migrate/20160803003932_add_attachments_to_questions.rb @@ -0,0 +1,5 @@ +class AddAttachmentsToQuestions < ActiveRecord::Migration[5.0] + def change + add_column :questions, :attachment, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index bc22151..61aa979 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160727154057) do +ActiveRecord::Schema.define(version: 20160803003932) do create_table "answers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| t.integer "candidate_id" @@ -51,6 +51,7 @@ ActiveRecord::Schema.define(version: 20160727154057) do t.boolean "active" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "attachment" t.index ["active"], name: "index_questions_on_active", using: :btree t.index ["quiz_id"], name: "index_questions_on_quiz_id", using: :btree t.index ["sort"], name: "index_questions_on_sort", using: :btree diff --git a/test/fixtures/questions.yml b/test/fixtures/questions.yml index de67303..027955f 100644 --- a/test/fixtures/questions.yml +++ b/test/fixtures/questions.yml @@ -47,7 +47,8 @@ fed5: fed6: quiz: fed - question: List one advantage of using IDs over classes. List one disadvantage. + question: Comment on how realistic the following image is. + attachment: "http://dev.perficientxd.com/skill_assets/commets_css.jpg" category: CSS input_type: text input_options: