班级的统计模块显示“活跃度”、“英雄榜”、“项目活跃度”(单个作业的过滤未完成)
This commit is contained in:
parent
61d6a6a7c3
commit
e4ebd4dd2c
|
@ -1373,21 +1373,34 @@ class CoursesController < ApplicationController
|
||||||
#统计
|
#统计
|
||||||
def course_statistics
|
def course_statistics
|
||||||
@left_nav_type = 10
|
@left_nav_type = 10
|
||||||
# @order = params[:order] ? params[:order] : 'desc'
|
@order = params[:order] ? params[:order] : 'desc'
|
||||||
# if !params[:tab] || params[:tab] == "activity"
|
@tab = params[:tab] ? params[:tab].to_i : nil
|
||||||
# @type = params[:type] ? params[:type] : 'act_score'
|
if !params[:tab] || params[:tab] == "1"
|
||||||
# sql = "SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 + resource_num*5 + journal_num*1 + homework_journal_num*1) AS act_score,
|
@type = params[:type] ? params[:type] : 'act_score'
|
||||||
# message_num, message_reply_num, news_reply_num, news_num, resource_num, journal_num, homework_journal_num, ccs.user_id FROM course_contributor_scores ccs
|
sql = "SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 + resource_num*5 + journal_num*1 + homework_journal_num*1) AS act_score,
|
||||||
# JOIN students_for_courses ON students_for_courses.course_id = ccs.course_id AND students_for_courses.student_id = ccs.user_id
|
message_num, message_reply_num, news_reply_num, news_num, resource_num, journal_num, homework_journal_num, ccs.user_id FROM course_contributor_scores ccs
|
||||||
# WHERE ccs.course_id = #{@course.id} HAVING act_score != 0 ORDER BY #{@type} #{@order}, act_score #{@order}"
|
JOIN students_for_courses ON students_for_courses.course_id = ccs.course_id AND students_for_courses.student_id = ccs.user_id
|
||||||
# @members = CourseContributorScore.find_by_sql(sql)
|
WHERE ccs.course_id = #{@course.id} HAVING act_score != 0 ORDER BY #{@type} #{@order}, act_score #{@order}"
|
||||||
# end
|
@members = CourseContributorScore.find_by_sql(sql)
|
||||||
#
|
|
||||||
# @limit = 20
|
elsif params[:tab] == "2"
|
||||||
# @page = params[:page].nil? ? 1 : params['page'].to_i
|
@type = params[:type] ? params[:type] : 'total_score'
|
||||||
# @members_count = @members.count
|
@members = @course.course_homework_statisticss.reorder("#{@type} #{@order}, total_score #{@order}")
|
||||||
# @mem_pages = Paginator.new @members_count, @limit, @page
|
|
||||||
# @members = paginateHelper @members, @limit
|
elsif params[:tab] == "3"
|
||||||
|
@type = params[:type] ? params[:type] : 'project_act_score'
|
||||||
|
sql = "SELECT (IFNULL(changeset_num, 0)*4 + issue_num*4 + issue_journal_num*1 + attach_num*5 + board_num*2 + board_message_num*1) AS project_act_score,
|
||||||
|
changeset_num, issue_num, issue_journal_num, attach_num, board_num, board_message_num, pss.project_id FROM project_scores pss
|
||||||
|
JOIN student_work_projects ON student_work_projects.project_id = pss.project_id AND student_work_projects.course_id = #{@course.id}
|
||||||
|
GROUP BY pss.project_id ORDER BY #{@type} #{@order}, project_act_score #{@order}"
|
||||||
|
@members = ProjectScore.find_by_sql(sql)
|
||||||
|
end
|
||||||
|
|
||||||
|
@limit = 20
|
||||||
|
@page = params[:page].nil? ? 1 : params['page'].to_i
|
||||||
|
@members_count = @members.count
|
||||||
|
@mem_pages = Paginator.new @members_count, @limit, @page
|
||||||
|
@members = paginateHelper @members, @limit
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
format.html {render :layout => 'base_courses'}
|
format.html {render :layout => 'base_courses'}
|
||||||
|
|
|
@ -97,6 +97,9 @@ class HomeworkCommonController < ApplicationController
|
||||||
st.late_penalty = @homework.late_penalty
|
st.late_penalty = @homework.late_penalty
|
||||||
st.work_status = 2
|
st.work_status = 2
|
||||||
st.save
|
st.save
|
||||||
|
#更新CourseHomeworkStatistics中学生的迟交作品数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, st.user_id)
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -105,6 +108,9 @@ class HomeworkCommonController < ApplicationController
|
||||||
st.late_penalty = 0
|
st.late_penalty = 0
|
||||||
st.work_status = 1
|
st.work_status = 1
|
||||||
st.save
|
st.save
|
||||||
|
#更新CourseHomeworkStatistics中学生的迟交作品数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, st.user_id)
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -134,9 +140,22 @@ class HomeworkCommonController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
status = false
|
status = false
|
||||||
if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
|
if @homework.publish_time > Date.today && homework_detail_manual.comment_status == 1
|
||||||
|
homework_detail_manual.comment_status = 0
|
||||||
|
@homework.student_works.destroy_all
|
||||||
|
#更新CourseHomeworkStatistics中每个学生的未交作品数
|
||||||
|
@homework.course.student.each do |student|
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
|
||||||
|
end
|
||||||
|
elsif @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
|
||||||
homework_detail_manual.comment_status = 1
|
homework_detail_manual.comment_status = 1
|
||||||
status = true
|
status = true
|
||||||
|
#更新CourseHomeworkStatistics中每个学生的未交作品数
|
||||||
|
@homework.course.student.each do |student|
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||||
|
end
|
||||||
end
|
end
|
||||||
eval_start = homework_detail_manual.evaluation_start
|
eval_start = homework_detail_manual.evaluation_start
|
||||||
if eval_start.nil? || (eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1)
|
if eval_start.nil? || (eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1)
|
||||||
|
@ -216,6 +235,36 @@ class HomeworkCommonController < ApplicationController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if @homework.destroy
|
if @homework.destroy
|
||||||
|
#更新CourseHomeworkStatistics中每个学生的未交作品数、已交作品数、迟交作品数
|
||||||
|
hw_count = @course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").count
|
||||||
|
homework_ids = @course.homework_commons.empty? ? "(-1)" : "(" + @course.homework_commons.map{|hw| hw.id}.join(",") + ")"
|
||||||
|
student_works = StudentWork.where("homework_common_id in #{homework_ids} and work_status !=0")
|
||||||
|
is_eva_homeworks = @course.homework_commons.includes(:homework_detail_manual).where("homework_commons.anonymous_comment = 0 and homework_detail_manuals.comment_status = 2")
|
||||||
|
is_eva_student_works = StudentWork.where(:homework_common_id => is_eva_homeworks.map{|hw| hw.id})
|
||||||
|
has_eva_homeworks = @course.homework_commons.includes(:homework_detail_manual).where("homework_commons.anonymous_comment = 0 and homework_detail_manuals.comment_status = 3")
|
||||||
|
has_eva_student_works = StudentWork.where(:homework_common_id => has_eva_homeworks.map{|hw| hw.id})
|
||||||
|
@course.student.each do |student|
|
||||||
|
user = student.student
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student.student_id)
|
||||||
|
if user && course_statistics
|
||||||
|
committed_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status != 0").count
|
||||||
|
un_commit_work_num = (hw_count - committed_work_num) < 0 ? 0 : (hw_count - committed_work_num)
|
||||||
|
late_commit_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status = 2").count
|
||||||
|
absence_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => has_eva_student_works.map(&:id)).count -
|
||||||
|
user.student_works_scores.where(:reviewer_role => 3, :student_work_id => has_eva_student_works.map(&:id)).group_by(&:student_work_id).count
|
||||||
|
absence_evaluation_work_num = absence_evaluation_work_num < 0 ? 0 : absence_evaluation_work_num
|
||||||
|
un_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => is_eva_student_works.map(&:id)).count -
|
||||||
|
user.student_works_scores.where(:reviewer_role => 3, :student_work_id => is_eva_student_works.map(&:id)).group_by(&:student_work_id).count
|
||||||
|
un_evaluation_work_num = un_evaluation_work_num < 0 ? 0 : un_evaluation_work_num
|
||||||
|
appeal_num = user.student_works_scores.where(:student_work_id => student_works.map(&:id), :appeal_status => 3).count
|
||||||
|
average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0
|
||||||
|
total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
|
||||||
|
course_statistics.update_attributes(:committed_work_num => committed_work_num, :un_commit_work_num => un_commit_work_num,
|
||||||
|
:late_commit_work_num => late_commit_work_num, :absence_evaluation_work_num => absence_evaluation_work_num, :un_evaluation_work_num => un_evaluation_work_num,
|
||||||
|
:appeal_num => appeal_num, :average_score => average_score, :total_score => total_score)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
@hw_status = params[:hw_status].to_i
|
@hw_status = params[:hw_status].to_i
|
||||||
|
@ -272,6 +321,10 @@ class HomeworkCommonController < ApplicationController
|
||||||
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
|
||||||
student_works_evaluation_distributions.save
|
student_works_evaluation_distributions.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中该学生的待匿评数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, pro_work.user_id)
|
||||||
|
course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
student_works.each_with_index do |work, index|
|
student_works.each_with_index do |work, index|
|
||||||
|
@ -283,6 +336,10 @@ class HomeworkCommonController < ApplicationController
|
||||||
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
|
||||||
student_works_evaluation_distributions.save
|
student_works_evaluation_distributions.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中该学生的待匿评数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, user.id)
|
||||||
|
course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@homework_detail_manual.update_column('comment_status', 2)
|
@homework_detail_manual.update_column('comment_status', 2)
|
||||||
|
@ -315,6 +372,11 @@ class HomeworkCommonController < ApplicationController
|
||||||
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} and reviewer_role = 3").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} and reviewer_role = 3").count
|
||||||
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
|
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
|
||||||
student_work.save
|
student_work.save
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中该学生的待匿评数和缺评数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student_work.user_id)
|
||||||
|
course_statistics.update_attribute('un_evaluation_work_num', (course_statistics.un_evaluation_work_num - absence_penalty_count) < 0 ? 0 : (course_statistics.un_evaluation_work_num - absence_penalty_count)) if course_statistics
|
||||||
|
course_statistics.update_attribute('absence_evaluation_work_num', course_statistics.absence_evaluation_work_num + absence_penalty_count) if course_statistics
|
||||||
end
|
end
|
||||||
|
|
||||||
# 未参与匿评的缺评计算
|
# 未参与匿评的缺评计算
|
||||||
|
|
|
@ -607,11 +607,20 @@ class StudentWorkController < ApplicationController
|
||||||
anon_count = all_dis_eva.count / has_sw_count
|
anon_count = all_dis_eva.count / has_sw_count
|
||||||
student_work.absence_penalty = @homework.homework_detail_manual.absence_penalty * anon_count
|
student_work.absence_penalty = @homework.homework_detail_manual.absence_penalty * anon_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中学生的迟交作品数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, User.current.id)
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
|
||||||
else
|
else
|
||||||
student_work.late_penalty = 0
|
student_work.late_penalty = 0
|
||||||
student_work.work_status = 1
|
student_work.work_status = 1
|
||||||
end
|
end
|
||||||
if student_work.save
|
if student_work.save
|
||||||
|
#更新CourseHomeworkStatistics中学生的未交作品数、已交作品数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, User.current.id)
|
||||||
|
course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
|
||||||
|
|
||||||
if @homework.homework_type == 3
|
if @homework.homework_type == 3
|
||||||
if @homework.homework_detail_group.base_on_project == 1
|
if @homework.homework_detail_group.base_on_project == 1
|
||||||
@student_work_project.student_work_id = student_work.id
|
@student_work_project.student_work_id = student_work.id
|
||||||
|
@ -627,6 +636,14 @@ class StudentWorkController < ApplicationController
|
||||||
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => student_work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => members[i].to_i, :is_leader => 0, :course_id => @homework.course_id)
|
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => student_work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => members[i].to_i, :is_leader => 0, :course_id => @homework.course_id)
|
||||||
stu_project.save
|
stu_project.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中学生的未交作品数、已交作品数、迟交作品数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, members[i].to_i)
|
||||||
|
course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
|
||||||
|
if student_work.work_status == 2
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@homework.update_column(:updated_at, Time.now)
|
@homework.update_column(:updated_at, Time.now)
|
||||||
|
@ -676,6 +693,14 @@ class StudentWorkController < ApplicationController
|
||||||
student_work_projects = @homework.student_work_projects.where("student_work_id=? and is_leader =?",@work.id,0)
|
student_work_projects = @homework.student_work_projects.where("student_work_id=? and is_leader =?",@work.id,0)
|
||||||
user_ids = student_work_projects.empty? ? "(-1)" : "(" + student_work_projects.map{|stu|stu.user_id}.join(",") + ")"
|
user_ids = student_work_projects.empty? ? "(-1)" : "(" + student_work_projects.map{|stu|stu.user_id}.join(",") + ")"
|
||||||
student_works = @homework.student_works.where("user_id in #{user_ids}")
|
student_works = @homework.student_works.where("user_id in #{user_ids}")
|
||||||
|
student_works.each do |sw|
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, sw.user_id)
|
||||||
|
if @work.work_status == 2
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
|
||||||
|
end
|
||||||
|
course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||||
|
end
|
||||||
student_works.delete_all
|
student_works.delete_all
|
||||||
student_work_projects.delete_all
|
student_work_projects.delete_all
|
||||||
members = params[:group_member_ids].split(',')
|
members = params[:group_member_ids].split(',')
|
||||||
|
@ -685,6 +710,14 @@ class StudentWorkController < ApplicationController
|
||||||
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => @work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => members[i].to_i, :is_leader => 0, :course_id => @homework.course_id)
|
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => @work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => members[i].to_i, :is_leader => 0, :course_id => @homework.course_id)
|
||||||
stu_project.save
|
stu_project.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中学生的未交作品数、已交作品数、迟交作品数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, members[i].to_i)
|
||||||
|
course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
|
||||||
|
if @work.work_status == 2
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -736,6 +769,16 @@ class StudentWorkController < ApplicationController
|
||||||
pros = @work.student_work_projects.where("is_leader = 0")
|
pros = @work.student_work_projects.where("is_leader = 0")
|
||||||
user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
|
user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
|
||||||
student_works = @homework.student_works.where("user_id in #{user_ids}")
|
student_works = @homework.student_works.where("user_id in #{user_ids}")
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中每个学生的未交作品数、已交作品数、迟交作品数
|
||||||
|
student_works.each do |sw|
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, sw.user_id)
|
||||||
|
if @work.work_status == 2
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
|
||||||
|
end
|
||||||
|
course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||||
|
end
|
||||||
student_works.delete_all
|
student_works.delete_all
|
||||||
pros.delete_all
|
pros.delete_all
|
||||||
|
|
||||||
|
@ -747,6 +790,14 @@ class StudentWorkController < ApplicationController
|
||||||
end
|
end
|
||||||
@work.destroy
|
@work.destroy
|
||||||
else
|
else
|
||||||
|
#更新CourseHomeworkStatistics中学生的已交作品数、迟交作品数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
|
||||||
|
if @work.work_status == 2
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
|
||||||
|
end
|
||||||
|
course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||||
|
|
||||||
@work.attachments.destroy_all
|
@work.attachments.destroy_all
|
||||||
@work.student_works_scores.destroy_all
|
@work.student_works_scores.destroy_all
|
||||||
@work.course_messages.destroy_all
|
@work.course_messages.destroy_all
|
||||||
|
@ -762,20 +813,44 @@ class StudentWorkController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_work
|
def delete_work
|
||||||
@work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first
|
@work = StudentWork.where("user_id =? and homework_common_id =? and work_status != 0", User.current.id, @homework.id).first
|
||||||
if @work
|
if @work
|
||||||
@work.destroy
|
if @homework.homework_type == 3
|
||||||
if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
|
|
||||||
pros = @work.student_work_projects.where("is_leader = 0")
|
pros = @work.student_work_projects.where("is_leader = 0")
|
||||||
pros.each do |pro|
|
user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
|
||||||
pro.destroy
|
student_works = @homework.student_works.where("user_id in #{user_ids}")
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中每个学生的已交作品数、迟交作品数
|
||||||
|
student_works.each do |sw|
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, sw.user_id)
|
||||||
|
if @work.work_status == 2
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
|
||||||
|
end
|
||||||
|
course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||||
end
|
end
|
||||||
|
student_works.delete_all
|
||||||
|
pros.delete_all
|
||||||
|
|
||||||
project = @work.student_work_projects.where("is_leader = 1").first
|
project = @work.student_work_projects.where("is_leader = 1").first
|
||||||
project.update_attributes(:student_work_id => nil)
|
if @homework.homework_detail_group.base_on_project == 1
|
||||||
elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
|
project.update_attributes(:student_work_id => nil)
|
||||||
@work.student_work_projects.each do |pro2|
|
else
|
||||||
pro2.destroy
|
project.destroy
|
||||||
end
|
end
|
||||||
|
@work.destroy
|
||||||
|
else
|
||||||
|
#更新CourseHomeworkStatistics中学生的已交作品数、迟交作品数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
|
||||||
|
if @work.work_status == 2
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
|
||||||
|
end
|
||||||
|
course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||||
|
|
||||||
|
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil, :project_id => 0)
|
||||||
|
@work.attachments.destroy_all
|
||||||
|
@work.course_messages.destroy_all
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect_to student_work_index_path(:homework => @homework.id)
|
redirect_to student_work_index_path(:homework => @homework.id)
|
||||||
|
@ -786,6 +861,16 @@ class StudentWorkController < ApplicationController
|
||||||
pros = @work.student_work_projects.where("is_leader = 0")
|
pros = @work.student_work_projects.where("is_leader = 0")
|
||||||
user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
|
user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
|
||||||
student_works = @homework.student_works.where("user_id in #{user_ids}")
|
student_works = @homework.student_works.where("user_id in #{user_ids}")
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中每个学生的已交作品数、迟交作品数
|
||||||
|
student_works.each do |sw|
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, sw.user_id)
|
||||||
|
if @work.work_status == 2
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
|
||||||
|
end
|
||||||
|
course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||||
|
end
|
||||||
student_works.delete_all
|
student_works.delete_all
|
||||||
pros.delete_all
|
pros.delete_all
|
||||||
|
|
||||||
|
@ -797,6 +882,14 @@ class StudentWorkController < ApplicationController
|
||||||
end
|
end
|
||||||
@work.destroy
|
@work.destroy
|
||||||
else
|
else
|
||||||
|
#更新CourseHomeworkStatistics中学生的已交作品数、迟交作品数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
|
||||||
|
if @work.work_status == 2
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
|
||||||
|
end
|
||||||
|
course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||||
|
|
||||||
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil, :project_id => 0)
|
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil, :project_id => 0)
|
||||||
@work.attachments.destroy_all
|
@work.attachments.destroy_all
|
||||||
@work.course_messages.destroy_all
|
@work.course_messages.destroy_all
|
||||||
|
@ -835,6 +928,10 @@ class StudentWorkController < ApplicationController
|
||||||
@new_score.student_work_id = @work.id
|
@new_score.student_work_id = @work.id
|
||||||
if @is_teacher && !@new_score.score.nil? && @work.work_status == 0
|
if @is_teacher && !@new_score.score.nil? && @work.work_status == 0
|
||||||
@work.update_attributes(:work_status => 1, :commit_time => Time.now)
|
@work.update_attributes(:work_status => 1, :commit_time => Time.now)
|
||||||
|
#更新CourseHomeworkStatistics中学生的已交作品数、未交作品数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, @work.user_id)
|
||||||
|
course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
|
||||||
end
|
end
|
||||||
if User.current.admin?
|
if User.current.admin?
|
||||||
@new_score.reviewer_role = 1
|
@new_score.reviewer_role = 1
|
||||||
|
@ -884,7 +981,13 @@ class StudentWorkController < ApplicationController
|
||||||
if @is_group_leader
|
if @is_group_leader
|
||||||
add_score_to_member @work, @homework, @new_score
|
add_score_to_member @work, @homework, @new_score
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
#更新CourseHomeworkStatistics中该学生的待匿评数, 只计算第一次评分
|
||||||
|
if User.current.student_works_scores.where(:student_work_id => @work.id, :reviewer_role => 3).count == 1
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, student_work.user_id)
|
||||||
|
course_statistics.update_attribute('un_evaluation_work_num', (course_statistics.un_evaluation_work_num - 1) < 0 ? 0 : (course_statistics.un_evaluation_work_num - 1)) if course_statistics
|
||||||
|
end
|
||||||
|
end
|
||||||
@homework.update_column('updated_at', Time.now)
|
@homework.update_column('updated_at', Time.now)
|
||||||
update_course_activity(@homework.class,@homework.id)
|
update_course_activity(@homework.class,@homework.id)
|
||||||
update_user_activity(@homework.class,@homework.id)
|
update_user_activity(@homework.class,@homework.id)
|
||||||
|
@ -1178,11 +1281,18 @@ class StudentWorkController < ApplicationController
|
||||||
score_appeal.applied_messages.update_all(:status => params[:status].to_i == 2 ? 3 : (params[:status].to_i == 3 ? 1 : 2))
|
score_appeal.applied_messages.update_all(:status => params[:status].to_i == 2 ? 3 : (params[:status].to_i == 3 ? 1 : 2))
|
||||||
if params[:status].to_i == 3 || params[:status].to_i == 4
|
if params[:status].to_i == 3 || params[:status].to_i == 4
|
||||||
homework = @student_work_score.student_work.homework_common
|
homework = @student_work_score.student_work.homework_common
|
||||||
|
course = homework.course
|
||||||
if params[:status].to_i == 3
|
if params[:status].to_i == 3
|
||||||
# 申诉成功后 扣匿评学生的违规匿评扣分
|
# 申诉成功后 扣匿评学生的违规匿评扣分
|
||||||
sw = homework.student_works.where("user_id = #{@student_work_score.user_id}").first
|
sw = homework.student_works.where("user_id = #{@student_work_score.user_id}").first
|
||||||
sw.update_attribute("appeal_penalty", homework.homework_detail_manual.appeal_penalty + sw.appeal_penalty)
|
sw.update_attribute("appeal_penalty", homework.homework_detail_manual.appeal_penalty + sw.appeal_penalty)
|
||||||
|
|
||||||
|
#申诉成功,匿评学生的被申诉记录加一
|
||||||
|
course_homework_statistics = CourseHomeworkStatistics.where(:user_id => @student_work_score.user_id, :course_id => course.id).first
|
||||||
|
if course_homework_statistics
|
||||||
|
course_homework_statistics.update_attribute('appeal_num', course_homework_statistics.appeal_num + 1)
|
||||||
|
end
|
||||||
|
|
||||||
# 申诉成功 重新计算申诉者的匿评分
|
# 申诉成功 重新计算申诉者的匿评分
|
||||||
work = @student_work_score.student_work
|
work = @student_work_score.student_work
|
||||||
if work.student_works_scores.where("reviewer_role = 3 AND appeal_status != 3").count > 0
|
if work.student_works_scores.where("reviewer_role = 3 AND appeal_status != 3").count > 0
|
||||||
|
@ -1193,7 +1303,6 @@ class StudentWorkController < ApplicationController
|
||||||
end
|
end
|
||||||
@student_work_score.student_work.save
|
@student_work_score.student_work.save
|
||||||
end
|
end
|
||||||
course = homework.course
|
|
||||||
CourseMessage.create(:user_id => @student_work_score.user_id, :course_id => course.id, :viewed => false,:course_message_id=> score_appeal.id,:course_message_type=>'StudentWorksScoresAppeal',:status=>params[:status].to_i,:apply_result =>User.current.id)
|
CourseMessage.create(:user_id => @student_work_score.user_id, :course_id => course.id, :viewed => false,:course_message_id=> score_appeal.id,:course_message_type=>'StudentWorksScoresAppeal',:status=>params[:status].to_i,:apply_result =>User.current.id)
|
||||||
CourseMessage.create(:user_id => score_appeal.user_id, :course_id => course.id, :viewed => false,:course_message_id=> score_appeal.id,:course_message_type=>'StudentWorksScoresAppeal',:status=>params[:status].to_i,:apply_result =>User.current.id)
|
CourseMessage.create(:user_id => score_appeal.user_id, :course_id => course.id, :viewed => false,:course_message_id=> score_appeal.id,:course_message_type=>'StudentWorksScoresAppeal',:status=>params[:status].to_i,:apply_result =>User.current.id)
|
||||||
end
|
end
|
||||||
|
@ -1368,6 +1477,14 @@ class StudentWorkController < ApplicationController
|
||||||
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => student_work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => params[:member_id][i].to_i, :is_leader => 0, :course_id => @homework.course_id)
|
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => student_work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => params[:member_id][i].to_i, :is_leader => 0, :course_id => @homework.course_id)
|
||||||
stu_project.save
|
stu_project.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中学生的未交作品数、已交作品数、迟交作品数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, params[:member_id][i].to_i)
|
||||||
|
course_statistics.update_attribute('committed_work_num', course_statistics.committed_work_num + 1) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', (course_statistics.un_commit_work_num - 1) < 0 ? 0 : (course_statistics.un_commit_work_num - 1)) if course_statistics
|
||||||
|
if student_work.work_status == 2
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', course_statistics.late_commit_work_num + 1) if course_statistics
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1378,6 +1495,14 @@ class StudentWorkController < ApplicationController
|
||||||
work = StudentWork.where("homework_common_id = #{@homework.id} and user_id = #{sp.user_id}").first
|
work = StudentWork.where("homework_common_id = #{@homework.id} and user_id = #{sp.user_id}").first
|
||||||
sp.destroy
|
sp.destroy
|
||||||
if work
|
if work
|
||||||
|
#更新CourseHomeworkStatistics中学生的未交作品数、已交作品数、迟交作品数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(@homework.course_id, work.user_id)
|
||||||
|
if student_work.work_status == 2
|
||||||
|
course_statistics.update_attribute('late_commit_work_num', (course_statistics.late_commit_work_num - 1) < 0 ? 0 : (course_statistics.late_commit_work_num - 1)) if course_statistics
|
||||||
|
end
|
||||||
|
course_statistics.update_attribute('committed_work_num', (course_statistics.committed_work_num - 1) < 0 ? 0 : (course_statistics.committed_work_num - 1)) if course_statistics
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||||
|
|
||||||
work.destroy
|
work.destroy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1373,6 +1373,12 @@ class UsersController < ApplicationController
|
||||||
homework_detail_manual.comment_status = 0
|
homework_detail_manual.comment_status = 0
|
||||||
else
|
else
|
||||||
homework_detail_manual.comment_status = 1
|
homework_detail_manual.comment_status = 1
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中每个学生的未交作品数
|
||||||
|
homework.course.student.each do |student|
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework.course_id, student.student_id)
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||||
|
end
|
||||||
end
|
end
|
||||||
homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? homework.end_time + 7 : params[:evaluation_start]
|
homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? homework.end_time + 7 : params[:evaluation_start]
|
||||||
homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end]
|
homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end]
|
||||||
|
|
|
@ -324,7 +324,7 @@ module ApplicationHelper
|
||||||
# 获取项目/课程总分
|
# 获取项目/课程总分
|
||||||
# 发布缺陷 4分 回复缺陷 1分 提交一次 4分 讨论帖子 2分 回复帖子 1分 发布新闻 1分
|
# 发布缺陷 4分 回复缺陷 1分 提交一次 4分 讨论帖子 2分 回复帖子 1分 发布新闻 1分
|
||||||
def static_project_score obj
|
def static_project_score obj
|
||||||
score = obj.issue_num * 4 + obj.issue_journal_num + (obj.changeset_num||0) * 4 + obj.board_num * 2 + obj.board_message_num + obj.news_num + obj.attach_num * 5
|
score = obj.issue_num * 4 + obj.issue_journal_num + (obj.changeset_num||0) * 4 + obj.board_num * 2 + obj.board_message_num + obj.attach_num * 5
|
||||||
end
|
end
|
||||||
|
|
||||||
# 获取组织成员中文名字
|
# 获取组织成员中文名字
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Course < ActiveRecord::Base
|
||||||
has_many :student_works, :through => :homework_commons, :dependent => :destroy
|
has_many :student_works, :through => :homework_commons, :dependent => :destroy
|
||||||
|
|
||||||
has_many :course_groups, :dependent => :destroy
|
has_many :course_groups, :dependent => :destroy
|
||||||
#has_many :course_homework_statistics, :dependent => :destroy
|
has_many :course_homework_statisticss, :dependent => :destroy
|
||||||
# 课程动态
|
# 课程动态
|
||||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class CourseHomeworkStatistics < ActiveRecord::Base
|
||||||
|
# attr_accessible :title, :body
|
||||||
|
|
||||||
|
belongs_to :user
|
||||||
|
belongs_to :course
|
||||||
|
end
|
|
@ -19,6 +19,7 @@ class StudentWork < ActiveRecord::Base
|
||||||
before_destroy :delete_praise
|
before_destroy :delete_praise
|
||||||
before_save :set_program_score, :set_src
|
before_save :set_program_score, :set_src
|
||||||
|
|
||||||
|
after_save :update_avg_sum_score
|
||||||
after_create :act_as_message
|
after_create :act_as_message
|
||||||
acts_as_attachable
|
acts_as_attachable
|
||||||
|
|
||||||
|
@ -173,6 +174,20 @@ class StudentWork < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新course_homework_statistics中的avg_score和total_score
|
||||||
|
def update_avg_sum_score
|
||||||
|
course_homework_statistics = CourseHomeworkStatistics.where(:user_id => self.user_id, :course_id => self.homework_common.course_id).first
|
||||||
|
if course_homework_statistics
|
||||||
|
course = self.homework_common.course
|
||||||
|
homework_ids = course.homework_commons.empty? ? "(-1)" : "(" + course.homework_commons.map{|hw| hw.id}.join(",") + ")"
|
||||||
|
student_works = StudentWork.where("homework_common_id in #{homework_ids} and work_status !=0")
|
||||||
|
user = self.user
|
||||||
|
average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0
|
||||||
|
total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
|
||||||
|
course_homework_statistics.update_attributes(:average_score => average_score, :total_score => total_score)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# status == 0 : delay
|
# status == 0 : delay
|
||||||
def act_as_message
|
def act_as_message
|
||||||
if self.work_status != 0 && self.created_at > self.homework_common.end_time + 1
|
if self.work_status != 0 && self.created_at > self.homework_common.end_time + 1
|
||||||
|
|
|
@ -40,38 +40,36 @@ class StudentsForCourse < ActiveRecord::Base
|
||||||
|
|
||||||
#加入班级时创建一条记录
|
#加入班级时创建一条记录
|
||||||
def create_course_homework_statistic
|
def create_course_homework_statistic
|
||||||
# if CourseHomeworkStatistic.where(:user_id => self.student_id, :course_id => self.course_id).count == 0
|
if CourseHomeworkStatistic.where(:user_id => self.student_id, :course_id => self.course_id).count == 0
|
||||||
# course = self.course
|
course = self.course
|
||||||
# user = self.student
|
user = self.student
|
||||||
# hw_count = course.homework_commons.count
|
hw_count = course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").count
|
||||||
# homework_ids = course.homework_commons.empty? ? "(-1)" : "(" + course.homework_commons.map{|hw| hw.id}.join(",") + ")"
|
homework_ids = course.homework_commons.empty? ? "(-1)" : "(" + course.homework_commons.map{|hw| hw.id}.join(",") + ")"
|
||||||
# student_works = StudentWork.where("homework_common_id in #{homework_ids}")
|
student_works = StudentWork.where("homework_common_id in #{homework_ids} and work_status !=0")
|
||||||
# is_eva_homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_commons.anonymous_comment = 0 and homework_detail_manuals.comment_status = 2")
|
is_eva_homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_commons.anonymous_comment = 0 and homework_detail_manuals.comment_status = 2")
|
||||||
# is_eva_student_works = StudentWork.where(:homework_common_id => is_eva_homeworks.map{|hw| hw.id})
|
is_eva_student_works = StudentWork.where(:homework_common_id => is_eva_homeworks.map{|hw| hw.id})
|
||||||
# has_eva_homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_commons.anonymous_comment = 0 and homework_detail_manuals.comment_status = 3")
|
has_eva_homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_commons.anonymous_comment = 0 and homework_detail_manuals.comment_status = 3")
|
||||||
# has_eva_student_works = StudentWork.where(:homework_common_id => has_eva_homeworks.map{|hw| hw.id})
|
has_eva_student_works = StudentWork.where(:homework_common_id => has_eva_homeworks.map{|hw| hw.id})
|
||||||
# course.student.each do |student|
|
|
||||||
# user = student.student
|
committed_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status != 0").count
|
||||||
# if user
|
un_commit_work_num = (hw_count - committed_work_num) < 0 ? 0 : (hw_count - committed_work_num)
|
||||||
# committed_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status != 0").count
|
late_commit_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status = 2").count
|
||||||
# un_commit_work_num = hw_count - committed_work_num
|
absence_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => has_eva_student_works.map(&:id)).count -
|
||||||
# late_commit_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status = 2").count
|
user.student_works_scores.where(:reviewer_role => 3, :student_work_id => has_eva_student_works.map(&:id)).group_by(&:student_work_id).count
|
||||||
# absence_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => has_eva_student_works.map(&:id)).count -
|
absence_evaluation_work_num = absence_evaluation_work_num < 0 ? 0 : absence_evaluation_work_num
|
||||||
# user.student_works_scores.where(:reviewer_role => 3, :student_work_id => has_eva_student_works.map(&:id)).group_by(&:student_work_id).count
|
un_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => is_eva_student_works.map(&:id)).count -
|
||||||
# un_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => is_eva_student_works.map(&:id)).count -
|
user.student_works_scores.where(:reviewer_role => 3, :student_work_id => is_eva_student_works.map(&:id)).group_by(&:student_work_id).count
|
||||||
# user.student_works_scores.where(:reviewer_role => 3, :student_work_id => is_eva_student_works.map(&:id)).group_by(&:student_work_id).count
|
un_evaluation_work_num = un_evaluation_work_num < 0 ? 0 : un_evaluation_work_num
|
||||||
# appeal_num = user.student_works_scores.where(:student_work_id => student_works.map(&:id), :appeal_status => 3).count
|
appeal_num = user.student_works_scores.where(:student_work_id => student_works.map(&:id), :appeal_status => 3).count
|
||||||
# average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
|
average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0
|
||||||
# total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
|
total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
|
||||||
# CourseHomeworkStatistic.create(:course_id => course.id, :user_id => user.id, :committed_work_num => committed_work_num, :un_commit_work_num => un_commit_work_num,
|
CourseHomeworkStatistic.create(:course_id => course.id, :user_id => user.id, :committed_work_num => committed_work_num, :un_commit_work_num => un_commit_work_num,
|
||||||
# :late_commit_work_num => late_commit_work_num, :absence_evaluation_work_num => absence_evaluation_work_num, :un_evaluation_work_num => un_evaluation_work_num,
|
:late_commit_work_num => late_commit_work_num, :absence_evaluation_work_num => absence_evaluation_work_num, :un_evaluation_work_num => un_evaluation_work_num,
|
||||||
# :appeal_num => appeal_num, :average_score => average_score, :total_score => total_score)
|
:appeal_num => appeal_num, :average_score => average_score, :total_score => total_score)
|
||||||
# end
|
end
|
||||||
# end
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_course_homework_statistic
|
def delete_course_homework_statistic
|
||||||
#CourseHomeworkStatistic.where(:user_id => self.student_id, :course_id => self.course_id).destroy_all
|
CourseHomeworkStatistic.where(:user_id => self.student_id, :course_id => self.course_id).destroy_all
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -183,7 +183,7 @@ class User < Principal
|
||||||
# 课程贡献榜
|
# 课程贡献榜
|
||||||
has_many :course_contributor_scores, :dependent => :destroy
|
has_many :course_contributor_scores, :dependent => :destroy
|
||||||
|
|
||||||
#has_many :course_homework_statistics, :dependent => :destroy
|
has_many :course_homework_statisticss, :dependent => :destroy
|
||||||
|
|
||||||
######added by nie
|
######added by nie
|
||||||
has_many :project_infos, :dependent => :destroy
|
has_many :project_infos, :dependent => :destroy
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
<p>= <%= (project_score.changeset_num||0) * 4 %>
|
<p>= <%= (project_score.changeset_num||0) * 4 %>
|
||||||
+ <%= project_score.issue_num * 4 + project_score.issue_journal_num %> + <%= project_score.attach_num * 5 %>
|
+ <%= project_score.issue_num * 4 + project_score.issue_journal_num %> + <%= project_score.attach_num * 5 %>
|
||||||
+ <%= project_score.board_num * 2 + project_score.board_message_num + project_score.news_num %></p>
|
+ <%= project_score.board_num * 2 + project_score.board_message_num %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
<p>= <%= (project_score.changeset_num||0) * 4 %>
|
<p>= <%= (project_score.changeset_num||0) * 4 %>
|
||||||
+ <%= project_score.issue_num * 4 + project_score.issue_journal_num %> + <%= project_score.attach_num * 5 %>
|
+ <%= project_score.issue_num * 4 + project_score.issue_journal_num %> + <%= project_score.attach_num * 5 %>
|
||||||
+ <%= project_score.board_num * 2 + project_score.board_message_num + project_score.news_num %></p>
|
+ <%= project_score.board_num * 2 + project_score.board_message_num %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
<% if @members.count != 0 %>
|
||||||
|
<table class="muban_table clearfix mb15 t-center" cellpadding="0" cellspacing="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="table-td-w30" >姓名</th>
|
||||||
|
<th class="table-td-w10">
|
||||||
|
<%= link_to '已交作品', course_statistics_course_path(@course, :tab => 2, :type => 'committed_work_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "committed_work_num" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "committed_work_num" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
<th class="table-td-w10">
|
||||||
|
<%= link_to '未交作品', course_statistics_course_path(@course, :tab => 2, :type => 'un_commit_work_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "un_commit_work_num" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "un_commit_work_num" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
<th class="table-td-w10">
|
||||||
|
<%= link_to '迟交作品', course_statistics_course_path(@course, :tab => 2, :type => 'late_commit_work_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "late_commit_work_num" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "late_commit_work_num" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
<th class="table-td-w10">
|
||||||
|
<%= link_to '匿评缺评', course_statistics_course_path(@course, :tab => 2, :type => 'absence_evaluation_work_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "absence_evaluation_work_num" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "absence_evaluation_work_num" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
<th class="table-td-w10">
|
||||||
|
<%= link_to '被申诉', course_statistics_course_path(@course, :tab => 2, :type => 'appeal_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "appeal_num" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "appeal_num" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
<th class="table-td-w10">
|
||||||
|
<%= link_to '平均分', course_statistics_course_path(@course, :tab => 2, :type => 'average_score', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "average_score" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "average_score" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
<th class="table-td-w10">
|
||||||
|
<%= link_to '英雄榜', course_statistics_course_path(@course, :tab => 2, :type => 'total_score', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "total_score" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "total_score" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% boo = !(User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) && course_has_score_open_common_homework(@course) %>
|
||||||
|
<% @members.each do |member| %>
|
||||||
|
<% is_hidden = boo && User.current.id != member.user_id %>
|
||||||
|
<tr>
|
||||||
|
<td><%= link_to member.user.show_name, user_path(member.user), :class => 'course_class_users_st_name' %></td>
|
||||||
|
<td><%= member.committed_work_num %></td>
|
||||||
|
<td><%= member.un_commit_work_num %></td>
|
||||||
|
<td><%= member.late_commit_work_num %></td>
|
||||||
|
<td><%= member.absence_evaluation_work_num %></td>
|
||||||
|
<td><%= member.appeal_num %></td>
|
||||||
|
<td><%= is_hidden ? '**' : (member.average_score.nil? ? 0 : format("%.1f", member.average_score < 0 ? 0 : member.average_score)) %></td>
|
||||||
|
<td><%= is_hidden ? '**' : (member.total_score.nil? ? 0 : format("%.1f", member.total_score < 0 ? 0 : member.total_score)) %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<div class="pages" style="width:auto; display:inline-block;">
|
||||||
|
<ul id="homework_pository_ref_pages">
|
||||||
|
<%= pagination_links_full @mem_pages, @members_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
|
||||||
|
</ul>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% else%>
|
||||||
|
<div class="icons_tishi"><img src="/images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
|
||||||
|
<p class="sy_tab_con_p">没有数据可以显示!</p>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,108 @@
|
||||||
|
<% if @members.count != 0 %>
|
||||||
|
<table class="muban_table clearfix mb15 t-center" cellpadding="0" cellspacing="0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="table-td-w30">项目名称</th>
|
||||||
|
<th class="table-td-w10">
|
||||||
|
<%= link_to '发布资源', course_statistics_course_path(@course, :tab => 3, :type => 'attach_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "attach_num" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "attach_num" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
<th class="table-td-w10">
|
||||||
|
<%= link_to '提交次数', course_statistics_course_path(@course, :tab => 3, :type => 'changeset_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "changeset_num" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "changeset_num" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
<th class="table-td-w10-5">
|
||||||
|
<%= link_to '发布Issue', course_statistics_course_path(@course, :tab => 3, :type => 'issue_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "issue_num" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "issue_num" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
<th class="table-td-w10-5">
|
||||||
|
<%= link_to 'Issue回复', course_statistics_course_path(@course, :tab => 3, :type => 'issue_journal_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "issue_journal_num" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "issue_journal_num" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
<th class="table-td-w10">
|
||||||
|
<%= link_to '发布帖子', course_statistics_course_path(@course, :tab => 3, :type => 'board_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "board_num" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "board_num" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
<th class="table-td-w10">
|
||||||
|
<%= link_to '帖子回复', course_statistics_course_path(@course, :tab => 3, :type => 'board_message_num', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "board_message_num" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "board_message_num" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
<th class="table-td-w9">
|
||||||
|
<%= link_to '活跃度', course_statistics_course_path(@course, :tab => 3, :type => 'project_act_score', :order => (@order == "desc" ? "asc" : "desc")), method: 'get', remote: true, :style => 'color:#000000;'%>
|
||||||
|
<% if @type == "project_act_score" && @order == 'desc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortupbtn"></a>
|
||||||
|
<% elsif @type == "project_act_score" && @order == 'asc' %>
|
||||||
|
<a href="javascript:" class= "sy_sortdownbtn"></a>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @members.each do |member| %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<%= link_to member.project.name, project_path(member.project_id), :class => 'new_project_title_width fl ml5' %>
|
||||||
|
<span class="<%= member.project.is_public ? 'syllabus_class_open' : 'syllabus_class_private' %> fl ml5 syllabus_class_property"><%= member.project.is_public ? '公开' : '私有' %></span>
|
||||||
|
</td>
|
||||||
|
<td><%= member.attach_num %></td>
|
||||||
|
<td><%= member.changeset_num || 0 %></td>
|
||||||
|
<td><%= member.issue_num %></td>
|
||||||
|
<td><%= member.issue_journal_num %></td>
|
||||||
|
<td><%= member.board_num %></td>
|
||||||
|
<td><%= member.board_message_num %></td>
|
||||||
|
<td class="pr">
|
||||||
|
<span><%= member.project_act_score %></span>
|
||||||
|
<div class="st_tips_box_inner undis" style="text-align:left;">
|
||||||
|
<em></em>
|
||||||
|
<span></span>
|
||||||
|
<p>发布资源数*5=<%= member.attach_num %>*5=<%= member.attach_num.to_i * 5 %><br/>
|
||||||
|
代码提交数*2=<%= member.changeset_num %>*2=<%= member.changeset_num.to_i * 2 %><br/>
|
||||||
|
发布Issue数*1=<%= member.issue_num %>*1=<%= member.issue_num.to_i * 1 %><br/>
|
||||||
|
Issue回复数*1=<%= member.issue_journal_num %>*1=<%= member.issue_journal_num.to_i * 1 %><br/>
|
||||||
|
发布帖子数*1=<%= member.board_num %>*1=<%= member.board_num.to_i * 1 %><br/>
|
||||||
|
回复帖子数*1=<%= member.board_message_num %>*1=<%= member.board_message_num.to_i * 1 %><br/>
|
||||||
|
总得分:<%= member.project_act_score %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div style="text-align:center;">
|
||||||
|
<div class="pages" style="width:auto; display:inline-block;">
|
||||||
|
<ul id="homework_pository_ref_pages">
|
||||||
|
<%= pagination_links_full @mem_pages, @members_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
|
||||||
|
</ul>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<div class="icons_tishi"><img src="/images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
|
||||||
|
<p class="sy_tab_con_p">没有数据可以显示!</p>
|
||||||
|
<% end %>
|
|
@ -64,9 +64,4 @@
|
||||||
<li>
|
<li>
|
||||||
<%=link_to "分班", course_member_path(@course, :role => 2) %>
|
<%=link_to "分班", course_member_path(@course, :role => 2) %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
|
||||||
<% if show_nav?(0) %>
|
|
||||||
<li>
|
|
||||||
<a href="<%=course_statistics_course_path(@course) %>">统计</a>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
<% end %>
|
|
@ -1,5 +1,88 @@
|
||||||
<div class="sy_class_r ml10">
|
<div class="sy_class_r ml10">
|
||||||
<div class="icons_tishi"><img src="../../images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
|
<h3 class="game-setting-h3"><span class="ml15"></span>统计</h3>
|
||||||
<p class="sy_tab_con_p">统计功能即将上线,届时我们一起享受教育大数据的红利吧!</p>
|
<div class="game-setting-tab">
|
||||||
<div style="height:400px;"></div>
|
<ul id="game-setting-tab-nav">
|
||||||
</div><!--sy_class_r end-->
|
<li id="game-setting-tab-nav-1" onclick="HoverLi(1);">
|
||||||
|
<a href="javascript:void(0);" >活跃度</a>
|
||||||
|
</li>
|
||||||
|
<li id="game-setting-tab-nav-2" onclick="HoverLi(2);">
|
||||||
|
<a href="javascript:void(0);" >英雄榜</a>
|
||||||
|
</li>
|
||||||
|
<li id="game-setting-tab-nav-3" onclick="HoverLi(3);">
|
||||||
|
<a href="javascript:void(0);" >项目活跃度</a>
|
||||||
|
</li>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</ul>
|
||||||
|
<div id="game-setting-content-1" class="undis">
|
||||||
|
<div class="alert alert-blue mt10 ml10 mr10 mb10" style="width: 703px;">
|
||||||
|
活跃度总分 = 资源发布数 * 权值(5分) + 发帖数 * 权值(2分) + 帖子回复数 * 权值(1分) + 通知发布数 * 权值(1分) + <br/>通知回复数 * 权值(1分) + 作业回复数 * 权值(1分) + 班级留言数 * 权值(1分)
|
||||||
|
</div>
|
||||||
|
<div class="clear ml10 mr10" id="act_table_<%=@course.id %>">
|
||||||
|
<% if @tab.nil? || @tab == 1 %>
|
||||||
|
<%=render :partial => 'act_table' %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div><!--issues_list_content_1 end-->
|
||||||
|
|
||||||
|
<div id="game-setting-content-2" class="undis">
|
||||||
|
<div class="alert alert-blue mt10 ml10 mr10 mb10" style="width: 703px;">
|
||||||
|
每个同学作业的得分总和
|
||||||
|
</div>
|
||||||
|
<div class="clear ml10 mr10" id="hero_table_<%=@course.id %>">
|
||||||
|
<% if @tab == 2 %>
|
||||||
|
<%=render :partial => 'hero_table' %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div><!--issues_list_content_2 end-->
|
||||||
|
<div id="game-setting-content-3" class="undis">
|
||||||
|
<div class="alert alert-blue mt10 ml10 mr10 mb10" style="width: 703px;">
|
||||||
|
项目活跃度 = 发布资源数 * 权值(5分) + 代码提交数 * 权值(4分) + 发布Issue数 * 权值(4分) + Issue回复数 * 权值(1分) + <br/>发布帖子数 * 权值(2分) + 回复帖子数 * 权值(1分)
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class=" clear ml10 mr10" >
|
||||||
|
<!--<div class="mb10 clear">-->
|
||||||
|
<!--<label class=" fl mt5 c_grey02"> 选择作业 : </label>-->
|
||||||
|
<!--<select class=" fl newupload_select w150" style="width:150px; height:30px; background:#fff;">-->
|
||||||
|
<!--<option>全部</option>-->
|
||||||
|
<!--<option>第一作业</option>-->
|
||||||
|
<!--<option>第二次作业</option>-->
|
||||||
|
<!--</select>-->
|
||||||
|
<!--</div>-->
|
||||||
|
|
||||||
|
<div id="project_table_<%=@course.id %>">
|
||||||
|
<% if @tab == 3 %>
|
||||||
|
<%=render :partial => 'project_table' %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div><!--issues_list_content_3 end-->
|
||||||
|
</div><!--issues_con_list end-->
|
||||||
|
</div><!--sy_class_r end-->
|
||||||
|
<div class="cl"></div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function(){
|
||||||
|
<% if @tab.nil? %>
|
||||||
|
g('game-setting-content-1').className='dis';
|
||||||
|
g('game-setting-tab-nav-1').className='game-setting-nav-hover';
|
||||||
|
<% else %>
|
||||||
|
g('game-setting-content-<%= @tab %>').className='dis';
|
||||||
|
g('game-setting-tab-nav-<%= @tab %>').className='game-setting-nav-hover';
|
||||||
|
<% end %>
|
||||||
|
});
|
||||||
|
|
||||||
|
function g(o){
|
||||||
|
return document.getElementById(o);
|
||||||
|
}
|
||||||
|
function HoverLi(n){
|
||||||
|
for(var i=1;i<=3;i++){
|
||||||
|
g('game-setting-tab-nav-'+i).className='';
|
||||||
|
g('game-setting-content-'+i).className='undis';
|
||||||
|
}
|
||||||
|
g('game-setting-content-'+n).className='dis';
|
||||||
|
g('game-setting-tab-nav-'+n).className='game-setting-nav-hover';
|
||||||
|
$.get('<%= course_statistics_course_path() %>'+'?tab='+n);
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -1,5 +1,7 @@
|
||||||
<% if !params[:tab] || params[:tab] == "activity" %>
|
<% if !params[:tab] || params[:tab] == "1" %>
|
||||||
$("#act_table_<%=@course.id %>").html("<%= escape_javascript(render :partial => 'act_table')%>");
|
$("#act_table_<%=@course.id %>").html("<%= escape_javascript(render :partial => 'act_table')%>");
|
||||||
<% else %>
|
<% elsif params[:tab] == "2" %>
|
||||||
|
$("#hero_table_<%=@course.id %>").html("<%= escape_javascript(render :partial => 'hero_table')%>");
|
||||||
|
<% elsif params[:tab] == "3" %>
|
||||||
|
$("#project_table_<%=@course.id %>").html("<%= escape_javascript(render :partial => 'project_table')%>");
|
||||||
<% end %>
|
<% end %>
|
|
@ -124,13 +124,10 @@
|
||||||
<%= render :partial => 'layouts/group_children_list', :locals => {:course => @course, :is_teacher => is_teacher} %>
|
<%= render :partial => 'layouts/group_children_list', :locals => {:course => @course, :is_teacher => is_teacher} %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% statistics_count = 0 %>
|
<li id="sy_010" class="sy_icons_st">
|
||||||
<% unless show_nav?(statistics_count) %>
|
<a href="<%=course_statistics_course_path(@course) %>">统计</a>
|
||||||
<li id="sy_10" class="sy_icons_st">
|
<!--<a href="javascript:void(0);" class="sy_class_add"></a>-->
|
||||||
<a href="<%=course_statistics_course_path(@course) %>">统计<span></span></a>
|
</li>
|
||||||
<!--<a href="javascript:void(0);" class="sy_class_add"></a>-->
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
<%# 工具栏展开 %>
|
<%# 工具栏展开 %>
|
||||||
<% if @course.homework_commons.count == 0 || @course.news.count == 0 || course_file_num == 0 || course_poll_count == 0 || @course.exercises.count == 0 ||
|
<% if @course.homework_commons.count == 0 || @course.news.count == 0 || course_file_num == 0 || course_poll_count == 0 || @course.exercises.count == 0 ||
|
||||||
course_feedback_count == 0 || @course.exercises.count == 0 || (@course.boards.first ? @course.boards.first.topics.count : 0) == 0 || statistics_count == 0%>
|
course_feedback_count == 0 || @course.exercises.count == 0 || (@course.boards.first ? @course.boards.first.topics.count : 0) == 0 || statistics_count == 0%>
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
<p>= <%= (project_score.changeset_num||0) * 4 %>
|
<p>= <%= (project_score.changeset_num||0) * 4 %>
|
||||||
+ <%= project_score.issue_num * 4 + project_score.issue_journal_num %> + <%= project_score.attach_num * 5 %>
|
+ <%= project_score.issue_num * 4 + project_score.issue_journal_num %> + <%= project_score.attach_num * 5 %>
|
||||||
+ <%= project_score.board_num * 2 + project_score.board_message_num + project_score.news_num %></p>
|
+ <%= project_score.board_num * 2 + project_score.board_message_num %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
class CreateCourseHomeworkStatistics < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :course_homework_statistics do |t|
|
||||||
|
t.references :user
|
||||||
|
t.references :course
|
||||||
|
t.integer :committed_work_num, :default => 0
|
||||||
|
t.integer :un_commit_work_num, :default => 0
|
||||||
|
t.integer :late_commit_work_num, :default => 0
|
||||||
|
t.integer :absence_evaluation_work_num, :default => 0
|
||||||
|
t.integer :un_evaluation_work_num, :default => 0
|
||||||
|
t.integer :appeal_num, :default => 0
|
||||||
|
t.float :average_score, :default => 0
|
||||||
|
t.float :total_score, :default => 0
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
count =Course.all.count / 30 + 2
|
||||||
|
transaction do
|
||||||
|
for i in 1 ... count do i
|
||||||
|
Course.page(i).per(30).each do |course|
|
||||||
|
hw_count = course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").count
|
||||||
|
homework_ids = course.homework_commons.empty? ? "(-1)" : "(" + course.homework_commons.map{|hw| hw.id}.join(",") + ")"
|
||||||
|
student_works = StudentWork.where("homework_common_id in #{homework_ids} and work_status !=0")
|
||||||
|
is_eva_homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_commons.anonymous_comment = 0 and homework_detail_manuals.comment_status = 2")
|
||||||
|
is_eva_student_works = StudentWork.where(:homework_common_id => is_eva_homeworks.map{|hw| hw.id})
|
||||||
|
has_eva_homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_commons.anonymous_comment = 0 and homework_detail_manuals.comment_status = 3")
|
||||||
|
has_eva_student_works = StudentWork.where(:homework_common_id => has_eva_homeworks.map{|hw| hw.id})
|
||||||
|
course.student.each do |student|
|
||||||
|
user = student.student
|
||||||
|
if user
|
||||||
|
committed_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status != 0").count
|
||||||
|
un_commit_work_num = (hw_count - committed_work_num) < 0 ? 0 : (hw_count - committed_work_num)
|
||||||
|
late_commit_work_num = user.student_works.where("homework_common_id in #{homework_ids} and work_status = 2").count
|
||||||
|
absence_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => has_eva_student_works.map(&:id)).count -
|
||||||
|
user.student_works_scores.where(:reviewer_role => 3, :student_work_id => has_eva_student_works.map(&:id)).group_by(&:student_work_id).count
|
||||||
|
absence_evaluation_work_num = absence_evaluation_work_num < 0 ? 0 : absence_evaluation_work_num
|
||||||
|
un_evaluation_work_num = user.student_works_evaluation_distributions.where(:student_work_id => is_eva_student_works.map(&:id)).count -
|
||||||
|
user.student_works_scores.where(:reviewer_role => 3, :student_work_id => is_eva_student_works.map(&:id)).group_by(&:student_work_id).count
|
||||||
|
un_evaluation_work_num = un_evaluation_work_num < 0 ? 0 : un_evaluation_work_num
|
||||||
|
appeal_num = user.student_works_scores.where(:student_work_id => student_works.map(&:id), :appeal_status => 3).count
|
||||||
|
average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0
|
||||||
|
total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0
|
||||||
|
CourseHomeworkStatistics.create(:course_id => course.id, :user_id => user.id, :committed_work_num => committed_work_num, :un_commit_work_num => un_commit_work_num,
|
||||||
|
:late_commit_work_num => late_commit_work_num, :absence_evaluation_work_num => absence_evaluation_work_num, :un_evaluation_work_num => un_evaluation_work_num,
|
||||||
|
:appeal_num => appeal_num, :average_score => average_score, :total_score => total_score)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
102
db/schema.rb
102
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20170207060207) do
|
ActiveRecord::Schema.define(:version => 20170209020934) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -350,16 +350,14 @@ ActiveRecord::Schema.define(:version => 20170207060207) do
|
||||||
add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids"
|
add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids"
|
||||||
|
|
||||||
create_table "changesets", :force => true do |t|
|
create_table "changesets", :force => true do |t|
|
||||||
t.integer "repository_id", :null => false
|
t.integer "repository_id", :null => false
|
||||||
t.string "revision", :null => false
|
t.string "revision", :null => false
|
||||||
t.string "committer"
|
t.string "committer"
|
||||||
t.datetime "committed_on", :null => false
|
t.datetime "committed_on", :null => false
|
||||||
t.text "comments"
|
t.text "comments"
|
||||||
t.date "commit_date"
|
t.date "commit_date"
|
||||||
t.string "scmid"
|
t.string "scmid"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.integer "project_id"
|
|
||||||
t.integer "type", :default => 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on"
|
add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on"
|
||||||
|
@ -521,13 +519,6 @@ ActiveRecord::Schema.define(:version => 20170207060207) do
|
||||||
add_index "contest_messages", ["contest_id"], :name => "index_contest_messages_on_contest_id"
|
add_index "contest_messages", ["contest_id"], :name => "index_contest_messages_on_contest_id"
|
||||||
add_index "contest_messages", ["user_id"], :name => "index_contest_messages_on_user_id"
|
add_index "contest_messages", ["user_id"], :name => "index_contest_messages_on_user_id"
|
||||||
|
|
||||||
create_table "contest_notifications", :force => true do |t|
|
|
||||||
t.text "title"
|
|
||||||
t.text "content"
|
|
||||||
t.datetime "created_at", :null => false
|
|
||||||
t.datetime "updated_at", :null => false
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "contestant_for_contests", :force => true do |t|
|
create_table "contestant_for_contests", :force => true do |t|
|
||||||
t.integer "student_id"
|
t.integer "student_id"
|
||||||
t.integer "contest_id"
|
t.integer "contest_id"
|
||||||
|
@ -595,37 +586,6 @@ ActiveRecord::Schema.define(:version => 20170207060207) do
|
||||||
add_index "contestant_works", ["user_id"], :name => "index_contestant_works_on_user_id"
|
add_index "contestant_works", ["user_id"], :name => "index_contestant_works_on_user_id"
|
||||||
add_index "contestant_works", ["work_id"], :name => "index_contestant_works_on_work_id"
|
add_index "contestant_works", ["work_id"], :name => "index_contestant_works_on_work_id"
|
||||||
|
|
||||||
create_table "contesting_projects", :force => true do |t|
|
|
||||||
t.integer "project_id"
|
|
||||||
t.string "contest_id"
|
|
||||||
t.integer "user_id"
|
|
||||||
t.string "description"
|
|
||||||
t.datetime "created_at", :null => false
|
|
||||||
t.datetime "updated_at", :null => false
|
|
||||||
t.string "reward"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "contesting_softapplications", :force => true do |t|
|
|
||||||
t.integer "softapplication_id"
|
|
||||||
t.integer "contest_id"
|
|
||||||
t.integer "user_id"
|
|
||||||
t.string "description"
|
|
||||||
t.datetime "created_at", :null => false
|
|
||||||
t.datetime "updated_at", :null => false
|
|
||||||
t.string "reward"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "contestnotifications", :force => true do |t|
|
|
||||||
t.integer "contest_id"
|
|
||||||
t.string "title"
|
|
||||||
t.string "summary"
|
|
||||||
t.text "description"
|
|
||||||
t.integer "author_id"
|
|
||||||
t.integer "notificationcomments_count"
|
|
||||||
t.datetime "created_at", :null => false
|
|
||||||
t.datetime "updated_at", :null => false
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "contests", :force => true do |t|
|
create_table "contests", :force => true do |t|
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
@ -668,6 +628,20 @@ ActiveRecord::Schema.define(:version => 20170207060207) do
|
||||||
t.integer "container_id", :default => 0
|
t.integer "container_id", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "course_class_post", :id => false, :force => true do |t|
|
||||||
|
t.integer "班级id", :default => 0, :null => false
|
||||||
|
t.string "班级名"
|
||||||
|
t.integer "帖子id", :default => 0, :null => false
|
||||||
|
t.integer "主贴id"
|
||||||
|
t.string "帖子标题", :default => "", :null => false
|
||||||
|
t.text "帖子内容"
|
||||||
|
t.integer "帖子用户id"
|
||||||
|
t.integer "帖子回复数", :default => 0, :null => false
|
||||||
|
t.integer "最后回帖id"
|
||||||
|
t.datetime "发帖时间", :null => false
|
||||||
|
t.datetime "帖子更新时间", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "course_contributor_scores", :force => true do |t|
|
create_table "course_contributor_scores", :force => true do |t|
|
||||||
t.integer "course_id"
|
t.integer "course_id"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
|
@ -695,6 +669,21 @@ ActiveRecord::Schema.define(:version => 20170207060207) do
|
||||||
|
|
||||||
add_index "course_groups", ["course_id"], :name => "index_course_groups_on_course_id"
|
add_index "course_groups", ["course_id"], :name => "index_course_groups_on_course_id"
|
||||||
|
|
||||||
|
create_table "course_homework_statistics", :force => true do |t|
|
||||||
|
t.integer "user_id"
|
||||||
|
t.integer "course_id"
|
||||||
|
t.integer "committed_work_num", :default => 0
|
||||||
|
t.integer "un_commit_work_num", :default => 0
|
||||||
|
t.integer "late_commit_work_num", :default => 0
|
||||||
|
t.integer "absence_evaluation_work_num", :default => 0
|
||||||
|
t.integer "un_evaluation_work_num", :default => 0
|
||||||
|
t.integer "appeal_num", :default => 0
|
||||||
|
t.float "average_score", :default => 0.0
|
||||||
|
t.float "total_score", :default => 0.0
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "course_infos", :force => true do |t|
|
create_table "course_infos", :force => true do |t|
|
||||||
t.integer "course_id"
|
t.integer "course_id"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
|
@ -843,21 +832,6 @@ ActiveRecord::Schema.define(:version => 20170207060207) do
|
||||||
|
|
||||||
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
|
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
|
||||||
|
|
||||||
create_table "delayed_jobs_20161218", :id => false, :force => true do |t|
|
|
||||||
t.integer "id", :default => 0, :null => false
|
|
||||||
t.integer "priority", :default => 0, :null => false
|
|
||||||
t.integer "attempts", :default => 0, :null => false
|
|
||||||
t.text "handler", :null => false
|
|
||||||
t.text "last_error"
|
|
||||||
t.datetime "run_at"
|
|
||||||
t.datetime "locked_at"
|
|
||||||
t.datetime "failed_at"
|
|
||||||
t.string "locked_by"
|
|
||||||
t.string "queue"
|
|
||||||
t.datetime "created_at"
|
|
||||||
t.datetime "updated_at"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "discuss_demos", :force => true do |t|
|
create_table "discuss_demos", :force => true do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
t.text "body"
|
t.text "body"
|
||||||
|
@ -983,11 +957,13 @@ ActiveRecord::Schema.define(:version => 20170207060207) do
|
||||||
t.integer "exercise_status"
|
t.integer "exercise_status"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.integer "time"
|
t.integer "time"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.datetime "publish_time"
|
t.datetime "publish_time"
|
||||||
t.datetime "end_time"
|
t.datetime "end_time"
|
||||||
t.integer "show_result"
|
t.integer "show_result"
|
||||||
|
t.integer "question_random", :default => 0
|
||||||
|
t.integer "choice_random", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "first_pages", :force => true do |t|
|
create_table "first_pages", :force => true do |t|
|
||||||
|
@ -1177,10 +1153,6 @@ ActiveRecord::Schema.define(:version => 20170207060207) do
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "innodb_monitor", :id => false, :force => true do |t|
|
|
||||||
t.integer "a"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "invite_lists", :force => true do |t|
|
create_table "invite_lists", :force => true do |t|
|
||||||
t.integer "project_id"
|
t.integer "project_id"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
|
|
|
@ -32,6 +32,10 @@ namespace :homework_evaluation do
|
||||||
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
|
||||||
student_works_evaluation_distributions.save
|
student_works_evaluation_distributions.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中该学生的待匿评数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework_common.course_id, pro_work.user_id)
|
||||||
|
course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
student_works.each_with_index do |work, index|
|
student_works.each_with_index do |work, index|
|
||||||
|
@ -43,6 +47,10 @@ namespace :homework_evaluation do
|
||||||
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
|
||||||
student_works_evaluation_distributions.save
|
student_works_evaluation_distributions.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中该学生的待匿评数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework_common.course_id, user.id)
|
||||||
|
course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
homework_detail_manual.update_column('comment_status', 2)
|
homework_detail_manual.update_column('comment_status', 2)
|
||||||
|
@ -87,6 +95,11 @@ namespace :homework_evaluation do
|
||||||
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} and reviewer_role = 3").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} and reviewer_role = 3").count
|
||||||
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
|
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
|
||||||
student_work.save
|
student_work.save
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中该学生的待匿评数和缺评数
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework_common.course_id, student_work.user_id)
|
||||||
|
course_statistics.update_attribute('un_evaluation_work_num', (course_statistics.un_evaluation_work_num - absence_penalty_count) < 0 ? 0 : (course_statistics.un_evaluation_work_num - absence_penalty_count)) if course_statistics
|
||||||
|
course_statistics.update_attribute('absence_evaluation_work_num', course_statistics.absence_evaluation_work_num + absence_penalty_count) if course_statistics
|
||||||
end
|
end
|
||||||
|
|
||||||
# 未参与匿评
|
# 未参与匿评
|
||||||
|
|
|
@ -26,6 +26,13 @@ namespace :homework_publishtime do
|
||||||
ActiveRecord::Base.connection.execute sql
|
ActiveRecord::Base.connection.execute sql
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新CourseHomeworkStatistics中每个学生的未交作品数
|
||||||
|
homework.course.student.each do |student|
|
||||||
|
course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework.course_id, student.student_id)
|
||||||
|
course_statistics.update_attribute('un_commit_work_num', course_statistics.un_commit_work_num + 1) if course_statistics
|
||||||
|
end
|
||||||
|
|
||||||
course = homework.course
|
course = homework.course
|
||||||
course.members.each do |m|
|
course.members.each do |m|
|
||||||
homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => nil)
|
homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => nil)
|
||||||
|
|
|
@ -525,9 +525,11 @@ a.banner-course-notice {position: absolute; font-size: 12px; line-height: 20px;
|
||||||
.game-setting-h3{ width: 100%; height: 40px; line-height: 40px; font-size: 14px; color: #666; font-weight: normal; background: #fff; border-bottom: 10px solid #eaebec;}
|
.game-setting-h3{ width: 100%; height: 40px; line-height: 40px; font-size: 14px; color: #666; font-weight: normal; background: #fff; border-bottom: 10px solid #eaebec;}
|
||||||
.t-center{ text-align: center;}
|
.t-center{ text-align: center;}
|
||||||
.table-td-w20{ width: 18%;}
|
.table-td-w20{ width: 18%;}
|
||||||
|
.table-td-w9{ width: 9%;}
|
||||||
.table-td-w10{ width: 10%;}
|
.table-td-w10{ width: 10%;}
|
||||||
|
.table-td-w10-5{ width: 10.5%;}
|
||||||
.table-td-w30{ width: 30%;}
|
.table-td-w30{ width: 30%;}
|
||||||
.new_project_title_width {font-size: 14px;color: #666; max-width: 180px;font-weight: normal;white-space: nowrap;overflow: hidden; text-overflow: ellipsis;}
|
.new_project_title_width {font-size: 12px;color: #666; max-width: 170px;font-weight: normal;white-space: nowrap;overflow: hidden; text-overflow: ellipsis;}
|
||||||
.syllabus_class_property { font-size: 12px; padding: 0 5px;border-radius: 3px;line-height: 14px;}
|
.syllabus_class_property { font-size: 12px; padding: 0 5px;border-radius: 3px;line-height: 14px;}
|
||||||
.syllabus_class_private {color: #ff4a1b;border: 1px solid #ff4a1b;}
|
.syllabus_class_private {color: #ff4a1b;border: 1px solid #ff4a1b;}
|
||||||
.syllabus_class_open { color: #7dd26c; border: 1px solid #7dd26c;}
|
.syllabus_class_open { color: #7dd26c; border: 1px solid #7dd26c;}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :course_homework_statistic, :class => 'CourseHomeworkStatistics' do
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe CourseHomeworkStatistics, :type => :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in New Issue