题库发送的课程列表中不包含当前作业所在的课程

This commit is contained in:
cxt 2016-03-04 13:18:43 +08:00
parent 8aff404f0c
commit 6ca702eb2c
2 changed files with 5 additions and 3 deletions

View File

@ -422,11 +422,12 @@ class UsersController < ApplicationController
end
def choose_user_course
homework = HomeworkCommon.find params[:homework].to_i
if !params[:search].nil?
search = "%#{params[:search].to_s.strip.downcase}%"
@course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)}
@course = @user.courses.where("#{Course.table_name}.id != #{homework.course_id} and #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)}
else
@course = @user.courses.select { |course| @user.allowed_to?(:as_teacher,course)}
@course = @user.courses.where("#{Course.table_name}.id != #{homework.course_id}").select { |course| @user.allowed_to?(:as_teacher,course)}
end
@search = params[:search]
#这里仅仅是传递需要发送的资源id

View File

@ -20,10 +20,11 @@
if(check.length == 0) {
$("#choose_homework_notice").text("请先选择一个作业");
} else {
var hw_id = $('input[name="checkMenu"]:checked').val();
$("#choose_homework_notice").text("");
$.ajax({
type: 'get',
url: '/users/' + user_id + '/choose_user_course',
url: '/users/' + user_id + '/choose_user_course?homework='+hw_id,
data:{send_id:$('input[name="checkMenu"]:checked').val()}
});
}