added working time estimation into user feedback

This commit is contained in:
Thomas Hille
2017-04-12 10:57:44 +02:00
parent 8ca944558c
commit 3cf123c61e
5 changed files with 49 additions and 7 deletions

View File

@ -11,6 +11,14 @@ class UserExerciseFeedbacksController < ApplicationController
[4,t('user_exercise_feedback.difficult_too_difficult')]] [4,t('user_exercise_feedback.difficult_too_difficult')]]
end end
def time_presets
[[0,t('user_exercise_feedback.estimated_time_less_5')],
[1,t('user_exercise_feedback.estimated_time_5_to_10')],
[2,t('user_exercise_feedback.estimated_time_10_to_20')],
[3,t('user_exercise_feedback.estimated_time_20_to_30')],
[4,t('user_exercise_feedback.estimated_time_more_30')]]
end
def authorize! def authorize!
authorize(@uef) authorize(@uef)
end end
@ -36,16 +44,18 @@ class UserExerciseFeedbacksController < ApplicationController
def edit def edit
@texts = comment_presets.to_a @texts = comment_presets.to_a
@times = time_presets.to_a
authorize! authorize!
end end
def uef_params def uef_params
params[:user_exercise_feedback].permit(:feedback_text, :difficulty, :exercise_id).merge(user_id: current_user.id, user_type: current_user.class.name) params[:user_exercise_feedback].permit(:feedback_text, :difficulty, :exercise_id, :user_estimated_worktime).merge(user_id: current_user.id, user_type: current_user.class.name)
end end
private :uef_params private :uef_params
def new def new
@texts = comment_presets.to_a @texts = comment_presets.to_a
@times = time_presets.to_a
@uef = UserExerciseFeedback.new @uef = UserExerciseFeedback.new
@exercise = Exercise.find(params[:user_exercise_feedback][:exercise_id]) @exercise = Exercise.find(params[:user_exercise_feedback][:exercise_id])
authorize! authorize!
@ -68,11 +78,20 @@ class UserExerciseFeedbacksController < ApplicationController
def set_user_exercise_feedback def set_user_exercise_feedback
@exercise = Exercise.find(params[:user_exercise_feedback][:exercise_id]) @exercise = Exercise.find(params[:user_exercise_feedback][:exercise_id])
@uef = UserExerciseFeedback.find_by(exercise_id: params[:user_exercise_feedback][:exercise_id], user: current_user) @uef = UserExerciseFeedback.find_by(exercise_id: params[:user_exercise_feedback][:exercise_id], user: current_user)
@selectedDifficulty = @uef.difficulty
end end
def validate_inputs(uef_params) def validate_inputs(uef_params)
(uef_params[:difficulty].to_i >= 0 && uef_params[:difficulty].to_i < comment_presets.size) rescue false begin
if uef_params[:difficulty].to_i < 0 || uef_params[:difficulty].to_i >= comment_presets.size
return false
elsif uef_params[:user_estimated_worktime].to_i < 0 || uef_params[:user_estimated_worktime].to_i >= time_presets.size
return false
else
return true
end
rescue
return false
end
end end
end end

View File

@ -1,4 +1,13 @@
= form_for(@uef) do |f| = form_for(@uef) do |f|
div
span.badge.pull-right.score
h1 id="exercise-headline"
= t('activerecord.models.user_exercise_feedback.one') + " "
= link_to(@exercise.title, [:implement, @exercise])
#description-panel.lead.description-panel
u = t('activerecord.attributes.exercise.description')
= render_markdown(@exercise.description)
= render('shared/form_errors', object: @uef) = render('shared/form_errors', object: @uef)
h4 h4
== t('user_exercise_feedback.description') == t('user_exercise_feedback.description')
@ -7,5 +16,8 @@
h4 = t('user_exercise_feedback.difficulty') h4 = t('user_exercise_feedback.difficulty')
= f.collection_radio_buttons :difficulty, @texts, :first, :last, html_options={class: "radio-inline"} do |b| = f.collection_radio_buttons :difficulty, @texts, :first, :last, html_options={class: "radio-inline"} do |b|
= b.label(:class => 'radio') { b.radio_button + b.text } = b.label(:class => 'radio') { b.radio_button + b.text }
h4 = t('user_exercise_feedback.working_time')
= f.collection_radio_buttons :user_estimated_worktime, @times, :first, :last, html_options={class: "radio-inline"} do |b|
= b.label(:class => 'radio') { b.radio_button + b.text }
= f.hidden_field(:exercise_id, :value => @exercise.id) = f.hidden_field(:exercise_id, :value => @exercise.id)
.actions = render('shared/submit_button', f: f, object: @uef) .actions = render('shared/submit_button', f: f, object: @uef)

View File

@ -535,5 +535,11 @@ de:
difficulty_some_what_difficult: "es war etwas zu schwer" difficulty_some_what_difficult: "es war etwas zu schwer"
difficult_too_difficult: "es war zu schwer" difficult_too_difficult: "es war zu schwer"
difficulty: "Schwierigkeit der Aufgabe" difficulty: "Schwierigkeit der Aufgabe"
description: "Wir freuen uns, wenn Sie uns hier Feedback zur Aufgabe zu geben.<br>Bitte beschreiben Sie, was Ihnen an der Aufgabe gefallen hat und was nicht. Gabs Schwierigkeiten bei der Aufgabe? War die Aufgabe zu leicht oder zu schwer?<br>Wir freuen uns über jedes Feedback." description: "Wir freuen uns, wenn Sie uns hier Feedback zur Aufgabe zu geben.<br><br>Bitte beschreiben Sie, was Ihnen an der Aufgabe gefallen hat und was nicht. Gabs Schwierigkeiten bei der Aufgabe? War die Aufgabe zu leicht oder zu schwer?<br>Wir freuen uns über jedes Feedback."
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"

View File

@ -557,4 +557,10 @@ en:
difficulty_some_what_difficult: "it was somewhat difficult" difficulty_some_what_difficult: "it was somewhat difficult"
difficult_too_difficult: "it was too difficult" difficult_too_difficult: "it was too difficult"
difficulty: "Difficulty of the exercise" difficulty: "Difficulty of the exercise"
description: "Here you have the chance to comment on the exercise. Feel free to give us feedback on the exercise, the description or difficulty. Did you liked the question or was it too difficult or easy?" description: "We kindly ask you for feedback for this exercise.<br><br>Please describe what you liked on this exercise and what you did not. Was the exercise easy to understand or did you have problems understanding? How was the difficulty of the exercise to you?<br>We are happy about any feedback."
working_time: "Estimated time working on 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"

View File

@ -1,6 +1,5 @@
class ImproveUserFeedback < ActiveRecord::Migration class ImproveUserFeedback < ActiveRecord::Migration
def change def change
remove_column :user_exercise_feedbacks, :difficulty add_column :user_exercise_feedbacks, :user_estimated_worktime, :integer
add_column :user_exercise_feedbacks, :difficulty, :string
end end
end end