Skip to content

Commit

Permalink
new:numbas feature backend intital commit
Browse files Browse the repository at this point in the history
first commit containing endpoints and DB changes

new faeture
  • Loading branch information
maddernd committed Dec 5, 2023
1 parent 8b0af68 commit 1c467be
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
36 changes: 36 additions & 0 deletions app/models/test_attempt.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class TestAttempt < ApplicationRecord
include ApplicationHelper
include LogHelper
include GradeHelper

belongs_to :task

def self.permissions
student_role_permissions = [
:create,
:view_own,
:delete_own
]

tutor_role_permissions = [
:create,
:view_own,
:delete_own
]

convenor_role_permissions = [
:create,
:view_own,
:delete_own
]

nil_role_permissions = []

{
student: student_role_permissions,
tutor: tutor_role_permissions,
convenor: convenor_role_permissions,
nil: nil_role_permissions
}
end
end
16 changes: 16 additions & 0 deletions db/migrate/20231205011842_create_test_attempts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class CreateTestAttempts < ActiveRecord::Migration[7.0]
def change
create_table :test_attempts do |t|
t.references :task, foreign_key: true
t.string :name
t.integer :attempt_number, default: 1, null: false
t.boolean :pass_status
t.text :exam_data
t.boolean :completed, default: false
t.datetime :attempted_at
t.string :cmi_entry, default: "ab-initio"
t.string :exam_result
t.timestamps
end
end
end
19 changes: 19 additions & 0 deletions db/migrate/20231205011958_add_fields_to_task_def.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class AddFieldsToTaskDef < ActiveRecord::Migration[7.0]
def change
change_table :task_definitions do |t|
t.boolean :has_test, default: false
t.boolean :restrict_attempts, default: false
t.integer :delay_restart_minutes
t.boolean :retake_on_resubmit, default: false
end
end

def down
change_table :task_definitions do |t|
t.remove :has_test
t.remove :restrict_attempts
t.remove :delay_restart_minutes
t.remove :retake_on_resubmit
end
end
end
22 changes: 21 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2023_12_01_000245) do
ActiveRecord::Schema[7.0].define(version: 2023_12_05_011958) do
create_table "activity_types", charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t|
t.string "name", null: false
t.string "abbreviation", null: false
Expand Down Expand Up @@ -251,6 +251,10 @@
t.bigint "overseer_image_id"
t.string "tii_group_id"
t.string "moss_language"
t.boolean "has_test", default: false
t.boolean "restrict_attempts", default: false
t.integer "delay_restart_minutes"
t.boolean "retake_on_resubmit", default: false
t.index ["group_set_id"], name: "index_task_definitions_on_group_set_id"
t.index ["overseer_image_id"], name: "index_task_definitions_on_overseer_image_id"
t.index ["tutorial_stream_id"], name: "index_task_definitions_on_tutorial_stream_id"
Expand Down Expand Up @@ -347,6 +351,21 @@
t.index ["period", "year"], name: "index_teaching_periods_on_period_and_year", unique: true
end

create_table "test_attempts", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.bigint "task_id"
t.string "name"
t.integer "attempt_number", default: 1, null: false
t.boolean "pass_status"
t.text "exam_data"
t.boolean "completed", default: false
t.datetime "attempted_at"
t.string "cmi_entry", default: "ab-initio"
t.string "exam_result"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["task_id"], name: "index_test_attempts_on_task_id"
end

create_table "tii_actions", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "entity_type"
t.bigint "entity_id"
Expand Down Expand Up @@ -535,4 +554,5 @@
t.index ["user_id"], name: "index_webcals_on_user_id", unique: true
end

add_foreign_key "test_attempts", "tasks"
end

0 comments on commit 1c467be

Please sign in to comment.