Skip to content

Commit

Permalink
Issue #476 Modified the statistics method
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahdi authored and Mahdi committed May 11, 2014
1 parent c691505 commit 134139c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
4 changes: 4 additions & 0 deletions tutor/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ GEM
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
chartkick (1.2.4)
chronic (0.10.2)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
Expand All @@ -58,6 +59,7 @@ GEM
foreman (0.63.0)
dotenv (>= 0.7)
thor (>= 0.13.6)
googlecharts (1.6.8)
hashr (0.0.22)
hike (1.2.3)
i18n (0.6.9)
Expand Down Expand Up @@ -155,10 +157,12 @@ PLATFORMS
DEPENDENCIES
acts_as_list
carrierwave
chartkick
coffee-rails (~> 4.0.0)
composite_primary_keys (~> 6.0.1)
devise
foreman
googlecharts
jbuilder (~> 1.2)
jquery-rails (~> 3.1.0)
json_builder (= 3.1.0)
Expand Down
2 changes: 1 addition & 1 deletion tutor/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base
before_action :update_sanitized_params, if: :devise_controller?
before_action :check_resource, if: :devise_controller?

rescue_from Exception, :with => :render_not_found
#rescue_from Exception, :with => :render_not_found

private

Expand Down
15 changes: 9 additions & 6 deletions tutor/app/controllers/students_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ class StudentsController < ApplicationController
# @incomplete: [int] The number of incomplete problems
# Author: Mahdi
def get_performance
@solved = Attempt.where(student_id:params[:id], success:true).select("DISTINCT problem_id").count
@failed = Attempt.where(student_id:params[:id], failure:true).select("DISTINCT problem_id").count
@incomplete = Attempt.where(student_id:params[:id], incomplete:true).select("DISTINCT problem_id").count
@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
end

def list_courses
@courses_list = CourseStudent.where(student_id: current_student.id)
end
# [Performance of a student - Story 5.3]
# This method retrieve variables from tables in the database
# Parameters:
Expand All @@ -24,7 +27,7 @@ def get_performance
# An array of solved problems
# Author: Mahdi
def solved_problems
@solved_list = Attempt.where(student_id:params[:id], success:true).select("DISTINCT problem_id")
@solved_list = Attempt.where(student_id:params[:student_id], success: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 @@ -35,7 +38,7 @@ def solved_problems
# An array of failed problems
# Author: Mahdi
def failed_problems
@failure_list = Attempt.where(student_id:params[:id], failure:true).select("DISTINCT problem_id")
@failure_list = Attempt.where(student_id:params[:id], failure:true).where('topics.course_id' => params[:course_id]).select("DISTINCT problem_id")
end

# [Performance of a student - Story 5.3]
Expand All @@ -46,7 +49,7 @@ def failed_problems
# An array of incomplete problems
# Author: Mahdi
def incomplete_problems
@incomplete_list = Attempt.where(student_id:params[:id], incomplete:true).select("DISTINCT problem_id")
@incomplete_list = Attempt.where(student_id:params[:id], incomplete:true).where('topics.course_id' => params[:course_id]).select("DISTINCT problem_id")
end


Expand Down
17 changes: 7 additions & 10 deletions tutor/app/views/students/get_performance.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %>
<%= column_chart
[
[ "Solved ones", @solved ],
[ "Wrong attempts", @failed ],
[ "Uncompleted ones", @incomplete]
],
library: {bar: {groupWidth: "10%"}},
colors: ["lightblue"]
%>
<%= column_chart [["Solved ones", @solved],
["Wrong attempts", @failed],
["Incomplete attempts", @incomplete]],
library: {bar: {groupWidth: "10%"}},
colors: ["lightblue"]%>

<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>
<div><input class="btn btn-success" style="margin-left: 550px; margin-right:auto; margin-top: -110px" type="submit" value="Uncompleted Ones" /></div></form>
6 changes: 6 additions & 0 deletions tutor/app/views/students/list_courses.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h4>Choose a course :- </h4><br>
<% @courses_list.each do |crs| %>
<li> <%= link_to (Course.find_by_id(crs.course_id).name), students_get_performance_path(:student_id => crs.student_id, :course_id => crs.course_id) %></li><br>
<% end %>

<%= debug(@courses_list) %>
4 changes: 4 additions & 0 deletions tutor/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
post '/posts/:id' => 'posts#update'
post 'tracks/insert_recommendation' => 'tracks#insert_recommendation'
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'

get 'problems/edit'

Expand Down

0 comments on commit 134139c

Please sign in to comment.