@ -109,7 +109,11 @@ class SyllabusesController < ApplicationController
sort_name="updated_on"
sort_name="updated_on"
sort_type=@c_sort==1?"asc":"desc"
sort_type=@c_sort==1?"asc":"desc"
@courses=User.current.courses.visible.where("is_delete =? and syllabus_id =?",0,@syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name}#{sort_type}")
@courses=@syllabus.courses.where("is_delete = 0").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name}#{sort_type}")
else
@courses=User.current.courses.visible.where("is_delete =? and syllabus_id =?",0,@syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name}#{sort_type}")
@homeworks=HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and course_id not in #{course_ids}").order("#{@order}#{@b_sort}")
@homeworks=HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and course_id not in #{course_ids}").order("#{@order}#{@b_sort}")
sql="SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
@homeworks=HomeworkCommon.find_by_sql(sql)
elsif@order=="user_name"
@homeworks=HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
else
@homeworks=HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order}#{@b_sort}")
@ -812,17 +836,6 @@ class UsersController < ApplicationController
else
else
@homeworks=HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order}#{@b_sort}")
@homeworks=HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order}#{@b_sort}")
sql="SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
@homeworks=HomeworkCommon.find_by_sql(sql)
elsif@order=="user_name"
@homeworks=HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
else
@homeworks=HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order}#{@b_sort}")
@courses=User.current.courses.visible.where("is_delete =? and syllabus_id =?",0,@syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page*5)
@all_count=User.current.courses.visible.where("is_delete =? and syllabus_id =?",0,@syllabus.id).count
all_courses=@syllabus.courses.where("is_delete = 0").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc")
else
all_courses=User.current.courses.visible.where("is_delete =? and syllabus_id =?",0,@syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc")
end
@courses=all_courses.limit(5).offset(@page*5)
@all_count=all_courses.count
end
end
end
end
@ -2132,6 +2150,7 @@ class UsersController < ApplicationController
# 添加资源到对应的项目
# 添加资源到对应的项目
defadd_exist_file_to_project
defadd_exist_file_to_project
@flag=true
@flag=true
# 发送单个资源
ifparams[:send_id].present?
ifparams[:send_id].present?
send_id=params[:send_id]
send_id=params[:send_id]
project_ids=params[:projects_ids]
project_ids=params[:projects_ids]
@ -2168,6 +2187,8 @@ class UsersController < ApplicationController
sort_projects=ForgeActivity.find_by_sql("SELECT MAX(updated_at) AS updated_at,user_id, project_id FROM forge_activities WHERE project_id IN #{project_ids} GROUP BY project_id ORDER BY MAX(updated_at) DESC")
sort_projects=ForgeActivity.find_by_sql("SELECT MAX(updated_at) AS updated_at,user_id, project_id FROM forge_activities WHERE project_id IN #{project_ids} GROUP BY project_id ORDER BY MAX(updated_at) DESC")
ifCourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count!=0
ifCourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count!=0
attchments=Attachment.where("(author_id = #{user.id} and is_publish = 1 and container_id in #{courses_ids} and container_type = 'Course') or (container_type = 'Course' and is_publish = 1 and container_id in #{courses_ids})").order("created_on desc")
syllabus.courses=courses.where("syllabus_id = #{syllabus.id}").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("time desc")
syllabus.courses=courses.where("syllabus_id = #{syllabus.id}").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("time desc")
end
end
syllabuses.to_a<<other
# syllabuses.to_a << other
syllabuses.to_a
#管理权限 can_setting
#管理权限 can_setting
syllabuses.eachdo|s|
# syllabuses.each do |s|
s=judge_can_setting(s,user)
# s = judge_can_setting(s,user)
end
# end
syllabuses
syllabuses
end
end
@ -72,6 +67,15 @@ class SyllabusesService
course.course_infos<<course_info
course.course_infos<<course_info
end
end
defsend_wechat_create_class_noticeuser,course
count=ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count
<% courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %>
<% if User.current == @syllabus.user || User.current.admin?
<% all_count = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).count%>
all_courses = @syllabus.courses.where("is_delete = 0").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc")
else
all_courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc")