|
|
|
@ -43,7 +43,7 @@ class PollsController < ApplicationController
|
|
|
|
|
# polls的不同用户群体的显示
|
|
|
|
|
if @user_course_identity < Course::STUDENT # @is_teacher_or 1为老师/管理员/助教
|
|
|
|
|
@is_teacher_or = 1
|
|
|
|
|
@teacher_groups_ids = @course.teacher_course_groups.get_user_groups(current_user.id).pluck(:course_group_id).reject(&:blank?)
|
|
|
|
|
@teacher_groups_ids = @course.charge_group_ids(current_user)
|
|
|
|
|
@polls = @polls_all #老师能看到全部的问卷,不管是已发布的/未发布的/已截止的/统一设置的/私有设置的(看到内容不同)
|
|
|
|
|
elsif @user_course_identity == Course::STUDENT # 2为课堂成员,能看到统一设置的和自己班级的
|
|
|
|
|
@is_teacher_or = 2
|
|
|
|
@ -254,12 +254,12 @@ class PollsController < ApplicationController
|
|
|
|
|
if pl_status == 1 #如果问卷存在已发布的,或者是已截止的,那么则直接跳过
|
|
|
|
|
g_course = params[:group_ids] #表示是否传入分班参数,如果传入分班的参数,那么poll的统一设置需修改
|
|
|
|
|
if g_course
|
|
|
|
|
course_groups = @course.teacher_course_groups.get_user_groups(current_user.id)
|
|
|
|
|
if course_groups.blank?
|
|
|
|
|
user_course_groups = @course.course_groups.present? ? @course.course_groups.pluck(:id) : []
|
|
|
|
|
else
|
|
|
|
|
user_course_groups = course_groups.pluck(:course_group_id)
|
|
|
|
|
end
|
|
|
|
|
user_course_groups = @course.charge_group_ids(current_user)
|
|
|
|
|
# if course_groups.blank?
|
|
|
|
|
# user_course_groups = @course.course_groups.present? ? @course.course_groups.pluck(:id) : []
|
|
|
|
|
# else
|
|
|
|
|
# user_course_groups = course_groups.pluck(:course_group_id)
|
|
|
|
|
# end
|
|
|
|
|
if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则问卷不用分组,且问卷设定为统一设置,否则则分组设置
|
|
|
|
|
poll.poll_group_settings.destroy_all
|
|
|
|
|
poll_unified = true
|
|
|
|
@ -673,7 +673,7 @@ class PollsController < ApplicationController
|
|
|
|
|
@user_published_setting = @poll.poll_group_settings.find_in_poll_group("course_group_id",@being_setting_course_ids)
|
|
|
|
|
poll_ids = [@poll.id]
|
|
|
|
|
@poll_publish_count = get_user_permission_course(poll_ids,2).count
|
|
|
|
|
## 需添加发送消息的接口,稍后添加
|
|
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
|
tip_exception("页面调用失败!")
|
|
|
|
@ -688,7 +688,7 @@ class PollsController < ApplicationController
|
|
|
|
|
begin
|
|
|
|
|
error_count = 0 # 判断循环里是否有已发布/已截止的,且时间更改了的分班。
|
|
|
|
|
|
|
|
|
|
course_group_ids = @course.teacher_course_group_ids(current_user.id) #当前老师的班级id数组
|
|
|
|
|
course_group_ids = @course.charge_group_ids(current_user) #当前老师的班级id数组
|
|
|
|
|
|
|
|
|
|
poll_status = @poll.get_poll_status(current_user.id)
|
|
|
|
|
if poll_status == 1 && (course_group_ids - [0]).count > 0 # 问卷未发布,且老师的分班大于1 ,才可以修改统一设置,否则按poll默认的来处理
|
|
|
|
@ -951,7 +951,6 @@ class PollsController < ApplicationController
|
|
|
|
|
def poll_lists
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
logger.info("########___________@course.teacher_course_groups)________________####################{@course.teacher_course_groups.where(user_id:current_user.id).pluck(:course_group_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
|
|
|
|
@ -1213,12 +1212,13 @@ class PollsController < ApplicationController
|
|
|
|
|
def get_user_permission_course(poll_ids,status) #获取用户权限范围内的已发布/未发布
|
|
|
|
|
poll_status = status.to_i
|
|
|
|
|
unpublish_group = []
|
|
|
|
|
g_course_ids = @course.teacher_course_groups.get_user_groups(current_user.id).pluck(:course_group_id).reject(&:blank?).uniq
|
|
|
|
|
if g_course_ids.blank? || g_course_ids.include?(0) #当前用户的分班权限为空,即具体全部的分班权限
|
|
|
|
|
user_groups_id = @course.course_groups.pluck(:id)
|
|
|
|
|
else
|
|
|
|
|
user_groups_id = g_course_ids
|
|
|
|
|
end
|
|
|
|
|
# g_course_ids = @course.teacher_course_groups.get_user_groups(current_user.id).pluck(:course_group_id).reject(&:blank?).uniq
|
|
|
|
|
# if g_course_ids.blank? || g_course_ids.include?(0) #当前用户的分班权限为空,即具体全部的分班权限
|
|
|
|
|
# user_groups_id = @course.course_groups.pluck(:id)
|
|
|
|
|
# else
|
|
|
|
|
# user_groups_id = g_course_ids
|
|
|
|
|
# end
|
|
|
|
|
user_groups_id = @course.charge_group_ids(current_user)
|
|
|
|
|
all_polls = Poll.where(id:poll_ids)
|
|
|
|
|
all_polls.each do |poll|
|
|
|
|
|
if poll.present?
|
|
|
|
|