diff --git a/app/api/entities/unit_entity.rb b/app/api/entities/unit_entity.rb index b5b4c8e0e3..f1865d0151 100644 --- a/app/api/entities/unit_entity.rb +++ b/app/api/entities/unit_entity.rb @@ -50,12 +50,14 @@ def is_admin_staff?(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 + 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 :staff, using: UnitRoleEntity, 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| diff --git a/app/api/units_api.rb b/app/api/units_api.rb index a4de283e22..4dbc09cd1b 100644 --- a/app/api/units_api.rb +++ b/app/api/units_api.rb @@ -35,7 +35,7 @@ class UnitsApi < Grape::API units = units.where('active = true') unless params[:include_in_active] - present units, with: Entities::UnitEntity, user: current_user, summary_only: true + present units, with: Entities::UnitEntity, user: current_user, summary_only: true, in_unit: true end desc "Get a unit's details" @@ -252,7 +252,7 @@ class UnitsApi < Grape::API my_role = result.role_for(current_user) - present result, with: Entities::UnitEntity, my_role: my_role, user: current_user + present result, with: Entities::UnitEntity, my_role: my_role, user: current_user, in_unit: true end desc 'Download the tasks that are awaiting feedback for a unit'