diff --git a/AUview.php b/AUview.php
index 1315075..ccc6850 100755
--- a/AUview.php
+++ b/AUview.php
@@ -80,7 +80,7 @@
+
+libdir.'/tablelib.php');
+require_once($CFG->dirroot.'/mod/cmi5launch/locallib.php');
+require_once($CFG->libdir.'/formslib.php');
+require_once($CFG->dirroot. '/reportbuilder/classes/local/report/column.php');
+
+define('CMI5LAUNCH_REPORT_DEFAULT_PAGE_SIZE', 20);
+define('CMI5LAUNCH_REPORT_ATTEMPTS_ALL_STUDENTS', 0);
+define('CMI5LAUNCH_REPORT_ATTEMPTS_STUDENTS_WITH', 1);
+define('CMI5LAUNCH_REPORT_ATTEMPTS_STUDENTS_WITH_NO', 2);
+$PAGE->requires->jquery();
+
+global $cmi5launch, $CFG;
+
+// External classes and functions.
+$cmi5helper = new cmi5_connectors;
+$createtenant = $cmi5helper->cmi5launch_get_create_tenant();
+
+// Retrieve the name entered in previous pages prompt. This will be the new tenant name.
+ $fromsettings = required_param('variableName', PARAM_TEXT);
+
+// Button to return to settings page.
+$link = "
+
+
+
+
+ ";
+// Ensure a name was entered.
+if ($fromsettings != null) {
+
+ // Make the new tenant and grab results.
+ $tenant = $createtenant($fromsettings);
+
+ // The return response should be an array and have 'id' and 'code'
+ $response = $tenant;
+
+ //Do we need an if statement for response tyopo?
+ $name = $response['code'];
+ $id = $response['id'];
+
+
+ // maybe if we make the button link thing here and then just echo it we can save on repetitive code.
+ // if we have a response, we can save the tenant name to the settings
+ if ($name != null && $id != null) {
+ // Save the tenant name to the settings
+ $result = set_config('cmi5launchtenantname', $name, $plugin = 'cmi5launch');
+
+
+ if ($result) {
+
+ echo "Successfully made and saved new tenant";
+ echo "Tenant name: " . $name . " ";
+ echo "Tenant ID: " . $id . " ";
+
+ //Hopefully that worked? Now back to settings
+ $settingurl = new moodle_url($CFG->wwwroot . '/' . 'admin/settings.php', array('section' => 'modsettingcmi5launch'));
+
+ } else {
+ echo "Failed to make tenant. Check connection to player and tenant name.";
+ //if fail shoudl we freeze and alert user with a window towith error message
+
+ echo $link;
+ }
+
+ } else {
+
+ echo "Tenant name not retrieved from player. Check connection.";
+
+ echo $link;
+
+ }
+} else {
+ echo "Tenant name not retrieved or blank. Please try again.";
+
+ echo $link;
+}
+?>
+
+
+
+