diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 5791e05..1418e96 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -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]) diff --git a/app/views/courses/classtable.html.erb b/app/views/courses/classtable.html.erb new file mode 100644 index 0000000..f1fed1d --- /dev/null +++ b/app/views/courses/classtable.html.erb @@ -0,0 +1,62 @@ +
+
+
+ <%= render "shared/sidenav" %> +
+ +
+ +
+
+ <% if student_logged_in? %>

已选课程

<% end %> +
+ + + +
+ + + + + + + + + + + + + + + + + <%op="一二三四五六日"%> + <%k=Array[0,0,0,0,0,0,0]%> + <%for i in 1..11 %> + + <%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)%> + + <%k[j]=1%> + <%end%> + <%end%> + <%if k[j]==0%> + + <%end%> + <%end%> + + <%end%> + +
课程表
周一周二周三周四周五周六周日
<%=i%> <%=h.name%><%" "%>
+
+
+
+
+
\ No newline at end of file diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index dc79d72..be09b68 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -10,7 +10,9 @@
<% if teacher_logged_in? %>

授课列表

<% end %> - <% if student_logged_in? %>

已选课程

<% end %> + <% if student_logged_in? %>

已选课程

+ <%= link_to "个人课表",classtable_course_url(@course), class: 'btn btn-xs btn-info' %> + <% end %>
diff --git a/config/routes.rb b/config/routes.rb index 42303d6..be031c5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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