Remove PairProgrammingExerciseFeedback
* Remove view, controller, routes & policy for PairProgrammingExerciseFeedback * Keep model & database table
This commit is contained in:

committed by
Sebastian Serth

parent
2ce5687f53
commit
26552a0682
@ -6,12 +6,6 @@ module RedirectBehavior
|
||||
def redirect_after_submit
|
||||
Rails.logger.debug { "Redirecting user with score:s #{@submission.normalized_score}" }
|
||||
|
||||
# TEMPORARY: For the pythonjunior2023 course, we want to have a lot of feedback!
|
||||
if @submission.redirect_to_survey?
|
||||
redirect_to_pair_programming_survey
|
||||
return
|
||||
end
|
||||
|
||||
if @submission.normalized_score.to_d == BigDecimal('1.0')
|
||||
if redirect_to_community_solution?
|
||||
redirect_to_community_solution
|
||||
@ -105,16 +99,6 @@ module RedirectBehavior
|
||||
@community_solution_lock.user == current_user
|
||||
end
|
||||
|
||||
# TEMPORARY: For the pythonjunior2023 course, we introduced a pair programming survey
|
||||
def redirect_to_pair_programming_survey
|
||||
url = new_pair_programming_exercise_feedback_path(pair_programming_exercise_feedback: {exercise_id: @exercise.id, submission_id: @submission.id})
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(url) }
|
||||
format.json { render(json: {redirect: url}) }
|
||||
end
|
||||
end
|
||||
|
||||
def redirect_to_user_feedback
|
||||
uef = UserExerciseFeedback.find_by(exercise: @exercise, user: current_user)
|
||||
url = if uef
|
||||
|
@ -1,107 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PairProgrammingExerciseFeedbacksController < ApplicationController
|
||||
include CommonBehavior
|
||||
include RedirectBehavior
|
||||
|
||||
before_action :set_presets, only: %i[new create]
|
||||
|
||||
def comment_presets
|
||||
[[0, t('pair_programming_exercise_feedback.difficulty_easy')],
|
||||
[1, t('pair_programming_exercise_feedback.difficulty_some_what_easy')],
|
||||
[2, t('pair_programming_exercise_feedback.difficulty_ok')],
|
||||
[3, t('pair_programming_exercise_feedback.difficulty_some_what_difficult')],
|
||||
[4, t('pair_programming_exercise_feedback.difficult_too_difficult')]]
|
||||
end
|
||||
|
||||
def time_presets
|
||||
[[0, t('pair_programming_exercise_feedback.estimated_time_less_5')],
|
||||
[1, t('pair_programming_exercise_feedback.estimated_time_5_to_10')],
|
||||
[2, t('pair_programming_exercise_feedback.estimated_time_10_to_20')],
|
||||
[3, t('pair_programming_exercise_feedback.estimated_time_20_to_30')],
|
||||
[4, t('pair_programming_exercise_feedback.estimated_time_more_30')]]
|
||||
end
|
||||
|
||||
def reasons_presets
|
||||
[[0, t('pair_programming_exercise_feedback.reason_no_partner')],
|
||||
[1, t('pair_programming_exercise_feedback.reason_to_difficult_to_find_partner')],
|
||||
[2, t('pair_programming_exercise_feedback.reason_faster_alone')],
|
||||
[3, t('pair_programming_exercise_feedback.reason_not_working_with_strangers')],
|
||||
[4, t('pair_programming_exercise_feedback.reason_want_to_work_alone')],
|
||||
[5, t('pair_programming_exercise_feedback.reason_accidentally_alone')],
|
||||
[6, t('pair_programming_exercise_feedback.reason_other')]]
|
||||
end
|
||||
|
||||
def new
|
||||
exercise_id = if params[:pair_programming_exercise_feedback].nil?
|
||||
params[:exercise_id]
|
||||
else
|
||||
params[:pair_programming_exercise_feedback][:exercise_id]
|
||||
end
|
||||
@exercise = Exercise.find(exercise_id)
|
||||
|
||||
@submission = Submission.find(params[:pair_programming_exercise_feedback][:submission_id])
|
||||
authorize(@submission, :show?)
|
||||
|
||||
@uef = PairProgrammingExerciseFeedback.new(user: current_user, exercise: @exercise, programming_group:, submission: @submission)
|
||||
authorize!
|
||||
end
|
||||
|
||||
def create
|
||||
Sentry.set_extras(params: uef_params)
|
||||
|
||||
@exercise = Exercise.find(uef_params[:exercise_id])
|
||||
|
||||
if @exercise
|
||||
@uef = PairProgrammingExerciseFeedback.new(exercise: @exercise, programming_group:, study_group_id: current_user.current_study_group_id)
|
||||
@uef.update(uef_params)
|
||||
authorize!
|
||||
if validate_inputs(uef_params) && @uef.save
|
||||
redirect_after_submit
|
||||
else
|
||||
flash.now[:danger] = t('shared.message_failure')
|
||||
redirect_back fallback_location: pair_programming_exercise_feedback_path(@uef)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def authorize!
|
||||
authorize(@uef || @uefs)
|
||||
end
|
||||
|
||||
def set_presets
|
||||
@texts = comment_presets.to_a
|
||||
@times = time_presets.to_a
|
||||
@reasons = reasons_presets.to_a
|
||||
end
|
||||
|
||||
def uef_params
|
||||
return if params[:pair_programming_exercise_feedback].blank?
|
||||
|
||||
@submission = Submission.find(params[:pair_programming_exercise_feedback][:submission_id])
|
||||
|
||||
authorize(@submission, :show?)
|
||||
|
||||
params[:pair_programming_exercise_feedback]
|
||||
.permit(:difficulty, :user_estimated_worktime, :exercise_id, :reason_work_alone)
|
||||
.merge(user: current_user,
|
||||
submission: @submission,
|
||||
normalized_score: @submission&.normalized_score)
|
||||
end
|
||||
|
||||
def validate_inputs(uef_params)
|
||||
if uef_params[:difficulty].to_i.negative? || uef_params[:difficulty].to_i >= comment_presets.size
|
||||
false
|
||||
else
|
||||
!(uef_params[:user_estimated_worktime].to_i.negative? || uef_params[:user_estimated_worktime].to_i >= time_presets.size)
|
||||
end
|
||||
rescue StandardError
|
||||
false
|
||||
end
|
||||
|
||||
def programming_group
|
||||
current_contributor if current_contributor.programming_group?
|
||||
end
|
||||
end
|
@ -593,8 +593,6 @@ 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
|
||||
|
@ -12,6 +12,32 @@ class PairProgrammingExerciseFeedback < ApplicationRecord
|
||||
scope :intermediate, -> { where.not(normalized_score: 1.00) }
|
||||
scope :final, -> { where(normalized_score: 1.00) }
|
||||
|
||||
enum difficulty: {
|
||||
too_easy: 0,
|
||||
bit_too_easy: 1,
|
||||
just_right: 2,
|
||||
bit_too_difficult: 3,
|
||||
too_difficult: 4,
|
||||
}, _prefix: true
|
||||
|
||||
enum user_estimated_worktime: {
|
||||
less_5min: 0,
|
||||
between_5_and_10min: 1,
|
||||
between_10_and_20min: 2,
|
||||
between_20_and_30min: 3,
|
||||
more_30min: 4,
|
||||
}, _prefix: true
|
||||
|
||||
enum reason_work_alone: {
|
||||
found_no_partner: 0,
|
||||
too_difficult_to_find_partner: 1,
|
||||
faster_alone: 2,
|
||||
not_working_with_strangers: 3,
|
||||
prefer_to_work_alone: 4,
|
||||
accidentally_alone: 5,
|
||||
other: 6,
|
||||
}, _prefix: true
|
||||
|
||||
def to_s
|
||||
'Pair Programming Exercise Feedback'
|
||||
end
|
||||
|
@ -121,18 +121,12 @@ 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
|
||||
|
@ -1,11 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PairProgrammingExerciseFeedbackPolicy < AdminOnlyPolicy
|
||||
def create?
|
||||
everyone
|
||||
end
|
||||
|
||||
def new?
|
||||
everyone
|
||||
end
|
||||
end
|
@ -1,31 +0,0 @@
|
||||
= form_for(@uef) do |f|
|
||||
div
|
||||
h1 id="exercise-headline"
|
||||
= t('activerecord.models.user_exercise_feedback.one') + " " + @exercise.title
|
||||
= render('shared/form_errors', object: @uef)
|
||||
p
|
||||
== t('pair_programming_exercise_feedback.description')
|
||||
.mb-3
|
||||
h5.mt-4 = t('pair_programming_exercise_feedback.difficulty')
|
||||
= f.collection_radio_buttons :difficulty, @texts, :first, :last do |b|
|
||||
.form-check
|
||||
label.form-check-label
|
||||
= b.radio_button(class: 'form-check-input')
|
||||
= b.text
|
||||
h5.mt-4 = t('pair_programming_exercise_feedback.working_time')
|
||||
= f.collection_radio_buttons :user_estimated_worktime, @times, :first, :last do |b|
|
||||
.form-check
|
||||
label.form-check-label
|
||||
= b.radio_button(class: 'form-check-input')
|
||||
= b.text
|
||||
- if PairProgramming23Study.participate?(current_user, @exercise) && !current_contributor.programming_group?
|
||||
h5.mt-4 = t('pair_programming_exercise_feedback.reason_work_alone')
|
||||
= f.collection_radio_buttons :reason_work_alone, @reasons, :first, :last do |b|
|
||||
.form-check
|
||||
label.form-check-label
|
||||
= b.radio_button(class: 'form-check-input')
|
||||
== b.text
|
||||
|
||||
= f.hidden_field(:exercise_id, :value => @exercise.id)
|
||||
= f.hidden_field(:submission_id, :value => @submission.id)
|
||||
.actions = render('shared/submit_button', f: f, object: @uef)
|
@ -1 +0,0 @@
|
||||
= render('form')
|
Reference in New Issue
Block a user