Merge branch 'develop' into 'develop'

bug修复



See merge request !152
This commit is contained in:
陈晓婷 2017-02-17 18:56:12 +08:00
commit 6df43565f7
4 changed files with 65 additions and 16 deletions

View File

@ -150,6 +150,7 @@ class HomeworkCommonController < ApplicationController
end
elsif @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
homework_detail_manual.comment_status = 1
create_works_list @homework
status = true
#更新CourseHomeworkStatistics中每个学生的未交作品数
@homework.course.student.each do |student|

View File

@ -31,7 +31,7 @@ class StudentsForCourse < ActiveRecord::Base
#加入班级时创建已发布作业的作品
def create_student_works
course = self.course
course.homework_commons.each do |hw|
course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").each do |hw|
if hw.homework_type != 3 && hw.student_works.where("user_id = #{self.student_id}").count == 0
hw.student_works << StudentWork.new(:user_id => self.student_id, :name => hw.name.to_s+"的作品提交", :work_status => 0)
end
@ -39,7 +39,7 @@ class StudentsForCourse < ActiveRecord::Base
end
#加入班级时创建一条记录
def create_course_homework_statistic
def create_course_homework_statisticd
if CourseHomeworkStatistics.where(:user_id => self.student_id, :course_id => self.course_id).count == 0
course = self.course
user = self.student

View File

@ -0,0 +1,23 @@
class DeleteExcessStudentWorks < ActiveRecord::Migration
def up
homework = HomeworkCommon.where(:id => 4818)
unless homework.empty?
homework = homework.first
homework.course.student.each do |student|
student_works = homework.student_works.where(:user_id => student.student_id).reorder("created_at asc")
if student_works.count > 1
if student_works.first.work_status != 0
student_works.last.destroy
elsif student_works.last.work_status != 0
student_works.first.destroy
else
student_works.first.destroy
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 => 20170217004513) do
ActiveRecord::Schema.define(:version => 20170217104309) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -521,6 +521,13 @@ ActiveRecord::Schema.define(:version => 20170217004513) 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 +595,37 @@ ActiveRecord::Schema.define(:version => 20170217004513) 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"
@ -1154,19 +1192,6 @@ ActiveRecord::Schema.define(:version => 20170217004513) do
t.datetime "updated_at", :null => false
end
create_table "ii", :force => true do |t|
t.integer "project_id"
t.string "author_login"
t.string "rep_identifier"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "sonar_version", :default => 0
t.string "path"
t.string "branch"
t.string "language"
t.string "sonar_name"
end
create_table "innodb_monitor", :id => false, :force => true do |t|
t.integer "a"
end