班级统计列表数据不对

This commit is contained in:
cxt 2017-04-19 17:35:03 +08:00
parent 56e67fa0c0
commit 97e9fb5444
8 changed files with 358 additions and 27 deletions

View File

@ -446,11 +446,12 @@ class HomeworkCommonController < ApplicationController
# 参与匿评的缺评计算
@homework.student_works.where("work_status != 0").each do |student_work|
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").group_by(&:student_work_id).count
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
student_work.save
#更新CourseHomeworkStatistics中该学生的待匿评数和缺评数
absence_penalty_count = absence_penalty_count > 0 ? absence_penalty_count : 0
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

View File

@ -701,8 +701,8 @@ class StudentWorkController < ApplicationController
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_work_projects.delete_all
student_works.destroy_all
student_work_projects.destroy_all
members = params[:group_member_ids].split(',')
for i in 1 .. members.count-1
stu_work = StudentWork.new(:name => @work.name, :description => @work.description,:user_id=> members[i].to_i, :homework_common_id => @homework.id, :project_id => @work.project_id, :late_penalty => @work.late_penalty,:work_status => 3, :commit_time => @work.commit_time)

View File

@ -52,7 +52,7 @@ class HomeworkCommon < ActiveRecord::Base
def update_course_statistics
course = self.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(",") + ")"
homework_ids = course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").empty? ? "(-1)" : "(" + course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").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})

View File

@ -44,7 +44,7 @@ class StudentsForCourse < ActiveRecord::Base
course = self.course
user = self.student
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.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").empty? ? "(-1)" : "(" + course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").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})

View File

@ -20,7 +20,7 @@ class CreateCourseHomeworkStatistics < ActiveRecord::Migration
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(",") + ")"
homework_ids = course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").empty? ? "(-1)" : "(" + course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").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})

View File

@ -0,0 +1,42 @@
class CourseStatisticsMigration < ActiveRecord::Migration
def up
CourseHomeworkStatistics.destroy_all
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.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").empty? ? "(-1)" : "(" + course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").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
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20170309024921) do
ActiveRecord::Schema.define(:version => 20170418065031) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -84,6 +84,21 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.integer "role", :default => 0
end
create_table "apply_add_departments", :force => true do |t|
t.string "name"
t.integer "department_id"
t.integer "school_id"
t.text "remarks"
t.integer "user_id"
t.integer "status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "apply_add_departments", ["department_id"], :name => "index_apply_add_departments_on_department_id"
add_index "apply_add_departments", ["school_id"], :name => "index_apply_add_departments_on_school_id"
add_index "apply_add_departments", ["user_id"], :name => "index_apply_add_departments_on_user_id"
create_table "apply_add_schools", :force => true do |t|
t.string "name"
t.string "province"
@ -180,23 +195,24 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
create_table "attachments", :force => true do |t|
t.integer "container_id"
t.string "container_type", :limit => 30
t.string "filename", :default => "", :null => false
t.string "disk_filename", :default => "", :null => false
t.integer "filesize", :default => 0, :null => false
t.string "content_type", :default => ""
t.string "digest", :limit => 40, :default => "", :null => false
t.integer "downloads", :default => 0, :null => false
t.integer "author_id", :default => 0, :null => false
t.string "container_type", :limit => 30
t.string "filename", :default => "", :null => false
t.string "disk_filename", :default => "", :null => false
t.integer "filesize", :default => 0, :null => false
t.string "content_type", :default => ""
t.string "digest", :limit => 40, :default => "", :null => false
t.integer "downloads", :default => 0, :null => false
t.integer "author_id", :default => 0, :null => false
t.datetime "created_on"
t.text "description"
t.string "disk_directory"
t.integer "attachtype", :default => 1
t.integer "is_public", :default => 1
t.integer "attachtype", :default => 1
t.integer "is_public", :default => 1
t.integer "copy_from"
t.integer "quotes"
t.integer "is_publish", :default => 1
t.integer "is_publish", :default => 1
t.datetime "publish_time"
t.integer "resource_bank_id"
end
add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id"
@ -329,6 +345,42 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.datetime "updated_at", :null => false
end
create_table "challenge_samples", :force => true do |t|
t.string "input"
t.string "output"
t.integer "challenge_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "game_id"
end
create_table "challenge_tags", :force => true do |t|
t.string "name"
t.integer "challenge_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "challenges", :force => true do |t|
t.integer "shixun_id"
t.string "subject"
t.text "description"
t.integer "user_id"
t.integer "status", :limit => 1, :default => 0
t.integer "position", :limit => 1, :default => 1
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "ready_knowledge"
t.text "task_pass", :limit => 2147483647
t.text "answer", :limit => 2147483647
t.integer "score"
t.integer "visits", :default => 0
t.string "path"
t.integer "evaluation_way", :default => 0
t.integer "difficulty", :default => 1
t.text "pipeline_script"
end
create_table "changes", :force => true do |t|
t.integer "changeset_id", :null => false
t.string "action", :limit => 1, :default => "", :null => false
@ -521,6 +573,13 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
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"
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|
t.integer "student_id"
t.integer "contest_id"
@ -588,6 +647,37 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
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"
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|
t.integer "user_id"
t.string "name"
@ -820,6 +910,35 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
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 "departments", :force => true do |t|
t.string "name"
t.integer "school_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "departments", ["school_id"], :name => "index_departments_on_school_id"
create_table "discipline_categories", :force => true do |t|
t.integer "major_level"
t.string "name"
end
create_table "discuss_demos", :force => true do |t|
t.string "title"
t.text "body"
@ -957,6 +1076,13 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.integer "choice_random", :default => 0
end
create_table "first_level_disciplines", :force => true do |t|
t.integer "discipline_category_id"
t.string "name"
end
add_index "first_level_disciplines", ["discipline_category_id"], :name => "index_first_level_disciplines_on_discipline_category_id"
create_table "first_pages", :force => true do |t|
t.string "web_title"
t.string "title"
@ -1021,6 +1147,26 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.datetime "created_at"
end
create_table "game_outputs", :force => true do |t|
t.integer "code"
t.integer "game_id"
t.text "msg"
t.text "out_put"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "games", :force => true do |t|
t.integer "myshixun_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "status", :default => 0
t.integer "final_score", :default => 0
t.integer "challenge_id"
t.datetime "open_time"
end
create_table "groups_users", :id => false, :force => true do |t|
t.integer "group_id", :null => false
t.integer "user_id", :null => false
@ -1090,8 +1236,8 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.integer "homework_type", :default => 1
t.string "late_penalty"
t.integer "course_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "teacher_priority", :default => 1
t.integer "anonymous_comment", :default => 0
t.integer "quotes", :default => 0
@ -1099,6 +1245,8 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.datetime "simi_time"
t.integer "score_open", :default => 1
t.integer "anonymous_appeal", :default => 0
t.integer "homework_bank_id"
t.boolean "is_update", :default => false
end
add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id"
@ -1122,11 +1270,12 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.integer "evaluation_num"
t.integer "absence_penalty", :default => 1
t.integer "homework_common_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "no_anon_penalty", :default => 1
t.integer "appeal_penalty", :default => 0
t.integer "ta_mode", :default => 1
t.float "te_proportion", :default => 1.0
end
create_table "homework_detail_programings", :force => true do |t|
@ -1345,6 +1494,12 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.integer "owner_type", :default => 0
end
create_table "mark_downs", :force => true do |t|
t.text "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "member_roles", :force => true do |t|
t.integer "member_id", :null => false
t.integer "role_id", :null => false
@ -1437,6 +1592,27 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
add_index "messages", ["parent_id"], :name => "messages_parent_id"
add_index "messages", ["root_id"], :name => "index_messages_on_root_id"
create_table "myshixun_members", :force => true do |t|
t.integer "myshixun_id"
t.integer "user_id"
t.integer "role"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "myshixuns", :force => true do |t|
t.string "name"
t.text "description"
t.integer "shixun_id"
t.boolean "is_public", :default => true
t.integer "user_id"
t.integer "gpid"
t.integer "visits", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "status", :default => 0
end
create_table "news", :force => true do |t|
t.integer "project_id"
t.string "title", :limit => 60, :default => "", :null => false
@ -1632,6 +1808,15 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.integer "allow_teacher", :default => 0
end
create_table "outputs", :force => true do |t|
t.integer "code"
t.integer "game_id"
t.text "msg"
t.text "out_put", :limit => 2147483647
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "phone_app_versions", :force => true do |t|
t.string "version"
t.text "description"
@ -1849,6 +2034,17 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
add_index "queries", ["project_id"], :name => "index_queries_on_project_id"
add_index "queries", ["user_id"], :name => "index_queries_on_user_id"
create_table "reference_materials", :force => true do |t|
t.string "book"
t.string "editor"
t.string "press"
t.integer "syllabus_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "reference_materials", ["syllabus_id"], :name => "index_reference_materials_on_syllabus_id"
create_table "relative_memo_to_open_source_projects", :force => true do |t|
t.integer "osp_id"
t.integer "relative_memo_id"
@ -1903,10 +2099,37 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.string "identifier"
t.boolean "is_default", :default => false
t.boolean "hidden", :default => false
t.integer "shixun_id"
t.integer "myshixun_id"
end
add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
create_table "resource_banks", :force => true do |t|
t.integer "course_id"
t.integer "attachment_id"
t.string "filename"
t.string "disk_filename"
t.integer "filesize"
t.string "digest"
t.integer "downloads"
t.integer "user_id"
t.text "description"
t.string "disk_directory"
t.boolean "is_public"
t.integer "copy_from"
t.integer "quotes"
t.string "applicable_syllabus"
t.integer "major_level"
t.integer "discipline_category_id"
t.integer "first_level_discipline_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "resource_banks", ["course_id"], :name => "index_resource_banks_on_course_id"
add_index "resource_banks", ["user_id"], :name => "index_resource_banks_on_user_id"
create_table "rich_rich_files", :force => true do |t|
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
@ -1937,6 +2160,8 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.string "logo_link"
t.string "pinyin"
t.integer "school_type", :default => 0
t.string "city"
t.string "address"
end
create_table "secdomains", :force => true do |t|
@ -2007,6 +2232,29 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.datetime "updated_at", :null => false
end
create_table "shixun_members", :force => true do |t|
t.integer "user_id"
t.integer "shixun_id"
t.integer "role"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "shixuns", :force => true do |t|
t.string "name"
t.text "description"
t.text "script"
t.boolean "is_public", :default => true
t.integer "user_id"
t.integer "gpid"
t.integer "visits", :default => 0
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "changeset_num"
t.integer "status", :default => 0
t.string "language"
end
create_table "softapplications", :force => true do |t|
t.string "name"
t.text "description"
@ -2187,12 +2435,23 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
add_index "syllabus_members", ["syllabus_id"], :name => "index_syllabus_members_on_syllabus_id"
add_index "syllabus_members", ["user_id"], :name => "index_syllabus_members_on_user_id"
create_table "syllabus_update_records", :force => true do |t|
t.integer "user_id"
t.integer "syllabus_id"
t.integer "property"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "syllabus_update_records", ["syllabus_id"], :name => "index_syllabus_update_records_on_syllabus_id"
add_index "syllabus_update_records", ["user_id"], :name => "index_syllabus_update_records_on_user_id"
create_table "syllabuses", :force => true do |t|
t.string "title"
t.text "description"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "eng_name"
t.integer "syllabus_type"
t.integer "credit"
@ -2201,8 +2460,11 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.integer "practice_hours"
t.string "applicable_major"
t.string "pre_course"
t.integer "visits", :default => 0
t.integer "des_status", :default => 0
t.integer "visits", :default => 0
t.integer "des_status", :default => 0
t.integer "major_level"
t.integer "discipline_category_id"
t.integer "first_level_discipline_id"
end
add_index "syllabuses", ["user_id"], :name => "index_syllabuses_on_user_id"
@ -2244,6 +2506,19 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.string "extra"
end
create_table "test_sets", :force => true do |t|
t.string "input"
t.text "output"
t.integer "challenge_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "game_id"
t.string "actual_output"
t.boolean "is_public", :default => true
t.boolean "result", :default => true
t.integer "position"
end
create_table "time_entries", :force => true do |t|
t.integer "project_id", :null => false
t.integer "user_id", :null => false
@ -2335,6 +2610,7 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.string "location_city"
t.integer "school_id"
t.string "description", :default => ""
t.integer "department_id"
end
add_index "user_extensions", ["user_id"], :name => "index_user_extensions_on_user_id"
@ -2457,12 +2733,23 @@ ActiveRecord::Schema.define(:version => 20170309024921) do
t.integer "visits", :default => 0
t.integer "excellent_teacher", :default => 0
t.integer "excellent_student", :default => 0
t.string "phone"
end
add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"
add_index "users", ["id", "type"], :name => "index_users_on_id_and_type"
add_index "users", ["type"], :name => "index_users_on_type"
create_table "verification_codes", :force => true do |t|
t.string "code"
t.integer "code_type"
t.integer "status"
t.string "phone"
t.string "email"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "versions", :force => true do |t|
t.integer "project_id", :default => 0, :null => false
t.string "name", :default => "", :null => false

View File

@ -92,11 +92,12 @@ namespace :homework_evaluation do
work_ids = "(" + homework_common.student_works.has_committed.map(&:id).join(",") + ")"
homework_common.student_works.where("work_status != 0").each do |student_work|
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").group_by(&:student_work_id).count
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
student_work.save
#更新CourseHomeworkStatistics中该学生的待匿评数和缺评数
absence_penalty_count = absence_penalty_count > 0 ? absence_penalty_count : 0
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