新建分组作业时不创建作品列表

This commit is contained in:
cxt 2016-09-06 16:38:29 +08:00
parent 17f6b9c286
commit bf4c6d049c
3 changed files with 20 additions and 21 deletions

View File

@ -623,9 +623,7 @@ class StudentWorkController < ApplicationController
end end
members = params[:group_member_ids].split(',') members = params[:group_member_ids].split(',')
for i in 1 .. members.count-1 for i in 1 .. members.count-1
stu_work = @homework.student_works.where("user_id = #{members[i].to_i} and work_status = 0").first stu_work = StudentWork.new(:name => student_work.name, :description => student_work.description, :homeowrk_common_id => @homework.id,:project_id => student_work.project_id, :late_penalty => student_work.late_penalty,:work_status => 3, :commit_time => student_work.commit_time)
stu_work ||= StudentWork.new
stu_work.update_attributes(:name => student_work.name, :description => student_work.description, :project_id => student_work.project_id, :late_penalty => student_work.late_penalty,:work_status => 3, :commit_time => student_work.commit_time)
if stu_work.save if stu_work.save
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) 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)
stu_project.save stu_project.save
@ -679,13 +677,11 @@ 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.update_all(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil,:final_score => nil,:teacher_score => nil,:student_score => nil,:teaching_asistant_score => nil,:system_score => 0,:work_score => nil, :project_id => 0) 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(',')
for i in 1 .. members.count-1 for i in 1 .. members.count-1
stu_work = @homework.student_works.where("user_id = #{members[i].to_i} and work_status = 0").first stu_work = StudentWork.new(:name => @work.name, :description => @work.description, :homework_common_id => @homework.id, :project_id => @work.project_id, :late_penalty => @work.late_penalty,:work_status => 3, :commit_time => @work.commit_time)
stu_work ||= StudentWork.new
stu_work.update_attributes(:name => @work.name, :description => @work.description, :project_id => @work.project_id, :late_penalty => @work.late_penalty,:work_status => 3, :commit_time => @work.commit_time)
if stu_work.save if stu_work.save
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) 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)
stu_project.save stu_project.save
@ -727,7 +723,7 @@ 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}")
student_works.update_all(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil,:final_score => nil,:teacher_score => nil,:student_score => nil,:teaching_asistant_score => nil,:system_score => 0,:work_score => nil, :project_id => 0) student_works.delete_all
pros.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
@ -736,13 +732,15 @@ class StudentWorkController < ApplicationController
else else
project.destroy project.destroy
end end
@work.destroy
else
@work.attachments.destroy_all
@work.student_works_scores.destroy_all
@work.course_messages.destroy_all
@work.student_work_tests.destroy_all
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil,:final_score => nil,:teacher_score => nil,:student_score => nil,:teaching_asistant_score => nil,:system_score => 0,:work_score => nil, :project_id => 0)
@work.update_column("work_score",nil)
end end
@work.attachments.destroy_all
@work.student_works_scores.destroy_all
@work.course_messages.destroy_all
@work.student_work_tests.destroy_all
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil,:final_score => nil,:teacher_score => nil,:student_score => nil,:teaching_asistant_score => nil,:system_score => 0,:work_score => nil, :project_id => 0)
@work.update_column("work_score",nil)
respond_to do |format| respond_to do |format|
format.html { format.html {
redirect_to student_work_index_url(:homework => @homework.id) redirect_to student_work_index_url(:homework => @homework.id)
@ -784,11 +782,12 @@ class StudentWorkController < ApplicationController
else else
project.destroy project.destroy
end end
@work.destroy
else
@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
@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
@student_work = StudentWork.new @student_work = StudentWork.new
respond_to do |format| respond_to do |format|
format.js format.js
@ -1127,7 +1126,7 @@ class StudentWorkController < ApplicationController
end end
all_students = User.where("id in #{all_student_ids}") all_students = User.where("id in #{all_student_ids}")
student_work_id = @homework.student_work_projects.where("user_id=? and student_work_id is not null",User.current.id).first.nil? ? -1 : @homework.student_work_projects.where("user_id=?",User.current.id).first.student_work_id student_work_id = @homework.student_work_projects.where("user_id=? and student_work_id is not null",User.current.id).first.nil? ? -1 : @homework.student_work_projects.where("user_id=?",User.current.id).first.student_work_id
@commit_student_ids = @homework.student_work_projects.where("student_work_id != #{student_work_id}").map{|student| student.user_id} @commit_student_ids = @homework.student_works.has_committed.where("id != #{student_work_id}").map{|student| student.user_id}
@users = searchstudent_by_name all_students,name @users = searchstudent_by_name all_students,name
respond_to do |format| respond_to do |format|
format.js format.js

View File

@ -1115,7 +1115,7 @@ class UsersController < ApplicationController
homework_detail_programing.save if homework_detail_programing homework_detail_programing.save if homework_detail_programing
homework_detail_group.save if homework_detail_group homework_detail_group.save if homework_detail_group
if homework_detail_manual.comment_status == 1 if homework.homework_type != 3 && homework_detail_manual.comment_status == 1
create_works_list homework create_works_list homework
end end

View File

@ -32,7 +32,7 @@ class StudentWork < ActiveRecord::Base
private private
def set_program_score def set_program_score
if homework_common.is_program_homework? #编程作业,学生提交作品后计算系统得分 if self.homework_common.is_program_homework? #编程作业,学生提交作品后计算系统得分
#根据最后一次测试计算得分 #根据最后一次测试计算得分
unless last_test unless last_test
self.system_score = 0 self.system_score = 0