added matrix and score/time calculations
This commit is contained in:
@ -107,7 +107,7 @@ class Exercise < ActiveRecord::Base
|
|||||||
(created_at - lag(created_at) over (PARTITION BY user_id
|
(created_at - lag(created_at) over (PARTITION BY user_id
|
||||||
ORDER BY created_at)) AS working_time
|
ORDER BY created_at)) AS working_time
|
||||||
FROM submissions
|
FROM submissions
|
||||||
WHERE exercise_id=#{id} and user_id=#{user_id}) AS foo) AS bar
|
WHERE exercise_id=#{id} and user_id=#{user_id} and user_type='ExternalUser') AS foo) AS bar
|
||||||
""").first["working_time"]
|
""").first["working_time"]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -172,8 +172,12 @@ class Exercise < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
private :generate_token
|
private :generate_token
|
||||||
|
|
||||||
def maximum_score
|
def maximum_score(*user)
|
||||||
files.teacher_defined_tests.sum(:weight)
|
if user
|
||||||
|
submissions.where(user: user, cause: "assess").where("score IS NOT NULL").order("score DESC").first.score || 0 rescue 0
|
||||||
|
else
|
||||||
|
files.teacher_defined_tests.sum(:weight)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_default_values
|
def set_default_values
|
||||||
|
@ -43,8 +43,22 @@ class ProxyExercise < ActiveRecord::Base
|
|||||||
exercises.shuffle.first
|
exercises.shuffle.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# [score][quantile]
|
||||||
|
def scoring_matrix
|
||||||
|
[
|
||||||
|
[0 ,0 ,0 ,0 ,0 ],
|
||||||
|
[0.2,0.2,0.2,0.2,0.1],
|
||||||
|
[0.5,0.5,0.4,0.4,0.3],
|
||||||
|
[0.6,0.6,0.5,0.5,0.4],
|
||||||
|
[1 ,1 ,0.9,0.8,0.7],
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
def score(user, ex)
|
def score(user, ex)
|
||||||
1
|
points_ratio = ex.maximum_score(user) / ex.maximum_score.to_f
|
||||||
|
working_time_user = Time.parse(ex.average_working_time_for_only(user.id) || "00:00:00")
|
||||||
|
scoring_matrix = scoring_matrix
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def getRelativeKnowledgeLoss(user, execises)
|
def getRelativeKnowledgeLoss(user, execises)
|
||||||
|
Reference in New Issue
Block a user