提交作品选择分组成员时若某一个学生已加入到其他分组则不可选择

This commit is contained in:
cxt 2015-12-11 15:31:15 +08:00
parent bb2f49439e
commit c6470bc69b
2 changed files with 6 additions and 1 deletions

View File

@ -687,6 +687,7 @@ class StudentWorkController < ApplicationController
end
all_student_ids = "(" + @homework.course.student.map{|student| student.student_id}.join(",") + ")"
all_students = User.where("id in #{all_student_ids}")
@commit_student_ids = @homework.student_work_projects.map{|student| student.user_id}
@users = searchstudent_by_name all_students,name
respond_to do |format|
format.js

View File

@ -18,7 +18,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 && (@commit_student_ids.find{|e| e.to_i == user.id.to_i}).nil? %>
if (str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").one("click",function choose_student() {
var li = "<li id='choose_student_<%=user.id %>'";
@ -29,5 +29,9 @@ $("#all_students_list").empty();
$("#choose_students_list").append(li);
});
}
<% else %>
if (str.indexOf(<%=user.id.to_s %>) < 0) {
$("#student_<%=user.id %>").attr("title","该学生已加入其它分组");
}
<% end %>
<% end %>