public static function build()
 {
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     $title = __('Results of the Experiment', 'nelioab');
     $view = new NelioABEmptyAjaxPage($title);
     $controller = NelioABSelectExpProgressPageController::attempt_to_load_proper_controller();
     if ($controller != NULL) {
         call_user_func(array($controller, 'build'));
     } else {
         if (isset($_GET['id'])) {
             // The ID of the experiment to which the action applies
             $view->keep_request_param('id', $_GET['id']);
         }
         if (isset($_GET['exp_type'])) {
             $view->keep_request_param('exp_type', $_GET['exp_type']);
         }
         if (isset($_GET['goal'])) {
             $view->keep_request_param('goal', $_GET['goal']);
         }
         $view->get_content_with_ajax_and_render(__FILE__, __CLASS__);
     }
 }
 public static function build()
 {
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     $title = __('Results of the Experiment', 'nelioab');
     $view = new NelioABHeadlineAltExpProgressPage($title);
     if (isset($_GET['id'])) {
         // The ID of the experiment to which the action applies
         $view->keep_request_param('exp_id', $_GET['id']);
     }
     if (isset($_GET['exp_type'])) {
         $view->keep_request_param('exp_type', $_GET['exp_type']);
     }
     if (isset($_GET['actual_exp_type'])) {
         $view->keep_request_param('exp_type', $_GET['actual_exp_type']);
     }
     if (isset($_GET['goal'])) {
         $view->keep_request_param('goal', $_GET['goal']);
     }
     $view->get_content_with_ajax_and_render(__FILE__, __CLASS__);
 }
 protected function do_build()
 {
     $title = __('Edit Experiment', 'nelioab');
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     // We recover the experiment (if any)
     // ----------------------------------------------
     global $nelioab_admin_controller;
     $experiment = NULL;
     $other_names = array();
     if (!empty($nelioab_admin_controller->data)) {
         $experiment = $nelioab_admin_controller->data;
     } else {
         $experiment = new NelioABCssAlternativeExperiment(-time());
         $experiment->clear();
     }
     // ...and we also recover other experiment names (if any)
     if (isset($_POST['other_names'])) {
         $other_names = json_decode(urldecode($_POST['other_names']));
     } else {
         foreach (NelioABExperimentsManager::get_experiments() as $aux) {
             if ($aux->get_id() != $experiment->get_id()) {
                 array_push($other_names, $aux->get_name());
             }
         }
     }
     // If everything is OK, we keep going!
     // ---------------------------------------------------
     // Creating the view
     $view = $this->create_view();
     // Experiment information
     $view->set_basic_info($experiment->get_id(), $experiment->get_name(), $experiment->get_description(), $experiment->get_finalization_mode(), $experiment->get_finalization_value());
     // Experiment alternatives
     $alts = $experiment->get_json4js_alternatives();
     for ($i = 0; $i < count($alts); ++$i) {
         $alts[$i]['value'] = urlencode($alts[$i]['value']);
     }
     $view->set_alternatives($alts);
     // Goals
     $goals = $experiment->get_goals();
     foreach ($goals as $goal) {
         $view->add_goal($goal->json4js());
     }
     if (count($goals) == 0) {
         $new_goal = new NelioABAltExpGoal($experiment);
         $new_goal->set_name(__('Default', 'nelioab'));
         $view->add_goal($new_goal->json4js());
     }
     return $view;
 }
 public static function build()
 {
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     $aux = NelioABWidgetAltExpCreationPageController::get_instance();
     $view = $aux->do_build();
     $view->render();
 }
 public static function build()
 {
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     $title = __('Settings', 'nelioab');
     $view = new NelioABSettingsPage($title);
     $view->render();
 }
 public static function build()
 {
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     // Build the page and query data via AJAX
     $title = __('Dashboard', 'nelioab');
     $view = new NelioABDashboardPage($title);
     $view->get_content_with_ajax_and_render(__FILE__, __CLASS__);
 }
 public static function build()
 {
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     $aux = NelioABPostAltExpCreationPageController::get_instance();
     $view = $aux->do_build();
     $page_on_front = get_option('page_on_front');
     if (isset($_GET['lp']) && $page_on_front) {
         $view->set_original_id($page_on_front);
     }
     $view->render();
 }
 public static function build()
 {
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     $title = __('Experiments', 'nelioab');
     $view = new NelioABExperimentsPage($title);
     // Some GET options require APPSPOT connection. In order to make
     // them available in the ``generate_html_content'' method, we
     // use our ``keep_request_param'' function.
     if (isset($_GET['_nonce'])) {
         // Used for sorting
         $view->keep_request_param('_nonce', $_GET['_nonce']);
     }
     if (isset($_GET['status'])) {
         // Used for sorting
         $view->keep_request_param('status', $_GET['status']);
     }
     if (isset($_GET['action'])) {
         // Which GET action was requested
         $view->keep_request_param('GET_action', $_GET['action']);
     }
     if (isset($_GET['id'])) {
         // The ID of the experiment to which the action applies
         $view->keep_request_param('exp_id', $_GET['id']);
     }
     if (isset($_GET['exp_type'])) {
         // The type of the experiment (relevant along with its ID)
         $view->keep_request_param('exp_type', $_GET['exp_type']);
     }
     if (isset($_GET['schedule_date'])) {
         // Scheduled Date is relevant for scheduling an experiment
         $view->keep_request_param('schedule_date', $_GET['schedule_date']);
     }
     if (isset($_GET['name'])) {
         // Scheduled Date is relevant for scheduling an experiment
         $view->keep_request_param('name', $_GET['name']);
     }
     $view->get_content_with_ajax_and_render(__FILE__, __CLASS__);
 }
 public static function build()
 {
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     // Checking whether there are menus available
     $menus = wp_get_nav_menus();
     if (count($menus) == 0) {
         require_once NELIOAB_ADMIN_DIR . '/views/errors/message-page.php';
         $view = new NelioABMessagePage(sprintf(__('There are no menus available.<br><a href="%s">Create one now.</a>', 'nelioab'), admin_url('/nav-menus.php')));
     } else {
         $aux = NelioABMenuAltExpCreationPageController::get_instance();
         $view = $aux->do_build();
     }
     $view->render();
 }
 public static function build()
 {
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     $controller = NelioABSelectExpCreationPageController::attempt_to_load_proper_controller();
     if ($controller != NULL) {
         call_user_func(array($controller, 'build'));
     } else {
         if (isset($_GET['experiment-type'])) {
             $controller = NelioABSelectExpCreationPageController::get_controller($_GET['experiment-type']);
             call_user_func(array($controller, 'build'));
         } else {
             $title = __('Experiment Type Selection', 'nelioab');
             $view = new NelioABSelectExpCreationPage($title);
             $view->render();
         }
     }
 }
 protected function do_build()
 {
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     // We recover the experiment (if any)
     // ----------------------------------------------
     global $nelioab_admin_controller;
     $experiment = NULL;
     $other_names = array();
     if (!empty($nelioab_admin_controller->data)) {
         $experiment = $nelioab_admin_controller->data;
     } else {
         $experiment = new NelioABThemeAlternativeExperiment(-time());
         $experiment->clear();
     }
     // ...and we also recover other experiment names (if any)
     if (isset($_POST['other_names'])) {
         $other_names = json_decode(urldecode($_POST['other_names']));
     } else {
         foreach (NelioABExperimentsManager::get_experiments() as $aux) {
             if ($aux->get_id() != $experiment->get_id()) {
                 array_push($other_names, $aux->get_name());
             }
         }
     }
     // Checking whether there is more than one theme
     // available
     // ---------------------------------------------------
     $themes = wp_get_themes();
     usort($themes, array($this, 'sort_themes_alphabetically'));
     if (count($themes) < 2) {
         require_once NELIOAB_ADMIN_DIR . '/views/errors/message-page.php';
         $view = new NelioABMessagePage(__('There is only one theme available', 'nelioab'), __('Please, install one or more themes to create an experiment of this type.', 'nelioab'));
         return $view;
     }
     // If everything is OK, we keep going!
     // ---------------------------------------------------
     $current_theme = wp_get_theme();
     $current_theme_id = $current_theme['Stylesheet'];
     $current_theme_name = $current_theme->offsetGet('Title');
     // We select the alternatives
     $experiment->add_selected_theme($current_theme_id, $current_theme_name);
     if (isset($_POST['nelioab_selected_themes'])) {
         $selected_themes = json_decode(urldecode($_POST['nelioab_selected_themes']));
         if (is_array($selected_themes)) {
             foreach ($selected_themes as $theme) {
                 if (isset($theme->isSelected) && $theme->isSelected) {
                     $experiment->add_selected_theme($theme->value, $theme->name);
                 }
             }
         }
     } else {
         $ori = $experiment->get_original();
         if ($ori) {
             $experiment->add_selected_theme($ori->get_value(), $ori->get_name());
         }
         foreach ($experiment->get_alternatives() as $alt) {
             $experiment->add_selected_theme($alt->get_value(), $alt->get_name());
         }
     }
     if (isset($_POST['nelioab_appspot_ids'])) {
         $experiment->set_appspot_ids(json_decode(urldecode($_POST['nelioab_appspot_ids'])));
     } else {
         $experiment->set_appspot_ids($experiment->get_appspot_ids());
     }
     // Creating the view
     $view = $this->create_view();
     // Experiment information
     $view->set_basic_info($experiment->get_id(), $experiment->get_name(), $experiment->get_description(), $experiment->get_finalization_mode(), $experiment->get_finalization_value());
     // Experiment alternatives
     $view->set_selected_themes($experiment->get_selected_themes());
     $view->set_appspot_ids($experiment->get_appspot_ids());
     $view->set_current_theme($current_theme_id, $current_theme_name, $current_theme->get_screenshot(), $current_theme->offsetGet('Author'));
     foreach ($themes as $theme) {
         $id = $theme['Stylesheet'];
         if ($id == $current_theme_id) {
             continue;
         }
         $view->add_theme($id, $theme->offsetGet('Title'), $theme->get_screenshot(), $theme->offsetGet('Author'), $experiment->is_theme_selected($id));
     }
     // Goals
     $goals = $experiment->get_goals();
     foreach ($goals as $goal) {
         $view->add_goal($goal->json4js());
     }
     if (count($goals) == 0) {
         $new_goal = new NelioABAltExpGoal($experiment);
         $new_goal->set_name(__('Default', 'nelioab'));
         $view->add_goal($new_goal->json4js());
     }
     return $view;
 }
 protected function do_build()
 {
     $title = __('Edit Heatmap Experiment', 'nelioab');
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     // We recover the experiment (if any)
     // ----------------------------------------------
     global $nelioab_admin_controller;
     $experiment = NULL;
     $other_names = array();
     if (!empty($nelioab_admin_controller->data)) {
         $experiment = $nelioab_admin_controller->data;
     } else {
         $experiment = new NelioABHeatmapExperiment(-time());
         $experiment->clear();
     }
     // Get id of Original page or post
     // ----------------------------------------------
     if (isset($_GET['post-id']) && $_GET['experiment-type'] == NelioABExperiment::HEATMAP_EXP) {
         $experiment->set_post_id($_GET['post-id']);
     }
     if (isset($_GET['page-id']) && $_GET['experiment-type'] == NelioABExperiment::HEATMAP_EXP) {
         $experiment->set_post_id($_GET['page-id']);
     }
     // ...and we also recover other experiment names (if any)
     if (isset($_POST['other_names'])) {
         $other_names = json_decode(urldecode($_POST['other_names']));
     } else {
         foreach (NelioABExperimentsManager::get_experiments() as $aux) {
             if ($aux->get_id() != $experiment->get_id()) {
                 array_push($other_names, $aux->get_name());
             }
         }
     }
     // If everything is OK, we keep going!
     // ---------------------------------------------------
     // Creating the view
     $view = $this->create_view();
     foreach ($other_names as $name) {
         $view->add_another_experiment_name($name);
     }
     // Experiment information
     $view->set_basic_info($experiment->get_id(), $experiment->get_name(), $experiment->get_description(), $experiment->get_finalization_mode(), $experiment->get_finalization_value());
     $view->set_post_id($experiment->get_post_id());
     // Checking whether there are pages or posts available
     // ---------------------------------------------------
     // ...pages...
     $list_of_pages = get_pages();
     $options_for_posts = array('posts_per_page' => 1);
     $list_of_posts = get_posts($options_for_posts);
     require_once NELIOAB_UTILS_DIR . '/data-manager.php';
     NelioABArrays::sort_posts($list_of_posts);
     if (count($list_of_pages) + count($list_of_posts) == 0) {
         require_once NELIOAB_ADMIN_DIR . '/views/errors/error-page.php';
         $view = new NelioABErrorPage(__('There are no pages nor posts available.', 'nelioab'), __('Please, create some pages or posts and then try again.', 'nelioab'));
         return $view;
     }
     $is_there_a_static_front_page = nelioab_get_page_on_front();
     $view->show_latest_posts_option(!$is_there_a_static_front_page);
     return $view;
 }
 protected function do_build()
 {
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     // Preparing labels for CUSTOM POST alternatives
     // ----------------------------------------------
     $alt_type = NelioABExperiment::CPT_ALT_EXP;
     $title = __('Edit Custom Post Type Experiment', 'nelioab');
     // We recover the experiment (if any)
     // ----------------------------------------------
     global $nelioab_admin_controller;
     $experiment = NULL;
     $other_names = array();
     if (!empty($nelioab_admin_controller->data)) {
         $experiment = $nelioab_admin_controller->data;
         $alt_type = $experiment->get_type();
     } else {
         $experiment = new NelioABPostAlternativeExperiment(-time());
         $experiment->clear();
     }
     // ...and we also recover other experiment names (if any)
     if (isset($_POST['other_names'])) {
         $other_names = json_decode(urldecode($_POST['other_names']));
     } else {
         foreach (NelioABExperimentsManager::get_experiments() as $aux) {
             if ($aux->get_id() != $experiment->get_id()) {
                 array_push($other_names, $aux->get_name());
             }
         }
     }
     // Get id of Original custom post type
     // ----------------------------------------------
     if (isset($_GET['post-id']) && $_GET['experiment-type'] == NelioABExperiment::CPT_ALT_EXP) {
         $experiment->set_original($_GET['post-id']);
     }
     // Checking whether there are custom post types available
     // ---------------------------------------------------
     require_once NELIOAB_UTILS_DIR . '/wp-helper.php';
     $post_types = NelioABWpHelper::get_custom_post_types();
     if ($alt_type == NelioABExperiment::CPT_ALT_EXP && count($post_types) == 0) {
         require_once NELIOAB_ADMIN_DIR . '/views/errors/message-page.php';
         $view = new NelioABMessagePage(__('There are no custom post types available.', 'nelioab'), __('You have to create a public custom post type and publish some custom posts first to use this type of experiment.', 'nelioab'));
         return $view;
     }
     $found = false;
     foreach ($post_types as $post_type) {
         $options_for_posts = array('posts_per_page' => 1, 'post_type' => $post_type->name, 'post_status' => 'publish');
         $list_of_posts = get_posts($options_for_posts);
         require_once NELIOAB_UTILS_DIR . '/data-manager.php';
         NelioABArrays::sort_posts($list_of_posts);
         if (count($list_of_posts) > 0) {
             $found = true;
             break;
         }
     }
     if ($alt_type == NelioABExperiment::CPT_ALT_EXP && !$found) {
         require_once NELIOAB_ADMIN_DIR . '/views/errors/message-page.php';
         $view = new NelioABMessagePage(__('There are no custom posts available.', 'nelioab'), __('Please, create one custom post and try again.', 'nelioab'));
         return $view;
     }
     // If everything is OK, we keep going!
     // ---------------------------------------------------
     // Creating the view
     $view = $this->create_view($alt_type);
     foreach ($other_names as $name) {
         $view->add_another_experiment_name($name);
     }
     // Experiment information
     $view->set_basic_info($experiment->get_id(), $experiment->get_name(), $experiment->get_description(), $experiment->get_finalization_mode(), $experiment->get_finalization_value());
     // Experiment specific variables and alternatives
     $view->set_custom_post_type($experiment->get_post_type());
     $view->set_original_id($experiment->get_originals_id());
     $view->set_alternatives($experiment->get_json4js_alternatives());
     // Goals
     $goals = $experiment->get_goals();
     foreach ($goals as $goal) {
         $view->add_goal($goal->json4js());
     }
     return $view;
 }
 protected function do_build()
 {
     $title = __('Edit Product Summary Experiment', 'nelioab');
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     // We recover the experiment (if any)
     // ----------------------------------------------
     global $nelioab_admin_controller;
     $experiment = NULL;
     $other_names = array();
     if (!empty($nelioab_admin_controller->data)) {
         $experiment = $nelioab_admin_controller->data;
     } else {
         $experiment = new NelioABProductSummaryAlternativeExperiment(-time());
         $experiment->clear();
     }
     // ...and we also recover other experiment names (if any)
     if (isset($_POST['other_names'])) {
         $other_names = json_decode(urldecode($_POST['other_names']));
     } else {
         foreach (NelioABExperimentsManager::get_experiments() as $aux) {
             if ($aux->get_id() != $experiment->get_id()) {
                 array_push($other_names, $aux->get_name());
             }
         }
     }
     // Get id of Original page or post
     // ----------------------------------------------
     if (isset($_GET['post-id']) && $_GET['experiment-type'] == NelioABExperiment::WC_PRODUCT_SUMMARY_ALT_EXP) {
         $experiment->set_original($_GET['post-id']);
     }
     // Checking whether there are pages or posts available
     // ---------------------------------------------------
     // ...pages...
     $options_for_posts = array('posts_per_page' => 1, 'post_type' => 'product');
     $list_of_posts = get_posts($options_for_posts);
     require_once NELIOAB_UTILS_DIR . '/data-manager.php';
     NelioABArrays::sort_posts($list_of_posts);
     if (count($list_of_posts) == 0) {
         require_once NELIOAB_ADMIN_DIR . '/views/errors/message-page.php';
         $view = new NelioABMessagePage(__('There are no products available.', 'nelioab'), __('Please, create one and try again.', 'nelioab'));
         return $view;
     }
     // If everything is OK, we keep going!
     // ---------------------------------------------------
     // Creating the view
     $view = $this->create_view();
     foreach ($other_names as $name) {
         $view->add_another_experiment_name($name);
     }
     // Experiment information
     $view->set_basic_info($experiment->get_id(), $experiment->get_name(), $experiment->get_description(), $experiment->get_finalization_mode(), $experiment->get_finalization_value());
     // Experiment specific variables and alternatives
     $view->set_original_id($experiment->get_originals_id());
     $view->set_alternatives($experiment->get_json4js_alternatives());
     return $view;
 }
 protected function do_build()
 {
     // Check settings
     require_once NELIOAB_ADMIN_DIR . '/error-controller.php';
     $error = NelioABErrorController::build_error_page_on_invalid_settings();
     if ($error) {
         return;
     }
     // Preparing labels for PAGE vs POST alternatives
     // ----------------------------------------------
     $alt_type = NelioABExperiment::PAGE_ALT_EXP;
     $title = __('Edit Page Experiment', 'nelioab');
     if (isset($_GET['experiment-type']) && $_GET['experiment-type'] == NelioABExperiment::POST_ALT_EXP) {
         $alt_type = NelioABExperiment::POST_ALT_EXP;
         $title = __('Edit Post Experiment', 'nelioab');
     }
     // We recover the experiment (if any)
     // ----------------------------------------------
     global $nelioab_admin_controller;
     $experiment = NULL;
     $other_names = array();
     if (!empty($nelioab_admin_controller->data)) {
         $experiment = $nelioab_admin_controller->data;
         $alt_type = $experiment->get_type();
     } else {
         $experiment = new NelioABPostAlternativeExperiment(-time());
         $experiment->clear();
     }
     // ...and we also recover other experiment names (if any)
     if (isset($_POST['other_names'])) {
         $other_names = json_decode(urldecode($_POST['other_names']));
     } else {
         foreach (NelioABExperimentsManager::get_experiments() as $aux) {
             if ($aux->get_id() != $experiment->get_id()) {
                 array_push($other_names, $aux->get_name());
             }
         }
     }
     // Get id of Original page or post
     // ----------------------------------------------
     if (isset($_GET['post-id']) && $_GET['experiment-type'] == NelioABExperiment::POST_ALT_EXP) {
         $experiment->set_original($_GET['post-id']);
     }
     if (isset($_GET['page-id']) && $_GET['experiment-type'] == NelioABExperiment::PAGE_ALT_EXP) {
         $experiment->set_original($_GET['page-id']);
     }
     // Checking whether there are pages or posts available
     // ---------------------------------------------------
     // ...pages...
     $list_of_pages = get_pages();
     if ($alt_type == NelioABExperiment::PAGE_ALT_EXP && count($list_of_pages) == 0) {
         require_once NELIOAB_ADMIN_DIR . '/views/errors/message-page.php';
         $view = new NelioABMessagePage(sprintf(__('There are no pages available.<br/><br/><a class="button button-primary" href="%s">Create one now.</a>', 'nelioab'), admin_url('/post-new.php?post_type=page')));
         return $view;
     }
     // ...posts...
     $options_for_posts = array('posts_per_page' => 1);
     $list_of_posts = get_posts($options_for_posts);
     require_once NELIOAB_UTILS_DIR . '/data-manager.php';
     NelioABArrays::sort_posts($list_of_posts);
     if ($alt_type == NelioABExperiment::POST_ALT_EXP && count($list_of_posts) == 0) {
         require_once NELIOAB_ADMIN_DIR . '/views/errors/message-page.php';
         $view = new NelioABMessagePage(sprintf(__('There are no posts available.<br/><br/><a class="button button-primary" href="%s">Create one now</a>', 'nelioab'), admin_url('/post-new.php')));
         return $view;
     }
     // If everything is OK, we keep going!
     // ---------------------------------------------------
     // Creating the view
     $view = $this->create_view($alt_type);
     foreach ($other_names as $name) {
         $view->add_another_experiment_name($name);
     }
     // Experiment information
     $view->set_basic_info($experiment->get_id(), $experiment->get_name(), $experiment->get_description(), $experiment->get_finalization_mode(), $experiment->get_finalization_value());
     // Experiment specific variables and alternatives
     $view->set_original_id($experiment->get_originals_id());
     $view->set_alternatives($experiment->get_json4js_alternatives());
     // Goals
     $goals = $experiment->get_goals();
     foreach ($goals as $goal) {
         $view->add_goal($goal->json4js());
     }
     return $view;
 }