Distinguish between intermediate and final feedback

* Also add more information to user_exercise_feedback
* Migrate existing feedback to enrich with submissions
This commit is contained in:
Sebastian Serth
2020-10-20 13:50:04 +02:00
parent 712810dada
commit ad467fa58f
7 changed files with 63 additions and 9 deletions

View File

@@ -46,7 +46,7 @@ class Exercise < ApplicationRecord
@working_time_statistics = nil
attr_reader :working_time_statistics
MAX_EXERCISE_FEEDBACKS = 20
MAX_GROUP_EXERCISE_FEEDBACKS = 20
def average_percentage
if average_score && (maximum_score != 0.0) && submissions.exists?(cause: 'submit')
@@ -550,8 +550,12 @@ class Exercise < ApplicationRecord
end
private :valid_submission_deadlines?
def needs_more_feedback?
user_exercise_feedbacks.size <= MAX_EXERCISE_FEEDBACKS
def needs_more_feedback?(submission)
if submission.normalized_score == 1.00
user_exercise_feedbacks.final.size <= MAX_GROUP_EXERCISE_FEEDBACKS
else
user_exercise_feedbacks.intermediate.size <= MAX_GROUP_EXERCISE_FEEDBACKS
end
end
def last_submission_per_user

View File

@@ -101,9 +101,9 @@ class Submission < ApplicationRecord
end
def redirect_to_feedback?
# Redirect 10% of users to the exercise feedback page. Ensure, that always the
# same users get redirected per exercise and different users for different exercises.
# If desired, the number of feedbacks can be limited with exercise.needs_more_feedback?
# Redirect 10% of users to the exercise feedback page. Ensure, that always the same
# users get redirected per exercise and different users for different exercises. If
# desired, the number of feedbacks can be limited with exercise.needs_more_feedback?(submission)
(user_id + exercise.created_at.to_i) % 10 == 1
end

View File

@@ -2,10 +2,14 @@ class UserExerciseFeedback < ApplicationRecord
include Creation
belongs_to :exercise
belongs_to :submission, optional: true
has_one :execution_environment, through: :exercise
validates :user_id, uniqueness: { scope: [:exercise_id, :user_type] }
scope :intermediate, -> { where.not(normalized_score: 1.00) }
scope :final, -> { where(normalized_score: 1.00) }
def to_s
"User Exercise Feedback"
end