Merge pull request #8 from flyingwaters/master

课程表
This commit is contained in:
stormand 2017-01-04 01:05:09 +08:00 committed by GitHub
commit 8bc7863e5c
4 changed files with 71 additions and 3 deletions

View File

@ -66,7 +66,10 @@ class CoursesController < ApplicationController
@course_display=@course
@theparams=params
@credit_isdegree, @credit_nodegree=cal_degree
end
def classtable
@course=current_user.courses
end
def credit#add credit method
@ -89,6 +92,7 @@ class CoursesController < ApplicationController
redirect_to courses_path,flash: {:success=> "已经成功将 #{@course.name} 选为非学位课"}
end
def select
@allcourse=current_user.courses
@course=Course.find_by_id(params[:id])

View File

@ -0,0 +1,62 @@
<div class="container-fluid">
<div class="row-fluid">
<div class="col-sm-2">
<%= render "shared/sidenav" %>
</div>
<div class="col-sm-10">
<div class="panel panel-primary filterable">
<div class="panel-heading">
<% if student_logged_in? %><h3 class="panel-title">已选课程</h3><% end %>
</div>
<div class="container-fluid">
<table class= "table table-bordered">
<caption>课程表</caption>
<thead>
<tr>
<td> </td>
<td>周一</td>
<td>周二</td>
<td>周三</td>
<td>周四</td>
<td>周五</td>
<td>周六</td>
<td>周日</td>
</tr>
</thead>
</div>
<tbody>
<%op="一二三四五六日"%>
<%k=Array[0,0,0,0,0,0,0]%>
<%for i in 1..11 %>
<tr><td> <%=i%> </td>
<%for m in 0..6%>
<%k[m]=0%>
<%end%>
<%for j in 0..6 %>
<% @course.each do |h| %>
<%if(h.course_time.empty?)%>
<%next%>
<%end%>
<%if(h.course_time[1]==op[j]&&h.course_time[3].to_i<=i&&h.course_time[5,h.course_time.length-1].to_i>=i)%>
<td class="success",align="center"><%=h.name%></td>
<%k[j]=1%>
<%end%>
<%end%>
<%if k[j]==0%>
<td><%" "%></td>
<%end%>
<%end%>
</tr>
<%end%>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@ -10,7 +10,9 @@
<div class="panel panel-primary filterable">
<div class="panel-heading">
<% if teacher_logged_in? %><h3 class="panel-title">授课列表</h3><% end %>
<% if student_logged_in? %><h3 class="panel-title">已选课程</h3><% end %>
<% if student_logged_in? %><h3 class="panel-title">已选课程</h3>
<td><%= link_to "个人课表",classtable_course_url(@course), class: 'btn btn-xs btn-info' %></td>
<% end %>
</div>
<div class="panel-body">

View File

@ -24,6 +24,7 @@ Rails.application.routes.draw do
get :detail
get :open
get :close
get :classtable
get :isdegree #add route isdegree
get :nodegree #add route nodegree
end
@ -32,7 +33,6 @@ Rails.application.routes.draw do
get :search
get :refresh_search
get :credit #add credit route
end
end