Remove PairProgrammingExerciseFeedback

* Remove view, controller, routes & policy for PairProgrammingExerciseFeedback
* Keep model & database table
This commit is contained in:
kiragrammel
2023-10-13 12:18:28 +02:00
committed by Sebastian Serth
parent 2ce5687f53
commit 26552a0682
11 changed files with 26 additions and 228 deletions

View File

@ -6,12 +6,6 @@ module RedirectBehavior
def redirect_after_submit def redirect_after_submit
Rails.logger.debug { "Redirecting user with score:s #{@submission.normalized_score}" } 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 @submission.normalized_score.to_d == BigDecimal('1.0')
if redirect_to_community_solution? if redirect_to_community_solution?
redirect_to_community_solution redirect_to_community_solution
@ -105,16 +99,6 @@ module RedirectBehavior
@community_solution_lock.user == current_user @community_solution_lock.user == current_user
end 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 def redirect_to_user_feedback
uef = UserExerciseFeedback.find_by(exercise: @exercise, user: current_user) uef = UserExerciseFeedback.find_by(exercise: @exercise, user: current_user)
url = if uef url = if uef

View File

@ -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

View File

@ -593,8 +593,6 @@ class Exercise < ApplicationRecord
private :valid_submission_deadlines? private :valid_submission_deadlines?
def needs_more_feedback?(submission) def needs_more_feedback?(submission)
return false if PairProgramming23Study.experiment_course?(submission.study_group_id)
if submission.normalized_score.to_d == BigDecimal('1.0') if submission.normalized_score.to_d == BigDecimal('1.0')
user_exercise_feedbacks.final.size <= MAX_GROUP_EXERCISE_FEEDBACKS user_exercise_feedbacks.final.size <= MAX_GROUP_EXERCISE_FEEDBACKS
else else

View File

@ -12,6 +12,32 @@ class PairProgrammingExerciseFeedback < ApplicationRecord
scope :intermediate, -> { where.not(normalized_score: 1.00) } scope :intermediate, -> { where.not(normalized_score: 1.00) }
scope :final, -> { where(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 def to_s
'Pair Programming Exercise Feedback' 'Pair Programming Exercise Feedback'
end end

View File

@ -121,18 +121,12 @@ class Submission < ApplicationRecord
end end
def redirect_to_feedback? 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 # 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 # 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) # desired, the number of feedbacks can be limited with exercise.needs_more_feedback?(submission)
(contributor_id + exercise.created_at.to_i) % 10 == 1 (contributor_id + exercise.created_at.to_i) % 10 == 1
end end
def redirect_to_survey?
cause == 'submit' && pair_programming_exercise_feedback.blank? && PairProgramming23Study.experiment_course?(study_group_id)
end
def own_unsolved_rfc(user) def own_unsolved_rfc(user)
Pundit.policy_scope(user, RequestForComment).joins(:submission).where(submission: {contributor:}).unsolved.find_by(exercise:) Pundit.policy_scope(user, RequestForComment).joins(:submission).where(submission: {contributor:}).unsolved.find_by(exercise:)
end end

View File

@ -1,11 +0,0 @@
# frozen_string_literal: true
class PairProgrammingExerciseFeedbackPolicy < AdminOnlyPolicy
def create?
everyone
end
def new?
everyone
end
end

View File

@ -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)

View File

@ -1 +0,0 @@
= render('form')

View File

@ -230,9 +230,6 @@ de:
internal_user: internal_user:
one: Interner Nutzer one: Interner Nutzer
other: Interne Nutzer other: Interne Nutzer
pair_programming_exercise_feedback:
one: Feedback
other: Feedbacks
programming_group: programming_group:
one: Programmierpaar one: Programmierpaar
other: Programmierpaare other: Programmierpaare
@ -990,29 +987,6 @@ de:
previous_label: '&#8592; Vorherige Seite' previous_label: '&#8592; Vorherige Seite'
file_template: file_template:
no_template_label: "Leere Datei" no_template_label: "Leere Datei"
pair_programming_exercise_feedback:
difficulty_easy: "Die Aufgabe war viel zu einfach."
difficulty_some_what_easy: "Die Aufgabe war etwas zu einfach."
difficulty_ok: "Die Aufgabenschwierigkeit war genau richtig."
difficulty_some_what_difficult: "Die Aufgabe war etwas zu schwierig."
difficult_too_difficult: "Die Aufgabe war viel zu schwierig."
difficulty: "Schwierigkeit der Aufgabe:"
description: "Vielen Dank für Deine Abgabe! Bevor du die Aufgabe beendest, würden wir uns freuen, wenn Du uns hier Feedback zur Aufgabe gibst."
estimated_time_less_5: "weniger als 5 Minuten"
estimated_time_5_to_10: "zwischen 5 und 10 Minuten"
estimated_time_10_to_20: "zwischen 10 und 20 Minuten"
estimated_time_20_to_30: "zwischen 20 und 30 Minuten"
estimated_time_more_30: "mehr als 30 Minuten"
working_time: "Geschätze Bearbeitungszeit für diese Aufgabe:"
reason_no_partner: Ich habe keine:n Team-Partner:in gefunden.
reason_to_difficult_to_find_partner: Es war zu schwierig/aufwändig, eine:n Team Partner:in zu finden.
reason_faster_alone: Es ging schneller alleine zu arbeiten.
reason_not_working_with_strangers: Ich möchte nicht mit <i>fremden</i> Personen zusammenarbeiten.
reason_want_to_work_alone: Ich arbeite lieber alleine.
reason_accidentally_alone: Ich habe versehentlich alleine an dieser Aufgabe gearbeitet.
reason_other: <i>Sonstiges</i>
reason_work_alone: Warum hast Du Dich dafür entschieden die Aufgabe alleine zu lösen?
no_feedback: "Es wurde noch kein Feedback zu dieser Aufgabe gegeben."
user_exercise_feedback: user_exercise_feedback:
difficulty_easy: "Die Aufgabe war zu einfach" difficulty_easy: "Die Aufgabe war zu einfach"
difficulty_some_what_easy: "Die Aufgabe war etwas zu einfach" difficulty_some_what_easy: "Die Aufgabe war etwas zu einfach"

View File

@ -230,9 +230,6 @@ en:
internal_user: internal_user:
one: Internal User one: Internal User
other: Internal Users other: Internal Users
pair_programming_exercise_feedback:
one: Feedback
other: Feedbacks
programming_group: programming_group:
one: Programming Pair one: Programming Pair
other: Programming Pairs other: Programming Pairs
@ -990,29 +987,6 @@ en:
previous_label: '&#8592; Previous Page' previous_label: '&#8592; Previous Page'
file_template: file_template:
no_template_label: "Empty File" no_template_label: "Empty File"
pair_programming_exercise_feedback:
difficulty_easy: "The exercise was far too easy."
difficulty_some_what_easy: "The exercise was a bit too easy."
difficulty_ok: "The exercise difficulty was just right."
difficulty_some_what_difficult: "The exercise was a bit too difficult."
difficult_too_difficult: "The exercise was far too difficult."
difficulty: "Difficulty of the exercise:"
description: "Thank you for your submission! Before you finish the task, we kindly ask you for feedback for this exercise."
estimated_time_less_5: "less than 5 minutes"
estimated_time_5_to_10: "between 5 and 10 minutes"
estimated_time_10_to_20: "between 10 and 20 minutes"
estimated_time_20_to_30: "between 20 and 30 minutes"
estimated_time_more_30: "more than 30 minutes"
working_time: "Estimated time working on this exercise:"
reason_no_partner: I have not found a team partner.
reason_to_difficult_to_find_partner: It was too difficult to find a team partner.
reason_faster_alone: It was faster to work alone.
reason_not_working_with_strangers: I do not want to work with <i>strangers</i>.
reason_want_to_work_alone: I prefer to work alone.
reason_accidentally_alone: I accidentally worked alone on this exercise.
reason_other: <i>Other</i>
reason_work_alone: Why did you decide to solve this exercise alone?
no_feedback: "There is no feedback for this exercise yet."
user_exercise_feedback: user_exercise_feedback:
difficulty_easy: "the exercise was too easy" difficulty_easy: "the exercise was too easy"
difficulty_some_what_easy: "the exercise was somewhat easy" difficulty_some_what_easy: "the exercise was somewhat easy"

View File

@ -119,8 +119,6 @@ Rails.application.routes.draw do
resources :user_exercise_feedbacks, except: %i[show index] resources :user_exercise_feedbacks, except: %i[show index]
resources :pair_programming_exercise_feedbacks, only: %i[new create]
resources :external_users, only: %i[index show], concerns: :statistics do resources :external_users, only: %i[index show], concerns: :statistics do
resources :exercises do resources :exercises do
get :statistics, to: 'exercises#external_user_statistics', on: :member get :statistics, to: 'exercises#external_user_statistics', on: :member