From 8b6c71a1a1ea190f54dc61765b0f49e44d9d8d41 Mon Sep 17 00:00:00 2001 From: Mahdi Date: Wed, 14 May 2014 22:26:01 +0200 Subject: [PATCH] Issue #476 Adding a method and a view to collect registrants --- tutor/app/controllers/students_controller.rb | 8 ++++++-- tutor/app/views/students/failed_problems.html.erb | 4 +++- tutor/app/views/students/get_performance.html.erb | 10 +++------- tutor/app/views/students/incomplete_problems.html.erb | 6 ++++++ tutor/app/views/students/solved_problems.html.erb | 2 ++ tutor/app/views/students/view_registrants.html.erb | 5 +++++ tutor/config/routes.rb | 6 ++++-- 7 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 tutor/app/views/students/incomplete_problems.html.erb create mode 100644 tutor/app/views/students/view_registrants.html.erb diff --git a/tutor/app/controllers/students_controller.rb b/tutor/app/controllers/students_controller.rb index 4a9fcb75..c7ca2dc0 100644 --- a/tutor/app/controllers/students_controller.rb +++ b/tutor/app/controllers/students_controller.rb @@ -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 @@ -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] @@ -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 diff --git a/tutor/app/views/students/failed_problems.html.erb b/tutor/app/views/students/failed_problems.html.erb index 5c212986..3da31454 100644 --- a/tutor/app/views/students/failed_problems.html.erb +++ b/tutor/app/views/students/failed_problems.html.erb @@ -1,4 +1,6 @@ Failed Problems :-
<% @failure_list.each do |failed| %> Problem: <%= failed.problem_id %>
-<% end %> \ No newline at end of file +<% end %> + +<%= debug(params) %> \ No newline at end of file diff --git a/tutor/app/views/students/get_performance.html.erb b/tutor/app/views/students/get_performance.html.erb index 6d87937e..bcefa484 100644 --- a/tutor/app/views/students/get_performance.html.erb +++ b/tutor/app/views/students/get_performance.html.erb @@ -9,11 +9,7 @@ library: {bar: {groupWidth: "10%"}}, colors: ["lightblue", "grey", "lightgrey"]%> -
-
-
-
-
-
- <%= debug(@solved) %> \ No newline at end of file +<%= 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' %> \ No newline at end of file diff --git a/tutor/app/views/students/incomplete_problems.html.erb b/tutor/app/views/students/incomplete_problems.html.erb new file mode 100644 index 00000000..21fa87f6 --- /dev/null +++ b/tutor/app/views/students/incomplete_problems.html.erb @@ -0,0 +1,6 @@ +Incomplete Problems :-
+<% @incomplete_list.each do |incomplete| %> + Problem: <%= incomplete.problem_id %>
+<% end %> + +<%=debug(params)%> \ No newline at end of file diff --git a/tutor/app/views/students/solved_problems.html.erb b/tutor/app/views/students/solved_problems.html.erb index 5b3419a8..65851456 100644 --- a/tutor/app/views/students/solved_problems.html.erb +++ b/tutor/app/views/students/solved_problems.html.erb @@ -2,3 +2,5 @@ Solved Problems :-
<% @solved_list.each do |solved| %> Problem: <%= solved.problem_id %>
<% end %> + +<%=debug(params)%> diff --git a/tutor/app/views/students/view_registrants.html.erb b/tutor/app/views/students/view_registrants.html.erb new file mode 100644 index 00000000..70990ef6 --- /dev/null +++ b/tutor/app/views/students/view_registrants.html.erb @@ -0,0 +1,5 @@ +

Contest Name:-

<%= Contest.find_by_id(2).title %> +

Registrants:-

+<% @contest_registrants.each do |registrant| %> +
  • <%= registrant.name %>
  • +<% end %> \ No newline at end of file diff --git a/tutor/config/routes.rb b/tutor/config/routes.rb index d10bddb9..9fd7ce20 100644 --- a/tutor/config/routes.rb +++ b/tutor/config/routes.rb @@ -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'