@ -469,6 +471,23 @@ class AdminController < ApplicationController
end
end
end
end
#最近登录老师列表
deflatest_login_teachers
scope=User.find_by_sql("SELECT * FROM users,user_extensions WHERE users.id = user_extensions.user_id AND user_extensions.identity=0 ORDER BY last_login_on DESC")
ifparams[:startdate].present?
scope=User.find_by_sql("SELECT * FROM users,user_extensions WHERE users.id = user_extensions.user_id AND user_extensions.identity=0 and last_login_on>= '#{params[:startdate]} 00:00:00' ORDER BY last_login_on DESC")
end
ifparams[:enddate].present?
scope=User.find_by_sql("SELECT * FROM users,user_extensions WHERE users.id = user_extensions.user_id AND user_extensions.identity=0 and last_login_on <= '#{params[:enddate]} 23:59:59' ORDER BY last_login_on DESC")
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name
@stundet_works=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id=>pro.student_work_id)
end
else
else
@stundet_works=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id=>pro.student_work_id)
@stundet_works=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id =>User.current.id)
@stundet_works=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
my_work=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id=>pro.student_work_id)
my_work=[]
end
else
else
my_work=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id=>pro.student_work_id)
my_work=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
end
ifmy_work.empty?
@stundet_works=[]
else
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name
@show_all=true
end
end
else
else
my_work=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
end
ifmy_work.empty?
@stundet_works=[]
@stundet_works=[]
else
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name
@show_all=true
end
end
else
else
@stundet_works=[]
render_403
return
end
end
@student_work_count=(search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name).count
@student_work_count=(search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name).count
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order}#{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order}#{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order}#{@b_sort}"),@name
@stundet_works=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id=>pro.student_work_id)
end
else
else
@stundet_works=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id=>pro.student_work_id)
@stundet_works=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id =>User.current.id)
@stundet_works=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
my_work=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id=>pro.student_work_id)
my_work=[]
end
else
else
my_work=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id=>pro.student_work_id)
my_work=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
end
ifmy_work.empty?
@stundet_works=[]
else
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order}#{@b_sort}"),@name
@show_all=true
end
end
else
else
my_work=@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
end
ifmy_work.empty?
@stundet_works=[]
@stundet_works=[]
else
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order}#{@b_sort}"),@name
@show_all=true
end
end
else
else
@stundet_works=[]
render_403
return
end
end
@student_work_count=(search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order}#{@b_sort}"),@name).count
@student_work_count=(search_homework_member@homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order}#{@b_sort}"),@name).count
end
end
@ -802,6 +821,10 @@ class StudentWorkController < ApplicationController
@course=@user.courses.where("#{Course.table_name}.id != #{homework.course_id} and #{Course.table_name}.id = #{params[:search].to_i} or #{Course.table_name}.name like :p",:p=>search).select{|course|@user.allowed_to?(:as_teacher,course)}
@homeworks=HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc")
all_homeworks=HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'")
@homeworks=HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%' or user_id in #{user_ids})").order("created_at desc")
elsifparams[:type]=="2"#课程资源
elsifparams[:type]=="2"#课程资源
@homeworks=HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc")
@homeworks=HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc")
@attachments=Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')})) ").order("created_on desc")
@ -728,6 +855,8 @@ class UsersController < ApplicationController
@attachments=Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc")
@attachments=Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc")
elsifparams[:type]=="5"#用户资源
elsifparams[:type]=="5"#用户资源
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
elsifparams[:type]=="6"#公共资源
@attachments=Attachment.where("(is_public =1 and is_publish = 1 and container_id is not null)"+"or (author_id = #{params[:id]} and is_publish = 0)").order("created_on desc")
end
end
@type=params[:type]
@type=params[:type]
@limit=7
@limit=7
@ -768,7 +897,7 @@ class UsersController < ApplicationController
@user_activities=UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})"+
@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 = '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 = '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)
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page*10)
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)
# @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 = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}))").order("created_on desc")
@attachments=get_principal_resourcesparams[:id]
end
elsifparams[:type]=="2"#课程资源
ifUser.current.id.to_i==params[:id].to_i
user_course_ids=User.current.courses.map{|c|c.id}
@attachments=Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')})) ").order("created_on desc")
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}))").order("created_on desc")
end
elsifparams[:type]=="3"#项目资源
ifUser.current.id.to_i==params[:id].to_i
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
else
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc")
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}))").order("created_on desc")
end
elsifparams[:type]=="2"#课程资源
ifUser.current.id.to_i==params[:id].to_i
user_course_ids=User.current.courses.map{|c|c.id}
@attachments=Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')})) ").order("created_on desc")
@attachments=Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}))").order("created_on desc")
end
elsifparams[:type]=="3"#项目资源
ifUser.current.id.to_i==params[:id].to_i
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
else
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc")
attachments=Attachment.where("(is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)"+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty??'0':user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)").order("created_on desc")
attachments=Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)"+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty??'0':user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)").order("created_on desc")
end
# 获取我的课程资源
defget_course_resourcesauthor_id,user_course_ids
attchments=Attachment.where("(author_id = #{author_id} and container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc")
end
# 获取公共资源课程
defget_course_resources_publicuser_course_ids
attchments=Attachment.where("(container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc")
attchments=Attachment.where("(author_id = #{author_id} and container_type = 'Project') or (container_type = 'Course' and container_id in (#{user_project_ids.empty??'0':user_project_ids.join(',')}) and is_publish = 1) ").order("created_on desc")
end
# 获取公共资源的项目资源
defget_project_resources_publicuser_project_ids
attchments=Attachment.where("(container_type = 'Project') or (container_type = 'Project' and container_id in (#{user_project_ids.empty??'0':user_project_ids.join(',')}) and is_publish = 1) ").order("created_on desc")
end
# 获取我上传的附件
defget_attch_resourcesauthor_id
attchments=Attachment.where("author_id = #{author_id} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc")
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1)").order("created_on desc")
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1)").order("created_on desc")
elsifparams[:status]=="4"
end
@attachments=get_attch_resourcesparams[:id]
elsifparams[:type]=="2"#课程资源
elsifparams[:status]=="5"
ifUser.current.id.to_i==params[:id].to_i
@attachments=get_principal_resourcesparams[:id]
user_course_ids=User.current.courses.map{|c|c.id}
@attachments=Attachment.where("(author_id = #{params[:id]} and container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc")
@attachments=Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course' and is_publish = 1)"+
"or (container_type = 'Course' and is_public = 1 and is_publish = 1 and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}))").order("created_on desc")
end
elsifparams[:type]=="3"#项目资源
ifUser.current.id.to_i==params[:id].to_i
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
else
else
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc")
@attachments=Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)"+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty??'0':user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)",:p=>search).order("created_on desc")
@attachments=Attachment.where("((author_id = #{params[:id]} and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
@attachments=Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
" or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}))) and (filename like :p) ",:p=>search).order("created_on desc")
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)"+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty??'0':user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)",:p=>search).order("created_on desc")
@attachments=Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in"+
@attachments=Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in"+
@ -2273,6 +2599,11 @@ class UsersController < ApplicationController
else
else
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like :p)",:p=>search).order("created_on desc")
@attachments=Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like :p)",:p=>search).order("created_on desc")
end
end
elsifparams[:type]=="6"#全部资源
# 公共资源库:所有公开资源或者我上传的私有资源
@attachments=Attachment.where("((is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)"+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty??'0':user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)",:p=>search).order("created_on desc")
<% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %>
<% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %>