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 %> <%= link_to "删除", course_path(course), :method => "delete", class: 'btn btn-xs btn-danger', :data => {confirm: '确定要删除此课程?'} %> <% elsif student_logged_in? %> - <%= link_to "删除", quit_course_path(course), class: 'btn-sm btn-danger' %> + <%= link_to "退选", quit_course_path(course), class: 'btn-sm btn-danger' %> <% end %> <% end %> diff --git a/app/views/courses/list.html.erb b/app/views/courses/list.html.erb index 3a4926e2c..bf5027081 100644 --- a/app/views/courses/list.html.erb +++ b/app/views/courses/list.html.erb @@ -7,9 +7,21 @@
-

选修课程

+

可选课程

-
+
+
+ + <%= form_tag list_courses_path, :method => :get do %> +
+ <%= text_field_tag 'query', params[:query], class: "form-control inpu", placeholder: "可输入课程编号、课程名称、课程属性、授课方式、考试方式进行搜索" %> +
+ +
+
+ <% end %> + diff --git a/app/views/shared/_sidenav.html.erb b/app/views/shared/_sidenav.html.erb index 2c2245afe..0481945f6 100644 --- a/app/views/shared/_sidenav.html.erb +++ b/app/views/shared/_sidenav.html.erb @@ -37,7 +37,7 @@ <% if student_logged_in? %>
  • <%= link_to list_courses_path do %> - 选修课程 + 可选课程 <% @courses = Course.all %> <% @selectable_num = 0 %> diff --git a/tangmaomao b/tangmaomao index e69de29bb..1d45398c8 100644 --- a/tangmaomao +++ b/tangmaomao @@ -0,0 +1 @@ +tangmaomao \ No newline at end of file