@@ -10,10 +10,6 @@ class LearningOutcomesApi < Grape::API
1010 authenticated?
1111 end
1212
13- route :context_type_plural , values : %w[ units task_definitions ] do
14- params [ :context_type ] . pluralize
15- end
16-
1713 desc 'Get all global outcomes'
1814 get '/global/outcomes' do
1915 # can be read by any logged in user
@@ -26,6 +22,7 @@ class LearningOutcomesApi < Grape::API
2622 requires :short_description , type : String , desc : 'The ILO' 's short_description'
2723 optional :full_outcome_description , type : String , desc : 'The ILO' 's full_outcome_description'
2824 optional :linked_outcome_ids , type : Array [ Integer ] , desc : 'The ids of the linked outcome ids'
25+ requires :context_type_plural , type : String , desc : 'The context - a unit or task_definition' , values : %w[ units task_definitions ]
2926 end
3027 post '/:context_type_plural/:context_id/outcomes' do
3128 # find context model dynamically
@@ -36,7 +33,7 @@ class LearningOutcomesApi < Grape::API
3633 error! ( { error : 'You are not authorised to create outcomes in this context.' } , 403 )
3734 end
3835
39- outcome_params = declared ( params , include_missing : false ) . except ( :linked_outcome_ids )
36+ outcome_params = declared ( params , include_missing : false ) . except ( :linked_outcome_ids , :context_type_plural )
4037 outcome_params [ :context_type ] = context_type
4138
4239 learning_outcome = context_model . learning_outcomes . create! ( outcome_params )
@@ -76,6 +73,7 @@ class LearningOutcomesApi < Grape::API
7673 optional :full_outcome_description , type : String , desc : 'The ILO' 's full_outcome_description'
7774 optional :linked_outcome_ids , type : Array [ Integer ] , desc : 'The ids of the linked outcome ids'
7875 # optional :ilo_number, type: Integer, desc: 'The ILO''s new sequence number'
76+ requires :context_type_plural , type : String , desc : 'The context - a unit or task_definition' , values : %w[ units task_definitions ]
7977 end
8078 put '/:context_type_plural/:context_id/outcomes/:id' do
8179 # find context model dynamically
@@ -128,6 +126,7 @@ class LearningOutcomesApi < Grape::API
128126 params do
129127 requires :context_id , type : Integer , desc : 'The id of the context'
130128 requires :id , type : Integer , desc : 'The id for the outcome you wish to delete'
129+ requires :context_type_plural , type : String , desc : 'The context - a unit or task_definition' , values : %w[ units task_definitions ]
131130 end
132131 delete '/:context_type_plural/:context_id/outcomes/:id' do
133132 # find context model dynamically
@@ -165,6 +164,7 @@ class LearningOutcomesApi < Grape::API
165164 params do
166165 requires :context_id , type : Integer , desc : 'The id of the context'
167166 optional :includes_tlos , type : Boolean , desc : 'Include nested task learning outcomes in the export'
167+ requires :context_type_plural , type : String , desc : 'The context - a unit or task_definition' , values : %w[ units task_definitions ]
168168 end
169169 get '/:context_type_plural/:context_id/outcomes/csv' do
170170 # find context model dynamically
@@ -190,6 +190,7 @@ class LearningOutcomesApi < Grape::API
190190 params do
191191 requires :file , type : File , desc : 'CSV upload file.'
192192 requires :context_id , type : Integer , desc : 'The id of the context'
193+ requires :context_type_plural , type : String , desc : 'The context - a unit or task_definition' , values : %w[ units task_definitions ]
193194 end
194195 post '/:context_type_plural/:context_id/outcomes/csv' do
195196 # check mime is correct before uploading
0 commit comments