show方法
This commit is contained in:
parent
deb0f151c4
commit
25344ef0de
|
@ -30,7 +30,7 @@ class ExerciseController < ApplicationController
|
|||
redirect_to exercise_index_url(:course_id=> @course.id)
|
||||
else
|
||||
@can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin?
|
||||
@percent = get_percent(@exercise,User.current)
|
||||
# @percent = get_percent(@exercise,User.current)
|
||||
exercise_questions = @exercise.exercise_questions
|
||||
@exercise_questions = paginateHelper exercise_questions,5 #分页
|
||||
respond_to do |format|
|
||||
|
@ -239,6 +239,13 @@ class ExerciseController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
# 获取问题的答案
|
||||
def get_user_answer(question,user)
|
||||
user_answer = question.poll_votes.where("#{PollVote.table_name}.user_id = #{user.id}")
|
||||
user_answer
|
||||
end
|
||||
|
||||
# 是否完成了答题
|
||||
def get_complete_question(exercise,user)
|
||||
questions = exercise.exercise_questions
|
||||
complete_question = []
|
||||
|
@ -251,6 +258,7 @@ class ExerciseController < ApplicationController
|
|||
complete_question
|
||||
end
|
||||
|
||||
|
||||
def get_percent exercise,user
|
||||
complete_count = get_complete_question(exercise,user).count
|
||||
if exercise.exercise_questions.count == 0
|
||||
|
|
Loading…
Reference in New Issue