From bce58071d13b6a85e00f6823bef78c40b023b4b9 Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Tue, 3 Oct 2017 18:46:39 +0200 Subject: [PATCH 1/4] removed expected working time from show/create/index and database since we do not use it --- app/controllers/exercises_controller.rb | 3 +- app/views/exercises/_form.html.slim | 3 -- app/views/exercises/index.html.slim | 2 - app/views/exercises/show.html.slim | 1 - config/locales/de.yml | 1 - config/locales/en.yml | 1 - ...1002131135_remove_expected_working_time.rb | 5 ++ db/schema.rb | 50 ++++++++++++++++--- 8 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20171002131135_remove_expected_working_time.rb diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 141b47ee..4734b2c1 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -143,8 +143,7 @@ class ExercisesController < ApplicationController private :user_by_code_harbor_token def exercise_params - params[:exercise][:expected_worktime_seconds] = params[:exercise][:expected_worktime_minutes].to_i * 60 - params[:exercise].permit(:description, :execution_environment_id, :file_id, :instructions, :public, :hide_file_tree, :allow_file_creation, :allow_auto_completion, :title, :expected_difficulty, :expected_worktime_seconds, files_attributes: file_attributes, :tag_ids => []).merge(user_id: current_user.id, user_type: current_user.class.name) + params[:exercise].permit(:description, :execution_environment_id, :file_id, :instructions, :public, :hide_file_tree, :allow_file_creation, :allow_auto_completion, :title, :expected_difficulty, files_attributes: file_attributes, :tag_ids => []).merge(user_id: current_user.id, user_type: current_user.class.name) end private :exercise_params diff --git a/app/views/exercises/_form.html.slim b/app/views/exercises/_form.html.slim index bb4aa851..646c359a 100644 --- a/app/views/exercises/_form.html.slim +++ b/app/views/exercises/_form.html.slim @@ -35,9 +35,6 @@ .form-group = f.label(t('activerecord.attributes.exercise.difficulty')) = f.number_field :expected_difficulty, in: 1..10, step: 1 - .form-group - = f.label(t('activerecord.attributes.exercise.worktime')) - = f.number_field "expected_worktime_minutes", value: @exercise.expected_worktime_seconds / 60, in: 1..1000, step: 1 h2 = t('exercises.form.tags') ul.list-unstyled.panel-group diff --git a/app/views/exercises/index.html.slim b/app/views/exercises/index.html.slim index bd8fe880..8b78af65 100644 --- a/app/views/exercises/index.html.slim +++ b/app/views/exercises/index.html.slim @@ -18,7 +18,6 @@ h1 = Exercise.model_name.human(count: 2) th = t('activerecord.attributes.exercise.maximum_score') th = t('activerecord.attributes.exercise.tags') th = t('activerecord.attributes.exercise.difficulty') - th = t('activerecord.attributes.exercise.worktime') th = t('activerecord.attributes.exercise.public') - if policy(Exercise).batch_update? @@ -34,7 +33,6 @@ h1 = Exercise.model_name.human(count: 2) td = exercise.maximum_score td = exercise.exercise_tags.count td = exercise.expected_difficulty - td = (exercise.expected_worktime_seconds / 60).ceil td.public data-value=exercise.public? = symbol_for(exercise.public?) td = link_to(t('shared.edit'), edit_exercise_path(exercise)) if policy(exercise).edit? td = link_to(t('.implement'), implement_exercise_path(exercise)) if policy(exercise).implement? diff --git a/app/views/exercises/show.html.slim b/app/views/exercises/show.html.slim index 1efbd612..e3dfc7d5 100644 --- a/app/views/exercises/show.html.slim +++ b/app/views/exercises/show.html.slim @@ -20,7 +20,6 @@ h1 = row(label: 'exercise.embedding_parameters') do = content_tag(:input, nil, class: 'form-control', readonly: true, value: embedding_parameters(@exercise)) = row(label: 'exercise.difficulty', value: @exercise.expected_difficulty) -= row(label: 'exercise.worktime', value: "#{@exercise.expected_worktime_seconds/60} min") = row(label: 'exercise.tags', value: @exercise.exercise_tags.map{|et| "#{et.tag.name} (#{et.factor})"}.sort.join(", ")) h2 = t('activerecord.attributes.exercise.files') diff --git a/config/locales/de.yml b/config/locales/de.yml index a97023a4..27aba44f 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -41,7 +41,6 @@ de: allow_auto_completion: "Autovervollständigung aktivieren" allow_file_creation: "Dateierstellung erlauben" difficulty: Schwierigkeitsgrad - worktime: "vermutete Arbeitszeit in Minuten" token: "Aufgaben-Token" proxy_exercise: title: Title diff --git a/config/locales/en.yml b/config/locales/en.yml index 3d6e6b9c..380e5d7e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -41,7 +41,6 @@ en: allow_auto_completion: "Allow auto completion" allow_file_creation: "Allow file creation" difficulty: Difficulty - worktime: "Expected worktime in minutes" token: "Exercise Token" proxy_exercise: title: Title diff --git a/db/migrate/20171002131135_remove_expected_working_time.rb b/db/migrate/20171002131135_remove_expected_working_time.rb new file mode 100644 index 00000000..eb4bbcb4 --- /dev/null +++ b/db/migrate/20171002131135_remove_expected_working_time.rb @@ -0,0 +1,5 @@ +class RemoveExpectedWorkingTime < ActiveRecord::Migration + def change + remove_column :exercises, :expected_worktime_seconds + end +end diff --git a/db/schema.rb b/db/schema.rb index 988cd447..c8eb631b 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: 20170920145852) do +ActiveRecord::Schema.define(version: 20171002131135) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -47,6 +47,13 @@ ActiveRecord::Schema.define(version: 20170920145852) do t.string "oauth_secret", limit: 255 end + create_table "copy_paste_events", id: false, force: :cascade do |t| + t.integer "exercise_id" + t.string "text" + t.integer "user_id" + t.datetime "created_at" + end + create_table "errors", force: :cascade do |t| t.integer "execution_environment_id" t.text "message" @@ -99,19 +106,18 @@ ActiveRecord::Schema.define(version: 20170920145852) 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 - t.integer "expected_worktime_seconds", default: 60 - t.integer "expected_difficulty", default: 1 + t.boolean "allow_auto_completion", default: false + t.integer "expected_difficulty", default: 1 end create_table "exercises_proxy_exercises", id: false, force: :cascade do |t| @@ -124,6 +130,11 @@ ActiveRecord::Schema.define(version: 20170920145852) do add_index "exercises_proxy_exercises", ["exercise_id"], name: "index_exercises_proxy_exercises_on_exercise_id", using: :btree add_index "exercises_proxy_exercises", ["proxy_exercise_id"], name: "index_exercises_proxy_exercises_on_proxy_exercise_id", using: :btree + create_table "external_user_skill_level", id: false, force: :cascade do |t| + t.string "external_user_id" + t.integer "skill_level" + end + create_table "external_users", force: :cascade do |t| t.integer "consumer_id" t.string "email", limit: 255 @@ -342,4 +353,29 @@ ActiveRecord::Schema.define(version: 20170920145852) do add_index "user_proxy_exercise_exercises", ["proxy_exercise_id"], name: "index_user_proxy_exercise_exercises_on_proxy_exercise_id", using: :btree add_index "user_proxy_exercise_exercises", ["user_type", "user_id"], name: "index_user_proxy_exercise_exercises_on_user_type_and_user_id", using: :btree + create_table "user_proxy_exercise_exercises_copy", id: false, force: :cascade do |t| + t.integer "id" + t.integer "user_id" + t.string "user_type" + t.integer "proxy_exercise_id" + t.integer "exercise_id" + t.datetime "created_at" + t.datetime "updated_at" + t.json "reason" + t.json "reason_json" + end + + create_table "wk_with_wk_until_rfc", id: false, force: :cascade do |t| + t.string "external_user_id", limit: 255 + t.integer "user_id" + t.integer "exercise_id" + t.float "max_score" + t.float "max_reachable_points" + t.string "working_time" + t.string "working_time_until_rfc" + t.string "working_time_until_rfc_reply" + t.time "percentile75" + t.time "percentile90" + end + end From 95a849e9f551e369d47f5743e2f643d0d0f6ce40 Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Tue, 3 Oct 2017 18:46:39 +0200 Subject: [PATCH 2/4] removed expected working time from show/create/index and database since we do not use it --- app/controllers/exercises_controller.rb | 3 +- app/views/exercises/_form.html.slim | 3 -- app/views/exercises/index.html.slim | 2 - app/views/exercises/show.html.slim | 1 - config/locales/de.yml | 1 - config/locales/en.yml | 1 - ...1002131135_remove_expected_working_time.rb | 5 ++ db/schema.rb | 50 ++++++++++++++++--- 8 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20171002131135_remove_expected_working_time.rb diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 141b47ee..4734b2c1 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -143,8 +143,7 @@ class ExercisesController < ApplicationController private :user_by_code_harbor_token def exercise_params - params[:exercise][:expected_worktime_seconds] = params[:exercise][:expected_worktime_minutes].to_i * 60 - params[:exercise].permit(:description, :execution_environment_id, :file_id, :instructions, :public, :hide_file_tree, :allow_file_creation, :allow_auto_completion, :title, :expected_difficulty, :expected_worktime_seconds, files_attributes: file_attributes, :tag_ids => []).merge(user_id: current_user.id, user_type: current_user.class.name) + params[:exercise].permit(:description, :execution_environment_id, :file_id, :instructions, :public, :hide_file_tree, :allow_file_creation, :allow_auto_completion, :title, :expected_difficulty, files_attributes: file_attributes, :tag_ids => []).merge(user_id: current_user.id, user_type: current_user.class.name) end private :exercise_params diff --git a/app/views/exercises/_form.html.slim b/app/views/exercises/_form.html.slim index bb4aa851..646c359a 100644 --- a/app/views/exercises/_form.html.slim +++ b/app/views/exercises/_form.html.slim @@ -35,9 +35,6 @@ .form-group = f.label(t('activerecord.attributes.exercise.difficulty')) = f.number_field :expected_difficulty, in: 1..10, step: 1 - .form-group - = f.label(t('activerecord.attributes.exercise.worktime')) - = f.number_field "expected_worktime_minutes", value: @exercise.expected_worktime_seconds / 60, in: 1..1000, step: 1 h2 = t('exercises.form.tags') ul.list-unstyled.panel-group diff --git a/app/views/exercises/index.html.slim b/app/views/exercises/index.html.slim index bd8fe880..8b78af65 100644 --- a/app/views/exercises/index.html.slim +++ b/app/views/exercises/index.html.slim @@ -18,7 +18,6 @@ h1 = Exercise.model_name.human(count: 2) th = t('activerecord.attributes.exercise.maximum_score') th = t('activerecord.attributes.exercise.tags') th = t('activerecord.attributes.exercise.difficulty') - th = t('activerecord.attributes.exercise.worktime') th = t('activerecord.attributes.exercise.public') - if policy(Exercise).batch_update? @@ -34,7 +33,6 @@ h1 = Exercise.model_name.human(count: 2) td = exercise.maximum_score td = exercise.exercise_tags.count td = exercise.expected_difficulty - td = (exercise.expected_worktime_seconds / 60).ceil td.public data-value=exercise.public? = symbol_for(exercise.public?) td = link_to(t('shared.edit'), edit_exercise_path(exercise)) if policy(exercise).edit? td = link_to(t('.implement'), implement_exercise_path(exercise)) if policy(exercise).implement? diff --git a/app/views/exercises/show.html.slim b/app/views/exercises/show.html.slim index 1efbd612..e3dfc7d5 100644 --- a/app/views/exercises/show.html.slim +++ b/app/views/exercises/show.html.slim @@ -20,7 +20,6 @@ h1 = row(label: 'exercise.embedding_parameters') do = content_tag(:input, nil, class: 'form-control', readonly: true, value: embedding_parameters(@exercise)) = row(label: 'exercise.difficulty', value: @exercise.expected_difficulty) -= row(label: 'exercise.worktime', value: "#{@exercise.expected_worktime_seconds/60} min") = row(label: 'exercise.tags', value: @exercise.exercise_tags.map{|et| "#{et.tag.name} (#{et.factor})"}.sort.join(", ")) h2 = t('activerecord.attributes.exercise.files') diff --git a/config/locales/de.yml b/config/locales/de.yml index a97023a4..27aba44f 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -41,7 +41,6 @@ de: allow_auto_completion: "Autovervollständigung aktivieren" allow_file_creation: "Dateierstellung erlauben" difficulty: Schwierigkeitsgrad - worktime: "vermutete Arbeitszeit in Minuten" token: "Aufgaben-Token" proxy_exercise: title: Title diff --git a/config/locales/en.yml b/config/locales/en.yml index 3d6e6b9c..380e5d7e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -41,7 +41,6 @@ en: allow_auto_completion: "Allow auto completion" allow_file_creation: "Allow file creation" difficulty: Difficulty - worktime: "Expected worktime in minutes" token: "Exercise Token" proxy_exercise: title: Title diff --git a/db/migrate/20171002131135_remove_expected_working_time.rb b/db/migrate/20171002131135_remove_expected_working_time.rb new file mode 100644 index 00000000..eb4bbcb4 --- /dev/null +++ b/db/migrate/20171002131135_remove_expected_working_time.rb @@ -0,0 +1,5 @@ +class RemoveExpectedWorkingTime < ActiveRecord::Migration + def change + remove_column :exercises, :expected_worktime_seconds + end +end diff --git a/db/schema.rb b/db/schema.rb index 988cd447..c8eb631b 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: 20170920145852) do +ActiveRecord::Schema.define(version: 20171002131135) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -47,6 +47,13 @@ ActiveRecord::Schema.define(version: 20170920145852) do t.string "oauth_secret", limit: 255 end + create_table "copy_paste_events", id: false, force: :cascade do |t| + t.integer "exercise_id" + t.string "text" + t.integer "user_id" + t.datetime "created_at" + end + create_table "errors", force: :cascade do |t| t.integer "execution_environment_id" t.text "message" @@ -99,19 +106,18 @@ ActiveRecord::Schema.define(version: 20170920145852) 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 - t.integer "expected_worktime_seconds", default: 60 - t.integer "expected_difficulty", default: 1 + t.boolean "allow_auto_completion", default: false + t.integer "expected_difficulty", default: 1 end create_table "exercises_proxy_exercises", id: false, force: :cascade do |t| @@ -124,6 +130,11 @@ ActiveRecord::Schema.define(version: 20170920145852) do add_index "exercises_proxy_exercises", ["exercise_id"], name: "index_exercises_proxy_exercises_on_exercise_id", using: :btree add_index "exercises_proxy_exercises", ["proxy_exercise_id"], name: "index_exercises_proxy_exercises_on_proxy_exercise_id", using: :btree + create_table "external_user_skill_level", id: false, force: :cascade do |t| + t.string "external_user_id" + t.integer "skill_level" + end + create_table "external_users", force: :cascade do |t| t.integer "consumer_id" t.string "email", limit: 255 @@ -342,4 +353,29 @@ ActiveRecord::Schema.define(version: 20170920145852) do add_index "user_proxy_exercise_exercises", ["proxy_exercise_id"], name: "index_user_proxy_exercise_exercises_on_proxy_exercise_id", using: :btree add_index "user_proxy_exercise_exercises", ["user_type", "user_id"], name: "index_user_proxy_exercise_exercises_on_user_type_and_user_id", using: :btree + create_table "user_proxy_exercise_exercises_copy", id: false, force: :cascade do |t| + t.integer "id" + t.integer "user_id" + t.string "user_type" + t.integer "proxy_exercise_id" + t.integer "exercise_id" + t.datetime "created_at" + t.datetime "updated_at" + t.json "reason" + t.json "reason_json" + end + + create_table "wk_with_wk_until_rfc", id: false, force: :cascade do |t| + t.string "external_user_id", limit: 255 + t.integer "user_id" + t.integer "exercise_id" + t.float "max_score" + t.float "max_reachable_points" + t.string "working_time" + t.string "working_time_until_rfc" + t.string "working_time_until_rfc_reply" + t.time "percentile75" + t.time "percentile90" + end + end From 0e7decd7fcef13814a5bfdb2c4c8f1fcbb0b910c Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Wed, 4 Oct 2017 11:41:45 +0200 Subject: [PATCH 3/4] removed clutter in schema.rb --- db/schema.rb | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index c8eb631b..35042622 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -47,13 +47,6 @@ ActiveRecord::Schema.define(version: 20171002131135) do t.string "oauth_secret", limit: 255 end - create_table "copy_paste_events", id: false, force: :cascade do |t| - t.integer "exercise_id" - t.string "text" - t.integer "user_id" - t.datetime "created_at" - end - create_table "errors", force: :cascade do |t| t.integer "execution_environment_id" t.text "message" @@ -130,11 +123,6 @@ ActiveRecord::Schema.define(version: 20171002131135) do add_index "exercises_proxy_exercises", ["exercise_id"], name: "index_exercises_proxy_exercises_on_exercise_id", using: :btree add_index "exercises_proxy_exercises", ["proxy_exercise_id"], name: "index_exercises_proxy_exercises_on_proxy_exercise_id", using: :btree - create_table "external_user_skill_level", id: false, force: :cascade do |t| - t.string "external_user_id" - t.integer "skill_level" - end - create_table "external_users", force: :cascade do |t| t.integer "consumer_id" t.string "email", limit: 255 @@ -353,29 +341,4 @@ ActiveRecord::Schema.define(version: 20171002131135) do add_index "user_proxy_exercise_exercises", ["proxy_exercise_id"], name: "index_user_proxy_exercise_exercises_on_proxy_exercise_id", using: :btree add_index "user_proxy_exercise_exercises", ["user_type", "user_id"], name: "index_user_proxy_exercise_exercises_on_user_type_and_user_id", using: :btree - create_table "user_proxy_exercise_exercises_copy", id: false, force: :cascade do |t| - t.integer "id" - t.integer "user_id" - t.string "user_type" - t.integer "proxy_exercise_id" - t.integer "exercise_id" - t.datetime "created_at" - t.datetime "updated_at" - t.json "reason" - t.json "reason_json" - end - - create_table "wk_with_wk_until_rfc", id: false, force: :cascade do |t| - t.string "external_user_id", limit: 255 - t.integer "user_id" - t.integer "exercise_id" - t.float "max_score" - t.float "max_reachable_points" - t.string "working_time" - t.string "working_time_until_rfc" - t.string "working_time_until_rfc_reply" - t.time "percentile75" - t.time "percentile90" - end - end From a0ebd5bec519936fd7b6d868dd87f545e6ac9b66 Mon Sep 17 00:00:00 2001 From: ThommyH Date: Wed, 4 Oct 2017 11:50:57 +0200 Subject: [PATCH 4/4] Update schema.rb --- db/schema.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 35042622..896ffbd3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -99,14 +99,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