Skip to content

Commit 4ee087b

Browse files
feat: Add credit_points, prerequisites, corequisites to unit model
1 parent e87f2fd commit 4ee087b

File tree

5 files changed

+87
-4
lines changed

5 files changed

+87
-4
lines changed

app/api/entities/unit_entity.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,8 @@ def can_read_unit_config?(my_role)
6464
# unit.group_memberships.where(active: true)
6565
# end
6666
expose :unit_definition_id
67+
expose :credit_points
68+
expose :prerequisites
69+
expose :corequisites
6770
end
6871
end

app/api/units_api.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ class UnitsApi < Grape::API
8686
optional :extension_weeks_on_resubmit_request, type: Integer, desc: 'Determines the number of weeks extension on a resubmit request'
8787
optional :overseer_image_id, type: Integer, desc: 'The id of the docker image used with '
8888
optional :assessment_enabled, type: Boolean
89+
optional :credit_points, type: Integer
90+
optional :prerequisites, type: String
91+
optional :corequisites, type: String
8992

9093
mutually_exclusive :teaching_period_id, :start_date
9194
mutually_exclusive :teaching_period_id, :end_date
@@ -116,7 +119,10 @@ class UnitsApi < Grape::API
116119
:extension_weeks_on_resubmit_request,
117120
:allow_student_change_tutorial,
118121
:overseer_image_id,
119-
:assessment_enabled)
122+
:assessment_enabled,
123+
:credit_points,
124+
:prerequisites,
125+
:corequisites)
120126

121127
if unit.teaching_period_id.present? && (unit_parameters.key?(:start_date) || unit_parameters['teaching_period_id'] == -1)
122128
unit.teaching_period = nil
@@ -159,6 +165,9 @@ class UnitsApi < Grape::API
159165
optional :extension_weeks_on_resubmit_request, type: Integer, desc: 'Determines the number of weeks extension on a resubmit request', default: 1
160166
optional :portfolio_auto_generation_date, type: Date, desc: 'Indicates a date where student portfolio will automatically compile'
161167
optional :allow_student_change_tutorial, type: Boolean, desc: 'Can turn on/off student ability to change tutorials', default: true
168+
optional :credit_points, type: Integer
169+
optional :prerequisites, type: String
170+
optional :corequisites, type: String
162171

163172
mutually_exclusive :teaching_period_id, :start_date
164173
mutually_exclusive :teaching_period_id, :end_date
@@ -187,6 +196,9 @@ class UnitsApi < Grape::API
187196
:extension_weeks_on_resubmit_request,
188197
:portfolio_auto_generation_date,
189198
:allow_student_change_tutorial,
199+
:credit_points,
200+
:prerequisites,
201+
:corequisites,
190202
)
191203

192204
# Ensure the user is authorised to convene units
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddDetailsToUnits < ActiveRecord::Migration[7.1]
2+
def change
3+
add_column :units, :credit_points, :integer
4+
end
5+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class AddPrerequisitesAndCorequisitesToUnits < ActiveRecord::Migration[7.1]
2+
def change
3+
add_column :units, :prerequisites, :text
4+
add_column :units, :corequisites, :text
5+
end
6+
end

db/schema.rb

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.1].define(version: 2025_05_15_025346) do
13+
ActiveRecord::Schema[7.1].define(version: 2025_07_24_054022) do
1414
create_table "activity_types", charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t|
1515
t.string "name", null: false
1616
t.string "abbreviation", null: false
@@ -24,6 +24,8 @@
2424
t.datetime "auth_token_expiry", null: false
2525
t.bigint "user_id"
2626
t.string "authentication_token", null: false
27+
t.integer "token_type", default: 0, null: false
28+
t.index ["token_type"], name: "index_auth_tokens_on_token_type"
2729
t.index ["user_id"], name: "index_auth_tokens_on_user_id"
2830
end
2931

@@ -81,6 +83,15 @@
8183
t.datetime "updated_at", null: false
8284
end
8385

86+
create_table "d2l_assessment_mappings", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
87+
t.bigint "unit_id", null: false
88+
t.string "org_unit_id"
89+
t.integer "grade_object_id"
90+
t.datetime "created_at", null: false
91+
t.datetime "updated_at", null: false
92+
t.index ["unit_id"], name: "index_d2l_assessment_mappings_on_unit_id", unique: true
93+
end
94+
8495
create_table "discussion_comments", charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t|
8596
t.datetime "time_started"
8697
t.datetime "time_completed"
@@ -274,10 +285,11 @@
274285
t.integer "extension_weeks"
275286
t.string "extension_response"
276287
t.bigint "reply_to_id"
277-
t.bigint "overseer_assessment_id"
288+
t.bigint "commentable_id"
289+
t.string "commentable_type"
278290
t.index ["assessor_id"], name: "index_task_comments_on_assessor_id"
291+
t.index ["commentable_type", "commentable_id"], name: "index_task_comments_on_commentable_type_and_commentable_id"
279292
t.index ["discussion_comment_id"], name: "index_task_comments_on_discussion_comment_id"
280-
t.index ["overseer_assessment_id"], name: "index_task_comments_on_overseer_assessment_id"
281293
t.index ["recipient_id"], name: "fk_rails_1dbb49165b"
282294
t.index ["reply_to_id"], name: "index_task_comments_on_reply_to_id"
283295
t.index ["task_id"], name: "index_task_comments_on_task_id"
@@ -310,10 +322,18 @@
310322
t.bigint "overseer_image_id"
311323
t.string "tii_group_id"
312324
t.string "moss_language"
325+
t.boolean "scorm_enabled", default: false
326+
t.boolean "scorm_allow_review", default: false
327+
t.boolean "scorm_bypass_test", default: false
328+
t.boolean "scorm_time_delay_enabled", default: false
329+
t.integer "scorm_attempt_limit", default: 0
330+
t.boolean "tutorial_self_enrolment_enabled", default: false
331+
t.bigint "tutorial_self_enrolment_stream_id"
313332
t.index ["abbreviation", "unit_id"], name: "index_task_definitions_on_abbreviation_and_unit_id", unique: true
314333
t.index ["group_set_id"], name: "index_task_definitions_on_group_set_id"
315334
t.index ["name", "unit_id"], name: "index_task_definitions_on_name_and_unit_id", unique: true
316335
t.index ["overseer_image_id"], name: "index_task_definitions_on_overseer_image_id"
336+
t.index ["tutorial_self_enrolment_stream_id"], name: "index_task_definitions_on_tutorial_self_enrolment_stream_id"
317337
t.index ["tutorial_stream_id"], name: "index_task_definitions_on_tutorial_stream_id"
318338
t.index ["unit_id"], name: "index_task_definitions_on_unit_id"
319339
end
@@ -390,6 +410,7 @@
390410
t.integer "contribution_pts", default: 3
391411
t.integer "quality_pts", default: -1
392412
t.integer "extensions", default: 0, null: false
413+
t.integer "scorm_extensions", default: 0, null: false
393414
t.index ["group_submission_id"], name: "index_tasks_on_group_submission_id"
394415
t.index ["project_id", "task_definition_id"], name: "tasks_uniq_proj_task_def", unique: true
395416
t.index ["project_id"], name: "index_tasks_on_project_id"
@@ -406,6 +427,17 @@
406427
t.index ["period", "year"], name: "index_teaching_periods_on_period_and_year", unique: true
407428
end
408429

430+
create_table "test_attempts", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
431+
t.bigint "task_id"
432+
t.datetime "attempted_time", null: false
433+
t.boolean "terminated", default: false
434+
t.boolean "completion_status", default: false
435+
t.boolean "success_status", default: false
436+
t.float "score_scaled", default: 0.0
437+
t.text "cmi_datamodel"
438+
t.index ["task_id"], name: "index_test_attempts_on_task_id"
439+
end
440+
409441
create_table "tii_actions", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
410442
t.string "entity_type"
411443
t.bigint "entity_id"
@@ -547,14 +579,36 @@
547579
t.datetime "portfolio_auto_generation_date"
548580
t.string "tii_group_context_id"
549581
t.boolean "archived", default: false
582+
t.integer "credit_points"
550583
t.bigint "unit_definition_id"
584+
t.text "prerequisites"
585+
t.text "corequisites"
551586
t.index ["draft_task_definition_id"], name: "index_units_on_draft_task_definition_id"
552587
t.index ["main_convenor_id"], name: "index_units_on_main_convenor_id"
553588
t.index ["overseer_image_id"], name: "index_units_on_overseer_image_id"
554589
t.index ["teaching_period_id"], name: "index_units_on_teaching_period_id"
555590
t.index ["unit_definition_id"], name: "index_units_on_unit_definition_id"
556591
end
557592

593+
create_table "user_oauth_states", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
594+
t.bigint "user_id", null: false
595+
t.string "state"
596+
t.datetime "created_at", null: false
597+
t.datetime "updated_at", null: false
598+
t.index ["state"], name: "index_user_oauth_states_on_state", unique: true
599+
t.index ["user_id"], name: "index_user_oauth_states_on_user_id"
600+
end
601+
602+
create_table "user_oauth_tokens", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
603+
t.bigint "user_id", null: false
604+
t.integer "provider", default: 0, null: false
605+
t.text "token"
606+
t.datetime "expires_at"
607+
t.datetime "created_at", null: false
608+
t.datetime "updated_at", null: false
609+
t.index ["user_id"], name: "index_user_oauth_tokens_on_user_id"
610+
end
611+
558612
create_table "users", charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t|
559613
t.string "email", default: "", null: false
560614
t.string "encrypted_password", default: "", null: false
@@ -609,5 +663,8 @@
609663
t.index ["user_id"], name: "index_webcals_on_user_id", unique: true
610664
end
611665

666+
add_foreign_key "task_definitions", "tutorial_streams", column: "tutorial_self_enrolment_stream_id"
612667
add_foreign_key "units", "unit_definitions"
668+
add_foreign_key "user_oauth_states", "users"
669+
add_foreign_key "user_oauth_tokens", "users"
613670
end

0 commit comments

Comments
 (0)