dev_forum
cxt 6 years ago
parent 23ee7debfb
commit 4d3dbcee4a

@ -60,6 +60,7 @@ class CoursesController < ApplicationController
# FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a") # FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a")
# .order("courses.id = 1309 desc, a desc") # .order("courses.id = 1309 desc, a desc")
if @order == "mine" if @order == "mine"
tip_exception(401, "..") unless current_user.logged?
@courses = Course.joins(:course_members) @courses = Course.joins(:course_members)
.where("is_delete = 0 AND is_hidden = 0 AND course_members.user_id = ?", @user.id) .where("is_delete = 0 AND is_hidden = 0 AND course_members.user_id = ?", @user.id)
elsif @order == "created_at" elsif @order == "created_at"

@ -22,6 +22,7 @@ class ShixunsController < ApplicationController
## 我的实训 ## 我的实训
@shixuns = @shixuns =
if params[:order_by] == 'mine' if params[:order_by] == 'mine'
tip_exception(401, "..") unless current_user.logged?
current_user.my_shixuns current_user.my_shixuns
else else
Shixun.unhidden Shixun.unhidden

@ -37,6 +37,8 @@ class SubjectsController < ApplicationController
else else
# 我的路径 # 我的路径
if reorder == "mine" if reorder == "mine"
tip_exception(401, "..") unless current_user.logged?
mine_subject_id = StageShixun.find_by_sql("select DISTINCT(subject_id) from stage_shixuns where shixun_id in mine_subject_id = StageShixun.find_by_sql("select DISTINCT(subject_id) from stage_shixuns where shixun_id in
(select distinct(shixun_id) from myshixuns where user_id=#{current_user.id})").map(&:subject_id) (select distinct(shixun_id) from myshixuns where user_id=#{current_user.id})").map(&:subject_id)
manage_subject_id = SubjectMember.where(user_id: current_user.id).pluck(:subject_id) manage_subject_id = SubjectMember.where(user_id: current_user.id).pluck(:subject_id)
@ -137,7 +139,7 @@ class SubjectsController < ApplicationController
if current_user.admin? if current_user.admin?
@shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier]).where(hidden: 0) @shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier]).where(hidden: 0)
else else
none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id)}").pluck(:shixun_id) none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id)
@shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier]).where.not(id: none_shixun_ids).where(hidden: 0) @shixuns = Shixun.select([:id, :name, :status, :myshixuns_count, :identifier]).where.not(id: none_shixun_ids).where(hidden: 0)
end end
@ -174,7 +176,7 @@ class SubjectsController < ApplicationController
WHERE m.course_id = c.id AND m.role in (1,2,3) WHERE m.course_id = c.id AND m.role in (1,2,3)
AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id) AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id)
@courses = Course.where(id: course_ids) @courses = Course.where(id: course_ids)
@none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id)}").pluck(:shixun_id) @none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id)
end end
def send_to_course def send_to_course

Loading…
Cancel
Save