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

42 lines
1.7 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();
/*var 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,"");
str += id;
if (i != lists.length -1) {
str += ",";
}
}
}*/
<% 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) %>
2015-12-11 14:57:09 +08:00
if (str.indexOf(<%=user.id.to_s %>) < 0) {
$("#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()+"</li>";
$("#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 %>