diff --git a/app/assets/stylesheets/dmpopidor.scss b/app/assets/stylesheets/dmpopidor.scss index ffbedca..3fb3f34 100644 --- a/app/assets/stylesheets/dmpopidor.scss +++ b/app/assets/stylesheets/dmpopidor.scss @@ -669,7 +669,7 @@ } /* - Datasets + Research Outputs */ .nav-tabs { li.disabled { @@ -680,21 +680,21 @@ } } -.datasets-description { +.research-outputs-description { width: 50vw; padding: 0 5px; margin-top: 5px; - .dataset-element { + .research-output-element { display: flex; flex-direction: row; - .dataset-name { + .research-output-name { width: 30%; } - .dataset-description { + .research-output-description { width: 60%; } - .dataset-actions { + .research-output-actions { width: 10%; display: flex; align-items: center; diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index a66ef44..a2c5f4a 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -135,7 +135,7 @@ def permitted_params permitted = params.require(:answer).permit(:id, :text, :plan_id, :user_id, :question_id, :lock_version, - :dataset_id, :is_common, + :research_output_id, :is_common, question_option_ids: []) # If question_option_ids has been filtered out because it was a # scalar value (e.g. radiobutton answer) diff --git a/app/controllers/datasets_controller.rb b/app/controllers/datasets_controller.rb deleted file mode 100644 index 9d6bcd4..0000000 --- a/app/controllers/datasets_controller.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -class DatasetsController < ApplicationController - - after_action :verify_authorized - - # GET /plans/:plan_id/datasets - def index - begin - @plan = Plan.find(params[:plan_id]) - @datasets = @plan.datasets - - authorize @plan - render('plans/datasets', locals: { plan: @plan, datasets: @datasets }) - rescue ActiveRecord::RecordNotFound - flash[:alert] = _("There is no plan associated with id %{id}") % { - id: params[:id] - } - redirect_to(:controller => 'plans', :action => 'index') - end - end - - def destroy - @plan = Plan.find(params[:plan_id]) - @dataset = Dataset.find(params[:id]) - authorize @plan - if @dataset.destroy - flash[:notice] = success_message(@plan, _("deleted")) - redirect_to(:action => 'index') - else - flash[:alert] = failure_message(@plan, _("delete")) - redirect_to(:action => 'index') - end - end - - - -end diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index ab67067..287a1a0 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -152,7 +152,7 @@ def note_params params.require(:note) .permit(:text, :archived_by, :user_id, :answer_id, :plan_id, - :question_id, :dataset_id) + :question_id, :research_output_id) end end diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 274563e..d61c936 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -150,7 +150,7 @@ ).find(params[:id]) authorize @plan - @datasets = @plan.datasets.order(:order) + @research_outputs = @plan.research_outputs.order(:order) @visibility = if @plan.visibility.present? @plan.visibility.to_s @@ -400,7 +400,7 @@ :principal_investigator_phone, :principal_investigator, :principal_investigator_email, :data_contact, :principal_investigator_identifier, :data_contact_email, - :data_contact_phone, :guidance_group_ids, datasets_attributes: %i[id name description order _destroy]) + :data_contact_phone, :guidance_group_ids, research_outputs_attributes: %i[id name description order _destroy]) end # different versions of the same template have the same family_id @@ -457,7 +457,7 @@ readonly = !plan.editable_by?(current_user.id) # Since the answers have been pre-fetched through plan (see Plan.load_for_phase) # we create a hash whose keys are question id and value is the answer associated - answers = plan.answers.reduce({}) { |m, a| m["#{a.question_id}_#{a.dataset_id}"] = a; m } + answers = plan.answers.reduce({}) { |m, a| m["#{a.question_id}_#{a.research_output_id}"] = a; m } render("/phases/edit", locals: { base_template_org: phase.template.base_org, plan: plan, diff --git a/app/controllers/research_outputs_controller.rb b/app/controllers/research_outputs_controller.rb new file mode 100644 index 0000000..5ed2c20 --- /dev/null +++ b/app/controllers/research_outputs_controller.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +class ResearchOutputsController < ApplicationController + + after_action :verify_authorized + + # GET /plans/:plan_id/research_outputs + def index + begin + @plan = Plan.find(params[:plan_id]) + @research_outputs = @plan.research_outputs + + authorize @plan + render('plans/research_outputs', locals: { plan: @plan, research_outputs: @research_outputs }) + rescue ActiveRecord::RecordNotFound + flash[:alert] = _("There is no plan associated with id %{id}") % { + id: params[:id] + } + redirect_to(:controller => 'plans', :action => 'index') + end + end + + def destroy + @plan = Plan.find(params[:plan_id]) + @research_output = ResearchOutput.find(params[:id]) + authorize @plan + if @research_output.destroy + flash[:notice] = success_message(@plan, _("deleted")) + redirect_to(:action => 'index') + else + flash[:alert] = failure_message(@plan, _("delete")) + redirect_to(:action => 'index') + end + end + + + +end diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 6624b5b..2d17974 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -33,10 +33,10 @@ import '../views/orgs/admin_edit'; import '../views/orgs/shibboleth_ds'; import '../views/plans/download'; -import '../views/plans/datasets'; import '../views/plans/edit_details'; import '../views/plans/index'; import '../views/plans/new'; +import '../views/plans/research_outputs'; import '../views/plans/share'; import '../views/public_templates/show'; import '../views/roles/edit'; diff --git a/app/javascript/views/answers/edit.js b/app/javascript/views/answers/edit.js index c2d6c47..2ca15a1 100644 --- a/app/javascript/views/answers/edit.js +++ b/app/javascript/views/answers/edit.js @@ -37,22 +37,22 @@ if (isObject(data.question)) { // Object related to question within data received if (isNumber(data.question.id)) { if (isString(data.question.answer_status)) { - $(`#answer-status-${data.question.id}-dataset-${data.dataset.id}`).html(data.question.answer_status); + $(`#answer-status-${data.question.id}-research-output-${data.research_output.id}`).html(data.question.answer_status); TimeagoFactory.render($('time.timeago')); } if (isString(data.question.locking)) { // When an answer is stale... // Removes event handlers for the saved form detachEventHandlers(form); // eslint-disable-line no-use-before-define // Reflesh form view with the new partial form received - $(`#answer-form-${data.question.id}-dataset-${data.dataset.id}`).html(data.question.form); + $(`#answer-form-${data.question.id}-research-output-${data.research_output.id}`).html(data.question.form); // Retrieves the newly form added to the DOM - const newForm = $(`#answer-form-${data.question.id}-dataset-${data.dataset.id}`).find('form'); + const newForm = $(`#answer-form-${data.question.id}-research-output-${data.research_output.id}`).find('form'); // Attaches event handlers for the new form attachEventHandlers(newForm); // eslint-disable-line no-use-before-define // Refresh optimistic locking view with the form that caused the locking - $(`#answer-locking-${data.question.id}-dataset-${data.dataset.id}`).html(data.question.locking); + $(`#answer-locking-${data.question.id}-research-output-${data.research_output.id}`).html(data.question.locking); } else { // When answer is NOT stale... - $(`#answer-locking-${data.question.id}-dataset-${data.dataset.id}`).html(''); + $(`#answer-locking-${data.question.id}-research-output-${data.research_output.id}`).html(''); if (isNumber(data.question.answer_lock_version)) { form.find('#answer_lock_version').val(data.question.answer_lock_version); } @@ -198,12 +198,12 @@ $('.is_common_cb').click((e) => { const target = $(e.currentTarget); const targetState = target.prop('checked'); - const parentTab = target.parents('.main_dataset'); + const parentTab = target.parents('.main_research_output'); const sectionContent = target.parents('.section-content'); // Set answers 'is_common' hidden checkbox to the same state // as the master checkbox - // Used to indicate that answers from the first dataset are common to all + // Used to indicate that answers from the first research output are common to all parentTab.find('.ans_is_common').each((i, el) => { $(el).prop('checked', targetState); }); @@ -215,13 +215,13 @@ } }); - // Enable or disable datasets tabs depending on 'is_common' state + // Enable or disable research outputs tabs depending on 'is_common' state if (targetState) { - sectionContent.find('.datasets_tabs').each((i, el) => { + sectionContent.find('.research_outputs_tabs').each((i, el) => { $(el).addClass('disabled'); }); } else { - sectionContent.find('.datasets_tabs').each((i, el) => { + sectionContent.find('.research_outputs_tabs').each((i, el) => { $(el).removeClass('disabled'); }); } diff --git a/app/javascript/views/notes/index.js b/app/javascript/views/notes/index.js index badfca7..25348eb 100644 --- a/app/javascript/views/notes/index.js +++ b/app/javascript/views/notes/index.js @@ -31,8 +31,8 @@ && isObject(data.title) && isString(data.title.id) && isString(data.title.html)) { - $(`#notes-${data.notes.id}-dataset-${data.dataset.id}`).html(data.notes.html); - $(`#notes-title-${data.title.id}-dataset-${data.dataset.id}`).html(data.title.html); + $(`#notes-${data.notes.id}-research-output-${data.research_output.id}`).html(data.notes.html); + $(`#notes-title-${data.title.id}-research-output-${data.research_output.id}`).html(data.title.html); } clean(); // eslint-disable-line no-use-before-define initOrReload(); // eslint-disable-line no-use-before-define diff --git a/app/javascript/views/plans/datasets.js b/app/javascript/views/plans/datasets.js deleted file mode 100644 index 5a9ffab..0000000 --- a/app/javascript/views/plans/datasets.js +++ /dev/null @@ -1,36 +0,0 @@ - -$(() => { - $('#datasets').sortable({ - handle: '.dataset-actions .handle', - stop: () => { - $('#datasets .dataset-element').each(function callback(index) { - $(this).find('.dataset-order').val(index + 1); - }); - }, - }); - - $('#add-dataset').click(() => { - const lastDataset = $('#datasets .dataset-element').last(); - const lastDatasetOrder = parseInt(lastDataset.find('.dataset-order').val(), 10); - const duplicated = lastDataset.clone(false, false); - const duplicatedId = `plan_datasets_attributes_${new Date().getTime()}`; - const duplicatedName = `plan[datasets_attributes][${new Date().getTime()}]`; - - // Dataset name - duplicated.find('.dataset-name input').attr('id', `${duplicatedId}_name`); - duplicated.find('.dataset-name input').attr('name', `${duplicatedName}[name]`); - duplicated.find('.dataset-name label').attr('for', `${duplicatedId}_name`); - duplicated.find('.dataset-name input').val(null); - // Dataset description - duplicated.find('.dataset-description input').attr('id', `${duplicatedId}_description`); - duplicated.find('.dataset-description input').attr('name', `${duplicatedName}[description]`); - duplicated.find('.dataset-description label').attr('for', `${duplicatedId}_description`); - duplicated.find('.dataset-description input').val(null); - // Dataset order - duplicated.find('.dataset-order').attr('id', `${duplicatedId}_order`); - duplicated.find('.dataset-order').attr('name', `${duplicatedName}[order]`); - duplicated.find('.dataset-order').val(lastDatasetOrder + 1); - - duplicated.appendTo('#datasets'); - }); -}); diff --git a/app/javascript/views/plans/download.js b/app/javascript/views/plans/download.js index e629812..a1b0b2d 100644 --- a/app/javascript/views/plans/download.js +++ b/app/javascript/views/plans/download.js @@ -28,14 +28,14 @@ } }); - $('#select-all-datasets').on('click', (e) => { + $('#select-all-research-outputs').on('click', (e) => { if (e.target.checked) { // Iterate each checkbox - $('.dataset-checkbox').each(function check() { + $('.research-output-checkbox').each(function check() { this.checked = true; }); } else { - $('.dataset-checkbox').each(function check() { + $('.research-output-checkbox').each(function check() { this.checked = false; }); } diff --git a/app/javascript/views/plans/research_outputs.js b/app/javascript/views/plans/research_outputs.js new file mode 100644 index 0000000..a3db2f0 --- /dev/null +++ b/app/javascript/views/plans/research_outputs.js @@ -0,0 +1,36 @@ + +$(() => { + $('#research-outputs').sortable({ + handle: '.research-output-actions .handle', + stop: () => { + $('#research-outputs .research-output-element').each(function callback(index) { + $(this).find('.research-output-order').val(index + 1); + }); + }, + }); + + $('#add-research-output').click(() => { + const lastResearchOutput = $('#research-outputs .research-output-element').last(); + const lastResearchOutputOrder = parseInt(lastResearchOutput.find('.research-output-order').val(), 10); + const duplicated = lastResearchOutput.clone(false, false); + const duplicatedId = `plan_research_outputs_attributes_${new Date().getTime()}`; + const duplicatedName = `plan[research_outputs_attributes][${new Date().getTime()}]`; + + // Research Output name + duplicated.find('.research-output-name input').attr('id', `${duplicatedId}_name`); + duplicated.find('.research-output-name input').attr('name', `${duplicatedName}[name]`); + duplicated.find('.research-output-name label').attr('for', `${duplicatedId}_name`); + duplicated.find('.research-output-name input').val(null); + // Research Output description + duplicated.find('.research-output-description input').attr('id', `${duplicatedId}_description`); + duplicated.find('.research-output-description input').attr('name', `${duplicatedName}[description]`); + duplicated.find('.research-output-description label').attr('for', `${duplicatedId}_description`); + duplicated.find('.research-output-description input').val(null); + // Research Output order + duplicated.find('.research-output-order').attr('id', `${duplicatedId}_order`); + duplicated.find('.research-output-order').attr('name', `${duplicatedName}[order]`); + duplicated.find('.research-output-order').val(lastResearchOutputOrder + 1); + + duplicated.appendTo('#research-outputs'); + }); +}); diff --git a/app/models/answer.rb b/app/models/answer.rb index 15e7ef7..b963cd5 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -3,29 +3,29 @@ # # Table name: answers # -# id :integer not null, primary key -# is_common :boolean default(FALSE) -# lock_version :integer default(0) -# text :text -# created_at :datetime -# updated_at :datetime -# dataset_id :integer -# plan_id :integer -# question_id :integer -# user_id :integer +# id :integer not null, primary key +# is_common :boolean default(FALSE) +# lock_version :integer default(0) +# text :text +# created_at :datetime +# updated_at :datetime +# plan_id :integer +# question_id :integer +# research_output_id :integer +# user_id :integer # # Indexes # -# answers_plan_id_idx (plan_id) -# answers_question_id_idx (question_id) -# answers_user_id_idx (user_id) -# index_answers_on_dataset_id (dataset_id) +# answers_plan_id_idx (plan_id) +# answers_question_id_idx (question_id) +# answers_user_id_idx (user_id) +# index_answers_on_research_output_id (research_output_id) # # Foreign Keys # -# fk_rails_... (dataset_id => datasets.id) # fk_rails_... (plan_id => plans.id) # fk_rails_... (question_id => questions.id) +# fk_rails_... (research_output_id => research_outputs.id) # fk_rails_... (user_id => users.id) # @@ -44,7 +44,7 @@ belongs_to :plan - belongs_to :dataset + belongs_to :research_output has_many :notes, dependent: :destroy diff --git a/app/models/concerns/exportable_plan.rb b/app/models/concerns/exportable_plan.rb index 0f10c0b..8001a14 100644 --- a/app/models/concerns/exportable_plan.rb +++ b/app/models/concerns/exportable_plan.rb @@ -55,7 +55,7 @@ hash[:customization] = template.customization_of.present? hash[:title] = self.title hash[:answers] = self.answers - hash[:datasets] = self.datasets + hash[:research_outputs] = self.research_outputs # add the relevant questions/answers phases = [] diff --git a/app/models/dataset.rb b/app/models/dataset.rb deleted file mode 100644 index 33316ea..0000000 --- a/app/models/dataset.rb +++ /dev/null @@ -1,55 +0,0 @@ -# == Schema Information -# -# Table name: datasets -# -# id :integer not null, primary key -# description :text -# is_default :boolean default(FALSE) -# name :string -# order :integer -# created_at :datetime not null -# updated_at :datetime not null -# plan_id :integer -# -# Indexes -# -# index_datasets_on_plan_id (plan_id) -# -# Foreign Keys -# -# fk_rails_... (plan_id => plans.id) -# - -class Dataset < ActiveRecord::Base - belongs_to :plan - has_many :answers, dependent: :destroy - - default_scope { order(order: :asc) } - - def main? - eql?(plan.datasets.where(order: 1).first) - end - - # Return main dataset - def get_main - plan.datasets.first - end - - def has_common_answers?(section_id) - self.answers.each do |answer| - if answer.question_id.in?(Section.find(section_id).questions.pluck(:id)) && answer.is_common - return true - end - end - return false - end - - ## - # deep copy the given dataset - # - # Returns Dataset - def self.deep_copy(dataset) - dataset.dup - end - - end diff --git a/app/models/plan.rb b/app/models/plan.rb index d02f552..f224511 100644 --- a/app/models/plan.rb +++ b/app/models/plan.rb @@ -106,21 +106,21 @@ has_many :roles - # DATASETS - has_many :datasets, dependent: :destroy, inverse_of: :plan do - # Returns the default dataset + # RESEARCH OUTPUTS + has_many :research_outputs, dependent: :destroy, inverse_of: :plan do + # Returns the default research output def default find_by(is_default: true) end - # Toggles the default dataset between default and normal + # Toggles the default research output between default and normal # Uses the 'is_default' flag: - # - Removes it if there are more than one dataset - # - Adds it back is there's only one dataset left + # - Removes it if there are more than one research output + # - Adds it back is there's only one research output left def toggle_default if count > 1 unless default.nil? - default.update(name: 'Default dataset') if default.name.nil? + default.update(name: 'Default research output') if default.name.nil? default.update(is_default: false) end else @@ -139,7 +139,7 @@ accepts_nested_attributes_for :roles - accepts_nested_attributes_for :datasets, reject_if: :all_blank, allow_destroy: true + accepts_nested_attributes_for :research_outputs, reject_if: :all_blank, allow_destroy: true # =============== # = Validations = @@ -232,20 +232,20 @@ # # Returns Plan # CHANGES - # Added Dataset Support + # Added Research Output Support def self.deep_copy(plan) plan_copy = plan.dup plan_copy.title = "Copy of " + plan.title plan_copy.save! - plan.datasets.each do |dataset| - dataset_copy = Dataset.deep_copy(dataset) - dataset_copy.plan_id = plan_copy.id - dataset_copy.save! + plan.research_outputs.each do |research_output| + research_output_copy = ResearchOutput.deep_copy(research_output) + research_output_copy.plan_id = plan_copy.id + research_output_copy.save! - dataset.answers.each do |answer| + research_output.answers.each do |answer| answer_copy = Answer.deep_copy(answer) answer_copy.plan_id = plan_copy.id - answer_copy.dataset_id = dataset_copy.id + answer_copy.research_output_id = research_output_copy.id answer_copy.save! end diff --git a/app/models/research_output.rb b/app/models/research_output.rb new file mode 100644 index 0000000..a7dec1f --- /dev/null +++ b/app/models/research_output.rb @@ -0,0 +1,55 @@ +# == Schema Information +# +# Table name: research_outputs +# +# id :integer not null, primary key +# description :text +# is_default :boolean default(FALSE) +# name :string +# order :integer +# created_at :datetime not null +# updated_at :datetime not null +# plan_id :integer +# +# Indexes +# +# index_research_output_on_plan_id (plan_id) +# +# Foreign Keys +# +# fk_rails_... (plan_id => plans.id) +# + +class ResearchOutput < ActiveRecord::Base + belongs_to :plan + has_many :answers, dependent: :destroy + + default_scope { order(order: :asc) } + + def main? + eql?(plan.research_outputs.where(order: 1).first) + end + + # Return main research output + def get_main + plan.research_outputs.first + end + + def has_common_answers?(section_id) + self.answers.each do |answer| + if answer.question_id.in?(Section.find(section_id).questions.pluck(:id)) && answer.is_common + return true + end + end + return false + end + + ## + # deep copy the given research output + # + # Returns Research output + def self.deep_copy(research_output) + research_output.dup + end + + end diff --git a/app/models/settings/template.rb b/app/models/settings/template.rb index d80c5c0..6bef9a9 100644 --- a/app/models/settings/template.rb +++ b/app/models/settings/template.rb @@ -1,20 +1,20 @@ -# == Schema Information -# -# Table name: settings -# -# id :integer not null, primary key -# target_type :string not null -# value :text -# var :string not null -# created_at :datetime not null -# updated_at :datetime not null -# target_id :integer not null -# -# Indexes -# -# settings_target_type_target_id_var_key (target_type,target_id,var) UNIQUE -# - +# == Schema Information +# +# Table name: settings +# +# id :integer not null, primary key +# target_type :string not null +# value :text +# var :string not null +# created_at :datetime not null +# updated_at :datetime not null +# target_id :integer not null +# +# Indexes +# +# settings_target_type_target_id_var_key (target_type,target_id,var) UNIQUE +# + module Settings class Template < RailsSettings::SettingObject diff --git a/app/views/branded/answers/_locking.html.erb b/app/views/branded/answers/_locking.html.erb index 193c2ed..0279a99 100644 --- a/app/views/branded/answers/_locking.html.erb +++ b/app/views/branded/answers/_locking.html.erb @@ -1,6 +1,6 @@

<%= _('The following answer cannot be saved') %>

<%# We do not need to re-show example answers in this lock conflict section so leave template nil %> - <%= render partial: '/answers/new_edit', locals: { template: nil, question: question, answer: answer, dataset: dataset, readonly: true, locking: true } %> + <%= render partial: '/answers/new_edit', locals: { template: nil, question: question, answer: answer, research_output: research_output, readonly: true, locking: true } %>

<%= _('since %{name} saved the answer below while you were editing. Please, combine your changes and then save the answer again.') % { name: user.name} %>

\ No newline at end of file diff --git a/app/views/branded/answers/_new_edit.html.erb b/app/views/branded/answers/_new_edit.html.erb index 8cba160..eec3f8d 100644 --- a/app/views/branded/answers/_new_edit.html.erb +++ b/app/views/branded/answers/_new_edit.html.erb @@ -1,6 +1,6 @@ -<%# locals: { template, question, answer, dataset, readonly, locking } %> +<%# locals: { template, question, answer, research_output, readonly, locking } %> <% q_format = question.question_format %> @@ -49,26 +49,24 @@ <%= f.hidden_field :plan_id %> <%= f.hidden_field :question_id %> <%= f.hidden_field :lock_version %> - <% if Dataset.table_exists? %> - <%= f.hidden_field :dataset_id, :value => dataset.id%> - <%= f.check_box :is_common, style: 'display: none', class: 'ans_is_common' if answer.dataset.main? %> - <%= f.hidden_field :id, class: 'answer_id' %> - <% end %> + <%= f.hidden_field :research_output_id, :value => research_output.id%> + <%= f.check_box :is_common, style: 'display: none', class: 'ans_is_common' if answer.research_output.main? %> + <%= f.hidden_field :id, class: 'answer_id' %> <% if q_format.rda_metadata? %> <%= hidden_field_tag :standards, answer_hash['standards'].to_json %> <% end %> <% end %>
> <% if question.option_based? || question.question_format.rda_metadata? %> - <%= render(partial: 'questions/new_edit_question_option_based', locals: { f: f, question: question, answer: answer, dataset: dataset }) %> + <%= render(partial: 'questions/new_edit_question_option_based', locals: { f: f, question: question, answer: answer, research_output: research_output }) %> <% elsif question.question_format.textfield?%> - <%= render(partial: 'questions/new_edit_question_textfield', locals: { f: f, question: question, answer: answer, dataset: dataset }) %> + <%= render(partial: 'questions/new_edit_question_textfield', locals: { f: f, question: question, answer: answer, research_output: research_output }) %> <% elsif question.question_format.date? %> - <%= render(partial: 'questions/new_edit_question_datefield', locals: { f: f, question: question, answer: answer, dataset: dataset }) %> + <%= render(partial: 'questions/new_edit_question_datefield', locals: { f: f, question: question, answer: answer, research_output: research_output }) %> <% elsif question.question_format.number? %> - <%= render(partial: 'questions/new_edit_question_numberfield', locals: { f: f, question: question, answer: answer, dataset: dataset }) %> + <%= render(partial: 'questions/new_edit_question_numberfield', locals: { f: f, question: question, answer: answer, research_output: research_output }) %> <% elsif question.question_format.textarea? %> - <%= render(partial: 'questions/new_edit_question_textarea', locals: { f: f, question: question, answer: answer, dataset: dataset, locking: locking, readonly: readonly}) %> + <%= render(partial: 'questions/new_edit_question_textarea', locals: { f: f, question: question, answer: answer, research_output: research_output, locking: locking, readonly: readonly}) %> <% end %> <%= f.button(_('Save'), class: "btn btn-default", type: "submit") %>
@@ -79,11 +77,11 @@
"> + data-target="<%= "#example-#{question.id}-research-output-#{research_output.id}" %>"> <%="#{annotation.org.abbreviation} "%> <%=_('example answer')%> -
"> +
"> <%= sanitize annotation.text %>
diff --git a/app/views/branded/guidance_groups/_index_by_theme.html.erb b/app/views/branded/guidance_groups/_index_by_theme.html.erb index 624c1f7..85ca9a9 100644 --- a/app/views/branded/guidance_groups/_index_by_theme.html.erb +++ b/app/views/branded/guidance_groups/_index_by_theme.html.erb @@ -1,4 +1,4 @@ -<%# locals{ question, dataset, guidance_groups_by_theme } %> +<%# locals{ question, research_output, guidance_groups_by_theme } %> <% parent_id = guidance_groups_by_theme.object_id %>
@@ -11,7 +11,7 @@ <% guidance_groups_by_theme.each_pair do |guidance_group, theme_hash| %> <% guidances_output = [] %> <% theme_hash.each_pair do |theme, guidances| %> - <% question_guidance_id = "#{question.object_id}-#{guidances.object_id}-dataset-#{dataset.id}" %> + <% question_guidance_id = "#{question.object_id}-#{guidances.object_id}-research-output-#{research_output.id}" %> <%# if guidances with this theme have not been output %> <% if (guidances.map(&:id) - guidances_output).any? %>
diff --git a/app/views/branded/notes/_layout.html.erb b/app/views/branded/notes/_layout.html.erb index 44bd258..a0f718b 100644 --- a/app/views/branded/notes/_layout.html.erb +++ b/app/views/branded/notes/_layout.html.erb @@ -1,4 +1,4 @@ -<%# locals: { plan, question, answer, dataset } %> +<%# locals: { plan, question, answer, research_output } %> <% notes = answer.non_archived_notes %>
@@ -10,15 +10,15 @@ <% if plan.commentable_by?(current_user) %>
-
" data-question-id="<%= question.id %>"> - <%= render partial: "/notes/new", locals: { question: question, answer: answer, plan: plan, dataset: dataset }, formats: [:html] %> +
" data-question-id="<%= question.id %>"> + <%= render partial: "/notes/new", locals: { question: question, answer: answer, plan: plan, research_output: research_output }, formats: [:html] %>
- <%= link_to(_('Add Comment'), "#note_new#{question.id}_dataset#{dataset.id}", class: "btn btn-default note_new_link", role: "button", style: "visibility: hidden") %> + <%= link_to(_('Add Comment'), "#note_new#{question.id}_research-output#{research_output.id}", class: "btn btn-default note_new_link", role: "button", style: "visibility: hidden") %>
diff --git a/app/views/branded/notes/_new.html.erb b/app/views/branded/notes/_new.html.erb index 4fddf06..e522da1 100644 --- a/app/views/branded/notes/_new.html.erb +++ b/app/views/branded/notes/_new.html.erb @@ -1,13 +1,13 @@ -<%# locals: { question, answer, plan, dataset } %> +<%# locals: { question, answer, plan, research_output } %> <%= form_for(Note.new, url: notes_path) do |f| %> <%= f.hidden_field :user_id, value: current_user.id %> <%= f.hidden_field :question_id, value: question.id %> <%= f.hidden_field :answer_id, value: answer.id %> <%= f.hidden_field :plan_id, value: plan.id %> - <%= f.hidden_field :dataset_id, value: dataset.id %> + <%= f.hidden_field :research_output_id, value: research_output.id %>
<%= f.label(:text, _('Add comments to share with collaborators')) %> - <%= f.text_area(:text, class: 'form-control note', id: "note-#{question.id}-dataset-#{dataset.id}") %> + <%= f.text_area(:text, class: 'form-control note', id: "note-#{question.id}-research-output-#{research_output.id}") %>
<%= f.button(_('Save'), class: "btn btn-default", type: "submit") %> diff --git a/app/views/branded/org_admin/sections/_progress_datasets.html.erb b/app/views/branded/org_admin/sections/_progress_datasets.html.erb deleted file mode 100644 index ad71966..0000000 --- a/app/views/branded/org_admin/sections/_progress_datasets.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -<%# locals: { section, plan } %> - -<% num_section_questions = section.questions.size() %> - - ( <%= num_section_questions %> <%= num_section_questions > 1 ? _('questions') : _('question') %> ) - \ No newline at end of file diff --git a/app/views/branded/org_admin/sections/_progress_research_outputs.html.erb b/app/views/branded/org_admin/sections/_progress_research_outputs.html.erb new file mode 100644 index 0000000..ad71966 --- /dev/null +++ b/app/views/branded/org_admin/sections/_progress_research_outputs.html.erb @@ -0,0 +1,6 @@ +<%# locals: { section, plan } %> + +<% num_section_questions = section.questions.size() %> + + ( <%= num_section_questions %> <%= num_section_questions > 1 ? _('questions') : _('question') %> ) + \ No newline at end of file diff --git a/app/views/branded/phases/_edit_plan_answers_datasets.html.erb b/app/views/branded/phases/_edit_plan_answers_datasets.html.erb deleted file mode 100644 index 3e48412..0000000 --- a/app/views/branded/phases/_edit_plan_answers_datasets.html.erb +++ /dev/null @@ -1,119 +0,0 @@ -
<%= _('Beta') %>
-
-
-
- -
-
- <% phase.sections.order(:number).each do |section| %> -
- -
-
- -
- <% plan.datasets.each_with_index do |dataset, i| %> -
- <% if dataset.main? && plan.datasets.count > 1 %> -

- ><%= _('This section\'s answers are common to all datasets') %> -

- <% end %> -
<%= sanitize section.description %>
- - <% section.questions.each_with_index do |question, i| %> - <% # Load the answer or create a new one - answer = answers["#{question.id}_#{dataset.id}"] if plan.present? - if answer.blank? - answer = Answer.new({ plan: plan, question: question, dataset: dataset }) - end - %> -
-
- -
-
" - class="answer-locking">
-
" class="answer-form"> - <%= render(partial: '/answers/new_edit', - locals: { template: phase.template, - question: question, - answer: answer, - dataset: dataset, - readonly: readonly, - locking: false, - base_template_org: base_template_org }) %> -
-
" class="mt-10"> - <%= render(partial: '/answers/status', - locals: { answer: answer }) %> -
-
-
-
- - <%= render partial: '/phases/guidances_notes', locals: { - plan: plan, - template: phase.template, - question: question, - answer: answer, - dataset: dataset, - guidance_presenter: guidance_presenter } %> -
-
- <% if i != section.questions.length - 1 %> -
- <% end %> - <% end %> -
- <% end %> -
-
-
-
- <% end %> -
-
-
\ No newline at end of file diff --git a/app/views/branded/phases/_edit_plan_answers_research_outputs.html.erb b/app/views/branded/phases/_edit_plan_answers_research_outputs.html.erb new file mode 100644 index 0000000..6ae5157 --- /dev/null +++ b/app/views/branded/phases/_edit_plan_answers_research_outputs.html.erb @@ -0,0 +1,119 @@ +
<%= _('Beta') %>
+
+
+
+ +
+
+ <% phase.sections.order(:number).each do |section| %> +
+ +
+
+ +
+ <% plan.research_outputs.each_with_index do |research_output, i| %> +
+ <% if research_output.main? && plan.research_outputs.count > 1 %> +

+ ><%= _('This section\'s answers are common to all research outputs') %> +

+ <% end %> +
<%= sanitize section.description %>
+ + <% section.questions.each_with_index do |question, i| %> + <% # Load the answer or create a new one + answer = answers["#{question.id}_#{research_output.id}"] if plan.present? + if answer.blank? + answer = Answer.new({ plan: plan, question: question, research_output: research_output }) + end + %> +
+
+ +
+
" + class="answer-locking">
+
" class="answer-form"> + <%= render(partial: '/answers/new_edit', + locals: { template: phase.template, + question: question, + answer: answer, + research_output: research_output, + readonly: readonly, + locking: false, + base_template_org: base_template_org }) %> +
+
" class="mt-10"> + <%= render(partial: '/answers/status', + locals: { answer: answer }) %> +
+
+
+
+ + <%= render partial: '/phases/guidances_notes', locals: { + plan: plan, + template: phase.template, + question: question, + answer: answer, + research_output: research_output, + guidance_presenter: guidance_presenter } %> +
+
+ <% if i != section.questions.length - 1 %> +
+ <% end %> + <% end %> +
+ <% end %> +
+
+
+
+ <% end %> +
+
+
\ No newline at end of file diff --git a/app/views/branded/phases/_guidances_notes.html.erb b/app/views/branded/phases/_guidances_notes.html.erb index 6cb8045..f149337 100644 --- a/app/views/branded/phases/_guidances_notes.html.erb +++ b/app/views/branded/phases/_guidances_notes.html.erb @@ -1,4 +1,4 @@ -<%# locals: { plan, template, question, answer, dataset, guidance_presenter } %> +<%# locals: { plan, template, question, answer, research_output, guidance_presenter } %> <% guidances_active = guidance_presenter.any?(question: question) %> <% active_nav = nil %>
@@ -6,17 +6,17 @@

<%= _('You can continue to edit and download the plan in the interim.') %>

-
- <%= link_to _('Request feedback'), - feedback_requests_path(plan_id: @plan.id), - data: { method: 'post' }, - class: "btn btn-default#{' disabled' if @plan.feedback_requested?}" %> - <%= _("Feedback has been requested.") if @plan.feedback_requested? %> -
+
+ <%= link_to _('Request feedback'), + feedback_requests_path(plan_id: @plan.id), + data: { method: 'post' }, + class: "btn btn-default#{' disabled' if @plan.feedback_requested?}" %> + <%= _("Feedback has been requested.") if @plan.feedback_requested? %> +
+
<% end %> diff --git a/app/views/branded/plans/datasets.html.erb b/app/views/branded/plans/datasets.html.erb deleted file mode 100644 index 62a9ed9..0000000 --- a/app/views/branded/plans/datasets.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -<%# locals: { plan, datasets } %> -
<%= _('Beta') %>
-<% title "#{plan.title}" %> -
-
-

<%= plan.title %>

-
-
- -
-
- <%= render partial: 'plans/datasets_form', layout: 'plans/navigation', locals: local_assigns %> -
-
\ No newline at end of file diff --git a/app/views/branded/plans/research_outputs.html.erb b/app/views/branded/plans/research_outputs.html.erb new file mode 100644 index 0000000..23c954e --- /dev/null +++ b/app/views/branded/plans/research_outputs.html.erb @@ -0,0 +1,14 @@ +<%# locals: { plan, research_outputs } %> +
<%= _('Beta') %>
+<% title "#{plan.title}" %> +
+
+

<%= plan.title %>

+
+
+ +
+
+ <%= render partial: 'plans/research_outputs_form', layout: 'plans/navigation', locals: local_assigns %> +
+
\ No newline at end of file diff --git a/app/views/branded/questions/_new_edit_question_datefield.html.erb b/app/views/branded/questions/_new_edit_question_datefield.html.erb index dce3c11..fea2b98 100644 --- a/app/views/branded/questions/_new_edit_question_datefield.html.erb +++ b/app/views/branded/questions/_new_edit_question_datefield.html.erb @@ -1,4 +1,4 @@ -<%# locals: { f, question, answer, dataset } %> +<%# locals: { f, question, answer, research_output } %>
<%= f.label(:text, raw(question.text), class: 'control-label') %> <%= date_field_tag('answer[text]', strip_tags(answer.text || question.default_value), class: 'form-control') %> diff --git a/app/views/branded/questions/_new_edit_question_numberfield.html.erb b/app/views/branded/questions/_new_edit_question_numberfield.html.erb index dcafbf0..a634e1e 100644 --- a/app/views/branded/questions/_new_edit_question_numberfield.html.erb +++ b/app/views/branded/questions/_new_edit_question_numberfield.html.erb @@ -1,4 +1,4 @@ -<%# locals: { f, question, answer, dataset } %> +<%# locals: { f, question, answer, research_output } %>
<%= f.label(:text, raw(question.text), class: 'control-label') %> <%= number_field_tag('answer[text]', strip_tags(answer.text || question.default_value), class: 'form-control', step: :any) %> diff --git a/app/views/branded/questions/_new_edit_question_option_based.html.erb b/app/views/branded/questions/_new_edit_question_option_based.html.erb index fe10e2e..6fc0b2b 100644 --- a/app/views/branded/questions/_new_edit_question_option_based.html.erb +++ b/app/views/branded/questions/_new_edit_question_option_based.html.erb @@ -1,4 +1,4 @@ -<%# locals: { f, question, answer, dataset } %> +<%# locals: { f, question, answer, research_output } %> <% options = question.question_options.by_number %> <% if question.question_format.checkbox? || question.question_format.multiselectbox? %> <%= f.label(:question_option_ids, sanitize(question.text), class: 'control-label') %> @@ -41,6 +41,6 @@ <% if question.option_comment_display %> <% text = question.question_format.rda_metadata? ? answer.answer_hash['text'] : answer.text %> <%= label_tag('answer[text]', _('Additional Information'), class: 'control-label') %> - <%= text_area_tag('answer[text]', text, id: "answer-text-#{question.id}-dataset-#{dataset.id}", class: "form-control tinymce_answer") %> + <%= text_area_tag('answer[text]', text, id: "answer-text-#{question.id}-research-output-#{research_output.id}", class: "form-control tinymce_answer") %> <% end %>
diff --git a/app/views/branded/questions/_new_edit_question_textarea.html.erb b/app/views/branded/questions/_new_edit_question_textarea.html.erb index 85874f6..e1bfc1f 100644 --- a/app/views/branded/questions/_new_edit_question_textarea.html.erb +++ b/app/views/branded/questions/_new_edit_question_textarea.html.erb @@ -1,4 +1,4 @@ -<%# locals: { f, question, answer, dataset, locking } %> +<%# locals: { f, question, answer, research_output, locking } %> <%# When locking variable is true, this partial renders a plain paragraph with the question answer or default value instead. Since the partial answers/_locking reuses the partial answers/_new_edit which reuses this partial within, when a stale answer is found @@ -12,6 +12,6 @@ <% if locking || readonly %> <%= sanitize("

#{answer.text || question.default_value}

") %> <% else %> - <%= text_area_tag('answer[text]', answer.text || question.default_value, id: "answer-text-#{question.id}-dataset-#{dataset.id}", class: "form-control tinymce_answer") %> + <%= text_area_tag('answer[text]', answer.text || question.default_value, id: "answer-text-#{question.id}-research-output-#{research_output.id}", class: "form-control tinymce_answer") %> <% end %>
\ No newline at end of file diff --git a/app/views/branded/questions/_new_edit_question_textfield.html.erb b/app/views/branded/questions/_new_edit_question_textfield.html.erb index cf05b45..44e746b 100644 --- a/app/views/branded/questions/_new_edit_question_textfield.html.erb +++ b/app/views/branded/questions/_new_edit_question_textfield.html.erb @@ -1,4 +1,4 @@ -<%# locals: { f, question, answer, dataset } %> +<%# locals: { f, question, answer, research_output } %>
<%= f.label(:text, sanitize(question.text), class: 'control-label') %> <%= text_field_tag('answer[text]', strip_tags(answer.text || question.default_value), class: 'form-control') %> diff --git a/app/views/branded/shared/export/_export_by_dataset.erb b/app/views/branded/shared/export/_export_by_dataset.erb deleted file mode 100644 index 7f003c6..0000000 --- a/app/views/branded/shared/export/_export_by_dataset.erb +++ /dev/null @@ -1,64 +0,0 @@ -<%# locals: { datasets, questions, section } %> -<% datasets.each do |dataset| %> - <% section_has_common_answers = dataset.get_main().has_common_answers?(section[:id]) %> - <% if !section_has_common_answers %> -
-

<%= dataset[:name] %>

- <% end %> - <% questions.each do |question| %> - <% answer = section_has_common_answers ? - @plan.answer(question[:id], false, dataset.get_main().id) : - @plan.answer(question[:id], false, dataset[:id]) %> - <% blank = answer.present? ? answer.is_blank? : true %> - <% options = answer.present? ? answer.question_options : [] %> - - <% unless @show_unanswered == false && blank %> -
- <% if !@public_plan && @show_sections_questions%> -

-

<%= sanitize question[:text].to_s, scrubber: TableFreeScrubber.new %>

-

-
- <% end %> - <%# case where question has not been answered sufficiently to display%> - <% if @show_unanswered && (answer.blank? || (options.blank? && blank))%> -

<%= _('Question not answered.') -%>

-
- <% else %> - - <%# case where Question has options %> - <% if options.any? %> -
    - <% options.each do |opt| %> -
  • <%= opt.text %>
  • - <% end %> -
- <% end %> - <%# case for RDA answer display %> - <% if question[:format].rda_metadata? && !blank %> - <% ah = answer.answer_hash %> - <% if ah['standards'].present? %> -
    - <% ah['standards'].each do |id, title| %> -
  • <%= title %>
  • - <% end %> -
- <% end %> -

<%= sanitize ah['text'] %>

- <%# case for displaying comments OR text %> - <% elsif !blank %> -

<%= sanitize answer.text %>

- <% end %> -
- <% end %> -
- <% end %> - <% end %> - - <% if !section_has_common_answers %> -
- <% end %> - <% if section_has_common_answers %> - <% break %> - <% end %> -<% end %> \ No newline at end of file diff --git a/app/views/branded/shared/export/_export_by_question.erb b/app/views/branded/shared/export/_export_by_question.erb index fafc753..db5aac4 100644 --- a/app/views/branded/shared/export/_export_by_question.erb +++ b/app/views/branded/shared/export/_export_by_question.erb @@ -1,12 +1,12 @@ -<%# locals: { datasets, questions, section } %> +<%# locals: { research_outputs, questions, section } %> <% questions.each do |question| %>
- <% datasets.each_with_index do |dataset, idx| %> - <% section_has_common_answers = dataset.get_main().has_common_answers?(section[:id]) %> + <% research_outputs.each_with_index do |research_output, idx| %> + <% section_has_common_answers = research_output.get_main().has_common_answers?(section[:id]) %> <% answer = section_has_common_answers ? - @plan.answer(question[:id], false, dataset.get_main().id) : - @plan.answer(question[:id], false, dataset[:id]) %> + @plan.answer(question[:id], false, research_output.get_main().id) : + @plan.answer(question[:id], false, research_output[:id]) %> <% blank = answer.present? ? answer.is_blank? : true %> <% options = answer.present? ? answer.question_options : [] %> @@ -23,7 +23,7 @@ <% if @show_unanswered && (answer.blank? || (options.blank? && blank))%>

<% if !section_has_common_answers %> - <%= dataset.name %> : + <%= research_output.name %> : <% end %> <%= _('Question not answered.') -%>

@@ -33,7 +33,7 @@ <%# case where Question has options %> <% if options.any? %> <% if !section_has_common_answers %> - <%= dataset.name %> : + <%= research_output.name %> : <% end %>
    <% options.each do |opt| %> @@ -46,7 +46,7 @@ <% ah = answer.answer_hash %> <% if ah['standards'].present? %> <% if !section_has_common_answers %> - <%= dataset.name %> : + <%= research_output.name %> : <% end %>
      <% ah['standards'].each do |id, title| %> @@ -59,7 +59,7 @@ <% elsif !blank %>

      <% if !section_has_common_answers %> - <%= dataset.name %> : + <%= research_output.name %> : <% end %> <%= sanitize answer.text %>

      @@ -68,9 +68,9 @@ <% end %> <% end %> <% if section_has_common_answers %> - <% break %> + <% break %> <% end %> - <% end %> + <% end %>
<% end %> \ No newline at end of file diff --git a/app/views/branded/shared/export/_export_by_research_output.erb b/app/views/branded/shared/export/_export_by_research_output.erb new file mode 100644 index 0000000..e95267b --- /dev/null +++ b/app/views/branded/shared/export/_export_by_research_output.erb @@ -0,0 +1,65 @@ +<%# locals: { research_outputs, questions, section } %> +<% research_outputs.each do |research_output| %> + <% section_has_common_answers = research_output.get_main().has_common_answers?(section[:id]) %> + <%= research_output.get_main() %> + <% if section_has_common_answers == false %> +
+

<%= research_output[:name] %>

+ <% end %> + <% questions.each do |question| %> + <% answer = section_has_common_answers ? + @plan.answer(question[:id], false, research_output.get_main().id) : + @plan.answer(question[:id], false, research_output[:id]) %> + <% blank = answer.present? ? answer.is_blank? : true %> + <% options = answer.present? ? answer.question_options : [] %> + + <% unless @show_unanswered == false && blank %> +
+ <% if !@public_plan && @show_sections_questions%> +

+

<%= sanitize question[:text].to_s, scrubber: TableFreeScrubber.new %>

+

+
+ <% end %> + <%# case where question has not been answered sufficiently to display%> + <% if @show_unanswered && (answer.blank? || (options.blank? && blank))%> +

<%= _('Question not answered.') -%>

+
+ <% else %> + + <%# case where Question has options %> + <% if options.any? %> +
    + <% options.each do |opt| %> +
  • <%= opt.text %>
  • + <% end %> +
+ <% end %> + <%# case for RDA answer display %> + <% if question[:format].rda_metadata? && !blank %> + <% ah = answer.answer_hash %> + <% if ah['standards'].present? %> +
    + <% ah['standards'].each do |id, title| %> +
  • <%= title %>
  • + <% end %> +
+ <% end %> +

<%= sanitize ah['text'] %>

+ <%# case for displaying comments OR text %> + <% elsif !blank %> +

<%= sanitize answer.text %>

+ <% end %> +
+ <% end %> +
+ <% end %> + <% end %> + + <% if !section_has_common_answers %> +
+ <% end %> + <% if section_has_common_answers %> + <% break %> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/branded/shared/export/_plan.erb b/app/views/branded/shared/export/_plan.erb index e8989d1..b5afd31 100644 --- a/app/views/branded/shared/export/_plan.erb +++ b/app/views/branded/shared/export/_plan.erb @@ -26,17 +26,17 @@ <% if @show_sections_questions %>

<%= section[:title] %>

<% end %> - <% if @dataset_export_mode == "by_section" %> - <%= render partial: 'shared/export/export_by_dataset', + <% if @research_output_export_mode == "by_section" %> + <%= render partial: 'shared/export/export_by_research_output', locals: { - datasets: @hash[:datasets], + research_outputs: @hash[:research_outputs], questions: section[:questions], section: section } %> - <% elsif @dataset_export_mode == "by_question" %> + <% elsif @research_output_export_mode == "by_question" %> <%= render partial: 'shared/export/export_by_question', locals: { - datasets: @hash[:datasets], + research_outputs: @hash[:research_outputs], questions: section[:questions], section: section } %> diff --git a/app/views/branded/shared/export/_plan_coversheet.erb b/app/views/branded/shared/export/_plan_coversheet.erb index c1448a6..52aef18 100644 --- a/app/views/branded/shared/export/_plan_coversheet.erb +++ b/app/views/branded/shared/export/_plan_coversheet.erb @@ -30,11 +30,11 @@
<%= sanitize(@plan.description) %>

<% end %> - <% if @hash[:datasets].length > 1 || !@hash[:datasets][0].main?%> -

<%= _("Datasets: ") %>

+ <% if @hash[:research_outputs].length > 1 || !@hash[:research_outputs][0].main?%> +

<%= _("Research outputs: ") %>

    - <% @hash[:datasets].each do |dataset| %> -
  • <%= dataset.name %> - <%= dataset.description %>
  • + <% @hash[:research_outputs].each do |research_output| %> +
  • <%= research_output.name %> - <%= research_output.description %>
  • <% end %>

diff --git a/app/views/branded/shared/export/_plan_styling.erb b/app/views/branded/shared/export/_plan_styling.erb index cf903fa..fa0d3e1 100644 --- a/app/views/branded/shared/export/_plan_styling.erb +++ b/app/views/branded/shared/export/_plan_styling.erb @@ -61,7 +61,7 @@ bottom: 0; } - .dataset { + .research-output { border: 1px solid black; margin: 5px; padding: 5px; diff --git a/app/views/plans/_share_form.html.erb b/app/views/plans/_share_form.html.erb index 93edf04..81a124e 100644 --- a/app/views/plans/_share_form.html.erb +++ b/app/views/plans/_share_form.html.erb @@ -128,7 +128,7 @@

<%= _('Request expert feedback') %>

<%= _('Click below to give data management staff at your organisation access to read and comment on your plan.') %>

- <%= sanitize current_user.org.feedback_email_msg.to_s %> + <%= sanitize current_user.org.feedback_email_msg.to_s % { user_name: current_user.name(false), plan_name: plan.title } %>

<%= _('You can continue to edit and download the plan in the interim.') %>

diff --git a/config/locale/dmpopidor.pot b/config/locale/dmpopidor.pot index 295009a..860d1f1 100644 --- a/config/locale/dmpopidor.pot +++ b/config/locale/dmpopidor.pot @@ -268,34 +268,34 @@ msgid "Editing Static Page" msgstr "" -# Datasets +# Research outputs -msgid "Select datasets to download" +msgid "Select research outputs to download" msgstr "" -msgid "Datasets" +msgid "Research outputs" msgstr "" -msgid "Dataset export mode" +msgid "Research output export mode" msgstr "" -msgid "Datasets by section" +msgid "Research outputs by section" msgstr "" -msgid "Datasets by question" +msgid "Research outputs by question" msgstr "" -msgid "Move dataset" +msgid "Move research output" msgstr "" -msgid "Delete dataset" +msgid "Delete research output" msgstr "" -msgid "Add a dataset" +msgid "Add a research output" msgstr "" -msgid "dataset" +msgid "research output" msgstr "" -msgid "Deleting this dataset will remove the associated answers. Do you confirm ?" +msgid "Deleting this research output will remove the associated answers. Do you confirm ?" msgstr "" diff --git a/config/locale/en_GB/dmpopidor.po b/config/locale/en_GB/dmpopidor.po index 4a96778..df58b9a 100644 --- a/config/locale/en_GB/dmpopidor.po +++ b/config/locale/en_GB/dmpopidor.po @@ -264,34 +264,34 @@ msgid "Editing Static Page" msgstr "Editing Static Page" -# Datasets +# Research outputs -msgid "Select datasets to download" -msgstr "Select datasets to download" +msgid "Select research outputs to download" +msgstr "Select research outputs to download" -msgid "Datasets" -msgstr "Datasets" +msgid "Research outputs" +msgstr "Research outputs" -msgid "Dataset export mode" -msgstr "Dataset export mode" +msgid "Research output export mode" +msgstr "Research output export mode" -msgid "Datasets by section" -msgstr "Datasets by section" +msgid "Research outputs by section" +msgstr "Research outputs by section" -msgid "Datasets by question" -msgstr "Datasets by question" +msgid "Research outputs by question" +msgstr "Research outputs by question" -msgid "Move dataset" -msgstr "Move dataset" +msgid "Move research output" +msgstr "Move research output" -msgid "Delete dataset" -msgstr "Delete dataset" +msgid "Delete research output" +msgstr "Delete research output" -msgid "Add a dataset" -msgstr "Add a dataset" +msgid "Add a research output" +msgstr "Add a research output" -msgid "dataset" -msgstr "dataset" +msgid "research output" +msgstr "research output" -msgid "Deleting this dataset will remove the associated answers. Do you confirm ?" -msgstr "Deleting this dataset will remove the associated answers. Do you confirm ?" \ No newline at end of file +msgid "Deleting this research output will remove the associated answers. Do you confirm ?" +msgstr "Deleting this research output will remove the associated answers. Do you confirm ?" \ No newline at end of file diff --git a/config/locale/fr_FR/dmpopidor.po b/config/locale/fr_FR/dmpopidor.po index a03d821..fc7b1ec 100644 --- a/config/locale/fr_FR/dmpopidor.po +++ b/config/locale/fr_FR/dmpopidor.po @@ -264,34 +264,34 @@ msgid "Successfully %{action} the %{object}." msgstr "%{object} %{action} avec succés." -# Datasets +# Research outputs -msgid "Select datasets to download" -msgstr "Sélectionner les jeux de données à télécharger" +msgid "Select research outputs to download" +msgstr "Sélectionner les produits de recherche à télécharger" -msgid "Datasets" -msgstr "Jeux de données" +msgid "Research outputs" +msgstr "Produits de recherche" -msgid "Dataset export mode" -msgstr "Mode d'export des jeux de données" +msgid "Research output export mode" +msgstr "Mode d'export des produits de recherche" -msgid "Datasets by section" -msgstr "Jeux de données par section" +msgid "Research outputs by section" +msgstr "Produits de recherche par section" -msgid "Datasets by question" -msgstr "Jeux de données par question" +msgid "Research outputs by question" +msgstr "Produits de recherche par question" -msgid "Move dataset" -msgstr "Déplacer le jeu de données" +msgid "Move research output" +msgstr "Déplacer le produit de recherche" -msgid "Delete dataset" -msgstr "Supprimer le jeu de données" +msgid "Delete research output" +msgstr "Supprimer le produit de recherche" -msgid "Add a dataset" -msgstr "Ajouter un jeu de données" +msgid "Add a research output" +msgstr "Ajouter un produit de recherche" -msgid "dataset" -msgstr "Jeu de données" +msgid "research output" +msgstr "Produit de recherche" -msgid "Deleting this dataset will remove the associated answers. Do you confirm ?" -msgstr "En supprimant ce jeu de données, les réponses associées seront également supprimées. Confirmez-vous la suppression ?" \ No newline at end of file +msgid "Deleting this research output will remove the associated answers. Do you confirm ?" +msgstr "En supprimant ce produit de recherche, les réponses associées seront également supprimées. Confirmez-vous la suppression ?" \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f523250..519bbfb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -116,7 +116,7 @@ post 'set_test', constraints: {format: [:json]} get 'overview' end - resources :datasets, only: [:index, :destroy], controller: 'datasets' + resources :research_outputs, only: [:index, :destroy], controller: 'research_outputs' end resources :usage, only: [:index] diff --git a/db/migrate/20190620120126_rename_datasets_to_research_outputs.rb b/db/migrate/20190620120126_rename_datasets_to_research_outputs.rb new file mode 100644 index 0000000..5a6bd00 --- /dev/null +++ b/db/migrate/20190620120126_rename_datasets_to_research_outputs.rb @@ -0,0 +1,10 @@ +class RenameDatasetsToResearchOutputs < ActiveRecord::Migration + def change + remove_foreign_key :answers, :datasets + remove_reference :answers, :dataset + + rename_table :datasets, :research_outputs + + add_reference :answers, :research_output, index: true, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 864cb53..5d6512b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190503130010) do +ActiveRecord::Schema.define(version: 20190620120126) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -37,14 +37,14 @@ t.integer "question_id" t.datetime "created_at" t.datetime "updated_at" - t.integer "lock_version", default: 0 - t.boolean "is_common", default: false - t.integer "dataset_id" + t.integer "lock_version", default: 0 + t.boolean "is_common", default: false + t.integer "research_output_id" end - add_index "answers", ["dataset_id"], name: "index_answers_on_dataset_id", using: :btree add_index "answers", ["plan_id"], name: "answers_plan_id_idx", using: :btree add_index "answers", ["question_id"], name: "answers_question_id_idx", using: :btree + add_index "answers", ["research_output_id"], name: "index_answers_on_research_output_id", using: :btree add_index "answers", ["user_id"], name: "answers_user_id_idx", using: :btree create_table "answers_question_options", id: false, force: :cascade do |t| @@ -55,18 +55,6 @@ add_index "answers_question_options", ["answer_id"], name: "answers_question_options_answer_id_idx", using: :btree add_index "answers_question_options", ["question_option_id"], name: "answers_question_options_question_option_id_idx", using: :btree - create_table "datasets", force: :cascade do |t| - t.string "name" - t.integer "order" - t.text "description" - t.boolean "is_default", default: false - t.integer "plan_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - - add_index "datasets", ["plan_id"], name: "index_datasets_on_plan_id", using: :btree - create_table "exported_plans", force: :cascade do |t| t.integer "plan_id" t.integer "user_id" @@ -311,6 +299,18 @@ t.integer "super_region_id" end + create_table "research_outputs", force: :cascade do |t| + t.string "name" + t.integer "order" + t.text "description" + t.boolean "is_default", default: false + t.integer "plan_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "research_outputs", ["plan_id"], name: "index_research_outputs_on_plan_id", using: :btree + create_table "roles", force: :cascade do |t| t.integer "user_id" t.integer "plan_id" @@ -492,13 +492,12 @@ add_foreign_key "annotations", "orgs" add_foreign_key "annotations", "questions" - add_foreign_key "answers", "datasets" add_foreign_key "answers", "plans" add_foreign_key "answers", "questions" + add_foreign_key "answers", "research_outputs" add_foreign_key "answers", "users" add_foreign_key "answers_question_options", "answers" add_foreign_key "answers_question_options", "question_options" - add_foreign_key "datasets", "plans" add_foreign_key "guidance_groups", "orgs" add_foreign_key "guidances", "guidance_groups" add_foreign_key "notes", "answers" @@ -520,6 +519,7 @@ add_foreign_key "questions", "sections" add_foreign_key "questions_themes", "questions" add_foreign_key "questions_themes", "themes" + add_foreign_key "research_outputs", "plans" add_foreign_key "roles", "plans" add_foreign_key "roles", "users" add_foreign_key "sections", "phases" diff --git a/lib/dmpopidor/controllers/answers.rb b/lib/dmpopidor/controllers/answers.rb index e74a3a9..96faa5c 100644 --- a/lib/dmpopidor/controllers/answers.rb +++ b/lib/dmpopidor/controllers/answers.rb @@ -1,7 +1,7 @@ module Dmpopidor module Controllers module Answers - # Added Datasets support + # Added Research outputs support def create_or_update p_params = permitted_params() @@ -34,16 +34,10 @@ # rubocop:disable BlockLength Answer.transaction do begin - if Dataset.table_exists? - @answer = Answer.find_by!({ - plan_id: p_params[:plan_id], question_id: p_params[:question_id], - dataset_id: p_params[:dataset_id] - }) - else - @answer = Answer.find_by!({ - plan_id: p_params[:plan_id], question_id: p_params[:question_id] - }) - end + @answer = Answer.find_by!({ + plan_id: p_params[:plan_id], question_id: p_params[:question_id], + research_output_id: p_params[:research_output_id] + }) authorize @answer @answer.update(p_params.merge(user_id: current_user.id)) if p_params[:question_option_ids].present? @@ -89,7 +83,7 @@ @question = @answer.question @section = @plan.sections.find_by(id: @question.section_id) template = @section.phase.template - @dataset = @answer.dataset + @research_output = @answer.research_output # rubocop:disable LineLength render json: { "question" => { @@ -99,7 +93,7 @@ render_to_string(partial: "answers/locking", locals: { question: @question, answer: @stale_answer, - dataset: @dataset, + research_output: @research_output, user: @answer.user }, formats: [:html]) : nil, @@ -107,7 +101,7 @@ template: template, question: @question, answer: @answer, - dataset: @dataset, + research_output: @research_output, readonly: false, locking: false, base_template_org: template.base_org @@ -130,8 +124,8 @@ current_phase: @section.phase }, formats: [:html]) }, - "dataset" => { - "id" => @dataset.id + "research_output" => { + "id" => @research_output.id } }.to_json # rubocop:enable LineLength diff --git a/lib/dmpopidor/controllers/application.rb b/lib/dmpopidor/controllers/application.rb index ab52b54..a7bed09 100644 --- a/lib/dmpopidor/controllers/application.rb +++ b/lib/dmpopidor/controllers/application.rb @@ -5,10 +5,10 @@ def set_nav_static_pages @nav_static_pages = StaticPage.navigable end - # Added Dataset Support + # Added Research output Support def obj_name_for_display(obj) display_name = { - Dataset: d_('dmpopidor', "dataset"), + ResearchOutput: d_('dmpopidor', "research output"), ExportedPlan: _("plan"), GuidanceGroup: _("guidance group"), Note: _("comment"), diff --git a/lib/dmpopidor/controllers/notes.rb b/lib/dmpopidor/controllers/notes.rb index 09feff6..c74e84f 100644 --- a/lib/dmpopidor/controllers/notes.rb +++ b/lib/dmpopidor/controllers/notes.rb @@ -3,7 +3,7 @@ module Notes # CHANGES # Delivered mail contains the name of the collaborator leaving the note - # Added DATASET SUPPORT + # Added RESEARCH OUTPUT SUPPORT def create @note = Note.new @note.user_id = note_params[:user_id] @@ -15,13 +15,13 @@ @answer = Answer.find_by( plan_id: note_params[:plan_id], question_id: note_params[:question_id], - dataset_id: note_params[:dataset_id] + research_output_id: note_params[:research_output_id] ) if @answer.blank? @answer = Answer.new @answer.plan_id = note_params[:plan_id] @answer.question_id = note_params[:question_id] - @answer.dataset_id = note_params[:dataset_id] + @answer.research_output_id = note_params[:research_output_id] @answer.user_id = @note.user_id @answer.save! end @@ -33,7 +33,7 @@ authorize @note @plan = @answer.plan - @dataset = @answer.dataset + @research_output = @answer.research_output @question = Question.find(note_params[:question_id]) @@ -55,7 +55,7 @@ plan: @plan, question: @question, answer: @answer, - dataset: @dataset + research_output: @research_output }, formats: [:html]) }, "title" => { @@ -64,8 +64,8 @@ answer: @answer }, formats: [:html]) }, - "dataset" => { - "id" => note_params[:dataset_id] + "research_output" => { + "id" => note_params[:research_output_id] } }.to_json, status: :created) else @@ -78,7 +78,7 @@ end # CHANGES - # Dataset support + # Research Output support def update @note = Note.find(params[:id]) authorize @note @@ -87,7 +87,7 @@ @answer = @note.answer @question = @answer.question @plan = @answer.plan - @dataset = @answer.dataset + @research_output = @answer.research_output question_id = @note.answer.question_id.to_s @@ -100,7 +100,7 @@ plan: @plan, question: @question, answer: @answer, - dataset: @dataset + research_output: @research_output }, formats: [:html]) }, "title" => { @@ -109,8 +109,8 @@ answer: @answer }, formats: [:html]) }, - "dataset" => { - "id" => @dataset.id + "research_output" => { + "id" => @research_output.id } }.to_json, status: :ok) else @@ -122,7 +122,7 @@ end # CHANGES - # Dataset support + # Research Output support def archive @note = Note.find(params[:id]) authorize @note @@ -132,7 +132,7 @@ @answer = @note.answer @question = @answer.question @plan = @answer.plan - @dataset = @answer.dataset + @research_output = @answer.research_output question_id = @note.answer.question_id.to_s @@ -145,7 +145,7 @@ plan: @plan, question: @question, answer: @answer, - dataset: @dataset + research_output: @research_output }, formats: [:html]) }, "title" => { @@ -154,8 +154,8 @@ answer: @answer }, formats: [:html]) }, - "dataset" => { - "id" => @dataset.id + "research_output" => { + "id" => @research_output.id } }.to_json, status: :ok) else diff --git a/lib/dmpopidor/controllers/plan_exports.rb b/lib/dmpopidor/controllers/plan_exports.rb index 2388b90..4bc6d2b 100644 --- a/lib/dmpopidor/controllers/plan_exports.rb +++ b/lib/dmpopidor/controllers/plan_exports.rb @@ -4,7 +4,7 @@ # CHANGES: Can now send multiple phases when exporting def show - @plan = Plan.includes(:answers, :datasets).find(params[:plan_id]) + @plan = Plan.includes(:answers, :research_outputs).find(params[:plan_id]) if privately_authorized? && export_params[:form].present? skip_authorization @@ -28,7 +28,7 @@ @hash = @plan.as_pdf(@show_coversheet) @formatting = export_params[:formatting] || @plan.settings(:export).formattingz - @dataset_export_mode = export_params[:dataset_mode] + @research_output_export_mode = export_params[:research_output_mode] if @formatting.nil? @formatting = Settings::Template::DEFAULT_SETTINGS[:formatting] @@ -38,8 +38,8 @@ @hash[:phases] = @hash[:phases].select { |p| params[:selected_phases].include?(p[:id].to_s)} end - if params.key?(:selected_datasets) - @hash[:datasets] = @hash[:datasets].select { |d| params[:selected_datasets].include?(d[:id].to_s)} + if params.key?(:selected_research_outputs) + @hash[:research_outputs] = @hash[:research_outputs].select { |d| params[:selected_research_outputs].include?(d[:id].to_s)} end respond_to do |format| diff --git a/lib/dmpopidor/controllers/plans.rb b/lib/dmpopidor/controllers/plans.rb index b306882..443eaf0 100644 --- a/lib/dmpopidor/controllers/plans.rb +++ b/lib/dmpopidor/controllers/plans.rb @@ -22,13 +22,13 @@ # CHANGES: # Added Privately private visibility - # Added Datasets Support + # Added Research Output Support def create @plan = Plan.new authorize @plan - # Add default dataset if possible - @plan.datasets.new(is_default: true, order: 1) if Dataset.table_exists? + # Add default research output if possible + @plan.research_outputs.new(is_default: true, order: 1) # We set these ids to -1 on the page to trick ariatiseForm into allowing the # autocomplete to be blank if the no org/funder checkboxes are checked off @@ -129,7 +129,7 @@ # PUT /plans/1 # PUT /plans/1.json # CHANGES : - # Added Dataset Support + # Added Research Output Support def update @plan = Plan.find(params[:id]) authorize @plan @@ -146,10 +146,10 @@ @plan.guidance_groups = GuidanceGroup.where(id: guidance_group_ids) @plan.save if @plan.update_attributes(attrs) - @plan.datasets.toggle_default + @plan.research_outputs.toggle_default format.html do - redirect_to plan_datasets_path(@plan), + redirect_to plan_research_outputs_path(@plan), notice: success_message(@plan, _("saved")) end format.json do @@ -230,11 +230,11 @@ # rubocop:enable Metrics/LineLength end - # CHANGES : Datasets support + # CHANGES : Research Outputs support def download @plan = Plan.find(params[:id]) authorize @plan - @datasets = @plan.datasets + @research_outputs = @plan.research_outputs @phase_options = @plan.phases.order(:number).pluck(:title, :id) @export_settings = @plan.settings(:export) render "download" diff --git a/lib/dmpopidor/models/phase.rb b/lib/dmpopidor/models/phase.rb index 7e90c6b..124b38f 100644 --- a/lib/dmpopidor/models/phase.rb +++ b/lib/dmpopidor/models/phase.rb @@ -1,9 +1,9 @@ module Dmpopidor module Models module Phase - # CHANGES : ADDED DATASET SUPPORT + # CHANGES : ADDED RESEARCH OUTPUT SUPPORT def visibility_allowed?(plan) - num_answered = num_answered_questions(plan) / plan.num_datasets + num_answered = num_answered_questions(plan) / plan.num_research_outputs value = Rational(num_answered, plan.num_questions) * 100 value >= Rails.application.config.default_plan_percentage_answered.to_f end diff --git a/lib/dmpopidor/models/plan.rb b/lib/dmpopidor/models/plan.rb index b5d5d23..576b86b 100644 --- a/lib/dmpopidor/models/plan.rb +++ b/lib/dmpopidor/models/plan.rb @@ -1,19 +1,19 @@ module Dmpopidor module Models module Plan - # CHANGES : ADDED DATASET SUPPORT + # CHANGES : ADDED RESEARCH OUTPUT SUPPORT # The most recent answer to the given question id optionally can create an answer if # none exists. # # qid - The id for the question to find the answer for - # did - The id for the dataset to find the answer for + # roid - The id for the research output to find the answer for # create_if_missing - If true, will genereate a default answer # to the question (defaults: true). # # Returns Answer # Returns nil - def answer(qid, create_if_missing = true, did = nil) - answer = answers.where(question_id: qid, dataset_id: did).order("created_at DESC").first + def answer(qid, create_if_missing = true, roid = nil) + answer = answers.where(question_id: qid, research_output_id: roid).order("created_at DESC").first question = Question.find(qid) if answer.nil? && create_if_missing answer = Answer.new @@ -47,11 +47,11 @@ end - # The number of datasets for a plan. + # The number of research outputs for a plan. # # Returns Integer - def num_datasets - datasets.count + def num_research_outputs + research_outputs.count end end end diff --git a/lib/dmpopidor/policies/plan.rb b/lib/dmpopidor/policies/plan.rb index 8757818..bb1f8bc 100644 --- a/lib/dmpopidor/policies/plan.rb +++ b/lib/dmpopidor/policies/plan.rb @@ -1,7 +1,7 @@ module Dmpopidor module Policies module Plan - def datasets? + def research_outputs? @plan.readable_by?(@user.id) end end diff --git a/lib/tasks/dmpopidor_upgrade.rake b/lib/tasks/dmpopidor_upgrade.rake index 0c4107e..273f455 100644 --- a/lib/tasks/dmpopidor_upgrade.rake +++ b/lib/tasks/dmpopidor_upgrade.rake @@ -11,7 +11,7 @@ desc "Upgrade to 2.2.0" task v2_2_0: :environment do - Rake::Task['dmpopidor_upgrade:datasets_enable'].execute + Rake::Task['dmpopidor_upgrade:research_outputs_enable'].execute end @@ -50,35 +50,32 @@ end - # Migrates the database to use datasets - # - Adds a dataset table to the base (via the above migrations) - # - Creates a default dataset for every plan - # - Moves all plans' answers to their new default dataset - desc 'Migrate the database to use datasets' - task datasets_enable: :environment do + # Migrates the database to use research_outputs + # - Adds a research output table to the base (via the above migrations) + # - Creates a default research output for every plan + # - Moves all plans' answers to their new default research output + desc 'Migrate the database to use research outputs' + task research_outputs_enable: :environment do # Apply migration - # DatasetsMigration.new.up - # Create datasets and move answers + # Create research outputs and move answers Plan.all.each do |p| - dataset = p.datasets.create(is_default: true, order: 1) if p.datasets.empty? + research_output = p.research_outputs.create(is_default: true, order: 1) if p.research_outputs.empty? - p.answers.each { |a| a.update_column(:dataset_id, dataset.id) } + p.answers.each { |a| a.update_column(:research_output_id, research_output.id) } end end - # Rollback for the database migration enable the datasets - # - Remove all non default datasets and their answers - # - "Detach" remaining answers from their datasets (the default ones) - # - Drop the datasets table and reverse the migrations - desc 'Migrate the database to remove datasets' - task datasets_disable: :environment do - # Destroy all datasets which are not defaut datasets and their answers - Dataset.where(is_default: false).destroy_all - - # Rollback migration - # DatasetsMigration.new.down + # Rollback for the database migration enable the research outputs + # - Remove all non default research outputs and their answers + # - "Detach" remaining answers from their research outputs (the default ones) + # - Drop the research outputs table and reverse the migrations + desc 'Migrate the database to remove research outputs' + task research outputs_disable: :environment do + # Destroy all research outputs which are not defaut research outputs and their answers + ResearchOutput.where(is_default: false).destroy_all Rake::Task['db:migrate:down VERSION=20190503130010'].execute + Rake::Task['db:migrate:down VERSION=20190620120126'].execute end end diff --git a/spec/factories/answers.rb b/spec/factories/answers.rb index d3114bd..cf15b45 100644 --- a/spec/factories/answers.rb +++ b/spec/factories/answers.rb @@ -2,29 +2,29 @@ # # Table name: answers # -# id :integer not null, primary key -# is_common :boolean default(FALSE) -# lock_version :integer default(0) -# text :text -# created_at :datetime -# updated_at :datetime -# dataset_id :integer -# plan_id :integer -# question_id :integer -# user_id :integer +# id :integer not null, primary key +# is_common :boolean default(FALSE) +# lock_version :integer default(0) +# text :text +# created_at :datetime +# updated_at :datetime +# plan_id :integer +# question_id :integer +# research_output_id :integer +# user_id :integer # # Indexes # -# answers_plan_id_idx (plan_id) -# answers_question_id_idx (question_id) -# answers_user_id_idx (user_id) -# index_answers_on_dataset_id (dataset_id) +# answers_plan_id_idx (plan_id) +# answers_question_id_idx (question_id) +# answers_user_id_idx (user_id) +# index_answers_on_research_output_id (research_output_id) # # Foreign Keys # -# fk_rails_... (dataset_id => datasets.id) # fk_rails_... (plan_id => plans.id) # fk_rails_... (question_id => questions.id) +# fk_rails_... (research_output_id => research_outputs.id) # fk_rails_... (user_id => users.id) #