Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.4
8 changes: 3 additions & 5 deletions app/api/entities/unit_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def can_read_unit_config?(my_role)
expose :code
expose :id
expose :name
expose :creditpoint
expose :prerequisite
expose :corequisite
expose :my_role do |unit, options|
role = options[:my_role]
role = unit.role_for(options[:user]) if role.nil?
Expand Down Expand Up @@ -51,17 +54,12 @@ def can_read_unit_config?(my_role)
expose :learning_outcomes, using: LearningOutcomeEntity, as: :ilos, unless: :summary_only
expose :tutorial_streams, using: TutorialStreamEntity, unless: :summary_only

# Expose staff before tutorials, so that their details are available
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should probably remain in the code

expose :staff, using: UnitRoleEntity, unless: :summary_only
expose :tutorials, using: TutorialEntity, unless: :summary_only
# expose :tutorial_enrolments, using: TutorialEnrolmentEntity, unless: :summary_only, if: lambda { |unit, options| is_staff?(options[:my_role]) }

expose :task_definitions, using: TaskDefinitionEntity, unless: :summary_only
expose :task_outcome_alignments, using: TaskOutcomeAlignmentEntity, unless: :summary_only
expose :group_sets, using: GroupSetEntity, unless: :summary_only
expose :groups, using: GroupEntity, unless: :summary_only
# expose :group_memberships, using: GroupMembershipEntity, unless: :summary_only do |unit, options|
# unit.group_memberships.where(active: true)
# end
end
end
17 changes: 15 additions & 2 deletions app/api/units_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class UnitsApi < Grape::API
optional :teaching_period_id, type: Integer
optional :start_date, type: Date
optional :end_date, type: Date
optional :creditpoint, type: Integer
optional :prerequisite, type: String
optional :corequisite, type: String
Comment on lines +79 to +80
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prerequisites and corequisites should probably be some sort of (array of) references to the existing unit definitions, instead of string

optional :main_convenor_id, type: Integer
optional :auto_apply_extension_before_deadline, type: Boolean, desc: 'Indicates if extensions before the deadline should be automatically applied'
optional :send_notifications, type: Boolean, desc: 'Indicates if emails should be sent on updates each week'
Expand Down Expand Up @@ -117,7 +120,11 @@ class UnitsApi < Grape::API
:extension_weeks_on_resubmit_request,
:allow_student_change_tutorial,
:overseer_image_id,
:assessment_enabled)
:assessment_enabled,
:creditpoint,
:prerequisite,
:corequisite
)

if unit.teaching_period_id.present? && (unit_parameters.key?(:start_date) || unit_parameters['teaching_period_id'] == -1)
unit.teaching_period = nil
Expand Down Expand Up @@ -151,10 +158,13 @@ class UnitsApi < Grape::API
optional :teaching_period_id, type: Integer
optional :start_date, type: Date
optional :end_date, type: Date
optional :creditpoint, type: Integer
optional :prerequisite, type: String
optional :corequisite, type: String
optional :main_convenor_user_id, type: Integer
optional :auto_apply_extension_before_deadline, type: Boolean, desc: 'Indicates if extensions before the deadline should be automatically applied', default: true
optional :send_notifications, type: Boolean, desc: 'Indicates if emails should be sent on updates each week', default: true
optional :enable_sync_timetable, type: Boolean, desc: 'Sync to timetable automatically if supported by deployment', default: true
optional :enable_sync_timetable, type: Boolean, desc: 'Sync to timetable automatically if supported by deployment', default: true
optional :enable_sync_enrolments, type: Boolean, desc: 'Sync student enrolments automatically if supported by deployment', default: true
optional :allow_student_extension_requests, type: Boolean, desc: 'Can turn on/off student extension requests', default: true
optional :extension_weeks_on_resubmit_request, type: Integer, desc: 'Determines the number of weeks extension on a resubmit request', default: 1
Expand Down Expand Up @@ -188,6 +198,9 @@ class UnitsApi < Grape::API
:extension_weeks_on_resubmit_request,
:portfolio_auto_generation_date,
:allow_student_change_tutorial,
:creditpoint,
:prerequisite,
:corequisite
)

# Identify main convenor - ensure they have the correct role
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20250429043824_add_credit_points_to_units.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCreditPointsToUnits < ActiveRecord::Migration[7.1]
def change
add_column :units, :creditpoint, :integer
end
end
5 changes: 5 additions & 0 deletions db/migrate/20250429193655_add_prerequisite_to_units.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPrerequisiteToUnits < ActiveRecord::Migration[7.1]
def change
add_column :units, :prerequisite, :string
end
end
5 changes: 5 additions & 0 deletions db/migrate/20250430035259_add_corequisite_to_units.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCorequisiteToUnits < ActiveRecord::Migration[7.1]
def change
add_column :units, :corequisite, :string
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class SetDefaultForCorequisiteAndPrerequisiteInUnits < ActiveRecord::Migration[7.1]
def change
change_column_default :units, :corequisite, from: nil, to: "Nil"
change_column_default :units, :prerequisite, from: nil, to: "Nil"
Comment on lines +3 to +4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corequisite and prerequisite should be of NULL type if empty

end
end
Loading