diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index a657eb5..e7165d2 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -19,6 +19,7 @@ { msg: _('There is no plan with id %{id} for which to create or update an answer') %{ :id => p_params[:plan_id] }}) return end + q = Question.find(p_params[:question_id]) Answer.transaction do begin @@ -28,6 +29,9 @@ if p_params[:question_option_ids].present? @answer.touch() # Saves the record with the updated_at set to the current time. Needed if only answer.question_options is updated end + if q.question_format.rda_metadata? + a.update_answer_hash(JSON.parse(params[:standards]), p_params[:text]) + end rescue ActiveRecord::RecordNotFound @answer = Answer.new(p_params.merge({ user_id: current_user.id })) @answer.lock_version = 1 diff --git a/app/controllers/question_formats_controller.rb b/app/controllers/question_formats_controller.rb new file mode 100644 index 0000000..ced3624 --- /dev/null +++ b/app/controllers/question_formats_controller.rb @@ -0,0 +1,10 @@ +class QuestionFormatsController < ApplicationController + # do we need authorizaton on this? it will only return the URL for the rda api + # down the line we will add more methods for other external api's + def rda_api_address + render json: { + 'url' => QuestionFormat.rda_metadata.first.description + }.to_json + end + +end