From bf4c6d049c8c90742d75df4cd782ec2c0e68047d Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 6 Sep 2016 16:38:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E5=88=86=E7=BB=84=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=97=B6=E4=B8=8D=E5=88=9B=E5=BB=BA=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 37 +++++++++++----------- app/controllers/users_controller.rb | 2 +- app/models/student_work.rb | 2 +- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index dd454d17d..34bc889fd 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -623,9 +623,7 @@ class StudentWorkController < ApplicationController end members = params[:group_member_ids].split(',') 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 - 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) + 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) 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.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) 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.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 members = params[:group_member_ids].split(',') 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 - 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) + 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) 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.save @@ -727,7 +723,7 @@ class StudentWorkController < ApplicationController pros = @work.student_work_projects.where("is_leader = 0") 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.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 project = @work.student_work_projects.where("is_leader = 1").first @@ -736,13 +732,15 @@ class StudentWorkController < ApplicationController else project.destroy 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 - @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| format.html { redirect_to student_work_index_url(:homework => @homework.id) @@ -784,11 +782,12 @@ class StudentWorkController < ApplicationController else project.destroy 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 - - @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 respond_to do |format| format.js @@ -1127,7 +1126,7 @@ class StudentWorkController < ApplicationController end 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 - @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 respond_to do |format| format.js diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4d2b4794c..5aab1df49 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1115,7 +1115,7 @@ class UsersController < ApplicationController homework_detail_programing.save if homework_detail_programing 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 end diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 35308ca05..59e5b76bc 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -32,7 +32,7 @@ class StudentWork < ActiveRecord::Base private def set_program_score - if homework_common.is_program_homework? #编程作业,学生提交作品后计算系统得分 + if self.homework_common.is_program_homework? #编程作业,学生提交作品后计算系统得分 #根据最后一次测试计算得分 unless last_test self.system_score = 0