absence_penalty_count=student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count-student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
absence_penalty_count=student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count-student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
Attachment.where("container_id is not null and container_type is not null and container_type <> 'Bid' and container_type <> 'HomeworkAttach'").eachdo|attachment|
@stundet_works=search_homework_member@homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order}#{@b_sort}"),@name
my_work=@homework.student_works.select("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
@stundet_works=search_homework_member@homework.student_works.select("*,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("*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id=>User.current.id)
@ -120,17 +120,17 @@ class Mailer < ActionMailer::Base
count=courses.count
count=count-1
foriin0..countdo
bids=courses[i].homework_commons.where("homework_commons.created_at between '#{date_from}' and '#{date_to}'").order("homework_commons.created_at desc")
attachments=courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'").order('attachments.created_on DESC')
bids=courses[i].homework_commons.where("homework_commons.created_at between '#{date_from}' and '#{date_to}'").order(" '#{courses[i].id}', homework_commons.created_at desc")
attachments=courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'").order(" '#{courses[i].id}',attachments.created_on DESC' ")
@bids+=bidsifbids.count>0
@attachments+=attachmentsifattachments.count>0
end
@bids.sort{|a,b|a.created_at<=>b.created_at}
# @bids = @bids.sort_by { |obj| obj.created_at }
end
# 项目附件
@project_attachments=Attachment.find_by_sql("select DISTINCT a.* from members m, attachments a
# messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
@course_messages||=[]
@project_messages||=[]
@ -168,31 +168,31 @@ class Mailer < ActionMailer::Base
# 查询user在课程中发布的通知和回复通知
@course_news=(course_ids&&!course_ids.empty?)?News.find_by_sql("select DISTINCT n.* from news n
@user_journal_messages=user.journals_for_messages.where("jour_type='Principal' and (created_on between '#{date_from}' and '#{date_to}')").order('created_on DESC')
# 查询user在项目中留言(用户反馈)
@project_journal_messages=JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, projects p
@forums=Forum.find_by_sql("select DISTINCT * from forums where creator_id = #{user.id} and (created_at between '#{date_from}' and '#{date_to}') order by created_at desc")
sql="select users.*,sum(IFNULL(0,student_works.final_score))/#{homework_count} score from student_works left outer join users on student_works.user_id = users.id"<<
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{course.id}) GROUP BY student_works.user_id ORDER BY score limit 0,6"
sql="select users.*,sum(IFNULL(0,student_works.final_score))/#{homework_count} score from student_works left outer join users on student_works.user_id = users.id"<<
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{params[:course_id]}) GROUP BY student_works.user_id ORDER BY score limit #{page*10},10"