@ -477,8 +477,8 @@ class UsersController < ApplicationController
ah=ApplyHomework.where("user_id = ? and homework_common_id = ?",User.current.id,params[:send_id].to_i)
ifah.empty?
@status=2
elsifah.first.status== 1
@status=1
elsifah.first.status!= 2
@status=ah.first.status
end
end
if!params[:search].nil?
@ -1208,13 +1208,13 @@ class UsersController < ApplicationController
#显示更多用户课程
defuser_courses4show
@page=params[:page].to_i+1
@courses=@user.courses.visible.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").limit(5).offset(@page*5)
@courses=@user.courses.visible.where("is_delete =?",0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page*5)
end
#显示更多用户项目
defuser_projects4show
@page=params[:page].to_i+1
@projects=@user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5).offset(@page*5)
@projects=@user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5).offset(@page*5)
end
defuser_course_activities
@ -2948,20 +2948,19 @@ class UsersController < ApplicationController
sort_name="created_at"
sort_type=@c_sort==1?"asc":"desc"
if@user.courses.visible.count>0
course_order_ids="("+CourseActivity.find_by_sql("SELECT c.course_id, updated_at FROM(SELECT ca.course_id, MAX(ca.updated_at) AS updated_at FROM course_activities ca WHERE ca.course_id IN ("+@user.courses.visible.select('courses.id').map{|c|c.id}.join(',')+") GROUP BY ca.course_id) AS c ").map{|c|c.course_id}.join(",")+")"
@courses=Course.where("id in #{course_order_ids}").order("#{sort_name}#{sort_type}")
else
@courses=[]
end
@courses=@user.courses.visible.where("is_delete =?",0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a #{sort_type}")
@ -2993,21 +2992,19 @@ class UsersController < ApplicationController
sort_name="created_on"
sort_type=@c_sort==1?"asc":"desc"
if@user.projects.visible.count>0
project_order_ids="("+ForgeActivity.find_by_sql("SELECT p.project_id, p.created_at FROM (SELECT fa.project_id, MAX(fa.created_at) AS created_at FROM forge_activities fa WHERE fa.project_id IN ("+@user.projects.visible.select('projects.id').map{|p|p.id}.join(',')+") GROUP BY fa.project_id) AS p ").map{|p|p.project_id}.join(",")+")"
@projects=Project.where("projects.id in #{project_order_ids}").order("#{sort_name}#{sort_type}")
else
@projects=[]
end
@projects=@user.projects.visible.select("projects.*, (SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a #{sort_type}")
ifShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count==0
count=ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count
@ -108,7 +109,8 @@ class HomeworkCommon < ActiveRecord::Base
#修改作业后发送微信模板消息
defwechat_message
self.course.members.eachdo|member|
ifShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count==0
count=ShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
@ -162,7 +162,7 @@ class Issue < ActiveRecord::Base
end
self.project.members.eachdo|m|
count=ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project_id}").count
ifself.jour_type=='HomeworkCommon'&&ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count==0
count=ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count
ifShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count==0
count=ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count
count=ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project.id}").count
ifShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count==0
count=ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count
var coursecount = <%= @user.courses.visible.count%>;
var coursecount = <%= @user.courses.visible.where("is_delete =?", 0).select("courses.* FROM `course_activities` WHERE course_activities.course_id = courses.id) ").count%>;
var courseshowcount = document.getElementsByClassName("coursesLineGrey").length;
<div class = "leftCoursesList" id="homepageLeftMenuCourses">
@ -258,7 +258,7 @@
end
%>
<% projects = @user.projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%>
<% projects = @user.projects.visible.select("projects.*, (SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %>
<% student_works = activity.student_works.select("student_works.*,student_works.work_score as score").where("student_works.id in #{ids}").order("score desc") %>
<% else %>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %>
<% student_works = activity.student_works.select("student_works.*,student_works.work_score as score").order("score desc") %>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %>
<% student_works = activity.student_works.select("student_works.*,student_works.work_score as score").where("student_works.id in #{ids}").order("score desc") %>
<% else %>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %>
<% student_works = activity.student_works.select("student_works.*,student_works.work_score as score").order("score desc") %>
<% end %>
<% student_works.includes(:user).each_with_index do |sw, i| %>
<% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %>
<% student_works = homework_common.student_works.select("student_works.*,student_works.work_score as score").where("student_works.id in #{ids}").order("score desc") %>
<% else %>
<% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %>
<% student_works = homework_common.student_works.select("student_works.*,student_works.work_score as score").order("score desc") %>
<% end %>
<% student_works.includes(:user).each_with_index do |sw, i| %>