From 73c3b902a3fdf11c7c6f8bf3c95116eec6b70fe7 Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Tue, 11 Apr 2017 15:00:35 +0200 Subject: [PATCH 1/8] save progress. added user feedback view and stuff --- .../user_exercise_feedbacks_controller.rb | 42 +++++++++++++++++++ app/policies/user_exercise_feedback_policy.rb | 34 +++++++++++++++ .../user_exercise_feedbacks/_form.html.slim | 8 ++++ .../user_exercise_feedbacks/new.html.slim | 3 ++ config/locales/en.yml | 5 +++ config/routes.rb | 7 ++++ .../20170411090543_improve_user_feedback.rb | 6 +++ 7 files changed, 105 insertions(+) create mode 100644 app/controllers/user_exercise_feedbacks_controller.rb create mode 100644 app/policies/user_exercise_feedback_policy.rb create mode 100644 app/views/user_exercise_feedbacks/_form.html.slim create mode 100644 app/views/user_exercise_feedbacks/new.html.slim create mode 100644 db/migrate/20170411090543_improve_user_feedback.rb diff --git a/app/controllers/user_exercise_feedbacks_controller.rb b/app/controllers/user_exercise_feedbacks_controller.rb new file mode 100644 index 00000000..445b1a83 --- /dev/null +++ b/app/controllers/user_exercise_feedbacks_controller.rb @@ -0,0 +1,42 @@ +class UserExerciseFeedbackController < ApplicationController + include CommonBehavior + + def authorize! + authorize(@uef) + end + private :authorize! + + def create + @tag = Tag.new(tag_params) + authorize! + create_and_respond(object: @tag) + end + + def destroy + destroy_and_respond(object: @tag) + end + + def edit + end + + def uef_params + params[:tag].permit(:feedback_text, :difficulty) + end + private :uef_params + + def new + @uef = UserExerciseFeedback.new + authorize! + end + + def show + end + + def update + update_and_respond(object: @UserExerciseFeedback, params: uef_params) + end + + def to_s + name + end +end \ No newline at end of file diff --git a/app/policies/user_exercise_feedback_policy.rb b/app/policies/user_exercise_feedback_policy.rb new file mode 100644 index 00000000..8325b9fa --- /dev/null +++ b/app/policies/user_exercise_feedback_policy.rb @@ -0,0 +1,34 @@ +class TagPolicy < AdminOrAuthorPolicy + def author? + @user == @record.author + end + private :author? + + def batch_update? + admin? + end + + def show? + @user.internal_user? + end + + [:clone?, :destroy?, :edit?, :update?].each do |action| + define_method(action) { admin? || author?} + end + + [:reload?].each do |action| + define_method(action) { everyone } + end + + class Scope < Scope + def resolve + if @user.admin? + @scope.all + elsif @user.internal_user? + @scope.where('user_id = ? OR public = TRUE', @user.id) + else + @scope.none + end + end + end +end diff --git a/app/views/user_exercise_feedbacks/_form.html.slim b/app/views/user_exercise_feedbacks/_form.html.slim new file mode 100644 index 00000000..60bde323 --- /dev/null +++ b/app/views/user_exercise_feedbacks/_form.html.slim @@ -0,0 +1,8 @@ += form_for(@uef) do |f| + = render('shared/form_errors', object: @uef) + .form-group + = f.label(:feedback_text) + = f.text_field(:feedback_text, class: 'form-control', required: true) + = f.label(:difficulty) + = f.text_field(:difficulty, class: 'form-control', required: true) + .actions = render('shared/submit_button', f: f, object: @uef) diff --git a/app/views/user_exercise_feedbacks/new.html.slim b/app/views/user_exercise_feedbacks/new.html.slim new file mode 100644 index 00000000..7abfbd34 --- /dev/null +++ b/app/views/user_exercise_feedbacks/new.html.slim @@ -0,0 +1,3 @@ +h1 = t('shared.new_model', model: UserExerciseFeedback.model_name.human) + += render('form') diff --git a/config/locales/en.yml b/config/locales/en.yml index 853c703f..eeadb83a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -546,4 +546,9 @@ en: previous_label: '← Previous Page' file_template: no_template_label: "Empty File" + user_exercise_feedback: + easy: "it was easy" + some_what_easy: "it was somewhat easy" + some_what_difficult: "it was somewhat difficult" + difficult: "difficult" diff --git a/config/routes.rb b/config/routes.rb index a88a4c3d..281af37c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,6 +86,13 @@ Rails.application.routes.draw do end end + resources :user_exercise_feedbacks do + member do + get :reload + post :submit + end + end + resources :interventions do member do post :clone diff --git a/db/migrate/20170411090543_improve_user_feedback.rb b/db/migrate/20170411090543_improve_user_feedback.rb new file mode 100644 index 00000000..4050ee3a --- /dev/null +++ b/db/migrate/20170411090543_improve_user_feedback.rb @@ -0,0 +1,6 @@ +class ImproveUserFeedback < ActiveRecord::Migration + def change + remove_column :user_exercise_feedbacks, :difficulty + add_column :user_exercise_feedbacks, :difficulty, :string + end +end From e4d28452bf4ee6f4fcb9dcf8a406340fba5c2131 Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Tue, 11 Apr 2017 16:29:29 +0200 Subject: [PATCH 2/8] save progress --- app/controllers/exercises_controller.rb | 9 ++++ .../user_exercise_feedbacks_controller.rb | 53 +++++++++++++++---- app/policies/user_exercise_feedback_policy.rb | 6 ++- .../user_exercise_feedbacks/_form.html.slim | 11 ++-- .../user_exercise_feedbacks/edit.html.slim | 0 config/locales/en.yml | 4 ++ 6 files changed, 69 insertions(+), 14 deletions(-) create mode 100644 app/views/user_exercise_feedbacks/edit.html.slim diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 8af8bb8e..fc2848e7 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -164,6 +164,7 @@ class ExercisesController < ApplicationController private :handle_file_uploads def implement + redirect_to_user_feedback redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists? user_solved_exercise = @exercise.has_user_solved(current_user) user_got_enough_interventions = UserExerciseIntervention.where(user: current_user).where("created_at >= ?", Time.zone.now.beginning_of_day).count >= max_intervention_count @@ -409,4 +410,12 @@ class ExercisesController < ApplicationController redirect_to_lti_return_path end + def redirect_to_user_feedback + if UserExerciseFeedback.find_by(exercise: @exercise, user: current_user) + redirect_to(edit_user_exercise_feedback_path(user_exercise_feedback: {exercise_id: @exercise.id})) + else + redirect_to(new_user_exercise_feedback_path(user_exercise_feedback: {exercise_id: @exercise.id})) + end + end + end diff --git a/app/controllers/user_exercise_feedbacks_controller.rb b/app/controllers/user_exercise_feedbacks_controller.rb index 445b1a83..6a835a37 100644 --- a/app/controllers/user_exercise_feedbacks_controller.rb +++ b/app/controllers/user_exercise_feedbacks_controller.rb @@ -1,15 +1,33 @@ -class UserExerciseFeedbackController < ApplicationController +class UserExerciseFeedbacksController < ApplicationController include CommonBehavior + before_action :set_user_exercise_feedback, only: [:edit, :update] + + def comment_presets + [t('user_exercise_feedback.choose'), + t('user_exercise_feedback.easy'), + t('user_exercise_feedback.some_what_easy'), + t('user_exercise_feedback.some_what_difficult'), + t('user_exercise_feedback.difficult')] + end + def authorize! authorize(@uef) end private :authorize! def create - @tag = Tag.new(tag_params) - authorize! - create_and_respond(object: @tag) + if validate_feedback_text(uef_params[:difficulty]) + exercise = Exercise.find(uef_params[:exercise_id]) + if exercise + @uef = UserExerciseFeedback.new(uef_params) + authorize! + create_and_respond(object: @uef, path: proc{implement_exercise_path(exercise)}) + end + else + flash[:danger] = t('shared.message_failure') + redirect_to(:back, id: uef_params[:exercise_id]) + end end def destroy @@ -17,26 +35,43 @@ class UserExerciseFeedbackController < ApplicationController end def edit + @texts = comment_presets + authorize! end def uef_params - params[:tag].permit(:feedback_text, :difficulty) + params[:user_exercise_feedback].permit(:feedback_text, :difficulty, :exercise_id).merge(user_id: current_user.id, user_type: current_user.class.name) end private :uef_params def new + @texts = comment_presets @uef = UserExerciseFeedback.new + @exercise = Exercise.find(params[:user_exercise_feedback][:exercise_id]) authorize! end - def show - end - def update - update_and_respond(object: @UserExerciseFeedback, params: uef_params) + authorize! + if validate_feedback_text(uef_params[:difficulty]) && @exercise + update_and_respond(object: @uef, params: uef_params, path: implement_exercise_path(@exercise)) + else + flash[:danger] = t('shared.message_failure') + redirect_to(:back, id: uef_params[:exercise_id]) + end end def to_s name end + + def set_user_exercise_feedback + puts "params: #{params}" + @exercise = Exercise.find(params[:user_exercise_feedback][:exercise_id]) + @uef = UserExerciseFeedback.find_by(exercise_id: params[:user_exercise_feedback][:exercise_id], user: current_user) + end + + def validate_feedback_text(difficulty_text) + return comment_presets.include? difficulty_text + end end \ No newline at end of file diff --git a/app/policies/user_exercise_feedback_policy.rb b/app/policies/user_exercise_feedback_policy.rb index 8325b9fa..f005cc0d 100644 --- a/app/policies/user_exercise_feedback_policy.rb +++ b/app/policies/user_exercise_feedback_policy.rb @@ -1,4 +1,4 @@ -class TagPolicy < AdminOrAuthorPolicy +class UserExerciseFeedbackPolicy < AdminOrAuthorPolicy def author? @user == @record.author end @@ -8,6 +8,10 @@ class TagPolicy < AdminOrAuthorPolicy admin? end + def create? + everyone + end + def show? @user.internal_user? end diff --git a/app/views/user_exercise_feedbacks/_form.html.slim b/app/views/user_exercise_feedbacks/_form.html.slim index 60bde323..2d6cfd54 100644 --- a/app/views/user_exercise_feedbacks/_form.html.slim +++ b/app/views/user_exercise_feedbacks/_form.html.slim @@ -1,8 +1,11 @@ = form_for(@uef) do |f| = render('shared/form_errors', object: @uef) + h4 + p = t('user_exercise_feedback.description') .form-group - = f.label(:feedback_text) - = f.text_field(:feedback_text, class: 'form-control', required: true) - = f.label(:difficulty) - = f.text_field(:difficulty, class: 'form-control', required: true) + = f.text_area(:feedback_text, class: 'form-control', required: true, :rows => "10") + h4 = t('user_exercise_feedback.difficulty') + = f.collection_radio_buttons :difficulty, @texts, :to_s, :to_s, 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/app/views/user_exercise_feedbacks/edit.html.slim b/app/views/user_exercise_feedbacks/edit.html.slim new file mode 100644 index 00000000..e69de29b diff --git a/config/locales/en.yml b/config/locales/en.yml index eeadb83a..99d11c32 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -547,8 +547,12 @@ en: file_template: no_template_label: "Empty File" user_exercise_feedback: + choose: "choose one" easy: "it was easy" some_what_easy: "it was somewhat easy" some_what_difficult: "it was somewhat difficult" difficult: "difficult" + done: "done" + 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?" From 8ca944558c4a2979189fbb32061cf44b02794f92 Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Wed, 12 Apr 2017 10:13:23 +0200 Subject: [PATCH 3/8] improved texts of feedback, added ok button --- .../user_exercise_feedbacks_controller.rb | 37 ++++++++++--------- app/models/user_exercise_feedback.rb | 3 ++ .../user_exercise_feedbacks/_form.html.slim | 4 +- .../user_exercise_feedbacks/edit.html.slim | 1 + .../user_exercise_feedbacks/new.html.slim | 2 - config/locales/de.yml | 12 ++++++ config/locales/en.yml | 16 ++++---- 7 files changed, 46 insertions(+), 29 deletions(-) diff --git a/app/controllers/user_exercise_feedbacks_controller.rb b/app/controllers/user_exercise_feedbacks_controller.rb index 6a835a37..4052fbb5 100644 --- a/app/controllers/user_exercise_feedbacks_controller.rb +++ b/app/controllers/user_exercise_feedbacks_controller.rb @@ -4,11 +4,11 @@ class UserExerciseFeedbacksController < ApplicationController before_action :set_user_exercise_feedback, only: [:edit, :update] def comment_presets - [t('user_exercise_feedback.choose'), - t('user_exercise_feedback.easy'), - t('user_exercise_feedback.some_what_easy'), - t('user_exercise_feedback.some_what_difficult'), - t('user_exercise_feedback.difficult')] + [[0,t('user_exercise_feedback.difficulty_easy')], + [1,t('user_exercise_feedback.difficulty_some_what_easy')], + [2,t('user_exercise_feedback.difficulty_ok')], + [3,t('user_exercise_feedback.difficulty_some_what_difficult')], + [4,t('user_exercise_feedback.difficult_too_difficult')]] end def authorize! @@ -17,16 +17,16 @@ class UserExerciseFeedbacksController < ApplicationController private :authorize! def create - if validate_feedback_text(uef_params[:difficulty]) - exercise = Exercise.find(uef_params[:exercise_id]) - if exercise - @uef = UserExerciseFeedback.new(uef_params) + exercise = Exercise.find(uef_params[:exercise_id]) + if exercise + @uef = UserExerciseFeedback.new(uef_params) + if validate_inputs(uef_params) authorize! create_and_respond(object: @uef, path: proc{implement_exercise_path(exercise)}) + else + flash[:danger] = t('shared.message_failure') + redirect_to(:back, id: uef_params[:exercise_id]) end - else - flash[:danger] = t('shared.message_failure') - redirect_to(:back, id: uef_params[:exercise_id]) end end @@ -35,7 +35,7 @@ class UserExerciseFeedbacksController < ApplicationController end def edit - @texts = comment_presets + @texts = comment_presets.to_a authorize! end @@ -45,7 +45,7 @@ class UserExerciseFeedbacksController < ApplicationController private :uef_params def new - @texts = comment_presets + @texts = comment_presets.to_a @uef = UserExerciseFeedback.new @exercise = Exercise.find(params[:user_exercise_feedback][:exercise_id]) authorize! @@ -53,7 +53,7 @@ class UserExerciseFeedbacksController < ApplicationController def update authorize! - if validate_feedback_text(uef_params[:difficulty]) && @exercise + if @exercise && validate_inputs(uef_params) update_and_respond(object: @uef, params: uef_params, path: implement_exercise_path(@exercise)) else flash[:danger] = t('shared.message_failure') @@ -66,12 +66,13 @@ class UserExerciseFeedbacksController < ApplicationController end def set_user_exercise_feedback - puts "params: #{params}" @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_feedback_text(difficulty_text) - return comment_presets.include? difficulty_text + def validate_inputs(uef_params) + (uef_params[:difficulty].to_i >= 0 && uef_params[:difficulty].to_i < comment_presets.size) rescue false end + end \ No newline at end of file diff --git a/app/models/user_exercise_feedback.rb b/app/models/user_exercise_feedback.rb index d3ec09d5..4ff9626e 100644 --- a/app/models/user_exercise_feedback.rb +++ b/app/models/user_exercise_feedback.rb @@ -5,4 +5,7 @@ class UserExerciseFeedback < ActiveRecord::Base validates :user_id, uniqueness: { scope: [:exercise_id, :user_type] } + def to_s + "User Exercise Feedback" + 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 2d6cfd54..ebea7859 100644 --- a/app/views/user_exercise_feedbacks/_form.html.slim +++ b/app/views/user_exercise_feedbacks/_form.html.slim @@ -1,11 +1,11 @@ = form_for(@uef) do |f| = render('shared/form_errors', object: @uef) h4 - p = t('user_exercise_feedback.description') + == t('user_exercise_feedback.description') .form-group = f.text_area(:feedback_text, class: 'form-control', required: true, :rows => "10") h4 = t('user_exercise_feedback.difficulty') - = f.collection_radio_buttons :difficulty, @texts, :to_s, :to_s, 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 } = f.hidden_field(:exercise_id, :value => @exercise.id) .actions = render('shared/submit_button', f: f, object: @uef) diff --git a/app/views/user_exercise_feedbacks/edit.html.slim b/app/views/user_exercise_feedbacks/edit.html.slim index e69de29b..7e5cfff1 100644 --- a/app/views/user_exercise_feedbacks/edit.html.slim +++ b/app/views/user_exercise_feedbacks/edit.html.slim @@ -0,0 +1 @@ += render('form') diff --git a/app/views/user_exercise_feedbacks/new.html.slim b/app/views/user_exercise_feedbacks/new.html.slim index 7abfbd34..7e5cfff1 100644 --- a/app/views/user_exercise_feedbacks/new.html.slim +++ b/app/views/user_exercise_feedbacks/new.html.slim @@ -1,3 +1 @@ -h1 = t('shared.new_model', model: UserExerciseFeedback.model_name.human) - = render('form') diff --git a/config/locales/de.yml b/config/locales/de.yml index 80f88c2a..f6480823 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -152,6 +152,9 @@ de: submission: one: Abgabe other: Abgaben + user_exercise_feedback: + one: Feedback + other: Feedback errors: messages: together: 'muss zusammen mit %{attribute} definiert werden' @@ -525,3 +528,12 @@ de: previous_label: '← Vorherige Seite' file_template: no_template_label: "Leere Datei" + user_exercise_feedback: + difficulty_easy: "es war zu einfach" + difficulty_some_what_easy: "es war etwas zu einfach" + difficulty_ok: "es war ok" + 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." + diff --git a/config/locales/en.yml b/config/locales/en.yml index 99d11c32..90ba7d10 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -173,6 +173,9 @@ en: submission: one: Submission other: Submissions + user_exercise_feedback: + one: Feedback + other: Feedback errors: messages: together: 'has to be set along with %{attribute}' @@ -548,11 +551,10 @@ en: no_template_label: "Empty File" user_exercise_feedback: choose: "choose one" - easy: "it was easy" - some_what_easy: "it was somewhat easy" - some_what_difficult: "it was somewhat difficult" - difficult: "difficult" - done: "done" + difficulty_easy: "it was too easy" + difficulty_some_what_easy: "it was somewhat easy" + difficulty_ok: "it was just right" + 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?" - + 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 From 3cf123c61e857a70e5ce480a949ded9ced238999 Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Wed, 12 Apr 2017 10:57:44 +0200 Subject: [PATCH 4/8] 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 From 60e587b6903bdfc325831b6bba46927a3fa0e989 Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Wed, 12 Apr 2017 11:47:39 +0200 Subject: [PATCH 5/8] removed comment on exercise in the RFC view. redirect 10% of user instead of redirecting to the RFC view to the feedback view. redirect all users how submitted to the feedback view if score is less than 100% --- app/controllers/exercises_controller.rb | 11 ++++++-- .../user_exercise_feedbacks_controller.rb | 26 ++++++++++++++++--- .../_comment_exercise_dialogcontent.html.slim | 5 ---- app/views/request_for_comments/show.html.erb | 25 ------------------ .../user_exercise_feedbacks/_form.html.slim | 6 ++--- config/locales/de.yml | 2 +- config/locales/en.yml | 2 +- 7 files changed, 36 insertions(+), 41 deletions(-) delete mode 100644 app/views/exercises/_comment_exercise_dialogcontent.html.slim diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index fc2848e7..2e33d11a 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -164,7 +164,6 @@ class ExercisesController < ApplicationController private :handle_file_uploads def implement - redirect_to_user_feedback redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists? user_solved_exercise = @exercise.has_user_solved(current_user) user_got_enough_interventions = UserExerciseIntervention.where(user: current_user).where("created_at >= ?", Time.zone.now.beginning_of_day).count >= max_intervention_count @@ -381,7 +380,11 @@ class ExercisesController < ApplicationController if @submission.normalized_score == 1.0 # if user is external and has an own rfc, redirect to it and message him to clean up and accept the answer. (we need to check that the user is external, # otherwise an internal user could be shown a false rfc here, since current_user.id is polymorphic, but only makes sense for external users when used with rfcs.) - if current_user.respond_to? :external_id + # redirect 10 percent pseudorandomly to the feedback page + if ((current_user.id + @submission.exercise.created_at.to_i) % 10 == 1) + redirect_to_user_feedback + return + elsif current_user.respond_to? :external_id if rfc = RequestForComment.unsolved.where(exercise_id: @submission.exercise, user_id: current_user.id).first # set a message that informs the user that his own RFC should be closed. flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_own_rfc') @@ -406,6 +409,10 @@ class ExercisesController < ApplicationController return end end + else + # redirect to feedback page if score is less than 100 percent + redirect_to_user_feedback + return end redirect_to_lti_return_path end diff --git a/app/controllers/user_exercise_feedbacks_controller.rb b/app/controllers/user_exercise_feedbacks_controller.rb index 5b2a46d1..0d1e1925 100644 --- a/app/controllers/user_exercise_feedbacks_controller.rb +++ b/app/controllers/user_exercise_feedbacks_controller.rb @@ -25,17 +25,27 @@ class UserExerciseFeedbacksController < ApplicationController private :authorize! def create - exercise = Exercise.find(uef_params[:exercise_id]) - if exercise + @exercise = Exercise.find(uef_params[:exercise_id]) + rfc = RequestForComment.unsolved.where(exercise_id: @exercise.id, user_id: current_user.id).first + submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first rescue nil + + if @exercise @uef = UserExerciseFeedback.new(uef_params) if validate_inputs(uef_params) authorize! - create_and_respond(object: @uef, path: proc{implement_exercise_path(exercise)}) + path = + if rfc && submission && submission.normalized_score == 1.0 + request_for_comment_path(rfc) + else + implement_exercise_path(@exercise) + end + create_and_respond(object: @uef, path: proc{path}) else flash[:danger] = t('shared.message_failure') redirect_to(:back, id: uef_params[:exercise_id]) end end + end def destroy @@ -62,9 +72,17 @@ class UserExerciseFeedbacksController < ApplicationController end def update + submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first rescue nil + rfc = RequestForComment.unsolved.where(exercise_id: @exercise.id, user_id: current_user.id).first authorize! if @exercise && validate_inputs(uef_params) - update_and_respond(object: @uef, params: uef_params, path: implement_exercise_path(@exercise)) + path = + if rfc && submission && submission.normalized_score == 1.0 + request_for_comment_path(rfc) + else + implement_exercise_path(@exercise) + end + update_and_respond(object: @uef, params: uef_params, path: path) else flash[:danger] = t('shared.message_failure') redirect_to(:back, id: uef_params[:exercise_id]) diff --git a/app/views/exercises/_comment_exercise_dialogcontent.html.slim b/app/views/exercises/_comment_exercise_dialogcontent.html.slim deleted file mode 100644 index 89d1fd41..00000000 --- a/app/views/exercises/_comment_exercise_dialogcontent.html.slim +++ /dev/null @@ -1,5 +0,0 @@ -h5 =t('exercises.implement.comment.addComment') -textarea#commentOnExercise.form-control(style='resize:none;') - -p='' -button#addCommentExerciseButton.btn.btn-block.btn-primary(type='button') =t('exercises.implement.comment.addCommentButton') diff --git a/app/views/request_for_comments/show.html.erb b/app/views/request_for_comments/show.html.erb index 57c48828..ffc7f661 100644 --- a/app/views/request_for_comments/show.html.erb +++ b/app/views/request_for_comments/show.html.erb @@ -20,7 +20,6 @@ <%= t('activerecord.attributes.request_for_comments.question')%>: <%= t('request_for_comments.no_question') %> <% end %> - <% if (policy(@request_for_comment).mark_as_solved? and not @request_for_comment.solved?) %> @@ -62,7 +61,6 @@ also, all settings from the rails model needed for the editor configuration in t <% end %> <%= render('shared/modal', id: 'comment-modal', title: t('exercises.implement.comment.dialogtitle'), template: 'exercises/_comment_dialogcontent') %> -<%= render('shared/modal', id: 'comment-exercise-modal', title: t('exercises.implement.comment.addCommentExercise'), template: 'exercises/_comment_exercise_dialogcontent') %>