diff --git a/tutor/app/controllers/contests_controller.rb b/tutor/app/controllers/contests_controller.rb index b558ba48..a5d3866d 100644 --- a/tutor/app/controllers/contests_controller.rb +++ b/tutor/app/controllers/contests_controller.rb @@ -16,7 +16,13 @@ def index elsif teaching_assistant_signed_in? @contests = current_teaching_assistant.contests elsif student_signed_in? - @contests = current_student.contests + @my_contests = current_student.contests + @courses = current_student.courses + @courses.each do |course| + course.contests.each do |contest| + @contests << contest + end + end end end diff --git a/tutor/app/views/contests/index.html.erb b/tutor/app/views/contests/index.html.erb index 3a94e1cc..46875392 100644 --- a/tutor/app/views/contests/index.html.erb +++ b/tutor/app/views/contests/index.html.erb @@ -3,7 +3,37 @@ style="width:180px;display:inline"><%= flash[:notice] %> <% end %> -

Your Contests

+<% if @my_contests != nil %> +

Your Contests

+ + + + + + + + <% @my_contests.each do |contest| %> + + + + + + + <% end %> +
ContestsStart dateStart timeDuration
+

<%= link_to contest.title, :controller => 'contests', :action=> 'show', + :id => contest.id,:method => :get, class: + "btn btn-success" %>

+
+

<%= contest.start_date %>

+
+

<%= contest.start_time %>

+
+

<%= contest.end_time.to_i - contest.start_time.to_i / (60*60) %>

+
+<% end %> + +

Contests

<% if @contests %> diff --git a/tutor/spec/controllers/contests_controller_spec.rb b/tutor/spec/controllers/contests_controller_spec.rb index 47ebaac1..a6428053 100644 --- a/tutor/spec/controllers/contests_controller_spec.rb +++ b/tutor/spec/controllers/contests_controller_spec.rb @@ -1,5 +1,12 @@ require 'spec_helper' describe ContestsController do - + describe "GET index" do + it "renders the index template" do + sign_in_lecturer + ContestsController.skip_before_filter :autheticate! + get :index + expect(response).to render_template("index") + end + end end