|
|
|
@ -410,11 +410,11 @@ class StudentWorkController < ApplicationController
|
|
|
|
|
#开放作品 || 老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表
|
|
|
|
|
if (@homework.is_open == 1 && @course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.has_committed.where(:user_id => User.current.id).empty?)
|
|
|
|
|
if @order == 'lastname'
|
|
|
|
|
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
|
|
|
|
@stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
|
|
|
|
elsif @order == 'student_id'
|
|
|
|
|
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
|
|
|
|
@stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
|
|
|
|
else
|
|
|
|
|
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
|
|
|
|
|
@stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
|
|
|
|
|
end
|
|
|
|
|
@show_all = true
|
|
|
|
|
elsif User.current.member_of_course?(@course)
|
|
|
|
@ -476,11 +476,11 @@ class StudentWorkController < ApplicationController
|
|
|
|
|
else
|
|
|
|
|
if (@homework.is_open == 1 &&@course.is_public == 1) || (@homework.is_open == 1 && @course.is_public == 0 && User.current.member_of_course?(@course)) || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.has_committed.where(:user_id => User.current.id).empty?)
|
|
|
|
|
if @order == 'lastname'
|
|
|
|
|
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
|
|
|
|
@stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
|
|
|
|
elsif @order == 'student_id'
|
|
|
|
|
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
|
|
|
|
@stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
|
|
|
|
else
|
|
|
|
|
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").order("#{@order} #{@b_sort}"),@name
|
|
|
|
|
@stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").order("#{@order} #{@b_sort}"),@name
|
|
|
|
|
end
|
|
|
|
|
@show_all = true
|
|
|
|
|
elsif User.current.member_of_course?(@course)
|
|
|
|
@ -613,33 +613,23 @@ class StudentWorkController < ApplicationController
|
|
|
|
|
student_work.work_status = 1
|
|
|
|
|
end
|
|
|
|
|
if student_work.save
|
|
|
|
|
if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
|
|
|
|
|
@student_work_project.student_work_id = student_work.id
|
|
|
|
|
@student_work_project.save
|
|
|
|
|
members = params[:group_member_ids].split(',')
|
|
|
|
|
for i in 1 .. members.count-1
|
|
|
|
|
stu_project = StudentWorkProject.new
|
|
|
|
|
stu_project.homework_common_id = @homework.id
|
|
|
|
|
stu_project.student_work_id = student_work.id
|
|
|
|
|
stu_project.project_id = @student_work_project.project_id
|
|
|
|
|
stu_project.user_id = members[i].to_i
|
|
|
|
|
stu_project.is_leader = 0
|
|
|
|
|
if @homework.homework_type == 3
|
|
|
|
|
if @homework.homework_detail_group.base_on_project == 1
|
|
|
|
|
@student_work_project.student_work_id = student_work.id
|
|
|
|
|
@student_work_project.save
|
|
|
|
|
elsif @homework.homework_detail_group.base_on_project == 0
|
|
|
|
|
stu_project = StudentWorkProject.new(:homework_common_id => @homework.id, :student_work_id => student_work.id, :project_id => student_work.project_id, :user_id => student_work.user_id, :is_leader => 1)
|
|
|
|
|
stu_project.save
|
|
|
|
|
end
|
|
|
|
|
elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
|
|
|
|
|
members = params[:group_member_ids].split(',')
|
|
|
|
|
for i in 0 .. members.count-1
|
|
|
|
|
stu_project = StudentWorkProject.new
|
|
|
|
|
stu_project.homework_common_id = @homework.id
|
|
|
|
|
stu_project.student_work_id = student_work.id
|
|
|
|
|
stu_project.project_id = -1
|
|
|
|
|
stu_project.user_id = members[i].to_i
|
|
|
|
|
if i == 0
|
|
|
|
|
stu_project.is_leader = 1
|
|
|
|
|
else
|
|
|
|
|
stu_project.is_leader = 0
|
|
|
|
|
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)
|
|
|
|
|
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
|
|
|
|
|
end
|
|
|
|
|
stu_project.save
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@homework.update_column(:updated_at, Time.now)
|
|
|
|
@ -687,20 +677,19 @@ class StudentWorkController < ApplicationController
|
|
|
|
|
if @homework.homework_type == 3
|
|
|
|
|
@student_work_project = @homework.student_work_projects.where("user_id=?",User.current.id).first
|
|
|
|
|
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_work_projects.delete_all
|
|
|
|
|
members = params[:group_member_ids].split(',')
|
|
|
|
|
for i in 1 .. members.count-1
|
|
|
|
|
stu_project = StudentWorkProject.new
|
|
|
|
|
stu_project.homework_common_id = @homework.id
|
|
|
|
|
stu_project.student_work_id = @work.id
|
|
|
|
|
if @homework.homework_detail_group.base_on_project == 1
|
|
|
|
|
stu_project.project_id = @student_work_project.project_id
|
|
|
|
|
else @homework.homework_detail_group.base_on_project == 0
|
|
|
|
|
stu_project.project_id = -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)
|
|
|
|
|
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
|
|
|
|
|
end
|
|
|
|
|
stu_project.user_id = members[i].to_i
|
|
|
|
|
stu_project.is_leader = 0
|
|
|
|
|
stu_project.save
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -735,28 +724,25 @@ class StudentWorkController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|
if @homework.homework_type == 3
|
|
|
|
|
if @work.destroy
|
|
|
|
|
if @homework.homework_detail_group.base_on_project == 1
|
|
|
|
|
pros = @work.student_work_projects.where("is_leader = 0")
|
|
|
|
|
pros.each do |pro|
|
|
|
|
|
pro.destroy
|
|
|
|
|
end
|
|
|
|
|
project = @work.student_work_projects.where("is_leader = 1").first
|
|
|
|
|
project.update_attributes(:student_work_id => nil)
|
|
|
|
|
elsif @homework.homework_detail_group.base_on_project == 0
|
|
|
|
|
@work.student_work_projects.each do |pro2|
|
|
|
|
|
pro2.destroy
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
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)
|
|
|
|
|
pros.delete_all
|
|
|
|
|
|
|
|
|
|
project = @work.student_work_projects.where("is_leader = 1").first
|
|
|
|
|
if @homework.homework_detail_group.base_on_project == 1
|
|
|
|
|
project.update_attributes(:student_work_id => nil)
|
|
|
|
|
else
|
|
|
|
|
project.destroy
|
|
|
|
|
end
|
|
|
|
|
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)
|
|
|
|
|
@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)
|
|
|
|
@ -786,25 +772,23 @@ class StudentWorkController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def retry_work
|
|
|
|
|
if @homework.homework_type == 3
|
|
|
|
|
if @work.destroy
|
|
|
|
|
if @homework.homework_detail_group.base_on_project == 1
|
|
|
|
|
pros = @work.student_work_projects.where("is_leader = 0")
|
|
|
|
|
pros.each do |pro|
|
|
|
|
|
pro.destroy
|
|
|
|
|
end
|
|
|
|
|
project = @work.student_work_projects.where("is_leader = 1").first
|
|
|
|
|
project.update_attributes(:student_work_id => nil)
|
|
|
|
|
elsif @homework.homework_detail_group.base_on_project == 0
|
|
|
|
|
@work.student_work_projects.each do |pro2|
|
|
|
|
|
pro2.destroy
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
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, :project_id => 0)
|
|
|
|
|
pros.delete_all
|
|
|
|
|
|
|
|
|
|
project = @work.student_work_projects.where("is_leader = 1").first
|
|
|
|
|
if @homework.homework_detail_group.base_on_project == 1
|
|
|
|
|
project.update_attributes(:student_work_id => nil)
|
|
|
|
|
else
|
|
|
|
|
project.destroy
|
|
|
|
|
end
|
|
|
|
|
elsif @homework.homework_type == 1
|
|
|
|
|
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil)
|
|
|
|
|
@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
|
|
|
|
@ -1096,9 +1080,13 @@ class StudentWorkController < ApplicationController
|
|
|
|
|
|
|
|
|
|
#创建作业的关联项目
|
|
|
|
|
def student_work_project
|
|
|
|
|
@work = @homework.student_works.where("user_id = #{User.current.id} and work_status = 0").first
|
|
|
|
|
if @work
|
|
|
|
|
@work.update_column('project_id', params[:projectName].to_i)
|
|
|
|
|
end
|
|
|
|
|
@project = StudentWorkProject.new
|
|
|
|
|
@project.homework_common_id = @homework.id
|
|
|
|
|
@project.project_id = (Project.find params[:projectName].to_i).id
|
|
|
|
|
@project.project_id = params[:projectName].to_i
|
|
|
|
|
@project.user_id = User.current.id
|
|
|
|
|
@project.is_leader = 1
|
|
|
|
|
if @project.save
|
|
|
|
@ -1147,6 +1135,10 @@ class StudentWorkController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def cancel_relate_project
|
|
|
|
|
@work = @homework.student_works.where("user_id = #{User.current.id} and work_status = 0").first
|
|
|
|
|
if @work
|
|
|
|
|
@work.update_column('project_id', 0)
|
|
|
|
|
end
|
|
|
|
|
relate_pro = StudentWorkProject.where("user_id = #{User.current.id} and homework_common_id = #{@homework.id}").first
|
|
|
|
|
if relate_pro.destroy
|
|
|
|
|
@user_activity_id = params[:user_activity_id].to_i
|
|
|
|
@ -1586,6 +1578,10 @@ class StudentWorkController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if homework.homework_type == 3
|
|
|
|
|
student_works = group_student_works student_work, homework
|
|
|
|
|
student_works.update_all(:final_score => student_work.final_score,:teacher_score => student_work.teacher_score,:student_score => student_work.student_score,:teaching_asistant_score => student_work.teaching_asistant_score,:work_score => student_work.work_score)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|