Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/courses/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<% end %>
<td><%= link_to "删除", course_path(course), :method => "delete", class: 'btn btn-xs btn-danger', :data => {confirm: '确定要删除此课程?'} %></td>
<% elsif student_logged_in? %>
<td><%= link_to "删除", quit_course_path(course), class: 'btn-sm btn-danger' %></td>
<td><%= link_to "退选", quit_course_path(course), class: 'btn-sm btn-danger' %></td>
<% end %>
</tr>
<% end %>
Expand Down
16 changes: 14 additions & 2 deletions app/views/courses/list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@
<div class="col-sm-10">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">选修课程</h3>
<h3 class="panel-title">可选课程</h3>
</div>
<div class="panel-body" style="min-height: 450px">
<div class="panel-body" style="min-height: 15px">
</div>
<!--mao added #1 for searching-->
<%= form_tag list_courses_path, :method => :get do %>
<div class="input-group">
<%= text_field_tag 'query', params[:query], class: "form-control inpu", placeholder: "可输入课程编号、课程名称、课程属性、授课方式、考试方式进行搜索" %>
<div class="input-group-btn">
<button class="btn btn-default btn" type="submit"><i class="glyphicon glyphicon-search"></i>
</button>
</div>
</div>
<% end %>
<!--mao added #1 for searching-->
<table class="table table-striped table-hover">
<thead>

Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_sidenav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<% if student_logged_in? %>
<li class="list-group-item">
<%= link_to list_courses_path do %>
<span class="glyphicon glyphicon-chevron-right"></span> 选修课程
<span class="glyphicon glyphicon-chevron-right"></span> 可选课程
<!-- TS add -->
<% @courses = Course.all %>
<% @selectable_num = 0 %>
Expand Down
1 change: 1 addition & 0 deletions tangmaomao
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tangmaomao