socialforge/app/views/student_work/search_course_students.js.erb

42 lines
1.8 KiB
Plaintext
Raw Normal View History

2015-12-11 14:57:09 +08:00
$("#all_students_list").empty();
<% @users.each do |user|%>
var link = "<li id='student_<%=user.id %>'><%=user.show_name %>";
<% unless user.user_extensions.student_id == "" %>
link += "(<%=user.user_extensions.student_id %>)";
<% end %>
link += "</li>";
$("#all_students_list").append(link);
var str = $("#group_member_ids").val();
2016-06-28 16:30:33 +08:00
var choose_str = "";
2015-12-11 14:57:09 +08:00
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,"");
2016-06-28 16:30:33 +08:00
choose_str += id;
2015-12-11 14:57:09 +08:00
if (i != lists.length -1) {
2016-06-28 16:30:33 +08:00
choose_str += ",";
2015-12-11 14:57:09 +08:00
}
}
2016-06-28 16:30:33 +08:00
}
<% if user.id.to_i != User.current.id.to_i && (@commit_student_ids.find{|e| e.to_i == user.id.to_i}).nil? && user.member_of_course?(@course) %>
2016-06-28 16:30:33 +08:00
if (str.indexOf(<%=user.id.to_s %>) < 0 && choose_str.indexOf(<%=user.id.to_s %>) < 0) {
2015-12-11 14:57:09 +08:00
$("#student_<%=user.id %>").one("click",function choose_student() {
var li = "<li id='choose_student_<%=user.id %>'";
<% if user.id.to_i != User.current.id.to_i %>
li += " onclick='delete_student(<%=user.id %>);'";
<% end %>
li += ">" + $("#student_<%=user.id %>").html()+"<input name='member_id[]' value='<%=user.id %>' type='hidden'/></li>";
2015-12-11 14:57:09 +08:00
$("#choose_students_list").append(li);
});
}
<% elsif !user.member_of_course?(@course) %>
if (str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").attr("title","该项目成员不是本课程的学生");
}
<% else %>
if (str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").attr("title","该学生已加入其它分组");
}
2015-12-11 14:57:09 +08:00
<% end %>
<% end %>