+
+
<%= text_area_tag("guidance-text", @guidance.text, class: "tinymce") %>
diff --git a/app/views/guidances/admin_new.html.erb b/app/views/guidances/admin_new.html.erb
index eb7f7a3..95239c0 100644
--- a/app/views/guidances/admin_new.html.erb
+++ b/app/views/guidances/admin_new.html.erb
@@ -19,7 +19,8 @@
<%= _('Text') %>
-
+
+
<%= text_area_tag("guidance-text", "", class: "tinymce") %>
diff --git a/app/views/layouts/_signin_signout.html.erb b/app/views/layouts/_signin_signout.html.erb
index 6222e55..27011a7 100644
--- a/app/views/layouts/_signin_signout.html.erb
+++ b/app/views/layouts/_signin_signout.html.erb
@@ -19,7 +19,7 @@
<% elsif current_user.can_modify_org_details? %>
<%= link_to _("Admin area"), admin_show_org_path(current_user.org_id), class: "signIn_dropdown_link" %>
<% elsif current_user.can_grant_permissions? %>
-
<%= link_to _("Admin area"), admin_index_user_path, class: "signIn_dropdown_link" %>
+
<%= link_to _("Admin area"), admin_index_users_path, class: "signIn_dropdown_link" %>
<% end %>
<% end %>
<%= link_to _('Sign out'), destroy_user_session_path, method: :delete, class: "signIn_dropdown_link" %>
diff --git a/app/views/phases/_answer_form.html.erb b/app/views/phases/_answer_form.html.erb
index bdd8c1d..7a1ab93 100644
--- a/app/views/phases/_answer_form.html.erb
+++ b/app/views/phases/_answer_form.html.erb
@@ -31,22 +31,18 @@
<%= raw question.text %>
-
- <% if question.suggested_answers.any? %>
- <% suggested_answer = question.suggested_answers.first %>
- <% if suggested_answer.text.present? %>
+
+ <% if question.annotations.where('type <> ?',Annotation.types[:example_answer]).any? %>
+ <% annotation = question.annotations.where('type <> ?',Annotation.types[:example_answer]).order(:created_at).first %>
+ <% if annotation.text.present? %>
- <% if suggested_answer.is_example? then %>
- <%= _('Example of answer')%>
- <%else%>
- <%= _('Suggested answer')%>
- <%end%>
+ <%="#{annotation.org.abbreviation} "%> <%=_('Example of answer')%>
- <%= raw suggested_answer.text %>
+ <%= raw annotation.text %>
@@ -119,7 +115,8 @@
<% comments = answer.notes.all %>
<%= hidden_field_tag :question_id, question_id, class: "question_id" %>
@@ -155,25 +152,28 @@
-
- <% if question.guidance.present? %>
-
+
+ <% if annotations.present? %>
+ <% annotations.each do |annotation| %>
-
-
+
-
-
-
<%= raw question.guidance %>
-
+
+
-
+
+
+
<%= raw annotation.text %>
+
+
+
+ <% end %>
<% end %>
@@ -182,13 +182,13 @@
<% group.each do |gobj| %>
-
+
<% guidance_accordion_id += 1 %>
diff --git a/app/views/phases/_answer_form_ro.html.erb b/app/views/phases/_answer_form_ro.html.erb
index 4f68019..915db2a 100644
--- a/app/views/phases/_answer_form_ro.html.erb
+++ b/app/views/phases/_answer_form_ro.html.erb
@@ -1,4 +1,4 @@
-
<% q_format = question.question_format%>
+
<% if readonly != "always" then %>
>
- <%= semantic_form_for answer, :url => {:controller => :answers, :action => :create }, :html=>{:method=>:post}, :remote => true do |f| %>
+ <%= semantic_form_for answer, :url => {:controller => :answers, :action => :update }, :html=>{:method=>:post}, :remote => true do |f| %>
<%= f.inputs do %>
<%= f.input :plan_id, :as => :hidden %>
<%= f.input :user_id, :as => :hidden, :input_html => { :value => current_user.id } %>
@@ -20,22 +21,18 @@
- <%= raw question.text %>
+
<%= raw question.text %>
- <% suggested_answer = question.suggested_answers.where(org_id: @plan.template.org_id).first %>
- <% if suggested_answer.present? %>
+ <% if question.annotations.where('type <> ?',Annotation.types[:example_answer]).any? %>
+ <% annotation = question.annotations.where('type <> ?',Annotation.types[:example_answer]).order(:created_at).first %>
- <% if suggested_answer.is_example? then %>
- <%= _('Example of answer')%>
- <%else%>
- <%= _('Suggested answer')%>
- <%end%>
+ <%= _('Example of answer')%>
- <%= raw suggested_answer.text %>
+ <%= raw annotation.text %>
@@ -45,21 +42,21 @@
<% if q_format.title == _('Check box') || q_format.title == _('Multi select box') || q_format.title == _('Radio buttons') || q_format.title == _('helpers.dropdown') then%>
<% options = question.options.order("number") %>
- <% if q_format.title == _('Check box') then %>
- <% if readonly then %>
+ <% if q_format.title == _('Check box') %>
+ <% if readonly %>
<%= f.input :options, :as => :check_boxes, :collection => options, :label => false, input_html => { :disabled => true, :id => "options-#{question.id}" } %>
<% else %>
<%= f.input :options, :as => :check_boxes, :collection => options, :label => false, :input_html => { :id => "options-#{question.id}" } %>
<% end %>
- <% elsif q_format.title == _('Multi select box') then %>
+ <% elsif q_format.title == _('Multi select box') %>
<% if readonly then %>
<%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => true, :disabled => true , :id => "options-#{question.id}" } %>
<% else %>
<%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => true , :id => "options-#{question.id}" } %>
<% end %>
- <% elsif q_format.title == _('Radio buttons') then%>
+ <% elsif q_format.title == _('Radio buttons') %>
<% options.each do |op| %>
@@ -67,31 +64,25 @@
<% if readonly then %>
<%= f.radio_button :option_ids, op.id, :checked => true, disabled: true, id: "answer_option_ids_#{op.id}"%>
<% else %>
- <%= f.radio_button :option_ids, op.id, :checked => true, id: "answer_option_ids_#{op.id}"%>
+ <%= f.radio_button :option_ids, op.id, :checked => true, id: "answer_option_ids_#{op.id}"%>
<% end %>
<%else%>
<% if readonly then %>
- <%= f.radio_button :option_ids, op.id, :checked => false, disabled: true, id: "answer_option_ids_#{op.id}"%>
+ <%= f.radio_button :option_ids, op.id, :checked => false, disabled: true, id: "answer_option_ids_#{op.id}"%>
<% else %>
- <%= f.radio_button :option_ids, op.id, :checked => false, id: "answer_option_ids_#{op.id}"%>
+ <%= f.radio_button :option_ids, op.id, :checked => false, id: "answer_option_ids_#{op.id}"%>
<% end %>
<% end %>
<%= op.text %>
<% end %>
- <% elsif q_format.title == _('Dropdown') then%>
- <% if readonly then %>
+ <% elsif q_format.title == _('Dropdown') %>
+ <% if readonly %>
<%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => false, :disabled => true, :id => "options-#{question.id}" } %>
<% else %>
<%= f.input :options, :as => :select, :collection => options, :label => false, :input_html => { :multiple => false, :id => "options-#{question.id}" } %>
<% end %>
- <% end %>
-
- <% if question.option_comment_display == true then%>
- <%= label_tag("answer-text-#{question.id}".to_sym, _('Comment')) %>
- <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %>
- <%end%>
<% elsif q_format.title == _('Text field') then %>
@@ -100,16 +91,17 @@
<% elsif q_format.title == _('Text area') then%>
<%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %>
<% end %>
+
+ <% if question.option_comment_display == true then%>
+ <%= label_tag("answer-text-#{question.id}".to_sym, _('Comment')) %>
+ <%= text_area_tag("answer-text-#{question.id}".to_sym, answer.text, class: "tinymce") %>
+ <%end%>
<% end %>
<%= f.actions do %>
- <% if readonly then %>
- <%= f.action :submit, :label => _('Save'), :button_html => { :class => "btn btn-primary"}, :input_html => { :disabled => true } %>
- <% else %>
- <%= f.action :submit, :label => _('Save'), :button_html => { :class => "btn btn-primary"} %>
- <% end %>
+
<%= _('Saving...')%>
<% end %>
<% end %>
@@ -117,7 +109,6 @@
<% end %>
>
-
<%= question.text %>
<% if q_format.title == _('Check box') || q_format.title == _('Multi select box') || q_format.title == _('Radio buttons') || q_format.title == _('Dropdown') %>
@@ -138,7 +129,7 @@
<% if answer.created_at.nil? then %>
<%= _('Not answered yet') %>
<% else %>
- <%= _('Answered')%><%= answer.created_at %> <%= _(' by')%><%= answer.user.name %>
+ <%= _('Answered ')%><%= answer.created_at %> <%= _(' by ')%><%= answer.user.name %>
<% end %>
<%= _('Unsaved changes') %>
@@ -147,12 +138,13 @@
- <% @comments = Notes.where("question_id = ? AND plan_id = ?", question.id, answer.plan_id ) %>
+ <% @comments = answer.notes.all %>
<%= hidden_field_tag :question_id, question.id, :class => "question_id" %>
- <% if (!question.guidance.nil? && question.guidance != "") || !question_guidances.empty? then %>
+ <% q_guidance = question.get_guidance_annotation(current_user.org) %>
+ <% if (q_guidance.present? && q_guidance.text.present?) || !question_guidances.empty? %>
<% css_style_comment_div = "display: none;"%>
<% css_style_guidance_div = ""%>
@@ -160,8 +152,8 @@
<%= link_to _('Guidance'), "#", :class => "guidance_accordion_button" %>
-<% if last_question_id == question.id then %>
+<% if last_question_id == question.id %>
<% else %>
-<% end %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/phases/_show_phase.html.erb b/app/views/phases/_show_phase.html.erb
index 0fb55d0..ecb5dd4 100644
--- a/app/views/phases/_show_phase.html.erb
+++ b/app/views/phases/_show_phase.html.erb
@@ -4,7 +4,7 @@
<%= _('Phase details')%>
- <% if @phase.modifiable %>
+ <% if @phase.modifiable && @edit %>
<%= link_to _('Edit phase details'), '#', class: "btn btn-primary", id: "edit_phase_button"%>
diff --git a/app/views/phases/admin_show.html.erb b/app/views/phases/admin_show.html.erb
index cd02a2d..e27f41e 100644
--- a/app/views/phases/admin_show.html.erb
+++ b/app/views/phases/admin_show.html.erb
@@ -17,7 +17,7 @@
-<%= render partial: "templates/admin_nav_tabs", locals: {template: @phase.template, active: @phase.id} %>
+<%= render partial: "templates/admin_nav_tabs", locals: {template: @phase.template, active: @phase.id, edit: @edit, current: @current} %>
diff --git a/app/views/phases/edit.html.erb b/app/views/phases/edit.html.erb
index f91d5f7..3a29a21 100644
--- a/app/views/phases/edit.html.erb
+++ b/app/views/phases/edit.html.erb
@@ -28,10 +28,10 @@
<% if session[:question_id_comments].to_i != 0 then %>
<% question_from_comment = Question.find(session[:question_id_comments])%>
- <% if sectionid == question_from_comment.section_id then %>
+ <% if sectionid == question_from_comment.section_id then %>
<%= hidden_field_tag :comment_section_id, question_from_comment.section_id, :class => "comment_section_id" %>
- <%end%>
- <% end%>
+ <%end%>
+ <% end%>
@@ -91,9 +91,9 @@
partialname += "_ro"
end
%>
-
+
<% guidances = @question_guidance[question.id] %>
-
+
<%= render partial: partialname,
locals: {
plan: @plan,
@@ -101,9 +101,10 @@
question: question,
question_guidances: guidances,
last_question_id: section.questions.last.id,
+ readonly: @readonly
}
%>
-
+
<% end %>
diff --git a/app/views/plans/_answer_form.html.erb b/app/views/plans/_answer_form.html.erb
deleted file mode 100644
index 45f908b..0000000
--- a/app/views/plans/_answer_form.html.erb
+++ /dev/null
@@ -1,269 +0,0 @@
-
-<% answer = @plan.answer(question.id) %>
-
-
-
- <% q_format = question.question_format%>
-
- <% if readonly != "always" then %>
-
- <% end %>
-
-
>
-
<%= question.text %>
-
- <% if q_format.title == "Check box" ||
- q_format.title == "Multi select box" ||
- q_format.title == "Radio buttons" ||
- q_format.title == "Dropdown" %>
-
- <% if answer.options.is_a? Option then %>
- <%= answer.options.text %>
- <% else %>
- <% answer.options.each do |o| %>
- <%= o.text %>
- <% end %>
- <% end %>
-
- <% end %>
-
- <%= raw answer.text %>
-
-
-
- <% if answer.created_at.nil? then %>
-
<%= _('Not answered yet') %>
- <% else %>
-
<%= _('Answered')%><%= answer.created_at %> <%= _(' by')%><%= answer.user.name %>
- <% end %>
-
<%= _('Unsaved changes') %>
-
-
-
-
-
-
- <% @comments = Comment.where("question_id = ? AND plan_id = ?", question.id, answer.plan_id ) %>
- <%= hidden_field_tag :question_id, question.id, :class => "question_id" %>
- <% @question_guidances = @plan.guidance_for_question(question) %>
-
-
-
-
-
-
-
-
- <% if !question.guidance.nil? && question.guidance != "" then %>
-
-
-
-
<%= raw question.guidance %>
-
-
- <% end %>
-
- <% @question_guidances.each_pair do |group,themes| %>
- <% themes.each_pair do |theme,guidances| %>
- <% guidances.each do |guidance| %>
-
-
-
-
<%= raw guidance.text %>
-
-
- <% end %>
- <% end %>
- <% end %>
-
-
-
-
-
-
-
-
-
-
-<% if last_question_id == question.id then %>
-
-<% else %>
-
-<% end %>
diff --git a/app/views/plans/edit.html.erb b/app/views/plans/edit.html.erb
index d44caea..57a7d38 100644
--- a/app/views/plans/edit.html.erb
+++ b/app/views/plans/edit.html.erb
@@ -8,6 +8,7 @@
<%= render :partial => "plan_title", locals: {plan: @plan} %>
+
<%=@readonly%>
<% status = @plan.status %>
diff --git a/app/views/plans/export.html.erb b/app/views/plans/export.html.erb
index 990af6c..8e79cc4 100644
--- a/app/views/plans/export.html.erb
+++ b/app/views/plans/export.html.erb
@@ -22,7 +22,7 @@
%>
- <%= admin_field_t(field.to_s) -%>
- <%= value.present? ? value : _('-') -%>
+ <%= value.present? ? value : _('-') %>
<% end %>
diff --git a/app/views/plans/export.pdf.erb b/app/views/plans/export.pdf.erb
index c41b244..874acd4 100644
--- a/app/views/plans/export.pdf.erb
+++ b/app/views/plans/export.pdf.erb
@@ -21,9 +21,10 @@
<%= @plan.title %>
<% @exported_plan.admin_details.each do |field|
value = @exported_plan.send(field)
- if value.present?
- %>
-
<%= admin_field_t(field.to_s) -%> <%= value -%>
+ if value.present? %>
+
<%= admin_field_t(field.to_s) -%> <%= value -%>
+ <% else %>
+
<%= admin_field_t(field.to_s) -%> <%= _('-') %>
<% end %>
<% end %>
diff --git a/app/views/questions/_add_question.html.erb b/app/views/questions/_add_question.html.erb
index 3a95f58..9ca04bf 100644
--- a/app/views/questions/_add_question.html.erb
+++ b/app/views/questions/_add_question.html.erb
@@ -114,20 +114,20 @@
- <%= _('Suggested answer/ Example')%>
+ <%= _('Example Answer')%>
- <% suggested_answer = @new_question.suggested_answers.build %>
- <%= f.fields_for :suggested_answers, suggested_answer do |s|%>
+ <% example_answer = @new_question.annotations.build %>
+ <% example_answer.type = :example_answer %>
+ <%= f.fields_for :annotations, example_answer do |s|%>
<%= s.hidden_field :org_id, value: current_user.org_id %>
- <%= s.select :is_example, {_('Example of answer') => true, _('Suggested answer') => false} %>
<%= s.text_area :text, rows: 5 %>
<% end %>
- <%= link_to( image_tag("help_button.png"), "#", class: "suggested_answer_popover", rel: "popover", "data-html" => "true", "data-content" => _('You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted.'))%>
+ <%= link_to( image_tag("help_button.png"), "#", class: "suggested_answer_popover", rel: "popover", "data-html" => "true", "data-content" => _('You can add an example answer to help users respond. These will be presented above the answer box and can be copied/ pasted.'))%>
diff --git a/app/views/questions/_edit_question.html.erb b/app/views/questions/_edit_question.html.erb
index 6c3d573..a0928df 100644
--- a/app/views/questions/_edit_question.html.erb
+++ b/app/views/questions/_edit_question.html.erb
@@ -106,16 +106,16 @@
- <%= _('Suggested answer/ Example')%>
+ <%= _('Example Answer')%>
- <% suggested_answer = question.suggested_answers.find_by_org_id(current_user.org.id) %>
- <% if suggested_answer.nil? %>
- <% suggested_answer = question.suggested_answers.build %>
+ <% example_answer = question.get_example_answer(current_user.org.id) %>
+ <% if example_answer.nil? %>
+ <% example_answer = question.annotations.build %>
+ <% example_answer.type = :example_answer %>
<% end %>
- <%= f.fields_for :suggested_answers, suggested_answer do |s|%>
+ <%= f.fields_for :annotations, example_answer do |s|%>
<%= s.hidden_field :org_id, value: current_user.org.id %>
- <%= s.select :is_example, {_('Example of answer') => true, _('Suggested answer') => false} %>
<%= s.text_area :text, rows: 5 %>
@@ -132,7 +132,9 @@
<%= _('Guidance')%>
- <%= text_area_tag("question-guidance-#{question.id}", question.guidance , class: "tinymce") %>
+ <% guidance = question.get_guidance_annotation(current_user.org_id) %>
+ <% guidance_text = guidance.present? ? guidance.text : "" %>
+ <%= text_area_tag("question-guidance-#{question.id}", guidance_text , class: "tinymce") %>
<%= link_to( image_tag("help_button.png"), "#", class: "question_guidance_popover", rel: "popover", "data-html" => "true", "data-content" => _("Enter specific guidance to accompany this question. If you have guidance by themes too, this will be pulled in based on your selections below so it's best not to duplicate too much text."))%>
diff --git a/app/views/questions/_preview_question.html.erb b/app/views/questions/_preview_question.html.erb
index dc51641..e4a86a8 100644
--- a/app/views/questions/_preview_question.html.erb
+++ b/app/views/questions/_preview_question.html.erb
@@ -57,19 +57,15 @@
<% end %>
- <% suggested_answer = question.suggested_answers.find_by(org_id: current_user.org_id) %>
- <% if !suggested_answer.blank? %>
+ <% if question.annotations.where('type <> ?',Annotation.types[:example_answer]).any? %>
+ <% annotation = question.annotations.where('type <> ?',Annotation.types[:example_answer]).order(:created_at).first %>
- <% if suggested_answer.is_example? %>
<%= _('Example of answer')%>
- <% else %>
- <%= _('Suggested answer')%>
- <% end %>
- <%= raw suggested_answer.text %>
+ <%= raw annotation.text %>
@@ -80,19 +76,15 @@
<% else %>
<%= raw question.text %>
- <% suggested_answer = question.suggested_answers.find_by(org_id: current_user.org_id) %>
- <% if !suggested_answer.blank? %>
+ <% annotations = question.annotations.find_by(org_id: current_user.org_id) %>
+ <% if !annotations.blank? %>
- <% if suggested_answer.is_example? %>
<%= _('Example of answer')%>
- <% else %>
- <%= _('Suggested answer')%>
- <% end %>
- <%= raw suggested_answer.text %>
+ <%= raw annotations.text %>
@@ -106,9 +98,9 @@
<% if q_format.title == _('Text field') %>
- <%elsif q_format.title == _('Text area') %>
+ <% elsif q_format.title == _('Text area') %>
- <%end%>
+ <% end %>
<%= link_to _('Save'), "#", class: "btn btn-primary", onclick: "event.preventDefault();" %>
diff --git a/app/views/questions/_show_question.html.erb b/app/views/questions/_show_question.html.erb
index 754d330..1f3423b 100644
--- a/app/views/questions/_show_question.html.erb
+++ b/app/views/questions/_show_question.html.erb
@@ -63,25 +63,22 @@
<% if !question.section.phase.template.org.funder? %>
- <% suggested_answer = question.get_suggested_answer(current_user.org_id) %>
- <% if !suggested_answer.nil? && suggested_answer.text != "" %>
+ <% example_answer = question.get_example_answer(current_user.org_id) %>
+ <% if example_answer.present? && example_answer.text.present? %>
- <% if suggested_answer.is_example? %>
- <%= _('Example of answer')%>
- <% else %>
- <%= _('Suggested answer')%>
- <% end %>
+ <%= _('Example of answer')%>
- <%= raw suggested_answer.text %>
+ <%= raw example_answer.text %>
<% end %>
<% end %>
- <% if !question.guidance.nil? %>
+ <% guidance = question.get_guidance_annotation(current_user.org_id) %>
+ <% if guidance.present? %>
<%= _('Guidance')%>
- <%= raw question.guidance %>
+ <%= raw guidance.text %>
<% end %>
@@ -104,17 +101,17 @@
<% if !question.modifiable %>
- <% suggested_answer = question.get_suggested_answer(current_user.org_id) %>
- <% if !suggested_answer.nil? && suggested_answer.text != "" %>
+ <% example_answer = question.get_example_answer(current_user.org_id) %>
+ <% if example_answer.present? && example_answer.text.present? %>
- <%= render partial: 'suggested_answers/show_suggested_answer', locals: {suggested_answer: suggested_answer, question: question} %>
+ <%= render partial: 'annotations/show_annotation', locals: {annotation: example_answer, question: question} %>
- <%= render partial: 'suggested_answers/edit_suggested_answer', locals: {suggested_answer: suggested_answer, question: question} %>
+ <%= render partial: 'annotations/edit_annotation', locals: {annotation: example_answer, question: question} %>
<% end %>
- <%= render partial: 'suggested_answers/add_suggested_answer', locals: {question: question} %>
+ <%= render partial: 'annotations/add_annotation', locals: {question: question} %>
<% end %>
@@ -129,12 +126,12 @@
confirm: _("You are about to delete '%{question_text}'. Are you sure?") % { :question_text => question.text }, method: :delete, class: "btn btn-primary"%>
<% elsif !@edit && question.modifiable %>
- <% suggested_answer = question.get_suggested_answer(current_user.org_id) %>
- <% if suggested_answer.nil? %>
+ <% example_answer = question.get_example_answer(current_user.org_id) %>
+ <% if example_answer.nil? %>
<% end %>
diff --git a/app/views/shared/_accessible_combobox.html.erb b/app/views/shared/_accessible_combobox.html.erb
index c2f99e0..e06ec20 100644
--- a/app/views/shared/_accessible_combobox.html.erb
+++ b/app/views/shared/_accessible_combobox.html.erb
@@ -4,6 +4,7 @@
"user", :url => registration_path("user"), :htmlb => {:autocomplete =>"off"}) do |f| %>
+<% javascript "shared/register_form.js" %>
+
+<%= form_for(resource, :as => "user", :url => registration_path("user"), :htmlb => {:autocomplete =>"off"}, :html => {class: "roadmap-form"}) do |f| %>
<%= devise_error_messages! %>
- <%= f.email_field :email, placeholder: (_('Email') + ' *'), :required => true, :as => :email, :class => 'text_field has-tooltip reg-input', 'data-toggle' => "tooltip", 'data-container' => "body", 'title' => _('This must be a valid email address - a message will be sent to it for confirmation.') %>
+ <%= f.email_field :email, placeholder: (_('Email') + ' *'), :as => :email, :class => 'text_field has-tooltip reg-input', 'data-toggle' => "tooltip", 'data-container' => "body", 'title' => _('Please enter your email') %>
<%= _('Error!')%> <%= _('You must enter a valid email address.')%>
@@ -36,24 +38,28 @@
<%= f.text_field :other_organisation, placeholder: ( _('Organisation name') + ' *'), :as => :string , :autocomplete => "off", :class => 'text_field has-tooltip reg-input', 'data-toggle' => "tooltip", 'data-container' => "body", 'title' => _('Please enter the name of your organisation.') %>
- <%= f.password_field :password, placeholder: (_('Password') + ' *'), :autocomplete => "off", :required => true, :as => :password, :class => 'text_field has-tooltip reg-input', 'data-toggle' => "tooltip", 'data-container' => "body", 'title' => _('Your password must contain at least 8 characters.') %>
+ <%= f.password_field :password, placeholder: (_('Password') + ' *'), :autocomplete => "off", :as => :password, :class => 'text_field has-tooltip reg-input', 'data-toggle' => "tooltip", 'data-container' => "body", 'title' => _('Your password must contain at least 8 characters.') %>
<%= _('Error!')%> <%= _('Your password must contain at least 8 characters.')%>
- <%= f.password_field :password_confirmation, placeholder: (_('Password confirmation') + ' *'), :required => true, :as => :password, :class => 'text_field has-tooltip reg-input', 'data-toggle' => "tooltip", 'data-container' => "body", 'title' => _('Your password must contain at least 8 characters.') %>
+ <%= f.password_field :password_confirmation, placeholder: (_('Password confirmation') + ' *'), :as => :password, :class => 'text_field has-tooltip reg-input', 'data-toggle' => "tooltip", 'data-container' => "body", 'title' => _('Your password must contain at least 8 characters.') %>
<%= _('Error!')%> <%= _('This must match what you entered in the previous field.')%>
- <%= f.check_box :accept_terms, :required => true %> <%= f.label :accept_terms, :class => "remember_div" do %>
- <%= raw _(' I accept the terms and conditions *') % { :current_locale => FastGettext.locale } %>
+ <%= f.check_box :accept_terms %> <%= f.label :accept_terms, :class => "remember_div" do %>
+ <%= raw _(' I accept the terms and conditions *') %>
<%end%>
- <%= f.submit _('Sign up'), :class => "btn btn-primary" %>
+ <%= render partial: 'shared/accessible_submit_button',
+ locals: {id: 'sign_up_submit',
+ val: _('Sign up'),
+ disabled_initially: true,
+ tooltip: _('You can not continue until you have filled in all of the required information.')} %>
<% end %>
diff --git a/app/views/suggested_answers/_add_suggested_answer.html.erb b/app/views/suggested_answers/_add_suggested_answer.html.erb
deleted file mode 100644
index fa5a8bf..0000000
--- a/app/views/suggested_answers/_add_suggested_answer.html.erb
+++ /dev/null
@@ -1,25 +0,0 @@
-
-<%= form_for :suggested_answer, url: admin_create_suggested_answer_path do |f| %>
- <%= f.hidden_field :org_id, value: current_user.org_id %>
- <%= f.hidden_field :question_id, value: question.id %>
-
-
-
- <%= _('Suggested answer/ Example')%>
-
-
- <%= f.select :is_example, {_('Example of answer') => true, _('Suggested answer') => false} %>
- <%= f.text_area :text, rows: 5 %>
-
-
-
-
-
-
-
-
-
- <%= f.submit _('Save'), class: "btn btn-primary" %>
- <%= link_to _('Cancel'), "#", id: "cancel_suugested_answer", class: "btn cancel" %>
-
-<%end%>
diff --git a/app/views/suggested_answers/_edit_suggested_answer.html.erb b/app/views/suggested_answers/_edit_suggested_answer.html.erb
deleted file mode 100644
index f0d92b7..0000000
--- a/app/views/suggested_answers/_edit_suggested_answer.html.erb
+++ /dev/null
@@ -1,26 +0,0 @@
-
-<%= form_for(suggested_answer, url: admin_update_suggested_answer_path(suggested_answer), html: { method: :put}) do |f| %>
- <%= f.hidden_field :org_id, value: current_user.org_id %>
-
-
-
- <%= _('Suggested answer/ Example')%>
-
-
- <%= f.select :is_example, {_('Example of answer') => true, _('Suggested answer') => false} %>
- <%= f.text_area :text, rows: 5 %>
-
-
-
-
-
-
-
-
- <%= f.submit _('Save'), class: 'btn btn-primary' %>
- <%= link_to _('Delete'), admin_destroy_suggested_answer_path(id: suggested_answer.id),
- confirm: _("You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?") % { :question_text => question.text }, method: :delete, class: "btn btn-primary"%>
- <%= hidden_field_tag :question_id, question.id, class: "question_id" %>
- <%= link_to _('Cancel'), '#', class: 'btn cancel cancel_edit_suggested_answer' %>
-
-<% end %>
diff --git a/app/views/suggested_answers/_show_suggested_answer.html.erb b/app/views/suggested_answers/_show_suggested_answer.html.erb
deleted file mode 100644
index 5d04606..0000000
--- a/app/views/suggested_answers/_show_suggested_answer.html.erb
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
- <% if suggested_answer.is_example? then %>
- <%= _('Example of answer')%>
- <% else %>
- <%= _('Suggested answer')%>
- <% end %>
-
- <%= raw suggested_answer.text %>
-
-
-
-
-
- <%= hidden_field_tag :question_id, question.id, class: "question_id" %>
- <%= link_to _('Edit suggested answer/ example'), '# ', class: "btn btn-primary edit_form_for_suggested_answer"%>
-
diff --git a/app/views/templates/_admin_nav_tabs.html.erb b/app/views/templates/_admin_nav_tabs.html.erb
index 79b61df..937faae 100644
--- a/app/views/templates/_admin_nav_tabs.html.erb
+++ b/app/views/templates/_admin_nav_tabs.html.erb
@@ -1,4 +1,5 @@
+
<% if active == "show_template" %>
@@ -19,17 +20,19 @@
<% end %>
- <% if current_user.can_org_admin? &&
- (template.org.funder? ||
- current_user.org.funder? ||
+ <% if current_user.can_org_admin? &&
+ (template.org.funder? ||
+ current_user.org.funder? ||
(template.org == current_user.org)) %>
<% if active == 'add_plan' %>
<% else %>
<% end %>
- <%= link_to _('Add new phase +'), admin_add_phase_path(template) %>
+ <% if @template == @current || @edit %>
+ <%= link_to _('Add new phase +'), admin_add_phase_path(template) %>
+ <% end %>
<%end%>
-
\ No newline at end of file
+
diff --git a/app/views/templates/_edit_annotations.html.erb b/app/views/templates/_edit_annotations.html.erb
index 96e7708..d388f61 100644
--- a/app/views/templates/_edit_annotations.html.erb
+++ b/app/views/templates/_edit_annotations.html.erb
@@ -44,19 +44,17 @@
- <%= _('Suggested answer/ Example')%>
+ <%= _('Example of Answer')%>
- <% suggested_answer = question.suggested_answers.find_by_org_id(current_user.org.id) %>
- <% if suggested_answer.nil? %>
- <% suggested_answer = question.suggested_answers.build %>
+ <% annotations = question.annotations.where(org_id: current_user.org_id).where('type <> ?',Annotation.types[:example_answer]).order(:created_at).first %>
+ <% if annotations.nil? %>
+ <% annotations = question.annotations.build %>
<% end %>
- <%= f.fields_for :suggested_answers, suggested_answer do |s|%>
+ <%= f.fields_for :annotations, annotation do |s|%>
<%= s.hidden_field :org_id, value: current_user.org.id %>
- <%= s.select :is_example, {_('Example of answer') => true, _('Suggested answer') => false} %>
- <%= s.text_area :text, rows: 5 %>
-
+ <%= s.text_area :text, rows: 5 %>
<% end %>
diff --git a/app/views/templates/_show_phases_sections.html.erb b/app/views/templates/_show_phases_sections.html.erb
index 0c15d12..64fe81f 100644
--- a/app/views/templates/_show_phases_sections.html.erb
+++ b/app/views/templates/_show_phases_sections.html.erb
@@ -17,13 +17,11 @@
<% if template == current && phase.modifiable %>
<%= link_to _('Delete'), admin_destroy_phase_path(phase_id: phase.id),
confirm: _("You are about to delete '%{phase_title}'. This will affect versions, sections and questions linked to this phase. Are you sure?") % { :phase_title => phase.title }, method: :delete, class: "btn btn-primary"%>
- <% end %>
- <% if !phase.modifiable %>
- <% b_label = _('View phase')%>
- <% else %>
<% b_label = _('Edit phase')%>
+ <% else %>
+ <% b_label = _('View phase')%>
<% end %>
- <%= link_to b_label, admin_show_phase_path(id: phase.id, edit: (b_label == _('org_admin.templates.edit_phase_label'))), class: "btn btn-primary" %>
+ <%= link_to b_label, admin_show_phase_path(id: phase.id, edit: (b_label == _('Edit phase'))), class: "btn btn-primary" %>
<% if phase_hash[:sections].present? %>
diff --git a/app/views/templates/admin_template_history.html.erb b/app/views/templates/admin_template_history.html.erb
index 297bf17..95897a8 100644
--- a/app/views/templates/admin_template_history.html.erb
+++ b/app/views/templates/admin_template_history.html.erb
@@ -36,6 +36,9 @@
<%= org_template.title%>
+ <% if org_template == @current && !org_template.published%>
+ <%=_('Draft')%>
+ <% end %>
<%= org_template.version %>
@@ -60,4 +63,4 @@
-<%end%>
\ No newline at end of file
+<%end%>
diff --git a/app/views/user_mailer/permissions_change_notification.html.erb b/app/views/user_mailer/permissions_change_notification.html.erb
index 92eed7f..c2c0740 100644
--- a/app/views/user_mailer/permissions_change_notification.html.erb
+++ b/app/views/user_mailer/permissions_change_notification.html.erb
@@ -12,7 +12,7 @@
end
%>
<%= _('Hello ') %><%= @role.user.name %>,
-
<%= _('Your permissions relating to ') %> "<%= link_to @role.plan.title, url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %>" <%= _(' have been changed by') %><%=" #{@current_user.firstname} #{@current_user.surname}. " %><%= _('You now have ') %><%= access_level %><%= _(' access. ') %><%= permissions %>
+
<%= _('Your permissions relating to ') %> "<%= link_to @role.plan.title, url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %>" <%= _(' have been changed by') %><%="#{@current_user.name(false)}. " %><%= _('You now have ') %><%= access_level %><%= _(' access. ') %><%= permissions %>
<%=_('All the best,')%> <%= _('The ')%><%= Rails.configuration.branding[:application][:name] %><%=_(' team')%>.
<% end %>
diff --git a/app/views/user_mailer/project_access_removed_notification.html.erb b/app/views/user_mailer/project_access_removed_notification.html.erb
index 63ec8d9..53a5e40 100644
--- a/app/views/user_mailer/project_access_removed_notification.html.erb
+++ b/app/views/user_mailer/project_access_removed_notification.html.erb
@@ -1,6 +1,6 @@
<% FastGettext.with_locale FastGettext.default_locale do %>
<%= _('Hello ') %><%= @user.email %>,
-
<%= _('Your access to ') %>"<%= @plan.title %>"<%= _(' has been removed by ') %><%= "#{@current_user.firstname} #{@current_user.surname}"%>.
+
<%= _('Your access to ') %>"<%= @plan.title %>"<%= _(' has been removed by ') %><%= "#{@current_user.name(false)}"%>.
<%=_('All the best,')%> <%= _('The ')%><%= Rails.configuration.branding[:application][:name] %><%=_(' team')%>.
<% end %>
diff --git a/app/views/user_mailer/sharing_notification.html.erb b/app/views/user_mailer/sharing_notification.html.erb
index 95ee5b1..dc2fed4 100644
--- a/app/views/user_mailer/sharing_notification.html.erb
+++ b/app/views/user_mailer/sharing_notification.html.erb
@@ -13,7 +13,7 @@
%>
<%= _('Hello ') %><%= @role.user.name %>,
<%= _('A colleague has invited you to contribute to their Data Management Plan at ') %><%= link_to Rails.configuration.branding[:application][:name], root_url %>.
-
<%= _('You have been given ') %><%= access_level %><%= _(' access to') %> "<%= link_to @role.plan.title, url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %>" <%=_(' by ')%><%= "#{@user.firstname} #{@user.surname}"%>.
+
<%= _('You have been given ') %><%= access_level %><%= _(' access to') %> "<%= link_to @role.plan.title, url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %>" <%=_('by ')%><%= "#{@user.name(false)}" %>.
<%= link_to _('Click here'), url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %><%= _(' to accept the invitation, (or copy ') %><%= url_for(action: 'show', controller: 'plans', id: @role.plan.id, locale: FastGettext.default_locale) %><%= _(' into your browser)')%>
<%= _('If you don\'t want to accept the invitation, please ignore this email.') %>
<%=_('All the best,')%> <%= _('The ')%><%= Rails.configuration.branding[:application][:name] %><%=_(' team')%>.
diff --git a/config/application.rb b/config/application.rb
index 8994e51..ce4f957 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -81,6 +81,7 @@
config.assets.precompile += %w(roadmap-form.scss)
config.assets.precompile += %w(plans/new_plan.js)
config.assets.precompile += %w(contacts/new_contact.js)
+ config.assets.precompile += %w(shared/register_form.js)
config.autoload_paths += %W(#{config.root}/lib)
config.action_controller.include_all_helpers = true
diff --git a/config/locale/app.pot b/config/locale/app.pot
index 6dd6de5..8383875 100644
--- a/config/locale/app.pot
+++ b/config/locale/app.pot
@@ -8,8 +8,8 @@
msgstr ""
"Project-Id-Version: app 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2017-05-15 20:57+0000\n"
-"PO-Revision-Date: 2017-05-15 20:57+0000\n"
+"POT-Creation-Date: 2017-05-19 17:36+0100\n"
+"PO-Revision-Date: 2017-05-19 17:36+0100\n"
"Last-Translator: FULL NAME
\n"
"Language-Team: LANGUAGE \n"
"Language: \n"
@@ -24,7 +24,10 @@
msgid " - "
msgstr ""
-msgid " I accept the terms and conditions *"
+msgid " Guidance"
+msgstr ""
+
+msgid " I accept the terms and conditions *"
msgstr ""
msgid " Plan"
@@ -252,6 +255,9 @@
msgid "Add collaborator"
msgstr ""
+msgid "Add example answer"
+msgstr ""
+
msgid "Add guidance"
msgstr ""
@@ -273,9 +279,6 @@
msgid "Add section"
msgstr ""
-msgid "Add suggested answer/ example"
-msgstr ""
-
msgid "Additional comment area will be displayed."
msgstr ""
@@ -303,6 +306,9 @@
msgid "Answered"
msgstr ""
+msgid "Answered "
+msgstr ""
+
msgid "Answered at"
msgstr ""
@@ -342,6 +348,9 @@
msgid "Before you get started, we need to ask a few questions to set you up with the best DMP template for your needs."
msgstr ""
+msgid "Begin typing to see a filtered list"
+msgstr ""
+
msgid "Below is a list of users registered for your organisation. You can sort the data by each field."
msgstr ""
@@ -465,6 +474,9 @@
msgid "Display additional comment area."
msgstr ""
+msgid "Draft"
+msgstr ""
+
msgid "Dropdown"
msgstr ""
@@ -474,6 +486,9 @@
msgid "Edit"
msgstr ""
+msgid "Edit Example of Answer"
+msgstr ""
+
msgid "Edit User Privileges"
msgstr ""
@@ -495,9 +510,6 @@
msgid "Edit question"
msgstr ""
-msgid "Edit suggested answer/ example"
-msgstr ""
-
msgid "Edit template details"
msgstr ""
@@ -537,6 +549,12 @@
msgid "Error!"
msgstr ""
+msgid "Example Answer"
+msgstr ""
+
+msgid "Example of Answer"
+msgstr ""
+
msgid "Example of answer"
msgstr ""
@@ -942,6 +960,9 @@
msgid "Please enter your current password below when changing your email address."
msgstr ""
+msgid "Please enter your email"
+msgstr ""
+
msgid "Please enter your first name."
msgstr ""
@@ -969,9 +990,6 @@
msgid "Please select one"
msgstr ""
-msgid "Policy Expectations"
-msgstr ""
-
msgid "Preview"
msgstr ""
@@ -1233,9 +1251,6 @@
msgid "This document was generated by %{application_name}"
msgstr ""
-msgid "This must be a valid email address - a message will be sent to it for confirmation."
-msgstr ""
-
msgid "This must match what you entered in the previous field."
msgstr ""
@@ -1392,12 +1407,18 @@
msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?"
msgstr ""
+msgid "You are about to delete an example answer for '%{question_text}'. Are you sure?"
+msgstr ""
+
msgid "You are not authorized to perform this action."
msgstr ""
msgid "You are viewing a historical version of this template. You will not be able to make changes."
msgstr ""
+msgid "You can add an example answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
+msgstr ""
+
msgid "You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
msgstr ""
@@ -1527,6 +1548,9 @@
msgid "by"
msgstr ""
+msgid "by "
+msgstr ""
+
msgid "can't be blank"
msgstr ""
@@ -1539,6 +1563,9 @@
msgid "e.g. School/ Department"
msgstr ""
+msgid "example answer"
+msgstr ""
+
msgid "from now"
msgstr ""
@@ -1596,9 +1623,6 @@
msgid "or copy"
msgstr ""
-msgid "org_admin.templates.edit_phase_label"
-msgstr ""
-
msgid "organisation"
msgstr ""
@@ -1632,9 +1656,6 @@
msgid "select at least one theme"
msgstr ""
-msgid "suggested answer"
-msgstr ""
-
msgid "template"
msgstr ""
diff --git a/config/locale/de/app.po b/config/locale/de/app.po
index bdbe788..b52820b 100644
--- a/config/locale/de/app.po
+++ b/config/locale/de/app.po
@@ -23,7 +23,11 @@
msgstr " - "
#, fuzzy
-msgid " I accept the terms and conditions *"
+msgid " Guidance"
+msgstr "Hilfestellung"
+
+#, fuzzy
+msgid " I accept the terms and conditions *"
msgstr "Ich akzeptiere die Nutzungsbedingungen *"
#, fuzzy
@@ -269,6 +273,9 @@
msgid "Add collaborator"
msgstr "Mitarbeitende(n) hinzufügen"
+msgid "Add example answer"
+msgstr ""
+
msgid "Add guidance"
msgstr "Hilfestellung hinzufügen"
@@ -290,9 +297,6 @@
msgid "Add section"
msgstr "Abschnitt hinzufügen"
-msgid "Add suggested answer/ example"
-msgstr "Antwortvorschlag / Beispiel hinzufügen"
-
msgid "Additional comment area will be displayed."
msgstr ""
@@ -323,6 +327,10 @@
msgstr "Beantwortet "
#, fuzzy
+msgid "Answered "
+msgstr "Beantwortet "
+
+#, fuzzy
msgid "Answered at"
msgstr "Beantwortet "
@@ -364,6 +372,9 @@
msgid "Before you get started, we need to ask a few questions to set you up with the best DMP template for your needs."
msgstr "Fragen"
+msgid "Begin typing to see a filtered list"
+msgstr ""
+
msgid "Below is a list of users registered for your organisation. You can sort the data by each field."
msgstr "Folgend findet sich die Liste von Benutzern registriert bzgl. Ihrer Org. Sie können diese Liste bzgl. aller Felder sortieren."
@@ -492,6 +503,9 @@
msgid "Display additional comment area."
msgstr ""
+msgid "Draft"
+msgstr ""
+
msgid "Dropdown"
msgstr "Klappliste"
@@ -501,6 +515,10 @@
msgid "Edit"
msgstr "Bearbeiten"
+#, fuzzy
+msgid "Edit Example of Answer"
+msgstr "Beispielantwort"
+
msgid "Edit User Privileges"
msgstr "Bearbeiten Benutzerberechtigungen"
@@ -522,9 +540,6 @@
msgid "Edit question"
msgstr "Frage bearbeiten"
-msgid "Edit suggested answer/ example"
-msgstr "Antwortvorschlag / Beispiel bearbeiten"
-
msgid "Edit template details"
msgstr "Details der Vorlage bearbeiten"
@@ -565,6 +580,14 @@
msgid "Error!"
msgstr "Fehler!"
+#, fuzzy
+msgid "Example Answer"
+msgstr "Beispielantwort"
+
+#, fuzzy
+msgid "Example of Answer"
+msgstr "Beispielantwort"
+
msgid "Example of answer"
msgstr "Beispielantwort"
@@ -983,6 +1006,9 @@
msgid "Please enter your current password below when changing your email address."
msgstr ""
+msgid "Please enter your email"
+msgstr ""
+
msgid "Please enter your first name."
msgstr "Bitte geben Sie ihren Vornamen ein."
@@ -1011,9 +1037,6 @@
msgid "Please select one"
msgstr ""
-msgid "Policy Expectations"
-msgstr "Policy Expectations"
-
msgid "Preview"
msgstr "Vorschau"
@@ -1282,9 +1305,6 @@
msgid "This document was generated by %{application_name}"
msgstr "%{application_name}"
-msgid "This must be a valid email address - a message will be sent to it for confirmation."
-msgstr ""
-
msgid "This must match what you entered in the previous field."
msgstr "Die Eingabe in diesem Feld muss mit der im vorherigen Feld übereinstimmen."
@@ -1450,6 +1470,10 @@
msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?"
msgstr "Sie sind dabei den Antwortvorschlag / das Beispiel für '%{question_text}' zu löschen. Sind Sie sicher?"
+#, fuzzy
+msgid "You are about to delete an example answer for '%{question_text}'. Are you sure?"
+msgstr "Sie sind dabei den Antwortvorschlag / das Beispiel für '%{question_text}' zu löschen. Sind Sie sicher?"
+
msgid "You are not authorized to perform this action."
msgstr ""
@@ -1457,6 +1481,10 @@
msgid "You are viewing a historical version of this template. You will not be able to make changes."
msgstr "templates"
+#, fuzzy
+msgid "You can add an example answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
+msgstr "Hier können Sie einen Text als Beispiel oder Vorschlag angeben, der Nutzern bei der Beantwortung helfen soll. Der Text erscheint oberhalb des Antwortfeldes und kann kopiert und eingefügt werden."
+
msgid "You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
msgstr "Hier können Sie einen Text als Beispiel oder Vorschlag angeben, der Nutzern bei der Beantwortung helfen soll. Der Text erscheint oberhalb des Antwortfeldes und kann kopiert und eingefügt werden."
@@ -1609,6 +1637,10 @@
msgid "by"
msgstr ""
+#, fuzzy
+msgid "by "
+msgstr " von "
+
msgid "can't be blank"
msgstr ""
@@ -1621,6 +1653,10 @@
msgid "e.g. School/ Department"
msgstr "z.B. Fakultät / Einrichtung"
+#, fuzzy
+msgid "example answer"
+msgstr "Beispielantwort"
+
msgid "from now"
msgstr ""
@@ -1687,10 +1723,6 @@
msgstr "(or copy"
#, fuzzy
-msgid "org_admin.templates.edit_phase_label"
-msgstr "org_admin"
-
-#, fuzzy
msgid "organisation"
msgstr "Organisation"
@@ -1731,10 +1763,6 @@
msgstr "select at least one theme"
#, fuzzy
-msgid "suggested answer"
-msgstr "Antwortvorschlag"
-
-#, fuzzy
msgid "template"
msgstr "templates"
diff --git a/config/locale/en_GB/app.po b/config/locale/en_GB/app.po
index 3a2db97..8c0cca3 100644
--- a/config/locale/en_GB/app.po
+++ b/config/locale/en_GB/app.po
@@ -22,7 +22,12 @@
msgid " - "
msgstr " - "
-msgid " I accept the terms and conditions *"
+#, fuzzy
+msgid " Guidance"
+msgstr "Guidance"
+
+#, fuzzy
+msgid " I accept the terms and conditions *"
msgstr " I accept the terms and conditions *"
#, fuzzy
@@ -259,6 +264,9 @@
msgid "Add collaborator"
msgstr "Add collaborator"
+msgid "Add example answer"
+msgstr ""
+
msgid "Add guidance"
msgstr "Add guidance"
@@ -280,9 +288,6 @@
msgid "Add section"
msgstr "Add section"
-msgid "Add suggested answer/ example"
-msgstr "Add suggested answer/ example"
-
msgid "Additional comment area will be displayed."
msgstr "Additional comment area will be displayed."
@@ -310,6 +315,10 @@
msgid "Answered"
msgstr "Answered"
+#, fuzzy
+msgid "Answered "
+msgstr "Answered"
+
msgid "Answered at"
msgstr "Answered at"
@@ -350,6 +359,9 @@
msgid "Before you get started, we need to ask a few questions to set you up with the best DMP template for your needs."
msgstr "questions"
+msgid "Begin typing to see a filtered list"
+msgstr ""
+
msgid "Below is a list of users registered for your organisation. You can sort the data by each field."
msgstr "Below is a list of users registered for your organisation. You can sort the data by each field."
@@ -474,6 +486,9 @@
msgid "Display additional comment area."
msgstr "Display additional comment area."
+msgid "Draft"
+msgstr ""
+
msgid "Dropdown"
msgstr "Dropdown"
@@ -483,6 +498,10 @@
msgid "Edit"
msgstr "Edit"
+#, fuzzy
+msgid "Edit Example of Answer"
+msgstr "Example of answer"
+
msgid "Edit User Privileges"
msgstr "Edit User Privileges"
@@ -504,9 +523,6 @@
msgid "Edit question"
msgstr "Edit question"
-msgid "Edit suggested answer/ example"
-msgstr "Edit suggested answer/ example"
-
msgid "Edit template details"
msgstr "Edit template details"
@@ -546,6 +562,14 @@
msgid "Error!"
msgstr "Error!"
+#, fuzzy
+msgid "Example Answer"
+msgstr "Example of answer"
+
+#, fuzzy
+msgid "Example of Answer"
+msgstr "Example of answer"
+
msgid "Example of answer"
msgstr "Example of answer"
@@ -959,6 +983,9 @@
msgid "Please enter your current password below when changing your email address."
msgstr ""
+msgid "Please enter your email"
+msgstr ""
+
msgid "Please enter your first name."
msgstr "Please enter your first name."
@@ -987,9 +1014,6 @@
msgid "Please select one"
msgstr ""
-msgid "Policy Expectations"
-msgstr "Policy Expectations"
-
msgid "Preview"
msgstr "Preview"
@@ -1256,9 +1280,6 @@
msgid "This document was generated by %{application_name}"
msgstr "This document was generated by %{application_name}"
-msgid "This must be a valid email address - a message will be sent to it for confirmation."
-msgstr "This must be a valid email address - a message will be sent to it for confirmation."
-
msgid "This must match what you entered in the previous field."
msgstr "This must match what you entered in the previous field."
@@ -1421,12 +1442,20 @@
msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?"
msgstr "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?"
+#, fuzzy
+msgid "You are about to delete an example answer for '%{question_text}'. Are you sure?"
+msgstr "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?"
+
msgid "You are not authorized to perform this action."
msgstr ""
msgid "You are viewing a historical version of this template. You will not be able to make changes."
msgstr "You are viewing a historical version of this template. You will not be able to make changes."
+#, fuzzy
+msgid "You can add an example answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
+msgstr "You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
+
msgid "You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
msgstr "You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
@@ -1560,6 +1589,10 @@
msgid "by"
msgstr ""
+#, fuzzy
+msgid "by "
+msgstr " by "
+
msgid "can't be blank"
msgstr ""
@@ -1572,6 +1605,10 @@
msgid "e.g. School/ Department"
msgstr "e.g. School/ Department"
+#, fuzzy
+msgid "example answer"
+msgstr "Example of answer"
+
msgid "from now"
msgstr "from now"
@@ -1631,9 +1668,6 @@
msgid "or copy"
msgstr "or copy"
-msgid "org_admin.templates.edit_phase_label"
-msgstr ""
-
msgid "organisation"
msgstr "organisation"
@@ -1667,9 +1701,6 @@
msgid "select at least one theme"
msgstr "select at least one theme"
-msgid "suggested answer"
-msgstr "suggested answer"
-
msgid "template"
msgstr "template"
diff --git a/config/locale/en_US/app.po b/config/locale/en_US/app.po
index dd2eafe..b70e2b3 100644
--- a/config/locale/en_US/app.po
+++ b/config/locale/en_US/app.po
@@ -22,7 +22,12 @@
msgid " - "
msgstr " - "
-msgid " I accept the terms and conditions *"
+#, fuzzy
+msgid " Guidance"
+msgstr "Guidance"
+
+#, fuzzy
+msgid " I accept the terms and conditions *"
msgstr " I accept the terms and conditions *"
#, fuzzy
@@ -259,6 +264,9 @@
msgid "Add collaborator"
msgstr "Add collaborator"
+msgid "Add example answer"
+msgstr ""
+
msgid "Add guidance"
msgstr "Add guidance"
@@ -280,9 +288,6 @@
msgid "Add section"
msgstr "Add section"
-msgid "Add suggested answer/ example"
-msgstr "Add suggested answer/ example"
-
msgid "Additional comment area will be displayed."
msgstr "Additional comment area will be displayed."
@@ -310,6 +315,10 @@
msgid "Answered"
msgstr "Answered"
+#, fuzzy
+msgid "Answered "
+msgstr "Answered"
+
msgid "Answered at"
msgstr "Answered at"
@@ -350,6 +359,9 @@
msgid "Before you get started, we need to ask a few questions to set you up with the best DMP template for your needs."
msgstr "questions"
+msgid "Begin typing to see a filtered list"
+msgstr ""
+
msgid "Below is a list of users registered for your organisation. You can sort the data by each field."
msgstr "Below is a list of users registered for your organization. You can sort the data by each field."
@@ -474,6 +486,9 @@
msgid "Display additional comment area."
msgstr "Display additional comment area."
+msgid "Draft"
+msgstr ""
+
msgid "Dropdown"
msgstr "Dropdown"
@@ -483,6 +498,10 @@
msgid "Edit"
msgstr "Edit"
+#, fuzzy
+msgid "Edit Example of Answer"
+msgstr "Example of answer"
+
msgid "Edit User Privileges"
msgstr "Edit User Permissions"
@@ -504,9 +523,6 @@
msgid "Edit question"
msgstr "Edit question"
-msgid "Edit suggested answer/ example"
-msgstr "Edit suggested answer/ example"
-
msgid "Edit template details"
msgstr "Edit template details"
@@ -546,6 +562,14 @@
msgid "Error!"
msgstr "Error!"
+#, fuzzy
+msgid "Example Answer"
+msgstr "Example of answer"
+
+#, fuzzy
+msgid "Example of Answer"
+msgstr "Example of answer"
+
msgid "Example of answer"
msgstr "Example of answer"
@@ -959,6 +983,9 @@
msgid "Please enter your current password below when changing your email address."
msgstr ""
+msgid "Please enter your email"
+msgstr ""
+
msgid "Please enter your first name."
msgstr "Please enter your first name."
@@ -987,9 +1014,6 @@
msgid "Please select one"
msgstr ""
-msgid "Policy Expectations"
-msgstr "Policy Expectations"
-
msgid "Preview"
msgstr "Preview"
@@ -1256,9 +1280,6 @@
msgid "This document was generated by %{application_name}"
msgstr "This document was generated by %{application_name}"
-msgid "This must be a valid email address - a message will be sent to it for confirmation."
-msgstr "This must be a valid email address - a message will be sent to it for confirmation."
-
msgid "This must match what you entered in the previous field."
msgstr "This must match what you entered in the previous field."
@@ -1421,12 +1442,20 @@
msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?"
msgstr "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?"
+#, fuzzy
+msgid "You are about to delete an example answer for '%{question_text}'. Are you sure?"
+msgstr "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?"
+
msgid "You are not authorized to perform this action."
msgstr ""
msgid "You are viewing a historical version of this template. You will not be able to make changes."
msgstr "You are viewing a historical version of this template. You will not be able to make changes."
+#, fuzzy
+msgid "You can add an example answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
+msgstr "You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
+
msgid "You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
msgstr "You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
@@ -1560,6 +1589,10 @@
msgid "by"
msgstr ""
+#, fuzzy
+msgid "by "
+msgstr " by "
+
msgid "can't be blank"
msgstr ""
@@ -1572,6 +1605,10 @@
msgid "e.g. School/ Department"
msgstr "e.g. School/ Department"
+#, fuzzy
+msgid "example answer"
+msgstr "Example of answer"
+
msgid "from now"
msgstr "from now"
@@ -1631,9 +1668,6 @@
msgid "or copy"
msgstr "or copy"
-msgid "org_admin.templates.edit_phase_label"
-msgstr ""
-
msgid "organisation"
msgstr "organization"
@@ -1667,9 +1701,6 @@
msgid "select at least one theme"
msgstr "select at least one theme"
-msgid "suggested answer"
-msgstr "suggested answer"
-
msgid "template"
msgstr "template"
diff --git a/config/locale/es/app.po b/config/locale/es/app.po
index 4909cb5..5711578 100644
--- a/config/locale/es/app.po
+++ b/config/locale/es/app.po
@@ -23,7 +23,11 @@
msgstr ""
#, fuzzy
-msgid " I accept the terms and conditions *"
+msgid " Guidance"
+msgstr "GuÃa"
+
+#, fuzzy
+msgid " I accept the terms and conditions *"
msgstr " Acepto los términos y condiciones *"
#, fuzzy
@@ -265,6 +269,9 @@
msgid "Add collaborator"
msgstr "Añadir colaborador"
+msgid "Add example answer"
+msgstr ""
+
msgid "Add guidance"
msgstr "Añadir orientación"
@@ -286,9 +293,6 @@
msgid "Add section"
msgstr "Añadir sección"
-msgid "Add suggested answer/ example"
-msgstr "Añadir respuesta sugerida / ejemplo"
-
msgid "Additional comment area will be displayed."
msgstr "Se mostrará un área adicional para comentarios."
@@ -319,6 +323,10 @@
msgstr "Contestado "
#, fuzzy
+msgid "Answered "
+msgstr "Contestado "
+
+#, fuzzy
msgid "Answered at"
msgstr "Contestado "
@@ -361,6 +369,9 @@
msgid "Before you get started, we need to ask a few questions to set you up with the best DMP template for your needs."
msgstr "Preguntas"
+msgid "Begin typing to see a filtered list"
+msgstr ""
+
msgid "Below is a list of users registered for your organisation. You can sort the data by each field."
msgstr "Debajo tiene la lista de usuarios registrados en su entidad. Puede ordenar los datos por campo."
@@ -488,6 +499,9 @@
msgid "Display additional comment area."
msgstr "Mostrar un área de comentarios adicional."
+msgid "Draft"
+msgstr ""
+
msgid "Dropdown"
msgstr "Dropdown"
@@ -497,6 +511,10 @@
msgid "Edit"
msgstr "Editar"
+#, fuzzy
+msgid "Edit Example of Answer"
+msgstr "Respuesta de ejemplo"
+
msgid "Edit User Privileges"
msgstr ""
@@ -518,9 +536,6 @@
msgid "Edit question"
msgstr "Editar la pregunta"
-msgid "Edit suggested answer/ example"
-msgstr "Editar respuesta sugerida / ejemplo"
-
msgid "Edit template details"
msgstr "Editar plantilla"
@@ -561,6 +576,14 @@
msgid "Error!"
msgstr "¡Error!"
+#, fuzzy
+msgid "Example Answer"
+msgstr "Respuesta de ejemplo"
+
+#, fuzzy
+msgid "Example of Answer"
+msgstr "Respuesta de ejemplo"
+
msgid "Example of answer"
msgstr "Respuesta de ejemplo"
@@ -978,6 +1001,9 @@
msgid "Please enter your current password below when changing your email address."
msgstr ""
+msgid "Please enter your email"
+msgstr ""
+
msgid "Please enter your first name."
msgstr "Por favor, introduzca su nombre."
@@ -1006,9 +1032,6 @@
msgid "Please select one"
msgstr ""
-msgid "Policy Expectations"
-msgstr "PolÃtica esperada"
-
msgid "Preview"
msgstr "Previsualización"
@@ -1275,9 +1298,6 @@
msgid "This document was generated by %{application_name}"
msgstr "DMPonline"
-msgid "This must be a valid email address - a message will be sent to it for confirmation."
-msgstr ""
-
msgid "This must match what you entered in the previous field."
msgstr "Ha de coincidir con lo que introdujo en el campo anterior."
@@ -1443,6 +1463,10 @@
msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?"
msgstr "Va a eliminar una respuesta sugerida / ejemplo de '%{question_text}'. ¿Está seguro?"
+#, fuzzy
+msgid "You are about to delete an example answer for '%{question_text}'. Are you sure?"
+msgstr "Va a eliminar una respuesta sugerida / ejemplo de '%{question_text}'. ¿Está seguro?"
+
msgid "You are not authorized to perform this action."
msgstr ""
@@ -1450,6 +1474,10 @@
msgid "You are viewing a historical version of this template. You will not be able to make changes."
msgstr "templates"
+#, fuzzy
+msgid "You can add an example answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
+msgstr "Puede añadir un ejemplo o respuesta sugerida para ayudar a responder a sus usuarios. Se presentará bajo la caja de respuestas y pueden ser copiada y pegada."
+
msgid "You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
msgstr "Puede añadir un ejemplo o respuesta sugerida para ayudar a responder a sus usuarios. Se presentará bajo la caja de respuestas y pueden ser copiada y pegada."
@@ -1594,6 +1622,10 @@
msgid "by"
msgstr ""
+#, fuzzy
+msgid "by "
+msgstr " por "
+
msgid "can't be blank"
msgstr ""
@@ -1606,6 +1638,10 @@
msgid "e.g. School/ Department"
msgstr "ej: Escuela / Departmento"
+#, fuzzy
+msgid "example answer"
+msgstr "Respuesta de ejemplo"
+
msgid "from now"
msgstr ""
@@ -1670,10 +1706,6 @@
msgstr ""
#, fuzzy
-msgid "org_admin.templates.edit_phase_label"
-msgstr "org_admin"
-
-#, fuzzy
msgid "organisation"
msgstr "Organización"
@@ -1714,10 +1746,6 @@
msgstr ""
#, fuzzy
-msgid "suggested answer"
-msgstr "Respuesta sugerida"
-
-#, fuzzy
msgid "template"
msgstr "templates"
diff --git a/config/locale/fr/app.po b/config/locale/fr/app.po
index e582167..21b7c0d 100644
--- a/config/locale/fr/app.po
+++ b/config/locale/fr/app.po
@@ -23,7 +23,11 @@
msgstr ""
#, fuzzy
-msgid " I accept the terms and conditions *"
+msgid " Guidance"
+msgstr "Conseils"
+
+#, fuzzy
+msgid " I accept the terms and conditions *"
msgstr " Jaccepte les Conditions générales dutilisation. *"
#, fuzzy
@@ -264,6 +268,9 @@
msgid "Add collaborator"
msgstr "Ajouter le collaborateur"
+msgid "Add example answer"
+msgstr ""
+
msgid "Add guidance"
msgstr "Ajoutez des conseils"
@@ -285,9 +292,6 @@
msgid "Add section"
msgstr "Ajouter une section"
-msgid "Add suggested answer/ example"
-msgstr "Ajouter une suggestion/un exemple de réponse"
-
msgid "Additional comment area will be displayed."
msgstr ""
@@ -318,6 +322,10 @@
msgstr "Réponse "
#, fuzzy
+msgid "Answered "
+msgstr "Réponse "
+
+#, fuzzy
msgid "Answered at"
msgstr "Réponse "
@@ -360,6 +368,9 @@
msgid "Before you get started, we need to ask a few questions to set you up with the best DMP template for your needs."
msgstr "Questions"
+msgid "Begin typing to see a filtered list"
+msgstr ""
+
msgid "Below is a list of users registered for your organisation. You can sort the data by each field."
msgstr "La liste ci-dessous indique les utilisateurs de votre organisme. Ces informations peuvent être triées par champ."
@@ -486,6 +497,9 @@
msgid "Display additional comment area."
msgstr ""
+msgid "Draft"
+msgstr ""
+
msgid "Dropdown"
msgstr "Liste déroulante"
@@ -495,6 +509,10 @@
msgid "Edit"
msgstr "Modifier"
+#, fuzzy
+msgid "Edit Example of Answer"
+msgstr "Exemple de réponse"
+
msgid "Edit User Privileges"
msgstr ""
@@ -516,9 +534,6 @@
msgid "Edit question"
msgstr "Modifier la question"
-msgid "Edit suggested answer/ example"
-msgstr "Modifier la suggestion/lexemple de réponse"
-
msgid "Edit template details"
msgstr "Modifier les détails du modèle"
@@ -559,6 +574,14 @@
msgid "Error!"
msgstr "Erreur!"
+#, fuzzy
+msgid "Example Answer"
+msgstr "Exemple de réponse"
+
+#, fuzzy
+msgid "Example of Answer"
+msgstr "Exemple de réponse"
+
msgid "Example of answer"
msgstr "Exemple de réponse"
@@ -975,6 +998,9 @@
msgid "Please enter your current password below when changing your email address."
msgstr ""
+msgid "Please enter your email"
+msgstr ""
+
msgid "Please enter your first name."
msgstr "Entrez votre prénom, svp."
@@ -1003,9 +1029,6 @@
msgid "Please select one"
msgstr ""
-msgid "Policy Expectations"
-msgstr "Résultats attendus du plan"
-
msgid "Preview"
msgstr "Aperçu"
@@ -1272,9 +1295,6 @@
msgid "This document was generated by %{application_name}"
msgstr "%{application_name}"
-msgid "This must be a valid email address - a message will be sent to it for confirmation."
-msgstr ""
-
msgid "This must match what you entered in the previous field."
msgstr ""
@@ -1440,6 +1460,10 @@
msgid "You are about to delete a suggested answer/ example for '%{question_text}'. Are you sure?"
msgstr "Vous allez supprimer la suggestion/lexemple de réponse à la questioo : %{question_text}. En êtes-vous sûr ?"
+#, fuzzy
+msgid "You are about to delete an example answer for '%{question_text}'. Are you sure?"
+msgstr "Vous allez supprimer la suggestion/lexemple de réponse à la questioo : %{question_text}. En êtes-vous sûr ?"
+
msgid "You are not authorized to perform this action."
msgstr ""
@@ -1447,6 +1471,10 @@
msgid "You are viewing a historical version of this template. You will not be able to make changes."
msgstr "templates"
+#, fuzzy
+msgid "You can add an example answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
+msgstr "Vous pouvez ajouter un exemple ou une suggestion de réponse pour aider les utilisateurs. Ils safficheront au-dessus de la grille de réponse et on peut les copier/coller."
+
msgid "You can add an example or suggested answer to help users respond. These will be presented above the answer box and can be copied/ pasted."
msgstr "Vous pouvez ajouter un exemple ou une suggestion de réponse pour aider les utilisateurs. Ils safficheront au-dessus de la grille de réponse et on peut les copier/coller."
@@ -1591,6 +1619,10 @@
msgid "by"
msgstr ""
+#, fuzzy
+msgid "by "
+msgstr " par "
+
msgid "can't be blank"
msgstr ""
@@ -1603,6 +1635,10 @@
msgid "e.g. School/ Department"
msgstr "par ex. : Faculté/Département"
+#, fuzzy
+msgid "example answer"
+msgstr "Exemple de réponse"
+
msgid "from now"
msgstr ""
@@ -1667,10 +1703,6 @@
msgstr ""
#, fuzzy
-msgid "org_admin.templates.edit_phase_label"
-msgstr "org_admin"
-
-#, fuzzy
msgid "organisation"
msgstr "Organisation"
@@ -1711,10 +1743,6 @@
msgstr ""
#, fuzzy
-msgid "suggested answer"
-msgstr "Suggestion de réponse"
-
-#, fuzzy
msgid "template"
msgstr "templates"
diff --git a/config/routes.rb b/config/routes.rb
index c09d22f..27c1d67 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,7 +12,7 @@
resources :questions
resources :question_formats
resources :question_options
- resources :suggested_answers
+ resources :annotations
resources :answers
resources :guidances
resources :guidance_groups
@@ -161,7 +161,7 @@
end
end
- resources :suggested_answers, path: 'org/admin/templates/suggested_answers', only: [] do
+ resources :annotations, path: 'org/admin/templates/annotations', only: [] do
member do
post 'admin_create'
put 'admin_update'
diff --git a/db/schema.rb b/db/schema.rb
index fe00e7b..f0bfbd2 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -16,6 +16,15 @@
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
+ create_table "annotations", force: :cascade do |t|
+ t.integer "question_id"
+ t.integer "org_id"
+ t.text "text"
+ t.integer "type", default: 0, null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "answers", force: :cascade do |t|
t.text "text"
t.integer "plan_id"
@@ -271,15 +280,6 @@
t.datetime "updated_at", null: false
end
- create_table "suggested_answers", force: :cascade do |t|
- t.integer "question_id"
- t.integer "org_id"
- t.text "text"
- t.boolean "is_example"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
create_table "templates", force: :cascade do |t|
t.string "title"
t.text "description"
@@ -330,8 +330,8 @@
t.string "email", default: "", null: false
t.string "orcid_id"
t.string "shibboleth_id"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
t.string "encrypted_password", default: ""
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
@@ -370,6 +370,8 @@
add_index "users_perms", ["user_id", "perm_id"], name: "index_users_perms_on_user_id_and_perm_id", using: :btree
+ add_foreign_key "annotations", "orgs"
+ add_foreign_key "annotations", "questions"
add_foreign_key "answers", "plans"
add_foreign_key "answers", "questions"
add_foreign_key "answers", "users"
@@ -395,8 +397,6 @@
add_foreign_key "roles", "plans"
add_foreign_key "roles", "users"
add_foreign_key "sections", "phases"
- add_foreign_key "suggested_answers", "orgs"
- add_foreign_key "suggested_answers", "questions"
add_foreign_key "templates", "orgs"
add_foreign_key "themes_in_guidance", "guidances"
add_foreign_key "themes_in_guidance", "themes"
diff --git a/db/seeds.rb b/db/seeds.rb
index 9277a5a..7da10a5 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -671,17 +671,17 @@
# Create suggested answers for a few questions
# -------------------------------------------------------
-suggested_answers = [
+annotations = [
{text: "We will preserve it in Dryad or a similar data repository service.",
- is_example: true,
+ type: Annotation.types[:example_answer],
org: Org.find_by(abbreviation: 'GA'),
question: Question.find_by(text: "What is your policy for long term access to your dataset?")},
{text: "We recommend that you identify the type(s) of content as well as the type of file(s) involved",
- is_example: false,
+ type: Annotation.types[:example_answer],
org: Org.find_by(abbreviation: 'GA'),
question: Question.find_by(text: "What types of data will you collect and how will it be stored?")},
]
-suggested_answers.map{ |s| SuggestedAnswer.create!(s) if SuggestedAnswer.find_by(text: s[:text]).nil? }
+annotations.map{ |s| Annotation.create!(s) if Annotation.find_by(text: s[:text]).nil? }
# Create options for the dropdown, multi-select and radio buttons
# -------------------------------------------------------
diff --git a/lib/assets/javascripts/application.js b/lib/assets/javascripts/application.js
index 59b9a26..3f45565 100644
--- a/lib/assets/javascripts/application.js
+++ b/lib/assets/javascripts/application.js
@@ -84,33 +84,6 @@
$(this).closest("form").submit();
});
- $("#user_email.text_field.reg-input").blur(function () {
- if (validateEmail($(this).val())) {
- $(this).parent().children("div").hide();
- }
- else {
- $(this).parent().children("div").show();
- }
- });
-
- $("#user_password.text_field.reg-input").blur(function () {
- if ($(this).val().length >= 8) {
- $(this).parent().children("div").hide();
- }
- else {
- $(this).parent().children("div").show();
- }
- });
-
- $("#user_password_confirmation.text_field.reg-input").blur(function () {
- if ($(this).val() == $("#user_password.text_field.reg-input").val()) {
- $(this).parent().children("div").hide();
- }
- else {
- $(this).parent().children("div").show();
- }
- });
-
$('#user_organisation_id').on("change", function(e) {
e.preventDefault();
var selected_org = $(this).select2("val");
@@ -199,17 +172,6 @@
});
// ---------------------------------------------------------------------------
-function validateEmail(sEmail) {
- var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
- if (filter.test(sEmail)) {
- return true;
- }
- else {
- return false;
- }
-}
-
-// ---------------------------------------------------------------------------
function selectItemsFromJsonArray(array, selector, array_of_values, callback){
var out = [];
diff --git a/lib/assets/javascripts/shared/register_form.js b/lib/assets/javascripts/shared/register_form.js
new file mode 100644
index 0000000..82b077d
--- /dev/null
+++ b/lib/assets/javascripts/shared/register_form.js
@@ -0,0 +1,61 @@
+$(document).ready(function() {
+ var email_regex = /[^@\s]+@(?:[-a-z0-9]+\.)+[a-z]{2,}$/;
+ var valid_email = false;
+ var valid_password = false;
+ var valid_password_confirmation = false;
+ var valid_accept_terms = false;
+
+ $("#user_email.text_field.reg-input").change(function(){
+ if (email_regex.test($(this).val())) {
+ $(this).next().hide();
+ valid_email = true;
+ }
+ else {
+ $(this).next().show();
+ valid_email = false;
+ }
+ set_aria_submit();
+ });
+ $("#user_password.text_field.reg-input").change(function() {
+ if($(this).val().length >= 8) {
+ $(this).next().hide();
+ valid_password = true;
+ }
+ else {
+ $(this).next().show();
+ valid_password = false;
+ }
+ // If password_confirmation is non empty already, force to check its validity
+ if($("#user_password_confirmation.text_field.reg-input").val().length > 0){
+ console.log('force to check validity of confirmation');
+ $("#user_password_confirmation.text_field.reg-input").change();
+ }
+ set_aria_submit();
+ });
+ $("#user_password_confirmation.text_field.reg-input").change(function() {
+ if ($(this).val() === $("#user_password.text_field.reg-input").val()) {
+ $(this).next().hide();
+ valid_password_confirmation = true;
+ }
+ else {
+ $(this).next().show();
+ valid_password_confirmation = false;
+ }
+ set_aria_submit();
+ });
+ $("#user_accept_terms").change(function(){
+ valid_accept_terms = $(this).prop('checked');
+ set_aria_submit();
+ });
+ function set_aria_submit(){
+ if(valid_email
+ && valid_password
+ && valid_password_confirmation
+ && valid_accept_terms){
+ $("#sign_up_submit").attr('aria-disabled', false);
+ }
+ else {
+ $("#sign_up_submit").attr('aria-disabled', true);
+ }
+ }
+});
\ No newline at end of file
diff --git a/lib/assets/stylesheets/admin.css.less b/lib/assets/stylesheets/admin.css.less
index 00ea783..89eadf6 100644
--- a/lib/assets/stylesheets/admin.css.less
+++ b/lib/assets/stylesheets/admin.css.less
@@ -1185,6 +1185,10 @@
width: 250px;
}
+table.dmp_details_table tr td.tinymce{
+ min-width: 370px;
+}
+
table.dmp_details_table .text_area{
width: 90%;
}
diff --git a/lib/assets/stylesheets/roadmap-form.scss b/lib/assets/stylesheets/roadmap-form.scss
index 9abd90a..72345a1 100644
--- a/lib/assets/stylesheets/roadmap-form.scss
+++ b/lib/assets/stylesheets/roadmap-form.scss
@@ -150,13 +150,12 @@
input.form-submit {
background-color: $primary-color;
color: $reverse-text;
- padding: 10px 30px;
- font-size: 12pt;
- margin-top: 15px;
-
- -webkit-border-radius: 10px;
- -moz-border-radius: 10px;
- border-radius: 10px;
+ font-size: 14px;
+ padding: 4px 12px;
+
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px;
}
/* Override the button color for the Org Admin sections */
input[type="submit"].admin{
@@ -171,13 +170,12 @@
button.form-cancel {
background-color: $cancel-button-color;
color: $reverse-text;
- padding: 10px 30px;
- font-size: 12pt;
- margin-top: 15px;
+ font-size: 14px;
+ padding: 4px 12px;
- -webkit-border-radius: 10px;
- -moz-border-radius: 10px;
- border-radius: 10px;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px;
}
.submit-tooltip {
display: none;
diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake
index cc9e87e..0bd54fd 100644
--- a/lib/tasks/migrate.rake
+++ b/lib/tasks/migrate.rake
@@ -248,5 +248,22 @@
end
end
end
+
+ desc "enforce single published version for templates"
+ task single_published_template: :environment do
+ # for each group of versions of a template
+ Template.all.pluck(:dmptemplate_id).uniq.each do |dmptemplate_id|
+ published = false
+ Template.where(dmptemplate_id: dmptemplate_id).order(version: :desc).each do |template|
+ # leave the first published template we find alone
+ if !published && template.published
+ published = true
+ elsif published && template.published
+ template.published = false
+ template.save!
+ end
+ end
+ end
+ end
end
diff --git a/test/functional/annotations_controller_test.rb b/test/functional/annotations_controller_test.rb
new file mode 100644
index 0000000..8615d16
--- /dev/null
+++ b/test/functional/annotations_controller_test.rb
@@ -0,0 +1,116 @@
+require 'test_helper'
+
+class AnnotationsControllerTest < ActionDispatch::IntegrationTest
+
+ include Devise::Test::IntegrationHelpers
+
+ setup do
+ @question = Annotation.first.question
+
+ # Get the first Org Admin
+ scaffold_org_admin(@question.section.phase.template.org)
+ end
+
+# TODO: The following methods SHOULD replace the old 'admin_' prefixed methods. The routes file already has
+# these defined. They are defined multiple times though and we need to clean this up! In particular
+# look at the unnamed routes after 'new_plan_phase' below. They are not named because they are duplicates.
+# We should just have:
+#
+# SHOULD BE:
+# --------------------------------------------------
+# suggested_answers GET /templates/:template_id/phases/:phase_id/sections/:section_id/questions/:id sections#index
+# POST /templates/:template_id/phases/:phase_id/sections/:section_id/questions/:id sections#create
+# suggested_answer GET /templates/:template_id/phases/:phase_id/sections/:section_id/questions/:question_id/suggested_answer/:id sections#show
+# PATCH /templates/:template_id/phases/:phase_id/section/:section_id/questions/:question_id/suggested_answer/:id sections#update
+# PUT /templates/:template_id/phases/:phase_id/section/:section_id/questions/:question_id/suggested_answer/:id sections#update
+# DELETE /templates/:template_id/phases/:phase_id/section/:section_id/questions/:question_id/suggested_answer/:id sections#destroy
+#
+# CURRENT RESULTS OF `rake routes`
+# --------------------------------------------------
+# admin_create_suggested_answer POST /org/admin/templates/suggested_answers/:id/admin_create suggested_answers#admin_create
+# admin_update_suggested_answer PUT /org/admin/templates/suggested_answers/:id/admin_update suggested_answers#admin_update
+# admin_destroy_suggested_answer DELETE /org/admin/templates/suggested_answers/:id/admin_destroy suggested_answers#admin_destroy
+
+
+
+ # POST /org/admin/templates/suggested_answers/:id/admin_create (admin_create_annotation_path)
+ # ----------------------------------------------------------
+ test "create a new annotation" do
+ params = {org_id: @user.org.id, question_id: @question.id, text: "Here's a suggestion"}
+
+ # Should redirect user to the root path if they are not logged in!
+ post admin_create_annotation_path(@question.id), {annotation: params}
+ assert_unauthorized_redirect_to_root_path
+
+ sign_in @user
+
+ post admin_create_annotation_path(@question.id), {annotation: params}
+ assert_response :redirect
+ assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}"
+ assert_equal _('Information was successfully created.'), flash[:notice]
+ assert_equal "Here's a suggestion", Annotation.last.text, "expected the record to have been created!"
+ assert assigns(:example_answer)
+
+ # Invalid object
+ post admin_create_annotation_path(@question.id), {annotation: {question_id: @question.id}}
+ assert flash[:notice].starts_with?(_('Could not create your'))
+ assert_response :success
+ assert assigns(:example_answer)
+ end
+
+ # PUT /org/admin/templates/suggested_answers/:id/admin_update (admin_update_suggested_answer_path)
+ # ----------------------------------------------------------
+ test "update the annotation" do
+ params = {text: 'UPDATE'}
+
+ # Should redirect user to the root path if they are not logged in!
+ put admin_update_annotation_path(Annotation.first), {annotation: params}
+ assert_unauthorized_redirect_to_root_path
+
+ sign_in @user
+
+ # Valid save
+ put admin_update_annotation_path(Annotation.first), {annotation: params}
+ assert_equal _('Information was successfully updated.'), flash[:notice]
+ assert_response :redirect
+ assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}"
+ assert assigns(:example_answer)
+ assert assigns(:question)
+ assert assigns(:section)
+ assert assigns(:phase)
+ assert_equal 'UPDATE', Annotation.first.text, "expected the record to have been updated"
+
+# TODO: We need to add in validation checks on the model and reactivate this test
+ # Invalid save
+# put admin_update_suggested_answer_path(SuggestedAnswer.first), {suggested_answer: {text: nil}}
+# assert flash[:notice].starts_with?(_('Could not update your'))
+# assert_response :success
+# assert assigns(:suggested_answer)
+# assert assigns(:question)
+# assert assigns(:section)
+# assert assigns(:phase)
+ end
+
+ # DELETE /org/admin/templates/suggested_answers/:id/admin_destroy (admin_destroy_suggested_answer_path)
+ # ----------------------------------------------------------
+ test "delete the section" do
+ id = Annotation.first.id
+ # Should redirect user to the root path if they are not logged in!
+ delete admin_destroy_annotation_path(id: id)
+ assert_unauthorized_redirect_to_root_path
+
+ sign_in @user
+
+ delete admin_destroy_annotation_path(id: id)
+ assert_equal _('Information was successfully deleted.'), flash[:notice]
+ assert_response :redirect
+ assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true§ion_id=#{@question.section.id}"
+ assert assigns(:question)
+ assert assigns(:section)
+ assert assigns(:phase)
+ assert_raise ActiveRecord::RecordNotFound do
+ Annotation.find(id).nil?
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/test/functional/plans_controller_test.rb b/test/functional/plans_controller_test.rb
index 259bfbf..3811003 100644
--- a/test/functional/plans_controller_test.rb
+++ b/test/functional/plans_controller_test.rb
@@ -107,20 +107,6 @@
assert assigns(:selected_guidance_groups)
end
- # GET /plan/:id/edit (edit_plan_path)
- # ----------------------------------------------------------
- test 'show the edit plan page' do
- # Should redirect user to the root path if they are not logged in!
- try_no_user_and_unauthorized(edit_plan_path(@plan))
-
- sign_in @user
- get edit_plan_path(@plan)
- assert_response :success
- assert assigns(:plan)
- assert assigns(:phase)
- assert assigns(:readonly)
- end
-
# PUT /plan/:id (plan_path)
# ----------------------------------------------------------
test 'update the plan' do
diff --git a/test/functional/questions_controller_test.rb b/test/functional/questions_controller_test.rb
index 2a9cbcf..9a156f5 100644
--- a/test/functional/questions_controller_test.rb
+++ b/test/functional/questions_controller_test.rb
@@ -38,7 +38,7 @@
# POST /org/admin/templates/questions/:id/admin_create (admin_create_question_path)
# ----------------------------------------------------------
test "create a new question" do
- params = {section_id: @section.id, text: 'Test Question', number: 9, question_format_id: @question_format.id}
+ params = {section_id: @section.id, text: 'Test Question', number: 9, question_format_id: @question_format.id, annotations_attributes: {0 => {text: "some text", org_id: Org.first.id}}}
@section.phase.template.dirty = false
@section.phase.template.save!
@@ -48,7 +48,11 @@
assert_unauthorized_redirect_to_root_path
sign_in @user
-
+ @new_question = Question.new
+ @new_question.number = @section.questions.count + 1
+ example_answer = @new_question.annotations.build
+ example_answer.type = :example_answer
+ example_answer.save
post admin_create_question_path(@section), {question: params}
assert_response :redirect
assert assigns(:question)
diff --git a/test/functional/suggested_answers_controller_test.rb b/test/functional/suggested_answers_controller_test.rb
deleted file mode 100644
index dcdd2ce..0000000
--- a/test/functional/suggested_answers_controller_test.rb
+++ /dev/null
@@ -1,116 +0,0 @@
-require 'test_helper'
-
-class SuggestedAnswersControllerTest < ActionDispatch::IntegrationTest
-
- include Devise::Test::IntegrationHelpers
-
- setup do
- @question = SuggestedAnswer.first.question
-
- # Get the first Org Admin
- scaffold_org_admin(@question.section.phase.template.org)
- end
-
-# TODO: The following methods SHOULD replace the old 'admin_' prefixed methods. The routes file already has
-# these defined. They are defined multiple times though and we need to clean this up! In particular
-# look at the unnamed routes after 'new_plan_phase' below. They are not named because they are duplicates.
-# We should just have:
-#
-# SHOULD BE:
-# --------------------------------------------------
-# suggested_answers GET /templates/:template_id/phases/:phase_id/sections/:section_id/questions/:id sections#index
-# POST /templates/:template_id/phases/:phase_id/sections/:section_id/questions/:id sections#create
-# suggested_answer GET /templates/:template_id/phases/:phase_id/sections/:section_id/questions/:question_id/suggested_answer/:id sections#show
-# PATCH /templates/:template_id/phases/:phase_id/section/:section_id/questions/:question_id/suggested_answer/:id sections#update
-# PUT /templates/:template_id/phases/:phase_id/section/:section_id/questions/:question_id/suggested_answer/:id sections#update
-# DELETE /templates/:template_id/phases/:phase_id/section/:section_id/questions/:question_id/suggested_answer/:id sections#destroy
-#
-# CURRENT RESULTS OF `rake routes`
-# --------------------------------------------------
-# admin_create_suggested_answer POST /org/admin/templates/suggested_answers/:id/admin_create suggested_answers#admin_create
-# admin_update_suggested_answer PUT /org/admin/templates/suggested_answers/:id/admin_update suggested_answers#admin_update
-# admin_destroy_suggested_answer DELETE /org/admin/templates/suggested_answers/:id/admin_destroy suggested_answers#admin_destroy
-
-
-
- # POST /org/admin/templates/suggested_answers/:id/admin_create (admin_create_suggested_answer_path)
- # ----------------------------------------------------------
- test "create a new section" do
- params = {org_id: @user.org.id, question_id: @question.id, text: "Here's a suggestion"}
-
- # Should redirect user to the root path if they are not logged in!
- post admin_create_suggested_answer_path(@question.id), {suggested_answer: params}
- assert_unauthorized_redirect_to_root_path
-
- sign_in @user
-
- post admin_create_suggested_answer_path(@question.id), {suggested_answer: params}
- assert_response :redirect
- assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}"
- assert_equal _('Information was successfully created.'), flash[:notice]
- assert_equal "Here's a suggestion", SuggestedAnswer.last.text, "expected the record to have been created!"
- assert assigns(:suggested_answer)
-
- # Invalid object
- post admin_create_suggested_answer_path(@question.id), {suggested_answer: {question_id: @question.id}}
- assert flash[:notice].starts_with?(_('Could not create your'))
- assert_response :success
- assert assigns(:suggested_answer)
- end
-
- # PUT /org/admin/templates/suggested_answers/:id/admin_update (admin_update_suggested_answer_path)
- # ----------------------------------------------------------
- test "update the section" do
- params = {text: 'UPDATE'}
-
- # Should redirect user to the root path if they are not logged in!
- put admin_update_suggested_answer_path(SuggestedAnswer.first), {suggested_answer: params}
- assert_unauthorized_redirect_to_root_path
-
- sign_in @user
-
- # Valid save
- put admin_update_suggested_answer_path(SuggestedAnswer.first), {suggested_answer: params}
- assert_equal _('Information was successfully updated.'), flash[:notice]
- assert_response :redirect
- assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true&question_id=#{@question.id}§ion_id=#{@question.section.id}"
- assert assigns(:suggested_answer)
- assert assigns(:question)
- assert assigns(:section)
- assert assigns(:phase)
- assert_equal 'UPDATE', SuggestedAnswer.first.text, "expected the record to have been updated"
-
-# TODO: We need to add in validation checks on the model and reactivate this test
- # Invalid save
-# put admin_update_suggested_answer_path(SuggestedAnswer.first), {suggested_answer: {text: nil}}
-# assert flash[:notice].starts_with?(_('Could not update your'))
-# assert_response :success
-# assert assigns(:suggested_answer)
-# assert assigns(:question)
-# assert assigns(:section)
-# assert assigns(:phase)
- end
-
- # DELETE /org/admin/templates/suggested_answers/:id/admin_destroy (admin_destroy_suggested_answer_path)
- # ----------------------------------------------------------
- test "delete the section" do
- id = SuggestedAnswer.first.id
- # Should redirect user to the root path if they are not logged in!
- delete admin_destroy_suggested_answer_path(id: id)
- assert_unauthorized_redirect_to_root_path
-
- sign_in @user
-
- delete admin_destroy_suggested_answer_path(id: id)
- assert_equal _('Information was successfully deleted.'), flash[:notice]
- assert_response :redirect
- assert_redirected_to "#{admin_show_phase_path(@question.section.phase.id)}?edit=true§ion_id=#{@question.section.id}"
- assert assigns(:question)
- assert assigns(:section)
- assert assigns(:phase)
- assert_raise ActiveRecord::RecordNotFound do
- SuggestedAnswer.find(id).nil?
- end
- end
-
-end
\ No newline at end of file
diff --git a/test/functional/templates_controller_test.rb b/test/functional/templates_controller_test.rb
index 45ca826..70e6edd 100644
--- a/test/functional/templates_controller_test.rb
+++ b/test/functional/templates_controller_test.rb
@@ -1,12 +1,12 @@
require 'test_helper'
class TemplatesControllerTest < ActionDispatch::IntegrationTest
-
+
include Devise::Test::IntegrationHelpers
-
+
setup do
scaffold_template
-
+
# Get the first Org Admin
scaffold_org_admin(@template.org)
end
@@ -36,41 +36,41 @@
# admin_destroy_template DELETE /org/admin/templates/:id/admin_destroy(.:format) templates#admin_destroy
# admin_create_template POST /org/admin/templates/:id/admin_create(.:format) templates#admin_create
# admin_update_template PUT /org/admin/templates/:id/admin_update(.:format) templates#admin_update
-
-
+
+
# GET /org/admin/templates/:id/admin_index (admin_index_template_path) the :id here makes no sense!
# ----------------------------------------------------------
test "get the list of admin templates" do
# Should redirect user to the root path if they are not logged in!
get admin_index_template_path(@user.org)
assert_unauthorized_redirect_to_root_path
-
+
sign_in @user
-
+
get admin_index_template_path(@user.org)
assert_response :success
-
+
assert assigns(:funder_templates)
assert assigns(:org_templates)
- end
-
+ end
+
# GET /org/admin/templates/:id/admin_template (admin_template_template_path)
# ----------------------------------------------------------
test "get the admin template" do
# Should redirect user to the root path if they are not logged in!
get admin_template_template_path(@template)
assert_unauthorized_redirect_to_root_path
-
+
sign_in @user
-
+
get admin_template_template_path(@template)
assert_response :success
-
+
assert assigns(:template)
assert assigns(:hash)
assert assigns(:current)
end
-
+
# TODO: Why are we passing an :id here!? Its a new record but we seem to need the last template's id
# GET /org/admin/templates/:id/admin_new (admin_new_template_path)
# ----------------------------------------------------------
@@ -78,30 +78,30 @@
# Should redirect user to the root path if they are not logged in!
get admin_new_template_path(Template.last.id)
assert_unauthorized_redirect_to_root_path
-
+
sign_in @user
-
+
get admin_new_template_path(Template.last.id)
assert_response :success
end
-
+
# GET /org/admin/templates/:id/admin_template_history (admin_template_history_template_path)
# ----------------------------------------------------------
test "get the admin template history page" do
# Should redirect user to the root path if they are not logged in!
get admin_template_history_template_path(@template)
assert_unauthorized_redirect_to_root_path
-
+
sign_in @user
-
+
get admin_template_history_template_path(@template)
assert_response :success
-
+
assert assigns(:template)
assert assigns(:templates)
assert assigns(:current)
end
-
+
# DELETE /org/admin/templates/:id/admin_destroy (admin_destroy_template_path)
# ----------------------------------------------------------
test "delete the admin template" do
@@ -109,16 +109,16 @@
# Should redirect user to the root path if they are not logged in!
delete admin_destroy_template_path(@template)
assert_unauthorized_redirect_to_root_path
-
+
sign_in @user
-
+
family = @template.dmptemplate_id
prior = Template.current(family)
-
+
version_the_template
-
+
current = Template.current(family)
-
+
# Try to delete a historical version should fail
delete admin_destroy_template_path(prior)
assert_equal _('You cannot delete historical versions of this template.'), flash[:notice]
@@ -130,31 +130,31 @@
delete admin_destroy_template_path(current)
assert_response :redirect
assert_redirected_to admin_index_template_path
- assert_raise ActiveRecord::RecordNotFound do
+ assert_raise ActiveRecord::RecordNotFound do
Template.find(current.id).nil?
end
assert_equal prior, Template.current(family), "expected the old version to now be the current version"
end
-
+
# TODO: Why are we passing an :id here!? Its a new record but we seem to need the last template's id
# POST /org/admin/templates/:id/admin_create (admin_create_template_path)
# ----------------------------------------------------------
test "create a template" do
params = {title: 'Testing create route'}
-
+
# Should redirect user to the root path if they are not logged in!
post admin_create_template_path(@user.org), {template: params}
assert_unauthorized_redirect_to_root_path
-
+
sign_in @user
-
+
post admin_create_template_path(@user.org), {template: params}
assert_equal _('Information was successfully created.'), flash[:notice]
assert_response :redirect
assert_redirected_to admin_template_template_url(Template.last.id)
assert assigns(:template)
assert_equal 'Testing create route', Template.last.title, "expected the record to have been created!"
-
+
# Invalid object
post admin_create_template_path(@user.org), {template: {title: nil, org_id: @user.org.id}}
assert flash[:notice].starts_with?(_('Could not create your'))
@@ -162,23 +162,25 @@
assert assigns(:template)
assert assigns(:hash)
end
-
+
# GET /org/admin/templates/:id/admin_update (admin_update_template_path)
# ----------------------------------------------------------
test "update the admin template" do
params = {title: 'ABCD'}
-
+
# Should redirect user to the root path if they are not logged in!
+ #get admin_template_template_path(@template) # Click on 'edit'
+ #@template = Template.current(@template.dmptemplate_id) # Edit working copy
put admin_update_template_path(@template), {template: params}
assert_unauthorized_redirect_to_root_path
-
+
sign_in @user
family = @template.dmptemplate_id
prior = Template.current(family)
-
+
version_the_template
-
+
current = Template.current(family)
# We shouldn't be able to edit a historical version
@@ -187,7 +189,7 @@
assert_response :redirect
assert_redirected_to admin_template_template_url(prior)
assert assigns(:template)
-
+
# Make sure we get the right response when editing an unpublished template
put admin_update_template_path(current), {template: params}
assert_equal _('Information was successfully updated.'), flash[:notice]
@@ -195,8 +197,8 @@
assert assigns(:template)
assert assigns(:hash)
assert_equal 'ABCD', current.reload.title, "expected the record to have been updated"
- assert current.reload.dirty?
-
+ assert current.reload.dirty?
+
# Make sure we get the right response when providing an invalid template
put admin_update_template_path(current), {template: {title: nil}}
assert flash[:notice].starts_with?(_('Could not update your'))
@@ -211,7 +213,7 @@
# Make sure we are redirected if we're not logged in
put admin_customize_template_path(@template)
assert_unauthorized_redirect_to_root_path
-
+
funder_template = Template.create(org: Org.funders.first, title: 'Testing integration')
# Sign in as the funder so that we cna publish the template
@@ -220,24 +222,24 @@
put admin_publish_template_path(funder_template)
assert_response :redirect
assert_redirected_to admin_index_template_path(funder_template.org)
-
+
# Sign in as the regular user so we can customize the funder template
sign_in @user
-
+
template = Template.live(funder_template.dmptemplate_id)
-
+
put admin_customize_template_path(template)
-
+
customization = Template.where(customization_of: template.dmptemplate_id).last
assert_response :redirect
assert_redirected_to admin_template_template_url(Template.last)
assert assigns(:template)
-
+
assert_equal 0, customization.version
assert_not customization.published?
assert_not customization.dirty?
-
+
# Make sure the funder templates data is not modifiable!
customization.phases.each do |p|
assert_not p.modifiable
@@ -249,21 +251,21 @@
end
end
end
-
+
# GET /org/admin/templates/:id/admin_publish (admin_publish_template_path)
# ----------------------------------------------------------
test "publish a template" do
# Should redirect user to the root path if they are not logged in!
put admin_publish_template_path(@template)
assert_unauthorized_redirect_to_root_path
-
+
sign_in @user
family = @template.dmptemplate_id
prior = Template.current(family)
-
+
version_the_template
-
+
current = Template.current(family)
# We shouldn't be able to edit a historical version
@@ -272,51 +274,56 @@
assert_response :redirect
assert_redirected_to admin_template_template_url(prior)
assert assigns(:template)
-
+
# Publish the current template
put admin_publish_template_path(current)
assert_equal _('Your template has been published and is now available to users.'), flash[:notice]
assert_response :redirect
assert_redirected_to admin_index_template_path(@user.org)
-
+ current = Template.current(family)
+
+ # Update the description so that the template gets versioned
+ get admin_template_template_path(current) # Click on 'edit'
+ new_version = Template.current(family) # Edit working copy
+ put admin_update_template_path(new_version), {template: {description: "this is an update"}}
+
# Make sure it versioned properly
- current = Template.includes(:phases, :sections, :questions).find(current.id)
new_version = Template.current(family)
assert_not_equal current.id = new_version.id, "expected it to create a new version"
assert_equal (current.version + 1), new_version.version, "expected the version to have incremented"
assert current.published?, "expected the old version to be published"
assert_not new_version.published?, "expected the new version to NOT be published"
assert_not current.dirty?, "expected the old dirty flag to be false"
- assert_not new_version.dirty?, "expected the new dirty flag to be false"
+ assert new_version.dirty?, "expected the new dirty flag to be true"
assert_equal current.dmptemplate_id, new_version.dmptemplate_id, "expected the old and new versions to share the same dmptemplate_id"
end
-
+
# GET /org/admin/templates/:id/admin_unpublish (admin_unpublish_template_path)
# ----------------------------------------------------------
test "unpublish a template" do
# Should redirect user to the root path if they are not logged in!
put admin_unpublish_template_path(@template)
assert_unauthorized_redirect_to_root_path
-
+
sign_in @user
family = @template.dmptemplate_id
prior = Template.current(family)
-
+
version_the_template
-
+
current = Template.current(family)
-
+
# Publish it so we can unpublish
put admin_publish_template_path(current)
assert_not Template.live(family).nil?
-
+
put admin_unpublish_template_path(current)
assert_equal _('Your template is no longer published. Users will not be able to create new DMPs for this template until you re-publish it'), flash[:notice]
assert_response :redirect
assert_redirected_to admin_index_template_path(@user.org)
-
+
# Make sure there are no published versions
assert Template.live(family).nil?
end
-end
\ No newline at end of file
+end
diff --git a/test/integration/template_versioning_test.rb b/test/integration/template_versioning_test.rb
index aea0d73..dd59836 100644
--- a/test/integration/template_versioning_test.rb
+++ b/test/integration/template_versioning_test.rb
@@ -6,74 +6,70 @@
setup do
scaffold_template
scaffold_org_admin(@template.org)
-
+
sign_in @user
-
+
# Make sure the template starts out as unpublished. The controller will not allow changes once its published
@template.published = false
@template.save!
-
+
@initial_id = @template.id
@initial_version = @template.version
@initial_title = @template.title
@dmptemplate_id = @template.dmptemplate_id
end
-
+
# ----------------------------------------------------------
test 'template gets versioned when its details are updated but it is already published' do
# Publish the template
put admin_publish_template_path(@template)
@template = Template.current(@dmptemplate_id)
+ get admin_template_template_path(@template) # Click on 'edit'
+ @template = Template.current(@dmptemplate_id) # Edit new version
- assert_equal (@initial_version + 1), @template.version, "expected the version to have incremented"
- assert_not_equal @initial_id, @template.id, "expected the id to have changed"
- assert_equal @dmptemplate_id, @template.dmptemplate_id, "expected the dmptemplate_id to match"
- assert_equal false, @template.published?, "expected the new version to be unpublished"
- assert_equal @initial_title, @template.title, "expected the title to have been updated"
-
# Change the title after its been published
put admin_update_template_path(@template), {template: {title: "Blah blah blah"}}
@template = Template.current(@dmptemplate_id)
-
+
# Make sure that the template was versioned
assert_equal (@initial_version + 1), @template.version, "expected the version to have incremented"
assert_not_equal @initial_id, @template.id, "expected the id to have changed"
assert_equal @dmptemplate_id, @template.dmptemplate_id, "expected the dmptemplate_id to match"
assert_equal false, @template.published?, "expected the new version to be unpublished"
assert_not_equal @initial_title, @template.title, "expected the title to have been updated"
-
+
# Now retrieve the published version and verify that it is unchanged
old = Template.live(@dmptemplate_id)
assert_equal @initial_version, old.version, "expected the version number of the published version to be the same"
assert_equal @initial_id, old.id, "expected the id of the published version to be the same"
assert_equal @initial_title, old.title, "expected the title of the published version to be the same"
end
-
+
# ----------------------------------------------------------
test 'template gets versioned when its phases are modified and it is already published' do
@template.dirty = false
@template.save!
-
+
put admin_update_phase_path @template.phases.first, {phase: {title: 'UPDATED'}}
@template.reload
assert @template.dirty
end
-
+
# ----------------------------------------------------------
test 'template gets versioned when its sections are modified and it is already published' do
@template.dirty = false
@template.save!
-
+
put admin_update_section_path @template.phases.first.sections.first, {section: {title: 'UPDATED'}}
@template.reload
assert @template.dirty
end
-
+
# ----------------------------------------------------------
test 'template gets versioned when its questions are modified and it is already published' do
@template.dirty = false
@template.save!
-
+
put admin_update_question_path @template.phases.first.sections.first.questions.first, {question: {text: 'UPDATED'}}
@template.reload
assert @template.dirty
@@ -90,7 +86,7 @@
assert_equal @dmptemplate_id, @template.dmptemplate_id, "expected the dmptemplate_id to match"
assert_equal false, @template.published?, "expected the version to have remained unpublished"
end
-
+
# ----------------------------------------------------------
test 'publishing a plan unpublishes the old published plan' do
put admin_publish_template_path(@template)
@@ -104,7 +100,7 @@
put admin_unpublish_template_path(@template)
assert Template.live(@dmptemplate_id).nil?
end
-
+
# ----------------------------------------------------------
test 'plans get attached to the appropriate template version' do
=begin
@@ -118,7 +114,7 @@
# Sign in as the funder so that we cna publish the template
sign_in User.find_by(org: funder_template.org)
-
+
# Publish the funder template
put admin_publish_template_path(funder_template)
assert_response :redirect
@@ -128,41 +124,41 @@
liveA = Template.live(funder_template.dmptemplate_id)
@dmptemplate_id = @template.dmptemplate_id
end
-
+
sign_in @user
-
+
# Plan A gets attached to the template v1
post plans_path, {plan: {funder_id: @template.org.id}}
planA = Plan.last
assert_equal liveA, planA.template, "expected the latest published version to have been assigned to PlanA"
-
+
# Template v2 is updated
put admin_update_template_path(@template), {template: {title: "Blah blah blah"}}
@template = Template.current(@dmptemplate_id)
-
+
# Plan B gets attached to the template v1 because v2 is not yet published
post plans_path, {plan: {funder_id: @template.org.id}}
planB = Plan.last
assert_equal liveA, planB.template, "expected the latest published version to have been assigned to PlanB"
-
+
# Plan A should still be attached to v1
assert_equal liveA, planA.template, "expected PlanA to still be attached to the original published version"
-
- # Sign back in as the funder
+
+ # Sign back in as the funder
sign_in User.find_by(org: funder_template.org)
-
+
# Template v2 is published
put admin_publish_template_path(@template)
@template = Template.current(@dmptemplate_id)
liveB = Template.live(@dmptemplate_id)
-
+
sign_in @user
-
+
# Plan C gets attached to template v2
post plans_path, {plan: {funder_id: @template.org.id}}
planC = Plan.last
assert_equal liveB, planC.template, "expected the latest published version to have been assigned to PlanA"
-
+
# Plan A and B are still attached to v1
assert_equal liveA, planA.template, "expected PlanA to still be attached to the original published version"
assert_equal liveA, planB.template, "expected PlanB to still be attached to the original published version"
diff --git a/test/test_helper.rb b/test/test_helper.rb
index def6783..43b64d3 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -11,16 +11,16 @@
class ActiveSupport::TestCase
include GlobalHelpers
-
+
# Suppress noisy ActiveRecord logs because fixtures load for each test
ActiveRecord::Base.logger.level = Logger::INFO
-
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
#fixtures :all
-
+
# Use the seeds.rb file to seed the test database
require_relative '../db/seeds.rb'
@@ -32,112 +32,115 @@
def scaffold_org_admin(org)
@user = User.create!(email: "admin-#{org.abbreviation.downcase}@example.com", firstname: "Org", surname: "Admin",
language: Language.find_by(abbreviation: FastGettext.locale),
- password: "password123", password_confirmation: "password123",
+ password: "password123", password_confirmation: "password123",
org: org, accept_terms: true, confirmed_at: Time.zone.now,
perms: Perm.where.not(name: ['admin', 'add_organisations', 'change_org_affiliation', 'grant_api_to_orgs']))
#perms: [Perm::GRANT_PERMISSIONS, Perm::MODIFY_TEMPLATES, Perm::MODIFY_GUIDANCE, Perm::CHANGE_ORG_DETAILS])
end
-
-
+
+
# Convert Ruby Class Names into attribute names (e.g. MyClass --> my_class)
# ----------------------------------------------------------------------
def class_name_to_attribute_name(name)
name.gsub(/([a-z]+)([A-Z])/, '\1_\2').gsub('-', '_').downcase
end
-
- # Scaffold a new Template with one Phase, one Section, and a Question for
- # each of the possible Question Formats.
+
+ # Scaffold a new Template with one Phase, one Section, and a Question for
+ # each of the possible Question Formats.
# ----------------------------------------------------------------------
def scaffold_template
- template = Template.new(title: 'Test template',
+ template = Template.new(title: 'Test template',
description: 'My test template',
org: Org.first)
-
- template.phases << Phase.new(title: 'Test phase',
- description: 'My test phase',
+
+ template.phases << Phase.new(title: 'Test phase',
+ description: 'My test phase',
number: 1)
-
- section = Section.new(title: 'Test section',
+
+ section = Section.new(title: 'Test section',
description: 'My test section',
number: 99, phase: template.phases.first)
-
+
i = 1
# Add each type of Question to the new section
QuestionFormat.all.each do |frmt|
- question = Question.new(text: "Test question - #{frmt.title}", number: i,
+ question = Question.new(text: "Test question - #{frmt.title}", number: i,
question_format: frmt)
-
+
if frmt.option_based?
3.times do |j|
question.question_options << QuestionOption.new(text: "Option #{j}", number: j)
end
end
-
+
section.questions << question
i += 1
end
-
+
template.phases.first.sections << section
template.save!
assert template.valid?, "unable to create new Template: #{template.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}"
-
+
@template = template.reload
end
-
+
# Version the template
# ----------------------------------------------------------------------
def version_the_template
put admin_publish_template_path(@template)
+ get admin_template_template_path(@template) # Click on 'edit'
+ @template = Template.current(@template.dmptemplate_id) # Edit working copy
+ put admin_update_template_path(@template), {template: {title: "#{@template.title} - VERSIONED"}}
end
-
- # Scaffold a new Plan based on the scaffolded Template
+
+ # Scaffold a new Plan based on the scaffolded Template
# ----------------------------------------------------------------------
def scaffold_plan
scaffold_template if @template.nil?
-
- @plan = Plan.new(template: @template, title: 'Test Plan', grant_number: 'Grant-123',
+
+ @plan = Plan.new(template: @template, title: 'Test Plan', grant_number: 'Grant-123',
principal_investigator: 'me', principal_investigator_identifier: 'me-1234',
description: "this is my plan's informative description",
identifier: '1234567890', data_contact: 'me@example.com', visibility: 0,
roles: [Role.new(user: User.last, creator: true)])
-
+
assert @plan.valid?, "unable to create new Plan: #{@plan.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}"
@plan.save!
end
-
-
+
+
# FUNCTIONAL/INTEGRATION TEST HELPERS
# ----------------------------------------------------------------------
def assert_unauthorized_redirect_to_root_path
assert_response :redirect
assert_match "#{root_url}", @response.redirect_url
-
+
follow_redirects
-
+
assert_response :success
assert_select '.welcome-message h2', _('Welcome.')
end
-
+
# ----------------------------------------------------------------------
def assert_authorized_redirect_to_plans_page
assert_response :redirect
assert_match "#{root_url}", @response.redirect_url
-
+
# Sometimes Devise has an intermediary step prior to sending the user to the final destination
follow_redirects
-
+
assert_response :success
assert_select '.main_page_content h1', _('My plans')
end
-
+
# ----------------------------------------------------------------------
def follow_redirects
while @response.status >= 300 && @response.status < 400
follow_redirect!
end
end
-
+
# UNIT TEST HELPERS
# ----------------------------------------------------------------------
def verify_deep_copy(object, exclusions)
@@ -153,40 +156,40 @@
end
end
end
-
+
# ----------------------------------------------------------------------
def verify_has_many_relationship(object, new_association, initial_expected_count)
# Assumes that the association name matches the pluralized name of the class
rel = "#{class_name_to_attribute_name(new_association.class.name).pluralize}"
-
+
assert_equal initial_expected_count, object.send(rel).count, "was expecting #{object.class.name} to initially have #{initial_expected_count} #{rel}"
-
+
# Add another association for the object
object.send(rel) << new_association
object.save!
assert_equal (initial_expected_count + 1), object.send(rel).count, "was expecting #{object.class.name} to have #{initial_expected_count + 1} #{rel} after adding a new one - #{new_association.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}"
-
+
# Remove the newly added association
object.send(rel).delete(new_association)
object.save!
assert_equal initial_expected_count, object.send(rel).count, "was expecting #{object.class.name} to have #{initial_expected_count} #{rel} after removing the new one we added"
end
-
+
# ----------------------------------------------------------------------
def verify_belongs_to_relationship(child, parent)
# Assumes that the association name matches the lower case name of the class
prnt = "#{class_name_to_attribute_name(parent.class.name)}"
chld = "#{class_name_to_attribute_name(child.class.name)}"
-
+
child.send("#{prnt}=", parent)
child.save!
assert_equal parent, child.send(prnt), "was expecting #{chld} to have a #{prnt}.id == #{parent.id}"
-
+
# Search the parent for the child
parent.reload
assert_includes parent.send("#{chld.pluralize}"), child, "was expecting the #{prnt}.#{chld.pluralize} to contain the #{chld}"
end
-
+
# STUBS FOR CALLS To EXTERNAL SITES
# ----------------------------------------------------------------------
def stub_blog_calls
@@ -206,7 +209,7 @@
"1 at http://www.example.com/stubbed/blog " +
"" +
""
-
+
stub_request(:get, "http://www.dcc.ac.uk/news/dmponline-0/feed").
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.2'}).
to_return(:status => 200, :body => blog_feed, :headers => {})
diff --git a/test/unit/annotation_test.rb b/test/unit/annotation_test.rb
new file mode 100644
index 0000000..9734c10
--- /dev/null
+++ b/test/unit/annotation_test.rb
@@ -0,0 +1,63 @@
+require 'test_helper'
+
+class AnnotationTest < ActiveSupport::TestCase
+
+ setup do
+ scaffold_template
+
+ @org = Org.last
+ @question = @template.phases.first.sections.first.questions.first
+
+ @annotation = Annotation.create(org: @org, question: @question, text: 'Test',
+ type: Annotation.types[:example_answer])
+ end
+
+ # ---------------------------------------------------
+ test "required fields are required" do
+ assert_not Annotation.new.valid?
+ assert_not Annotation.new(org: @org, text: 'Tester').valid?, "expected the 'question' field to be required"
+ assert_not Annotation.new(question: @question, text: 'Tester').valid?, "expected the 'org' field to be required"
+
+ # TODO: introduce validation on the model that requires text to be provided.
+ #assert_not Annotation.new(org: @org, question: @question).valid?, "expected the 'text' field to be required"
+
+ # Ensure the bare minimum and complete versions are valid
+ a = Annotation.new(org: @org, question: @question, text: 'Tester')
+ assert a.valid?, "expected the 'org', 'question' and 'text' fields to be enough to create an Annotation! - #{a.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}"
+ end
+
+ # ---------------------------------------------------
+ test "to_s returns the text" do
+ assert_equal @annotation.text, @annotation.to_s
+ end
+
+ # ---------------------------------------------------
+ test "deep_copy" do
+ verify_deep_copy(@annotation, ['id', 'created_at', 'updated_at'])
+ end
+
+ # ---------------------------------------------------
+ test "can CRUD Annotation" do
+ obj = Annotation.create(org: @org, question: @question, text: 'Tester')
+ assert_not obj.id.nil?, "was expecting to be able to create a new Annotation: #{obj.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}"
+
+ obj.text = 'my tester'
+ obj.save!
+ obj.reload
+ assert_equal 'my tester', obj.text, "Was expecting to be able to update the text of the Annotation!"
+
+ assert obj.destroy!, "Was unable to delete the Annotation!"
+ end
+
+ # ---------------------------------------------------
+ test "can manage belongs_to relationship with Org" do
+ annotation = Annotation.new(question: @question, text: 'Testing')
+ verify_belongs_to_relationship(annotation, @org)
+ end
+
+ # ---------------------------------------------------
+ test "can manage belongs_to relationship with Question" do
+ annotation = Annotation.new(org: @org, text: 'Testing')
+ verify_belongs_to_relationship(annotation, @question)
+ end
+end
\ No newline at end of file
diff --git a/test/unit/org_test.rb b/test/unit/org_test.rb
index c2c497d..3e7fd34 100644
--- a/test/unit/org_test.rb
+++ b/test/unit/org_test.rb
@@ -181,9 +181,9 @@
end
# ---------------------------------------------------
- test "can manage has_many relationship with SuggestedAnswers" do
- sa = SuggestedAnswer.new(question: Question.first, text: 'Test Suggested Answer')
- verify_has_many_relationship(@org, sa, @org.suggested_answers.count)
+ test "can manage has_many relationship with Annotations" do
+ a = Annotation.new(question: Question.first, text: 'Test Annotation')
+ verify_has_many_relationship(@org, a, @org.annotations.count)
end
# ---------------------------------------------------
diff --git a/test/unit/question_test.rb b/test/unit/question_test.rb
index be8981e..a5bb6c3 100644
--- a/test/unit/question_test.rb
+++ b/test/unit/question_test.rb
@@ -4,18 +4,18 @@
setup do
@user = User.last
-
+
scaffold_template
-
+
@section = @template.phases.first.sections.first
-
+
@question = Question.create(text: 'Test question', default_value: 'ABCD', guidance: 'Hello',
- number: 999, section: @section,
- question_format: QuestionFormat.where(option_based: false).first,
+ number: 999, section: @section,
+ question_format: QuestionFormat.where(option_based: false).first,
option_comment_display: true, modifiable: true,
- themes: [Theme.first],
- suggested_answers: [SuggestedAnswer.new(org: @user.org,
- text: "just a suggestion")])
+ themes: [Theme.first],
+ annotations: [Annotation.new(org: @user.org,
+ text: "just a suggestion")])
end
# ---------------------------------------------------
@@ -24,21 +24,21 @@
assert_not Question.new(section: @section, number: 7).valid?, "expected the 'text' field to be required"
assert_not Question.new(number: 7, text: 'Testing').valid?, "expected the 'section' field to be required"
assert_not Question.new(section: @section, text: 'Testing').valid?, "expected the 'number' field to be required"
-
+
# Ensure the bar minimum and complete versions are valid
a = Question.new(section: @section, text: 'Testing', number: 7)
assert a.valid?, "expected the 'text', 'section' and 'number' fields to be enough to create an Question! - #{a.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}"
end
-
+
# ---------------------------------------------------
test "to_s returns the Question text" do
assert_equal @question.text, @question.to_s
end
-
+
# ---------------------------------------------------
test "returns the correct themed guidance for the org" do
all = Theme.first.guidances + Theme.last.guidances
-
+
# Attach 2 themes to the question
@question.themes = [Theme.first, Theme.last]
@question.save!
@@ -53,25 +53,25 @@
assert @question.guidance_for_org(@user.org).first.first.include?(Theme.first.guidances.first.guidance_group.name), "expected the guidance_group.name"
assert_equal Theme.first.guidances.first, @question.guidance_for_org(@user.org).first.last, "expected the guidance object to be returned"
end
-
+
# ---------------------------------------------------
- test "returns the correct suggested answer for the org" do
- @question.suggested_answers = [SuggestedAnswer.new(org: @user.org, text: 'Test 1', is_example: false),
- SuggestedAnswer.new(org: Org.first, text: 'Test 2', is_example: false)]
+ test "returns the correct annotation for the org" do
+ @question.annotations = [Annotation.create(org: @user.org, text: 'Test 1', type: Annotation.types[:example_answer]),
+ Annotation.create(org: Org.first, text: 'Test 2', type: Annotation.types[:example_answer])]
@question.save!
-
- assert_equal 'Test 1', @question.get_suggested_answer(@user.org.id).text, "expected the correct suggested answer"
- assert_equal 'Test 2', @question.get_suggested_answer(Org.first.id).text, "expected the correct suggested answer"
-
+
+ assert_equal 'Test 1', @question.annotations.where(org_id: @user.org.id).first.text, "expected the correct annotation"
+ assert_equal 'Test 2', @question.annotations.where(org_id: Org.first.id).first.text, "expected the correct annotation"
+
org = Org.create(name: 'New One')
- assert_equal nil, @question.get_suggested_answer(org.id), "expected no suggested answer for a new org"
+ assert_equal nil, @question.get_example_answer(org.id), "expected no annotation for a new org"
end
-
+
# ---------------------------------------------------
test "deep copy" do
verify_deep_copy(@question, ['id', 'created_at', 'updated_at'])
end
-
+
# ---------------------------------------------------
test "can CRUD Question" do
obj = Question.create(section: @section, text: 'Test ABC', number: 7)
@@ -81,39 +81,39 @@
obj.save!
obj.reload
assert_equal 'Testing an update', obj.text, "Was expecting to be able to update the text of the Question!"
-
+
assert obj.destroy!, "Was unable to delete the Question!"
end
-
+
# ---------------------------------------------------
test "can manage belongs_to relationship with Section" do
verify_belongs_to_relationship(@question, @template.phases.first.sections.last)
end
-
+
# ---------------------------------------------------
test "can manage belongs_to relationship with QuestionFormat" do
verify_belongs_to_relationship(@question, QuestionFormat.where(option_based: false).last)
end
-
+
# ---------------------------------------------------
test "can manage has_many relationship with Answer" do
scaffold_plan
a = Answer.new(user: @user, plan: @plan, text: 'Test Answer')
verify_has_many_relationship(@question, a, @question.answers.count)
end
-
+
# ---------------------------------------------------
test "can manage has_many relationship with QuestionOption" do
qo = QuestionOption.new(text: 'Test', number: 9)
verify_has_many_relationship(@question, qo, @question.question_options.count)
end
-
+
# ---------------------------------------------------
- test "can manage has_many relationship with SuggestedAnswer" do
- sa = SuggestedAnswer.new(text: 'Suggested Answer', org: @user.org)
- verify_has_many_relationship(@question, sa, @question.suggested_answers.count)
+ test "can manage has_many relationship with Annotation" do
+ sa = Annotation.new(text: 'Suggested Answer', org: @user.org)
+ verify_has_many_relationship(@question, sa, @question.annotations.count)
end
-
+
# ---------------------------------------------------
test "can manage has_many relationship with Themes" do
t = Theme.new(title: 'Test Theme')
diff --git a/test/unit/suggested_answer_test.rb b/test/unit/suggested_answer_test.rb
deleted file mode 100644
index 31be604..0000000
--- a/test/unit/suggested_answer_test.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-require 'test_helper'
-
-class SuggestedAnswerTest < ActiveSupport::TestCase
-
- setup do
- scaffold_template
-
- @org = Org.last
- @question = @template.phases.first.sections.first.questions.first
-
- @suggested_answer = SuggestedAnswer.create(org: @org, question: @question, text: 'Test',
- is_example: true)
- end
-
- # ---------------------------------------------------
- test "required fields are required" do
- assert_not SuggestedAnswer.new.valid?
- assert_not SuggestedAnswer.new(org: @org, text: 'Tester').valid?, "expected the 'question' field to be required"
- assert_not SuggestedAnswer.new(question: @question, text: 'Tester').valid?, "expected the 'org' field to be required"
-
- # TODO: introduce validation on the model that requires text to be provided.
- #assert_not SuggestedAnswer.new(org: @org, question: @question).valid?, "expected the 'text' field to be required"
-
- # Ensure the bare minimum and complete versions are valid
- a = SuggestedAnswer.new(org: @org, question: @question, text: 'Tester')
- assert a.valid?, "expected the 'org', 'question' and 'text' fields to be enough to create an SuggestedAnswer! - #{a.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}"
- end
-
- # ---------------------------------------------------
- test "to_s returns the text" do
- assert_equal @suggested_answer.text, @suggested_answer.to_s
- end
-
- # ---------------------------------------------------
- test "deep_copy" do
- verify_deep_copy(@suggested_answer, ['id', 'created_at', 'updated_at'])
- end
-
- # ---------------------------------------------------
- test "can CRUD SuggestedAnswer" do
- obj = SuggestedAnswer.create(org: @org, question: @question, text: 'Tester')
- assert_not obj.id.nil?, "was expecting to be able to create a new SuggestedAnswer: #{obj.errors.map{|f, m| f.to_s + ' ' + m}.join(', ')}"
-
- obj.text = 'my tester'
- obj.save!
- obj.reload
- assert_equal 'my tester', obj.text, "Was expecting to be able to update the text of the SuggestedAnswer!"
-
- assert obj.destroy!, "Was unable to delete the SuggestedAnswer!"
- end
-
- # ---------------------------------------------------
- test "can manage belongs_to relationship with Org" do
- suggested_answer = SuggestedAnswer.new(question: @question, text: 'Testing')
- verify_belongs_to_relationship(suggested_answer, @org)
- end
-
- # ---------------------------------------------------
- test "can manage belongs_to relationship with Question" do
- suggested_answer = SuggestedAnswer.new(org: @org, text: 'Testing')
- verify_belongs_to_relationship(suggested_answer, @question)
- end
-end
\ No newline at end of file