From ec45ee89d9ff82173b381f85afdc370fc8f7b99d Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 1 Nov 2016 15:59:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E6=88=AA=E6=AD=A2=E7=9A=84=E5=88=86?= =?UTF-8?q?=E7=BB=84=E4=BD=9C=E4=B8=9A=EF=BC=9A=E7=BB=84=E9=95=BF=E5=8F=AF?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=88=90=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 36 +++++++- .../_add_or_delete_member.html.erb | 84 +++++++++++-------- .../student_work/_student_work_list.html.erb | 2 +- .../search_course_students.js.erb | 2 +- config/routes.rb | 1 + 5 files changed, 86 insertions(+), 39 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index d6300c6bf..51375b5f3 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -5,7 +5,9 @@ class StudentWorkController < ApplicationController include ApplicationHelper require 'bigdecimal' require "base64" - before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students,:work_canrepeat] + before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex, + :set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project, + :search_course_students,:work_canrepeat,:add_group_member] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment] before_filter :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] @@ -1149,6 +1151,38 @@ class StudentWorkController < ApplicationController render :json => req end + #作业截止后组长添加成员 + def add_group_member + student_work = @homework.student_works.where("user_id = #{User.current.id}").first + if params[:member_id] + for i in 1 .. params[:member_id].count do + work = StudentWork.find_by_homework_common_id_and_user_id(@homework.id, params[:member_id][i].to_i) + unless work + stu_work = StudentWork.new(:name => student_work.name, :description => student_work.description,:user_id =>params[:member_id][i].to_i, :homework_common_id => @homework.id,:project_id => student_work.project_id, :late_penalty => student_work.late_penalty,:work_status => 3, :commit_time => Time.now) + 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 => params[:member_id][i].to_i, :is_leader => 0) + stu_project.save + end + end + end + student_work_projects = @homework.student_work_projects.where("student_work_id=? and is_leader =?",student_work.id,0) + student_work_projects.each do |sp| + unless params[:member_id].include?(sp.user_id.to_s) + work = StudentWork.where("homework_common_id = #{@homework.id} and user_id = #{sp.user_id}").first + sp.destroy + if work + work.destroy + end + end + end + end + respond_to do |format| + format.html { + redirect_to student_work_index_url(:homework => @homework.id, :tab => 2) + } + end + end + private def searchstudent_by_name users, name mems = [] diff --git a/app/views/student_work/_add_or_delete_member.html.erb b/app/views/student_work/_add_or_delete_member.html.erb index 56682ea9e..f52898be6 100644 --- a/app/views/student_work/_add_or_delete_member.html.erb +++ b/app/views/student_work/_add_or_delete_member.html.erb @@ -9,6 +9,15 @@ +
+ <%=form_tag(add_group_member_student_work_index_path(:homework => homework.id), :method => :post, :id => 'add_group_member_form') do %> + <% str = User.current.id.to_s%> + <% student_work = StudentWork.where("homework_common_id = #{homework.id} and user_id = #{User.current.id}").first %> + <% student_work.student_work_projects.where("is_leader = ?", 0).each do |pro| %> + <% str += ','+pro.user_id.to_s %> + <% end %> + + <%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>str %>
-
取消
-
确定
+ +
取消
+
确定
+ <% end %>