已截止的分组作业:组长可编辑成员
This commit is contained in:
parent
936f610102
commit
ec45ee89d9
|
@ -5,7 +5,9 @@ class StudentWorkController < ApplicationController
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
require 'bigdecimal'
|
require 'bigdecimal'
|
||||||
require "base64"
|
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 :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 :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work]
|
||||||
before_filter :author_of_work, :only => [:edit, :update, :destroy]
|
before_filter :author_of_work, :only => [:edit, :update, :destroy]
|
||||||
|
@ -1149,6 +1151,38 @@ class StudentWorkController < ApplicationController
|
||||||
render :json => req
|
render :json => req
|
||||||
end
|
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
|
private
|
||||||
def searchstudent_by_name users, name
|
def searchstudent_by_name users, name
|
||||||
mems = []
|
mems = []
|
||||||
|
|
|
@ -9,6 +9,15 @@
|
||||||
<input type="text" name="serach" placeholder="输入关键字搜索" class="searchResourcePopup" />
|
<input type="text" name="serach" placeholder="输入关键字搜索" class="searchResourcePopup" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<%=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 %>
|
||||||
|
<!--<span class="none" id="group_member_ids"><%#=str %></span>-->
|
||||||
|
<%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>str %>
|
||||||
<ul class="addMemberC fl" id="all_students_list"></ul>
|
<ul class="addMemberC fl" id="all_students_list"></ul>
|
||||||
<div class="rightArrow"><img src="/images/course/right-arrow.png" width="16" height="30" /></div>
|
<div class="rightArrow"><img src="/images/course/right-arrow.png" width="16" height="30" /></div>
|
||||||
<ul class="addMemberC fr" id="choose_students_list">
|
<ul class="addMemberC fr" id="choose_students_list">
|
||||||
|
@ -16,12 +25,15 @@
|
||||||
<% unless User.current.user_extensions.student_id == "" %>
|
<% unless User.current.user_extensions.student_id == "" %>
|
||||||
(<%=User.current.user_extensions.student_id %>)
|
(<%=User.current.user_extensions.student_id %>)
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<input name='member_id[]' value='<%=User.current.id %>' type='hidden'/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div class="courseSendCancel mr15" style="float:right;"><a href="javascript:void(0);" class="sendSourceText" onclick="hideModal();">取消</a></div>
|
<span class="c_red fl none" id="add_group_member_notice"></span>
|
||||||
<div class="courseSendSubmit" style="float:right;"><a href="javascript:void(0);" class="sendSourceText" onclick="clickOK()">确定</a></div>
|
<div class="courseSendCancel" style="float: right;"><a href="javascript:void(0);" class="sendSourceText" onclick="hideModal();">取消</a></div>
|
||||||
|
<div class="courseSendSubmit" style="float: right;"><a href="javascript:void(0);" class="sendSourceText" onclick="clickOK(<%=homework.homework_detail_group.min_num %>, <%=homework.homework_detail_group.max_num %>)">确定</a></div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var lastSearchCondition = '';
|
var lastSearchCondition = '';
|
||||||
|
@ -50,40 +62,44 @@
|
||||||
throttle(search_stus,window,e);
|
throttle(search_stus,window,e);
|
||||||
});
|
});
|
||||||
|
|
||||||
function clickOK() {
|
function clickOK(min, max) {
|
||||||
var str="";
|
//var str="";
|
||||||
var show = "合作成员:";
|
//var show = "合作成员:";
|
||||||
var lists = $("#choose_students_list li");
|
var lists = $("#choose_students_list li");
|
||||||
if(lists.length > 0) {
|
if(lists.length < parseInt(min) || lists.length > parseInt(max)) {
|
||||||
for(var i=0; i<lists.length; i++) {
|
$("#add_group_member_notice").show();
|
||||||
var id = $(lists[i]).attr("id").replace(/[^0-9]/ig,"");
|
$("#add_group_member_notice").html("合作成员人数应为:"+min+"-"+max+"人");
|
||||||
str += id;
|
// for(var i=0; i<lists.length; i++) {
|
||||||
var show_name = $(lists[i]).html();
|
// var id = $(lists[i]).attr("id").replace(/[^0-9]/ig,"");
|
||||||
var index = show_name.indexOf("(");
|
// str += id;
|
||||||
if (index != -1) {
|
// var show_name = $(lists[i]).html();
|
||||||
var name = show_name.substring(0,show_name.indexOf("("));
|
// var index = show_name.indexOf("(");
|
||||||
} else {
|
// if (index != -1) {
|
||||||
var name = show_name;
|
// var name = show_name.substring(0,show_name.indexOf("("));
|
||||||
|
// } else {
|
||||||
|
// var name = show_name;
|
||||||
|
// }
|
||||||
|
// show += name;
|
||||||
|
// if (i == 0) {
|
||||||
|
// show += "(组长)";
|
||||||
|
// }
|
||||||
|
// if (i != lists.length -1) {
|
||||||
|
// str += ",";
|
||||||
|
// show += "、";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// $("#group_member_ids").val(str);
|
||||||
|
} else{
|
||||||
|
hideModal();
|
||||||
|
$("#add_group_member_form").submit();
|
||||||
}
|
}
|
||||||
show += name;
|
//$("#group_members_show").show().html(show);
|
||||||
if (i == 0) {
|
|
||||||
show += "(组长)";
|
|
||||||
}
|
|
||||||
if (i != lists.length -1) {
|
|
||||||
str += ",";
|
|
||||||
show += "、";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$("#group_member_ids").val(str);
|
|
||||||
}
|
|
||||||
hideModal("#popbox02");
|
|
||||||
$("#group_members_show").show().html(show);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_student(id) {
|
function delete_student(id) {
|
||||||
$("#choose_student_"+id).remove();
|
$("#choose_student_"+id).remove();
|
||||||
$("#student_"+id).one("click",function choose_student() {
|
$("#student_"+id).one("click",function choose_student() {
|
||||||
$("#choose_students_list").append("<li id='choose_student_"+id+"' onclick='delete_student("+id+");'>"+$("#student_"+id).html()+"</li>");
|
$("#choose_students_list").append("<li id='choose_student_"+id+"' onclick='delete_student("+id+");'>"+$("#student_"+id).html()+"<input name='member_id[]' value='"+id+"' type='hidden'/></li>");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,12 +108,8 @@
|
||||||
url: '<%= url_for(:controller => 'student_work', :action => 'search_course_students') %>'+'?homework='+<%=homework.id %>,
|
url: '<%= url_for(:controller => 'student_work', :action => 'search_course_students') %>'+'?homework='+<%=homework.id %>,
|
||||||
type:'get'
|
type:'get'
|
||||||
});
|
});
|
||||||
<% student_work = StudentWork.where("homework_common_id = #{homework.id} and user_id = #{User.current.id}").first %>
|
var ids = $("#group_member_ids").val().split(',');
|
||||||
<% ids = User.current.id %>
|
//var ids = <%#=ids %>;
|
||||||
<% student_work.student_work_projects.where("is_leader = ?", 0).each do |pro| %>
|
|
||||||
<% ids << pro.user_id %>
|
|
||||||
<% end %>
|
|
||||||
var ids = <%=ids %>;
|
|
||||||
if (ids.length > 1){
|
if (ids.length > 1){
|
||||||
for(var i=1; i<ids.length; i++) {
|
for(var i=1; i<ids.length; i++) {
|
||||||
if($("#choose_student_"+ids[i]).length == 0) {
|
if($("#choose_student_"+ids[i]).length == 0) {
|
||||||
|
@ -112,7 +124,7 @@
|
||||||
if (data.student_id != "" ) {
|
if (data.student_id != "" ) {
|
||||||
link += "("+data.student_id+")";
|
link += "("+data.student_id+")";
|
||||||
}
|
}
|
||||||
link += "</li>";
|
link += "<input name='member_id[]' type='hidden' value='" + data.id + "'/></li>";
|
||||||
$("#choose_students_list").append(link);
|
$("#choose_students_list").append(link);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
<% end%>
|
<% end%>
|
||||||
<% if @homework.homework_type == 3 && my_work && my_work.user == User.current && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") %>
|
<% if @homework.homework_type == 3 && my_work && my_work.user == User.current && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") %>
|
||||||
<div class="mt5 fr">
|
<div class="mt5 fr">
|
||||||
<a href="javascript:void(0);" class="memberBtn fl mt3 mr15" title="添加小组成员" onclick="add_or_delete_group_member();">合作成员</a>
|
<a href="javascript:void(0);" class="memberBtn fl mt3" title="添加小组成员" onclick="add_or_delete_group_member();">合作成员</a>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @is_teacher && @homework.homework_type == 3 %>
|
<% if @is_teacher && @homework.homework_type == 3 %>
|
||||||
|
|
|
@ -26,7 +26,7 @@ $("#all_students_list").empty();
|
||||||
<% if user.id.to_i != User.current.id.to_i %>
|
<% if user.id.to_i != User.current.id.to_i %>
|
||||||
li += " onclick='delete_student(<%=user.id %>);'";
|
li += " onclick='delete_student(<%=user.id %>);'";
|
||||||
<% end %>
|
<% end %>
|
||||||
li += ">" + $("#student_<%=user.id %>").html()+"</li>";
|
li += ">" + $("#student_<%=user.id %>").html()+"<input name='member_id[]' value='<%=user.id %>' type='hidden'/></li>";
|
||||||
$("#choose_students_list").append(li);
|
$("#choose_students_list").append(li);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -346,6 +346,7 @@ RedmineApp::Application.routes.draw do
|
||||||
post 'set_score_rule'
|
post 'set_score_rule'
|
||||||
get 'work_canrepeat'
|
get 'work_canrepeat'
|
||||||
get 'get_user_infor'
|
get 'get_user_infor'
|
||||||
|
post 'add_group_member'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue