课程:问卷导入时显示的数据未进行过滤

This commit is contained in:
cxt 2016-05-20 09:59:41 +08:00
parent df70c33bcd
commit b03b9a3c27
2 changed files with 15 additions and 16 deletions

View File

@ -423,9 +423,13 @@ class PollController < ApplicationController
# 将其他地方的问卷导出来
def other_poll
# 查作者是我,或者作者是当前课程的老师,且不在当前课程内的问卷 进行导入
tea_ids = '('
tea_ids << Course.find(params[:polls_group_id]).tea_id.to_s << ','<< User.current.id.to_s << ')'
@polls = Poll.where("user_id in #{tea_ids} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}")
courses = User.current.courses.select { |course| User.current.allowed_to?(:as_teacher,course)}
course_ids = courses.empty? ? "(-1)" : "(" + courses.map { |course| course.id}.join(',') + ")"
none_courses = User.current.courses.where("is_delete = 1 or #{Course.table_name}.id = #{params[:polls_group_id].to_i}")
none_course_ids = none_courses.empty? ? "(-1)" : "(" + none_courses.map { |course| course.id}.join(',') + ")"
#tea_ids = '('
#tea_ids << Course.find(params[:polls_group_id]).tea_id.to_s << ','<< User.current.id.to_s << ')'
@polls = Poll.where("(user_id = #{User.current.id} or polls_group_id in #{course_ids}) and polls_type = 'course' and polls_group_id not in #{none_course_ids}")
@polls_group_id = params[:polls_group_id]
respond_to do |format|
format.js

View File

@ -11,12 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
<<<<<<< HEAD
ActiveRecord::Schema.define(:version => 20160513120002) do
=======
ActiveRecord::Schema.define(:version => 20160513021204) do
>>>>>>> weixin_guange
ActiveRecord::Schema.define(:version => 20160519070718) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -455,15 +450,15 @@ ActiveRecord::Schema.define(:version => 20160513021204) do
create_table "course_contributor_scores", :force => true do |t|
t.integer "course_id"
t.integer "user_id"
t.integer "message_num"
t.integer "message_reply_num"
t.integer "news_reply_num"
t.integer "resource_num"
t.integer "journal_num"
t.integer "journal_reply_num"
t.integer "message_num", :default => 0
t.integer "message_reply_num", :default => 0
t.integer "news_reply_num", :default => 0
t.integer "resource_num", :default => 0
t.integer "journal_num", :default => 0
t.integer "journal_reply_num", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "total_score"
t.integer "total_score", :default => 0
t.integer "homework_journal_num", :default => 0
t.integer "news_num", :default => 0
end