Skip to content

Commit

Permalink
Add a access log for model solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Sep 3, 2018
1 parent 1c0c8c8 commit 1f3ea5e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/controllers/solutions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def show
end
end

ModelSolutionAccessLog.create!(user: current_user, course: @course, exercise_name: @exercise.name)

respond_to do |format|
format.html
format.zip do
Expand Down
5 changes: 5 additions & 0 deletions app/models/model_solution_access_log.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ModelSolutionAccessLog < ActiveRecord::Base
belongs_to :user
belongs_to :course
end

10 changes: 10 additions & 0 deletions db/migrate/20180903074526_add_model_solution_access_log.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class AddModelSolutionAccessLog < ActiveRecord::Migration
def change
create_table :model_solution_access_logs do |t|
t.references :user, null: false
t.references :course, null: false
t.string :exercise_name, null: false
t.timestamps
end
end
end
10 changes: 9 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180613083429) do
ActiveRecord::Schema.define(version: 20180903074526) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -177,6 +177,14 @@

add_index "migrated_submissions", ["from_course_id", "to_course_id", "original_submission_id", "new_submission_id"], name: "unique_values", unique: true, using: :btree

create_table "model_solution_access_log", force: :cascade do |t|
t.integer "user_id", null: false
t.integer "course_id", null: false
t.string "exercise_name", null: false
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "oauth_access_grants", force: :cascade do |t|
t.integer "resource_owner_id", null: false
t.integer "application_id", null: false
Expand Down

0 comments on commit 1f3ea5e

Please sign in to comment.