Skip to content

Commit

Permalink
Issue #476 Adding a method and a view to collect registrants
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahdi authored and Mahdi committed May 14, 2014
1 parent 448c5bd commit 8b6c71a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 12 deletions.
8 changes: 6 additions & 2 deletions tutor/app/controllers/students_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def get_performance
@solved = Attempt.where(student_id:params[:student_id], success:true).joins(problem: {track: :topic}).where('topics.course_id' => params[:course_id]).select("DISTINCT problem_id").count
@failed = Attempt.where(student_id:params[:student_id], failure:true).joins(problem: {track: :topic}).where('topics.course_id' => params[:course_id]).select("DISTINCT problem_id").count
@incomplete = Attempt.where(student_id:params[:student_id], incomplete:true).joins(problem: {track: :topic}).where('topics.course_id' => params[:course_id]).select("DISTINCT problem_id").count
#Recheck here for the missing DB
#@solved_contest = Attempt.where(student_id:params[:student_id], success:true).joins(contest_problem: {track: :topic}).where('topics.course_id' => params[:course_id]).select("DISTINCT problem_id").count
#@failed_contest = Attempt.where(student_id:params[:student_id], failure:true).joins(contest_problem: {track: :topic}).where('topics.course_id' => params[:course_id]).select("DISTINCT problem_id").count
end
Expand All @@ -40,7 +41,7 @@ def solved_problems
# An array of failed problems
# Author: Mahdi
def failed_problems
@failure_list = Attempt.where(student_id:params[:id], failure:true).where('topics.course_id' => params[:course_id]).select("DISTINCT problem_id")
@failure_list = Attempt.where(student_id:params[:student_id], failure:true).joins(problem: {track: :topic}).where('topics.course_id' => params[:course_id]).select("DISTINCT problem_id")
end

# [Performance of a student - Story 5.3]
Expand All @@ -51,9 +52,12 @@ def failed_problems
# An array of incomplete problems
# Author: Mahdi
def incomplete_problems
@incomplete_list = Attempt.where(student_id:params[:id], incomplete:true).where('topics.course_id' => params[:course_id]).select("DISTINCT problem_id")
@failure_list = Attempt.where(student_id:params[:student_id], icnomplete:true).joins(problem: {track: :topic}).where('topics.course_id' => params[:course_id]).select("DISTINCT problem_id")
end

def view_registrants
@contest_registrants = Contest.find_by_id(2).students
end

# [Profile - Story 5.8]
# Displays the profile of the student chosen
Expand Down
4 changes: 3 additions & 1 deletion tutor/app/views/students/failed_problems.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Failed Problems :- <br>
<% @failure_list.each do |failed| %>
Problem: <%= failed.problem_id %><br>
<% end %>
<% end %>

<%= debug(params) %>
10 changes: 3 additions & 7 deletions tutor/app/views/students/get_performance.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
library: {bar: {groupWidth: "10%"}},
colors: ["lightblue", "grey", "lightgrey"]%>

<form action="/students/solved_problems" class="button_to" method="get"><div>
<input class="btn btn-success" style="margin-left: 150px; margin-right:auto; margin-top: 60px" type="submit" value="Solved Ones" /></div></form>
<form action="/students/failed_problems" class="button_to" method="get"><div>
<input class="btn btn-success" style="margin-left: 350px; margin-right:auto; margin-top: -63px" type="submit" value="Failed Ones" /></div></form>
<form action="/students/incomplete_problems" class="button_to" method="get">
<div><input class="btn btn-success" style="margin-left: 550px; margin-right:auto; margin-top: -110px" type="submit" value="Uncompleted Ones" /></div></form>

<%= debug(@solved) %>
<%= button_to "Solved Ones", {:controller => "students", :action => "solved_problems", :student_id => params[:student_id], :course_id => params[:course_id]}, :class => 'btn btn-success' %>
<%= button_to "Wrong Ones", {:controller => "students", :action => "failed_problems", :student_id => params[:student_id], :course_id => params[:course_id]}, :class => 'btn btn-success' %>
<%= button_to "Incomplete Ones", {:controller => "students", :action => "incomplete_problems", :student_id => params[:student_id], :course_id => params[:course_id]}, :class => 'btn btn-success' %>
6 changes: 6 additions & 0 deletions tutor/app/views/students/incomplete_problems.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Incomplete Problems :- <br>
<% @incomplete_list.each do |incomplete| %>
Problem: <%= incomplete.problem_id %><br>
<% end %>

<%=debug(params)%>
2 changes: 2 additions & 0 deletions tutor/app/views/students/solved_problems.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ Solved Problems :- <br>
<% @solved_list.each do |solved| %>
Problem: <%= solved.problem_id %><br>
<% end %>

<%=debug(params)%>
5 changes: 5 additions & 0 deletions tutor/app/views/students/view_registrants.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h4>Contest Name:-</h4> <%= Contest.find_by_id(2).title %>
<h4> Registrants:-</h4>
<% @contest_registrants.each do |registrant| %>
<li><%= registrant.name %></li>
<% end %>
6 changes: 4 additions & 2 deletions tutor/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
post 'debuggers/:id' => 'debuggers#start'
get 'students/get_performance' => 'students#get_performance'
get 'students/list_courses' => 'students#list_courses'
get 'students/solved_problems' => 'students#solved_problems'
get 'students/failed_problems' => 'students#failed_problems'
post 'students/solved_problems' => 'students#solved_problems'
post 'students/failed_problems' => 'students#failed_problems'
post 'students/incomplete_problems' => 'students#incomplete_problems'
get 'students/view_registrants' => 'students#view_registrants'

get 'problems/edit'

Expand Down

0 comments on commit 8b6c71a

Please sign in to comment.