From b03b9a3c27feea203d763e41a952e4a1192cd73f Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 May 2016 09:59:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=EF=BC=9A=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=97=B6=E6=98=BE=E7=A4=BA=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9C=AA=E8=BF=9B=E8=A1=8C=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 10 +++++++--- db/schema.rb | 21 ++++++++------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 1d7b4117d..e4cf31f55 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 02a79aa9b..9c4b4b333 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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