From aedaf2f30af40677960d65bfb6395d526b08db88 Mon Sep 17 00:00:00 2001 From: Jure Grabnar Date: Wed, 3 Aug 2016 09:39:34 +0200 Subject: [PATCH] Adding of experiment content now works in reports --- app/controllers/reports_controller.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 60827b4c1..0e161ac37 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -321,8 +321,22 @@ class ReportsController < ApplicationController end def experiment_contents + experiment = Experiment.find_by_id(params[:id]) + if params.include? :modules then + modules = + (params[:modules].select { |m, p| p == "1" }) + .keys + .collect { |id| id.to_i } + end + respond_to do |format| - elements = generate_experiment_contents_json + if experiment.blank? + format.json { render json: {}, status: :not_found } + elsif modules.blank? + format.json { render json: {}, status: :no_content } + else + elements = generate_experiment_contents_json(experiment, modules) + end if elements_empty? elements format.json { render json: {}, status: :no_content }