From eab9af7e10a48923e0586cc3ee7ec4b75bc043c3 Mon Sep 17 00:00:00 2001 From: Tang maomao <419242057@qq.com> Date: Mon, 2 Jan 2017 13:21:50 +0000 Subject: [PATCH 1/5] primary operation --- tangmaomao | 1 + 1 file changed, 1 insertion(+) diff --git a/tangmaomao b/tangmaomao index e69de29bb..1d45398c8 100644 --- a/tangmaomao +++ b/tangmaomao @@ -0,0 +1 @@ +tangmaomao \ No newline at end of file From b663bc3f6998217ee16c5cb44ea2b34982d281cd Mon Sep 17 00:00:00 2001 From: Tang maomao <419242057@qq.com> Date: Tue, 3 Jan 2017 07:50:30 +0000 Subject: [PATCH 2/5] change nouns --- app/views/courses/index.html.erb | 2 +- app/views/courses/list.html.erb | 2 +- app/views/shared/_sidenav.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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..4af8af120 100644 --- a/app/views/courses/list.html.erb +++ b/app/views/courses/list.html.erb @@ -7,7 +7,7 @@
-

选修课程

+

可选课程

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 %> From 06520c9e6d7db18d3eeed3e81b1d5e048efee3c1 Mon Sep 17 00:00:00 2001 From: Tang maomao <419242057@qq.com> Date: Tue, 3 Jan 2017 10:06:01 +0000 Subject: [PATCH 3/5] searching function --- app/controllers/courses_controller.rb | 14 +++++++++++++- app/views/courses/list.html.erb | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 3374a1cfe..1fd51f6e0 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -58,11 +58,21 @@ def close #-------------------------for students---------------------- +# def list +# @course=Course.where(isopen: true) +# @course=@course-current_user.courses + # ts add +# end + +# mao changed #2 for searching def list @course=Course.where(isopen: true) + unless params[:query].blank? + @course=Course.where(isopen: true).where( "name=?", 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 +88,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/list.html.erb b/app/views/courses/list.html.erb index 4af8af120..0a4579213 100644 --- a/app/views/courses/list.html.erb +++ b/app/views/courses/list.html.erb @@ -9,7 +9,19 @@

    可选课程

    -
    +
    +
    + + <%= form_tag list_courses_path, :method => :get do %> +
    + <%= text_field_tag 'query', params[:query], class: "form-control inpu", placeholder: "搜索课程名称" %> +
    + +
    +
    + <% end %> +
  • From daa90bd3321e774ca44b85edff9445ccf8ab0cd8 Mon Sep 17 00:00:00 2001 From: Tang maomao <419242057@qq.com> Date: Tue, 3 Jan 2017 15:19:05 +0000 Subject: [PATCH 4/5] searching 2 --- app/controllers/courses_controller.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 1fd51f6e0..c3f47ddfc 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -64,12 +64,15 @@ def close # ts add # end -# mao changed #2 for searching +# 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=?", params[:query]) - end + 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 OR teacher.name LIKE :search', search:"%#{params[:query]}%") + end @course=@course-current_user.courses end # mao changed #2 for searching From d2ec39b5fa27cb144ab912641292554fb53d0983 Mon Sep 17 00:00:00 2001 From: Tang maomao <419242057@qq.com> Date: Tue, 3 Jan 2017 15:41:52 +0000 Subject: [PATCH 5/5] searching 3 --- app/controllers/courses_controller.rb | 2 +- app/views/courses/list.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index c3f47ddfc..32cdddca0 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -71,7 +71,7 @@ def close 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 OR teacher.name LIKE :search', search:"%#{params[:query]}%") + @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 end diff --git a/app/views/courses/list.html.erb b/app/views/courses/list.html.erb index 0a4579213..bf5027081 100644 --- a/app/views/courses/list.html.erb +++ b/app/views/courses/list.html.erb @@ -14,7 +14,7 @@ <%= form_tag list_courses_path, :method => :get do %>
    - <%= text_field_tag 'query', params[:query], class: "form-control inpu", placeholder: "搜索课程名称" %> + <%= text_field_tag 'query', params[:query], class: "form-control inpu", placeholder: "可输入课程编号、课程名称、课程属性、授课方式、考试方式进行搜索" %>