diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 3374a1cfe..32cdddca0 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -58,11 +58,24 @@ def close #-------------------------for students---------------------- +# def list +# @course=Course.where(isopen: true) +# @course=@course-current_user.courses + # ts add +# end + +# mao changed #2 for searching Question.where(:content.like => '%farming%') Question.where(:content =~ '%farming%') "%#{query}%" +# Question.where(Question.arel_table[:content].matches("%#{string}%")) +# House.where('community LIKE :search OR street LIKE :search OR floor LIKE :search OR room_shape LIKE :search', search: "%#{query}%") + def list @course=Course.where(isopen: true) + unless params[:query].blank? + @course=Course.where(isopen: true).where( 'name LIKE :search OR course_code LIKE :search OR course_type LIKE :search OR teaching_type LIKE :search OR exam_type LIKE :search', search:"%#{params[:query]}%") + end @course=@course-current_user.courses - # ts add end +# mao changed #2 for searching def select @course=Course.find_by_id(params[:id]) @@ -78,6 +91,8 @@ def quit redirect_to courses_path, flash: flash end + + def show_courses_table @ts_courses = current_user.courses @course_matrix = nil diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index 3c9b8474a..0909ab3b4 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -43,7 +43,7 @@ <% end %>