From d44ada37510e85bb0b00cc857e85f4d17ed71358 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 26 Jun 2019 17:24:38 +0800 Subject: [PATCH] check poll_user create --- app/controllers/polls_controller.rb | 3 ++- app/views/polls/poll_lists.json.jbuilder | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 675e3283c..be3316df6 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -951,6 +951,7 @@ class PollsController < ApplicationController def poll_lists ActiveRecord::Base.transaction do begin + @poll_new_users = @poll.poll_users.find_by(user_id:current_user.id) poll_ids = [@poll.id] @poll_list_status = @poll.get_poll_status(current_user.id) @poll_publish_count = get_user_permission_course(poll_ids,2).count @@ -1184,7 +1185,7 @@ class PollsController < ApplicationController def check_poll_commit_result poll_status = @poll.get_poll_status(current_user.id) commit_poll_user = @poll.poll_users.find_by_group_ids(current_user.id).commit_by_status(1) #当前用户已提交问卷的 - unless @user_course_identity < Course::STUDENT || (@poll.show_result && poll_status == 3 && commit_poll_user.present?) + unless (@user_course_identity < Course::STUDENT) || (@poll.show_result && poll_status == 3 && commit_poll_user.present?) normal_status(-1,"没有权限!") #当前为老师/问卷公开统计,且问卷已截止,且用户有过回答的 end end diff --git a/app/views/polls/poll_lists.json.jbuilder b/app/views/polls/poll_lists.json.jbuilder index f134967c9..b83e767a1 100644 --- a/app/views/polls/poll_lists.json.jbuilder +++ b/app/views/polls/poll_lists.json.jbuilder @@ -1,7 +1,7 @@ json.course do json.partial! "polls/course_name",locals:{course:@course} end - +json.current_poll_user @poll_new_users.present? ? @poll_new_users.id : "---" json.poll_types do if @poll_current_user_status == 0 json.published_count @poll_publish_count