You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/views/exercise_banks/show.json.jbuilder

53 lines
1.7 KiB

if @bank.container_type == "Exercise"
json.exercise do
json.extract! @bank, :id, :name, :description, :is_public
end
json.authorize @bank.user_id == current_user.id || current_user.admin_or_business?
json.partial! "exercises/exercise_scores"
json.exercise_questions do
json.array! @exercise_questions do |q|
json.partial! "exercise_bank_questions/exercise_bank_questions",
question: q,
choices:q.exercise_bank_choices,
shixun_challenges: q.exercise_bank_shixun_challenges,
ques_position:nil,
edit_type:nil
end
end
5 years ago
else
json.poll do
json.extract! @bank, :id, :name, :description, :is_public
end
json.authorize @bank.user_id == current_user.id || current_user.admin_or_business?
json.question_types do
json.q_counts @poll_questions_count
json.q_singles @poll_question_singles
json.q_doubles @poll_question_doubles
json.q_mains @poll_question_mains
end
5 years ago
5 years ago
json.questions @exercise_questions do | question|
json.question do
json.id question.id
json.question_number question.question_number
json.question_title question.question_title
json.question_type question.question_type
json.is_necessary question.is_necessary
if question.question_type == 2
json.max_choices question.max_choices
json.min_choices question.min_choices
end
json.answers do
json.array! question.exercise_bank_choices do | a|
json.answer_id a.id
json.answer_position a.choice_position
json.answer_text a.choice_text.nil? ? "other_choices" : a.choice_text ##
end
end
end
5 years ago
end
end