Add exercise feedback page for pair programming study

This commit is contained in:
kiragrammel
2023-09-05 22:07:00 +02:00
committed by Sebastian Serth
parent 79422225a8
commit 4b90a2a3c5
15 changed files with 261 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ class Exercise < ApplicationRecord
has_many :tags, through: :exercise_tags
accepts_nested_attributes_for :exercise_tags
has_many :user_exercise_feedbacks
has_many :pair_programming_exercise_feedbacks
has_many :exercise_tips
has_many :tips, through: :exercise_tips
@@ -590,6 +591,8 @@ class Exercise < ApplicationRecord
private :valid_submission_deadlines?
def needs_more_feedback?(submission)
return false if PairProgramming23Study.experiment_course?(submission.study_group_id)
if submission.normalized_score.to_d == BigDecimal('1.0')
user_exercise_feedbacks.final.size <= MAX_GROUP_EXERCISE_FEEDBACKS
else

View File

@@ -0,0 +1,18 @@
# frozen_string_literal: true
class PairProgrammingExerciseFeedback < ApplicationRecord
include Creation
belongs_to :exercise
belongs_to :submission
belongs_to :study_group
belongs_to :programming_group, optional: true
has_one :execution_environment, through: :exercise
scope :intermediate, -> { where.not(normalized_score: 1.00) }
scope :final, -> { where(normalized_score: 1.00) }
def to_s
'Pair Programming Exercise Feedback'
end
end

View File

@@ -11,6 +11,7 @@ class ProgrammingGroup < ApplicationRecord
has_many :runners, as: :contributor, dependent: :destroy
has_many :events
has_many :events_synchronized_editor, class_name: 'Event::SynchronizedEditor'
has_many :pair_programming_exercise_feedbacks
belongs_to :exercise
validate :min_group_size

View File

@@ -11,6 +11,7 @@ class StudyGroup < ApplicationRecord
has_many :lti_parameters, dependent: :delete_all
has_many :events
has_many :events_synchronized_editor, class_name: 'Event::SynchronizedEditor'
has_many :pair_programming_exercise_feedbacks
belongs_to :consumer
def users

View File

@@ -17,6 +17,8 @@ class Submission < ApplicationRecord
has_many :testruns
has_many :structured_errors, dependent: :destroy
has_many :comments, through: :files
has_one :user_exercise_feedback
has_one :pair_programming_exercise_feedback
belongs_to :external_users, lambda {
where(submissions: {contributor_type: 'ExternalUser'}).includes(:submissions)
@@ -118,12 +120,18 @@ class Submission < ApplicationRecord
end
def redirect_to_feedback?
return false if PairProgramming23Study.experiment_course?(study_group_id)
# 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)
(contributor_id + exercise.created_at.to_i) % 10 == 1
end
def redirect_to_survey?
cause == 'submit' && pair_programming_exercise_feedback.blank? && PairProgramming23Study.experiment_course?(study_group_id)
end
def own_unsolved_rfc(user)
Pundit.policy_scope(user, RequestForComment).joins(:submission).where(submission: {contributor:}).unsolved.find_by(exercise:)
end