分组作业结束后组长添加成员
This commit is contained in:
parent
157cf4262f
commit
936f610102
|
@ -0,0 +1,129 @@
|
|||
<% if homework.homework_detail_group %>
|
||||
<div>
|
||||
<div>
|
||||
<div class="relateText fl">请从<%= homework.homework_detail_group.base_on_project == 1 ? '项目成员':'课程成员' %>中添加小组成员</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
<form class="resourcesSearchBox">
|
||||
<input type="text" name="serach" placeholder="输入关键字搜索" class="searchResourcePopup" />
|
||||
</form>
|
||||
</div>
|
||||
<ul class="addMemberC fl" id="all_students_list"></ul>
|
||||
<div class="rightArrow"><img src="/images/course/right-arrow.png" width="16" height="30" /></div>
|
||||
<ul class="addMemberC fr" id="choose_students_list">
|
||||
<li id="choose_student_<%=User.current.id %>"><%=User.current.show_name %>
|
||||
<% unless User.current.user_extensions.student_id == "" %>
|
||||
(<%=User.current.user_extensions.student_id %>)
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<div class="courseSendCancel mr15" 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()">确定</a></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var lastSearchCondition = '';
|
||||
var count = 0;
|
||||
function search_stus(e){
|
||||
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastSearchCondition = $(e.target).val().trim();
|
||||
$.ajax({
|
||||
url: '<%= url_for(:controller => 'student_work', :action => 'search_course_students') %>'+'?name='+ e.target.value+'&homework='+<%=homework.id %>,
|
||||
type:'get'
|
||||
});
|
||||
}
|
||||
|
||||
function throttle(method,context,e){
|
||||
clearTimeout(method.tId);
|
||||
method.tId=setTimeout(function(){
|
||||
method.call(context,e);
|
||||
},500);
|
||||
}
|
||||
|
||||
//查询
|
||||
$("input[name='serach']").on('input', function (e) {
|
||||
throttle(search_stus,window,e);
|
||||
});
|
||||
|
||||
function clickOK() {
|
||||
var str="";
|
||||
var show = "合作成员:";
|
||||
var lists = $("#choose_students_list li");
|
||||
if(lists.length > 0) {
|
||||
for(var i=0; i<lists.length; i++) {
|
||||
var id = $(lists[i]).attr("id").replace(/[^0-9]/ig,"");
|
||||
str += id;
|
||||
var show_name = $(lists[i]).html();
|
||||
var index = show_name.indexOf("(");
|
||||
if (index != -1) {
|
||||
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);
|
||||
}
|
||||
hideModal("#popbox02");
|
||||
$("#group_members_show").show().html(show);
|
||||
}
|
||||
|
||||
function delete_student(id) {
|
||||
$("#choose_student_"+id).remove();
|
||||
$("#student_"+id).one("click",function choose_student() {
|
||||
$("#choose_students_list").append("<li id='choose_student_"+id+"' onclick='delete_student("+id+");'>"+$("#student_"+id).html()+"</li>");
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$.ajax({
|
||||
url: '<%= url_for(:controller => 'student_work', :action => 'search_course_students') %>'+'?homework='+<%=homework.id %>,
|
||||
type:'get'
|
||||
});
|
||||
<% student_work = StudentWork.where("homework_common_id = #{homework.id} and user_id = #{User.current.id}").first %>
|
||||
<% ids = User.current.id %>
|
||||
<% student_work.student_work_projects.where("is_leader = ?", 0).each do |pro| %>
|
||||
<% ids << pro.user_id %>
|
||||
<% end %>
|
||||
var ids = <%=ids %>;
|
||||
if (ids.length > 1){
|
||||
for(var i=1; i<ids.length; i++) {
|
||||
if($("#choose_student_"+ids[i]).length == 0) {
|
||||
$.get(
|
||||
'/student_work/get_user_infor',
|
||||
{
|
||||
user_id: ids[i]
|
||||
},
|
||||
function (data) {
|
||||
if (data.valid) {
|
||||
var link = "<li id='choose_student_"+data.id+"' onclick='delete_student("+data.id+");'>"+data.name;
|
||||
if (data.student_id != "" ) {
|
||||
link += "("+data.student_id+")";
|
||||
}
|
||||
link += "</li>";
|
||||
$("#choose_students_list").append(link);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
|
@ -31,11 +31,11 @@
|
|||
<%= link_to "代码查重", work_canrepeat_student_work_index_path(homework:@homework.id, course_id:@course.id), class: 'BlueCirBtn fl',:remote => true %>
|
||||
<% 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") %>
|
||||
<!--<div class="mt5 fr">-->
|
||||
<!--<a href="javascript:void(0);" class="memberBtn fl mt3 mr15" title="添加小组成员" onclick="add_or_delete_group_member();">合作成员</a>-->
|
||||
<!--</div>-->
|
||||
<%# 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") %>
|
||||
<div class="mt5 fr">
|
||||
<a href="javascript:void(0);" class="memberBtn fl mt3 mr15" title="添加小组成员" onclick="add_or_delete_group_member();">合作成员</a>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if @is_teacher && @homework.homework_type == 3 %>
|
||||
<div class="group_work_tip_box fontGrey2">
|
||||
<em></em>
|
||||
|
@ -110,7 +110,7 @@
|
|||
});
|
||||
|
||||
function add_or_delete_group_member() {
|
||||
var html_value = "<%#= escape_javascript(render :partial => 'student_work/add_or_delete_member',:locals => {:homework=>@homework,:edit_mode => true}) %>";
|
||||
pop_up_box(html_value, 528);
|
||||
var html_value = "<%= escape_javascript(render :partial => 'student_work/add_or_delete_member',:locals => {:homework=>@homework,:edit_mode => true}) %>";
|
||||
pop_up_box(html_value, 530);
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue