From 3cf123c61e857a70e5ce480a949ded9ced238999 Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Wed, 12 Apr 2017 10:57:44 +0200 Subject: [PATCH] added working time estimation into user feedback --- .../user_exercise_feedbacks_controller.rb | 25 ++++++++++++++++--- .../user_exercise_feedbacks/_form.html.slim | 12 +++++++++ config/locales/de.yml | 8 +++++- config/locales/en.yml | 8 +++++- .../20170411090543_improve_user_feedback.rb | 3 +-- 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/app/controllers/user_exercise_feedbacks_controller.rb b/app/controllers/user_exercise_feedbacks_controller.rb index 4052fbb5..5b2a46d1 100644 --- a/app/controllers/user_exercise_feedbacks_controller.rb +++ b/app/controllers/user_exercise_feedbacks_controller.rb @@ -11,6 +11,14 @@ class UserExerciseFeedbacksController < ApplicationController [4,t('user_exercise_feedback.difficult_too_difficult')]] 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! authorize(@uef) end @@ -36,16 +44,18 @@ class UserExerciseFeedbacksController < ApplicationController def edit @texts = comment_presets.to_a + @times = time_presets.to_a authorize! end 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 private :uef_params def new @texts = comment_presets.to_a + @times = time_presets.to_a @uef = UserExerciseFeedback.new @exercise = Exercise.find(params[:user_exercise_feedback][:exercise_id]) authorize! @@ -68,11 +78,20 @@ class UserExerciseFeedbacksController < ApplicationController def set_user_exercise_feedback @exercise = Exercise.find(params[:user_exercise_feedback][:exercise_id]) @uef = UserExerciseFeedback.find_by(exercise_id: params[:user_exercise_feedback][:exercise_id], user: current_user) - @selectedDifficulty = @uef.difficulty end 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 \ No newline at end of file diff --git a/app/views/user_exercise_feedbacks/_form.html.slim b/app/views/user_exercise_feedbacks/_form.html.slim index ebea7859..c3a783aa 100644 --- a/app/views/user_exercise_feedbacks/_form.html.slim +++ b/app/views/user_exercise_feedbacks/_form.html.slim @@ -1,4 +1,13 @@ = 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) h4 == t('user_exercise_feedback.description') @@ -7,5 +16,8 @@ h4 = t('user_exercise_feedback.difficulty') = f.collection_radio_buttons :difficulty, @texts, :first, :last, html_options={class: "radio-inline"} do |b| = 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) .actions = render('shared/submit_button', f: f, object: @uef) diff --git a/config/locales/de.yml b/config/locales/de.yml index f6480823..0d7f8afd 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -535,5 +535,11 @@ de: difficulty_some_what_difficult: "es war etwas zu schwer" difficult_too_difficult: "es war zu schwer" difficulty: "Schwierigkeit der Aufgabe" - description: "Wir freuen uns, wenn Sie uns hier Feedback zur Aufgabe zu geben.
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?
Wir freuen uns über jedes Feedback." + description: "Wir freuen uns, wenn Sie uns hier Feedback zur Aufgabe zu geben.

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?
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" diff --git a/config/locales/en.yml b/config/locales/en.yml index 90ba7d10..c8cf5003 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -557,4 +557,10 @@ en: difficulty_some_what_difficult: "it was somewhat difficult" difficult_too_difficult: "it was too difficult" 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?" \ No newline at end of file + description: "We kindly ask you for feedback for this exercise.

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?
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" diff --git a/db/migrate/20170411090543_improve_user_feedback.rb b/db/migrate/20170411090543_improve_user_feedback.rb index 4050ee3a..bfbd8a02 100644 --- a/db/migrate/20170411090543_improve_user_feedback.rb +++ b/db/migrate/20170411090543_improve_user_feedback.rb @@ -1,6 +1,5 @@ class ImproveUserFeedback < ActiveRecord::Migration def change - remove_column :user_exercise_feedbacks, :difficulty - add_column :user_exercise_feedbacks, :difficulty, :string + add_column :user_exercise_feedbacks, :user_estimated_worktime, :integer end end