From fc3e9ed4704dc6d64781a4bb3139558f135f1142 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Fri, 3 Aug 2018 13:20:31 +0200 Subject: [PATCH 1/3] Enable guessing the anomaly notification that triggered the user feedback --- app/models/user_exercise_feedback.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/user_exercise_feedback.rb b/app/models/user_exercise_feedback.rb index 5694573b..3075b96e 100644 --- a/app/models/user_exercise_feedback.rb +++ b/app/models/user_exercise_feedback.rb @@ -9,4 +9,9 @@ class UserExerciseFeedback < ActiveRecord::Base def to_s "User Exercise Feedback" end + + def anomaly_notification + AnomalyNotification.where({exercise_id: exercise.id, user_id: user_id, user_type: user_type}) + .where("created_at < ?", created_at).order("created_at DESC").to_a.first + end end From 064a7b8690be6b6733994c6643e05a6d61777947 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Fri, 3 Aug 2018 13:21:05 +0200 Subject: [PATCH 2/3] Show icon and tooltip for user feedback that was generated through the anomaly detection cycle --- app/views/exercises/feedback.html.slim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/exercises/feedback.html.slim b/app/views/exercises/feedback.html.slim index 3cdbc30f..508b1478 100644 --- a/app/views/exercises/feedback.html.slim +++ b/app/views/exercises/feedback.html.slim @@ -14,6 +14,8 @@ h1 = link_to(@exercise, exercise_path(@exercise)) .panel-heading role="tab" id="heading" div.clearfix.feedback-header span.username = link_to(feedback.user.name, statistics_external_user_exercise_path(id: @exercise.id, external_user_id: feedback.user.id)) + - if feedback.anomaly_notification + i class="fa fa-envelope-o" data-placement="top" data-toggle="tooltip" data-container="body" title=feedback.anomaly_notification.reason span.date = feedback.created_at .panel-collapse role="tabpanel" .panel-body.feedback @@ -22,3 +24,5 @@ h1 = link_to(@exercise, exercise_path(@exercise)) .worktime = "#{t('user_exercise_feedback.working_time')} #{feedback.user_estimated_worktime}" if feedback.user_estimated_worktime = render('shared/pagination', collection: @feedbacks) + + script type="text/javascript" $(function () { $('[data-toggle="tooltip"]').tooltip() }); From 1b7cb193d770657d32e98dcae9ef4fed9130f921 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Fri, 3 Aug 2018 13:21:23 +0200 Subject: [PATCH 3/3] Align feedback icon with header text --- app/assets/stylesheets/exercises.css.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/exercises.css.scss b/app/assets/stylesheets/exercises.css.scss index 2ef110d7..dbb3776e 100644 --- a/app/assets/stylesheets/exercises.css.scss +++ b/app/assets/stylesheets/exercises.css.scss @@ -114,6 +114,7 @@ a.file-heading { .feedback-header { display: flex; + align-items: baseline; .username { flex-grow: 1;