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/exercises/_user_exercise_info.json.jb...

77 lines
2.8 KiB

6 years ago
json.exercise do
json.extract! exercise, :id, :exercise_name,:exercise_description,:exercise_status,:answer_open
json.student_commit_status student_status #当前为学生且已提交时
end
json.exercise_answer_user do
json.is_teacher is_teacher_or
json.user_name ex_answerer.real_name
json.user_id ex_answerer.id
json.login ex_answerer.login
if exercise_user.present?
json.start_at exercise_user.start_at
json.score exercise_user.score.present? ? exercise_user.score.round(1).to_s : "0.0"
end
end
all_question_status = []
if student_status == 2
#试卷的全部分数
json.exercise_scores do
json.partial! "exercises/exercise_scores"
#试卷的客观题分数及是否错误
json.objective_scores do
json.partial! "exercises/question_scores", question_scores: ex_obj_array #客观问题正确与否的显示
end
#试卷的主观题及是否错误
json.subjective_scores do
json.partial! "exercises/question_scores", question_scores: ex_sub_array #主观题正确与否的显示
end
end
#主观题及客观题的全部分数及正确与否的状态
all_question_status = ex_obj_array + ex_sub_array
elsif student_status == 1
json.question_status question_status
end
5 years ago
exercise_status = exercise.get_exercise_status(ex_answerer)
6 years ago
#当前为老师,或为学生,但在试卷截止后且答案选择公开的
if is_teacher_or == 1 || (exercise_status == 3 && exercise.answer_open)
ex_type = 4
else
ex_type = 3
end
json.exercise_questions do
json.array! exercise_questions do |q|
user_ques_answers = user_question_answers(q,ex_answerer.id,student_status,is_teacher_or,exercise_status,q.question_type,ex_type)
user_ques_comments = user_ques_answers[:question_comment]
if all_question_status.size > 0
this_ques_status = all_question_status.detect {|f| f[:q_id] == q.id}
json.answer_status this_ques_status[:stand_status]
end
5 years ago
json.user_score user_ques_answers[:user_score]
6 years ago
json.partial! "exercise_questions/exercise_questions",
question: q,
ex_answerer: ex_answerer,
choices:q.exercise_choices,
shixun_challenges: q.exercise_shixun_challenges,
exercise_type: ex_type,
user_answer: user_ques_answers[:answered_content],
6 years ago
shixun_type: user_ques_answers[:shixun_type],
5 years ago
ques_position: nil
6 years ago
if user_ques_comments.count > 0
json.question_comments do
json.partial! "exercises/exercise_comments", question_comment:user_ques_answers[:question_comment].first
end
else
json.question_comments []
end
end
end
#exercise_type 表示选择公用的模板类型1为教师预览/编辑2为空白试卷,3表示学生开始答题/答题未截止。