@stundet_works=search_homework_member@homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
elsif@order=='student_id'
elsif@order=='student_id'
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order}#{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order}#{@b_sort}"),@name
else
else
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name
end
end
@show_all=true
@show_all=true
elsifUser.current.member_of_course?(@course)
elsifUser.current.member_of_course?(@course)
@ -476,11 +476,11 @@ class StudentWorkController < ApplicationController
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
elsif@order=='student_id'
elsif@order=='student_id'
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,student_works.work_score as score").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order}#{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order}#{@b_sort}"),@name
else
else
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,student_works.work_score as score").order("#{@order}#{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").order("#{@order}#{@b_sort}"),@name
end
end
@show_all=true
@show_all=true
elsifUser.current.member_of_course?(@course)
elsifUser.current.member_of_course?(@course)
@ -613,33 +613,21 @@ class StudentWorkController < ApplicationController
@ -1139,7 +1126,7 @@ class StudentWorkController < ApplicationController
end
end
all_students=User.where("id in #{all_student_ids}")
all_students=User.where("id in #{all_student_ids}")
student_work_id=@homework.student_work_projects.where("user_id=? and student_work_id is not null",User.current.id).first.nil??-1:@homework.student_work_projects.where("user_id=?",User.current.id).first.student_work_id
student_work_id=@homework.student_work_projects.where("user_id=? and student_work_id is not null",User.current.id).first.nil??-1:@homework.student_work_projects.where("user_id=?",User.current.id).first.student_work_id
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'HomeworkCommon'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Course'
act_type='HomeworkCommon'
when"course_news"
when"course_news"
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'News'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Course'
act_type='News'
when"course_message"
when"course_message"
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Course'
act_type='Message'
when"course_poll"
when"course_poll"
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Poll'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Course'
act_type='Poll'
when"course_journals"
when"course_journals"
@user_activities=UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'JournalsForMessage'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Course'
act_type='JournalsForMessage'
when"project_issue"
when"project_issue"
@user_activities=UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Issue'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Project'
act_type='Issue'
when"project_message"
when"project_message"
@user_activities=UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page*10)
container_type='Course'
act_type='Message'
when"user_journals"
when"user_journals"
@user_activities=UserActivity.where("container_type = 'Principal' and act_type= 'JournalsForMessage' and container_id = #{@user.id}").order('updated_at desc').limit(10).offset(@page*10)
container_type='Principal'
act_type='JournalsForMessage'
when"current_user"
when"current_user"
@user_activities=UserActivity.where("user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))").order('updated_at desc').limit(10).offset(@page*10)
sql="user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))"
end
ifUser.current!=@user
sql+=" and user_id = #{@user.id}"
end
end
else
else
# @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10)
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page*10)
# if params[:type].present?
end
# case params[:type]
# when "course_homework"
# @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'HomeworkCommon'").order('updated_at desc').limit(10).offset(@page * 10)
# when "course_news"
# @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'News'").order('updated_at desc').limit(10).offset(@page * 10)
# when "course_message"
# @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page * 10)
# when "course_poll"
# @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Poll'").order('updated_at desc').limit(10).offset(@page * 10)
# when "course_journals"
# @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'JournalsForMessage'").order('updated_at desc').limit(10).offset(@page * 10)
# when "project_issue"
# @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Issue'").order('updated_at desc').limit(10).offset(@page * 10)
# when "project_message"
# @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page * 10)
# when "user_journals"
# @user_activities = UserActivity.where("container_type = 'Principal' and act_type= 'JournalsForMessage' and container_id = #{@user.id}").order('updated_at desc').limit(10).offset(@page * 10)
# when "current_user"
# @user_activities = UserActivity.where("user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))").order('updated_at desc').limit(10).offset(@page * 10)
# @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
# "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
# "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " +
# "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10)
# end
# else
# # @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10)