diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index e7165d2..9c9f70e 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -30,12 +30,16 @@ @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]) + @answer.update_answer_hash(JSON.parse(params[:standards]), p_params[:text]) + @answer.save! end rescue ActiveRecord::RecordNotFound @answer = Answer.new(p_params.merge({ user_id: current_user.id })) @answer.lock_version = 1 authorize @answer + if q.question_format.rda_metadata? + @answer.update_answer_hash(JSON.parse(params[:standards]), p_params[:text]) + end @answer.save! rescue ActiveRecord::StaleObjectError @stale_answer = @answer diff --git a/app/views/answers/_new_edit.html.erb b/app/views/answers/_new_edit.html.erb index 64914b0..0e74706 100644 --- a/app/views/answers/_new_edit.html.erb +++ b/app/views/answers/_new_edit.html.erb @@ -50,7 +50,7 @@ <% end %> <% end %>
> - <% if question.option_based? %> + <% if question.option_based? || question.question_format.rda_metadata? %> <%= render(partial: 'questions/new_edit_question_option_based', locals: { f: f, question: question, answer: answer }) %> <% elsif question.question_format.textfield?%> <%= render(partial: 'questions/new_edit_question_textfield', locals: { f: f, question: question, answer: answer }) %> diff --git a/app/views/questions/_edit_question.html.erb b/app/views/questions/_edit_question.html.erb index 4d970dc..3de20c4 100644 --- a/app/views/questions/_edit_question.html.erb +++ b/app/views/questions/_edit_question.html.erb @@ -45,7 +45,7 @@ <% comment_disp = question.question_format.option_based? || question.question_format.rda_metadata? %> -
+
@@ -88,7 +88,7 @@
- <%= render partial: 'org_admin/shared/theme_selector', + <%= render partial: 'org_admin/shared/theme_selector', locals: { f: f, all_themes: Theme.all.order("title"), popover_message: _('Select one or more themes that are relevant to this question. This will allow similarly themed organisation-level guidance to appear alongside your question.') } %>
diff --git a/app/views/questions/_new_edit_question_option_based.html.erb b/app/views/questions/_new_edit_question_option_based.html.erb index b418360..0304b76 100644 --- a/app/views/questions/_new_edit_question_option_based.html.erb +++ b/app/views/questions/_new_edit_question_option_based.html.erb @@ -21,12 +21,12 @@
<% end %> <% elsif question.question_format.dropdown? || question.question_format.multiselectbox? %> - <% + <% options_html = "" options.each do |op| options_html += answer.has_question_option(op.id) ? "" : - "" + "" end %> <%= f.label(:question_option_ids, raw(question.text), class: 'control-label') %> @@ -38,7 +38,8 @@ <% end %>
<% if question.option_comment_display %> + <% text = question.question_format.rda_metadata? ? answer.answer_hash[:text] : answer.text %> <%= label_tag('answer[text]', _('Additional Information'), class: 'control-label') %> - <%= text_area_tag('answer[text]', answer.text, id: "answer-text-#{question.id}", class: "form-control tinymce_answer") %> + <%= text_area_tag('answer[text]', text, id: "answer-text-#{question.id}", class: "form-control tinymce_answer") %> <% end %>