Skip to content

Commit

Permalink
Issue #526 adding separate table for my courses
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Mamdouh authored and Muhammad Mamdouh committed May 15, 2014
1 parent acd2631 commit cf7c808
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
8 changes: 7 additions & 1 deletion tutor/app/controllers/contests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 31 additions & 1 deletion tutor/app/views/contests/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,37 @@
style="width:180px;display:inline"><%= flash[:notice] %></div>
<% end %>

<h1> Your Contests </h1>
<% if @my_contests != nil %>
<h1> Your Contests </h1>
<table class="table table-striped table-bordered table-responsive">
<tr>
<td>Contests</td>
<td>Start date</td>
<td>Start time</td>
<td>Duration</td>
</tr>
<% @my_contests.each do |contest| %>
<tr>
<td>
<h4><%= link_to contest.title, :controller => 'contests', :action=> 'show',
:id => contest.id,:method => :get, class:
"btn btn-success" %></h4>
</td>
<td>
<h4><%= contest.start_date %></h4>
</td>
<td>
<h4><%= contest.start_time %></h4>
</td>
<td>
<h4><%= contest.end_time.to_i - contest.start_time.to_i / (60*60) %></h4>
</td>
</tr>
<% end %>
</table>
<% end %>

<h1> Contests </h1>

<table class="table table-striped table-bordered table-responsive">
<% if @contests %>
Expand Down
9 changes: 8 additions & 1 deletion tutor/spec/controllers/contests_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cf7c808

Please sign in to comment.