simple question attachments

This commit is contained in:
Mark Moser 2016-08-03 08:55:30 -05:00
parent a3eab2b27a
commit f4abe5e281
7 changed files with 28 additions and 5 deletions

View File

@ -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/

View File

@ -9,6 +9,10 @@
<main class="answer-sec <%= @question.input_type %>-type questions_tpl" data-qid="<%= @question.question_id %>">
<h2 class="question-text"><%= @question.question %></h2>
<% if @question.attachment.present? %>
<%= image_tag @question.attachment %>
<% end %>
<div class="content-well">
<%= hidden_field_tag 'answer[question_id]', @question.question_id %>
<%= hidden_field_tag 'answer[answer_id]', @question.answer_id %>

View File

@ -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

View File

@ -26,6 +26,10 @@ class CandidateQuizQuestion
row["question"]
end
def attachment
row['attachment']
end
def category
row["category"]
end

View File

@ -0,0 +1,5 @@
class AddAttachmentsToQuestions < ActiveRecord::Migration[5.0]
def change
add_column :questions, :attachment, :string
end
end

View File

@ -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

View File

@ -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: