diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 1478bceae..374e26431 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1177,7 +1177,7 @@ class CoursesController < ApplicationController AND homework_commons.course_id = #{@course.id} AND student_works.user_id = members.user_id ) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 + - resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = 577 AND ccs.user_id = members.user_id + resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id ) AS act_score FROM members JOIN students_for_courses @@ -1191,7 +1191,7 @@ class CoursesController < ApplicationController AND homework_commons.course_id = #{@course.id} AND student_works.user_id = members.user_id ) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 + - resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = 577 AND ccs.user_id = members.user_id + resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = #{@course.id} AND ccs.user_id = members.user_id ) AS act_score FROM members JOIN students_for_courses 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