diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 2239f570d..e2d6110bd 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1140,6 +1140,7 @@ class ExercisesController < ApplicationController exercise_ids = [@exercise.id] @exercise_status = @exercise.get_exercise_status(current_user.id) @course_all_members = @course.students + @c_group_counts = @course.course_groups_count question_types = @exercise.exercise_questions.pluck(:question_type) @exercise_publish_count = get_user_permission_course(exercise_ids,2).count #判断是否有已发布的分班 @exercise_unpublish_count = get_user_permission_course(exercise_ids,1).count #判断是否有未发布的分班 diff --git a/app/controllers/poll_votes_controller.rb b/app/controllers/poll_votes_controller.rb index eef953d5e..d8a4ce852 100644 --- a/app/controllers/poll_votes_controller.rb +++ b/app/controllers/poll_votes_controller.rb @@ -30,16 +30,25 @@ class PollVotesController < ApplicationController #begin if question_type == 1 if user_votes.present? #用户曾经回答过的,答案选择不一样,否则新建 + logger.info("########___________user_votes.present1111____________________#######") current_user_answer = user_votes.first - if current_user_answer.poll_answer_id != question_answer_id #如果说更换了答案,则以前的答案删除,并新建记录 + if current_user_answer&.poll_answer_id != question_answer_id #如果说更换了答案,则以前的答案删除,并新建记录 + logger.info("########___________user_votes.present22222____________________#######") + current_user_answer.destroy PollVote.create(vote_answer_params) else + logger.info("########___________user_votes.present33333____________________#######") + if question_answer_text.present? + logger.info("########___________user_votes.present4444444____________________#######") + current_user_answer.update_attribute("vote_text", question_answer_text) end end else + logger.info("########___________user_votes.present555555____________________#######") + PollVote.create(vote_answer_params) end elsif question_type == 2 #多选题的话,答案应该是1个以上 diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index ae93357cc..675e3283c 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -956,6 +956,8 @@ class PollsController < ApplicationController @poll_publish_count = get_user_permission_course(poll_ids,2).count @poll_unpublish_count = get_user_permission_course(poll_ids,1).count @course_all_members = @course.students + @poll_group_counts = @course.course_groups_count + if @user_course_identity < Course::STUDENT #当前为老师,而且老师只能查看自己班级的/课堂的问卷 @poll_current_user_status = 0 @poll_users_list = @poll.all_poll_users(current_user.id).distinct #该老师分班的全部学生 diff --git a/app/views/exercises/exercise_lists.json.jbuilder b/app/views/exercises/exercise_lists.json.jbuilder index 5e7c83b35..26723c894 100644 --- a/app/views/exercises/exercise_lists.json.jbuilder +++ b/app/views/exercises/exercise_lists.json.jbuilder @@ -15,7 +15,7 @@ json.exercise_types do json.exercise_id @exercise.id json.subjective @subjective_type #是否包含主观题,1为包括,0为不包括 json.exercise_end_time ((@ex_user_end_time.nil? || @ex_user_end_time < Time.now) ? "--" : how_much_time(@ex_user_end_time)) - json.groups_count @exercise_course_groups.size + json.groups_count @c_group_counts end if @exercise_current_user_status == 0 #当为老师的时候 diff --git a/app/views/polls/poll_lists.json.jbuilder b/app/views/polls/poll_lists.json.jbuilder index 8278ac3e0..f134967c9 100644 --- a/app/views/polls/poll_lists.json.jbuilder +++ b/app/views/polls/poll_lists.json.jbuilder @@ -16,7 +16,7 @@ json.poll_types do json.user_permission @poll_current_user_status #当前用户存在且为课堂教师/管理员/超级管理员时为0 ,其他否则为1 json.poll_id @poll.id json.poll_end_time @poll.end_time - json.groups_count @poll_course_groups.size + json.groups_count @poll_group_counts end if @poll_current_user_status == 0 diff --git a/lib/tasks/exercise_publish.rake b/lib/tasks/exercise_publish.rake index 7d80dc2e9..bc9330b66 100644 --- a/lib/tasks/exercise_publish.rake +++ b/lib/tasks/exercise_publish.rake @@ -245,6 +245,6 @@ namespace :exercise_publish do end end end - logger.info("") + Rails.logger.info("log--------------------------------exercise_end completed") end end