diff --git a/app/assets/stylesheets/exercises.css.scss b/app/assets/stylesheets/exercises.css.scss index e46d59af..2ef110d7 100644 --- a/app/assets/stylesheets/exercises.css.scss +++ b/app/assets/stylesheets/exercises.css.scss @@ -95,14 +95,43 @@ a.file-heading { left: 0; } -.feedback { - .text { +.feedback-page { + .header { + font-weight: bold; margin-bottom: 10px; } - .difficulty { - font-weight: bold; + + .value { + border: 1px solid grey; + padding: 10px; + margin-bottom: 10px; } - .worktime { + + .no-feedback { font-weight: bold; + margin-top: 50px; + } + + .feedback-header { + display: flex; + + .username { + flex-grow: 1; + font-weight: bold; + } + + .date {} + } + + .feedback { + .text { + margin-bottom: 10px; + } + .difficulty { + font-weight: bold; + } + .worktime { + font-weight: bold; + } } } diff --git a/app/views/exercises/feedback.html.slim b/app/views/exercises/feedback.html.slim index 07b88167..3cdbc30f 100644 --- a/app/views/exercises/feedback.html.slim +++ b/app/views/exercises/feedback.html.slim @@ -1,15 +1,24 @@ -h1 = @exercise +h1 = link_to(@exercise, exercise_path(@exercise)) -ul.list-unstyled.panel-group#files - - @feedbacks.each do |feedback| - li.panel.panel-default - .panel-heading role="tab" id="heading" - div.clearfix - span = feedback.user.name - .panel-collapse role="tabpanel" - .panel-body.feedback - .text = feedback.feedback_text - .difficulty = "#{t('user_exercise_feedback.difficulty')} #{feedback.difficulty}" if feedback.difficulty - .worktime = "#{t('user_exercise_feedback.working_time')} #{feedback.user_estimated_worktime}" if feedback.user_estimated_worktime +.feedback-page + .header = t('activerecord.attributes.exercise.description') + .value = render_markdown(@exercise.description) -= render('shared/pagination', collection: @feedbacks) + .header = t('activerecord.models.user_exercise_feedback.other') + - if @feedbacks.nil? or @feedbacks.size == 0 + .no-feedback = t('user_exercise_feedback.no_feedback') + + ul.list-unstyled.panel-group + - @feedbacks.each do |feedback| + li.panel.panel-default + .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)) + span.date = feedback.created_at + .panel-collapse role="tabpanel" + .panel-body.feedback + .text = feedback.feedback_text + .difficulty = "#{t('user_exercise_feedback.difficulty')} #{feedback.difficulty}" if feedback.difficulty + .worktime = "#{t('user_exercise_feedback.working_time')} #{feedback.user_estimated_worktime}" if feedback.user_estimated_worktime + + = render('shared/pagination', collection: @feedbacks) diff --git a/config/locales/de.yml b/config/locales/de.yml index e4322037..ce03d90f 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -662,6 +662,7 @@ de: 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:" + no_feedback: "Es wurde noch kein Feedback zu dieser Aufgabe gegeben." error_templates: hints: signature: "Ein regulärer Ausdruck in Ruby-Syntax und ohne führende und schließende \"/\"" diff --git a/config/locales/en.yml b/config/locales/en.yml index 242ea312..be92de5b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -662,6 +662,7 @@ en: 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:" + no_feedback: "There is no feedback for this exercise yet." error_templates: hints: signature: "A regular expression in Ruby syntax without leading and trailing \"/\"" diff --git a/db/migrate/20171120153705_add_timestamps_to_user_exercise_feedbacks.rb b/db/migrate/20171120153705_add_timestamps_to_user_exercise_feedbacks.rb new file mode 100644 index 00000000..4529d527 --- /dev/null +++ b/db/migrate/20171120153705_add_timestamps_to_user_exercise_feedbacks.rb @@ -0,0 +1,6 @@ +class AddTimestampsToUserExerciseFeedbacks < ActiveRecord::Migration + def up + add_column :user_exercise_feedbacks, :created_at, :datetime, null: false, default: Time.now + add_column :user_exercise_feedbacks, :updated_at, :datetime, null: false, default: Time.now + end +end diff --git a/db/schema.rb b/db/schema.rb index 818030b1..3ed07240 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171002131135) do +ActiveRecord::Schema.define(version: 20171120153705) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -123,14 +123,14 @@ ActiveRecord::Schema.define(version: 20171002131135) do create_table "exercises", force: :cascade do |t| t.text "description" t.integer "execution_environment_id" - t.string "title", limit: 255 + t.string "title", limit: 255 t.datetime "created_at" t.datetime "updated_at" t.integer "user_id" t.text "instructions" t.boolean "public" - t.string "user_type", limit: 255 - t.string "token", limit: 255 + t.string "user_type", limit: 255 + t.string "token", limit: 255 t.boolean "hide_file_tree" t.boolean "allow_file_creation" t.boolean "allow_auto_completion", default: false @@ -347,13 +347,15 @@ ActiveRecord::Schema.define(version: 20171002131135) do end create_table "user_exercise_feedbacks", force: :cascade do |t| - t.integer "exercise_id", null: false - t.integer "user_id", null: false - t.string "user_type", null: false - t.integer "difficulty" - t.integer "working_time_seconds" - t.string "feedback_text" - t.integer "user_estimated_worktime" + t.integer "exercise_id", null: false + t.integer "user_id", null: false + t.string "user_type", null: false + t.integer "difficulty" + t.integer "working_time_seconds" + t.string "feedback_text" + t.integer "user_estimated_worktime" + t.datetime "created_at", default: '2017-11-20 18:20:25', null: false + t.datetime "updated_at", default: '2017-11-20 18:20:25', null: false end create_table "user_exercise_interventions", force: :cascade do |t|