{"id":4639,"date":"2024-10-28T04:39:01","date_gmt":"2024-10-28T04:39:01","guid":{"rendered":"https:\/\/beams-experiments.com\/?page_id=4639"},"modified":"2025-10-14T06:40:21","modified_gmt":"2025-10-14T05:40:21","slug":"bayes-ug-chatbot-pilot","status":"publish","type":"page","link":"https:\/\/beams-experiments.com\/index.php\/bayes-ug-chatbot-pilot\/","title":{"rendered":"Bayes UG Projects Chatbot &#8211; Pilot Study"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\" \/>\n  <style>\n    body { margin: 0; padding: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; box-sizing: border-box; }\n    #progressBarContainer { width: 90%; background-color: #e0e0e0; border-radius: 5px; margin-top: 20px; }\n    #progressBar { height: 10px; background-color: #007bff; border-radius: 5px; width: 66%; }\n    #progressText { text-align: center; margin-top: 5px; }\n    #submitForm { display: block; padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: not-allowed; opacity: 0.5; margin: 10px auto; width: fit-content; }\n    #submitForm:enabled { cursor: pointer; opacity: 1; }\n  <\/style>\n<\/head>\n<body>\n  <form id=\"postTaskQuestionnaire\">\n    <p>This pilot chatbot is designed for Bayes Business School undergraduate students working on their projects. Click on the chatbot icon on the left to access administrative support from ChatGPT. Please note that the chatbot is not intended for academic support or for feedback on your reports. To protect your privacy, avoid sharing any personal or identifying information. Once you have finished, we invite you to provide brief feedback on your experience by answering the following questions using a scale from 1 to 7, where 1 is &#8220;Not at all&#8221; and 7 is &#8220;Very much so&#8221;:<\/p>\n\n    <p><b>1. How helpful did you find the chatbot&#8217;s responses to your administrative questions?<\/b><br>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"helpfulness\" value=\"1\"> 1<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"helpfulness\" value=\"2\"> 2<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"helpfulness\" value=\"3\"> 3<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"helpfulness\" value=\"4\"> 4<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"helpfulness\" value=\"5\"> 5<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"helpfulness\" value=\"6\"> 6<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"helpfulness\" value=\"7\"> 7<\/label>\n    <\/p>\n\n    <p><b>2. How clearly and accurately did the chatbot address your queries?<\/b><br>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"clarity_accuracy\" value=\"1\"> 1<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"clarity_accuracy\" value=\"2\"> 2<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"clarity_accuracy\" value=\"3\"> 3<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"clarity_accuracy\" value=\"4\"> 4<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"clarity_accuracy\" value=\"5\"> 5<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"clarity_accuracy\" value=\"6\"> 6<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"clarity_accuracy\" value=\"7\"> 7<\/label>\n    <\/p>\n\n    <p><b>3. How likely are you to use this chatbot again for administrative support?<\/b><br>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"reuse_likelihood\" value=\"1\"> 1<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"reuse_likelihood\" value=\"2\"> 2<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"reuse_likelihood\" value=\"3\"> 3<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"reuse_likelihood\" value=\"4\"> 4<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"reuse_likelihood\" value=\"5\"> 5<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"reuse_likelihood\" value=\"6\"> 6<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"reuse_likelihood\" value=\"7\"> 7<\/label>\n    <\/p>\n\n    <p><b>4. Attention Check (please read carefully):<\/b><br>\n      Select the number &#8216;3&#8217; to demonstrate your attention to detail.<br>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"attentionCheck\" value=\"1\"> 1<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"attentionCheck\" value=\"2\"> 2<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"attentionCheck\" value=\"3\"> 3<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"attentionCheck\" value=\"4\"> 4<\/label>\n      <label style=\"margin-right:10px;\"><input type=\"radio\" name=\"attentionCheck\" value=\"5\"> 5<\/label>\n    <\/p>\n\n    <button type=\"button\" id=\"submitForm\" disabled>Done<\/button>\n  <\/form>\n\n  <div id=\"progressBarContainer\"><div id=\"progressBar\"><\/div><\/div>\n  <div id=\"progressText\">Page 2 out of 3<\/div>\n\n  <script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.5.1\/jquery.min.js\"><\/script>\n  <script>\n    \/\/ =========================\n    \/\/ Chatbot boot\n    \/\/ =========================\n    localStorage.removeItem('chatLog');\n    window.apiURL = 'https:\/\/beams-experiments.com\/AI_HE\/chatbot\/getAPIKeyUGProjects.php';\n\n    \/\/ ---- chatTime measurement (first open -> page unload) ----\n    \/\/ Initialise storage to a safe default\n    if (!localStorage.getItem('chatTime')) localStorage.setItem('chatTime', '0');\n\n    function setChatStartOnce() {\n      if (!localStorage.getItem('chatStartTs')) {\n        localStorage.setItem('chatStartTs', String(Date.now()));\n        \/\/ Optional: mark that the user opened the chat at least once\n        localStorage.setItem('chatOpened', '1');\n      }\n    }\n\n    \/\/ Delegate: when the dynamically injected chatbot icon is clicked for the first time\n    document.addEventListener('click', function (e) {\n      const icon = e.target.closest && e.target.closest('#chatbotIcon');\n      if (icon) setChatStartOnce();\n    }, true);\n\n    \/\/ On page exit, record total seconds from first open until unload\n    function recordChatTimeOnExit() {\n      const ts = Number(localStorage.getItem('chatStartTs')) || 0;\n      if (ts > 0) {\n        const seconds = Math.max(0, Math.round((Date.now() - ts) \/ 1000));\n        localStorage.setItem('chatTime', String(seconds));\n      }\n    }\n    window.addEventListener('beforeunload', recordChatTimeOnExit);\n    \/\/ Also persist if tab is backgrounded (optional, keeps a recent value)\n    document.addEventListener('visibilitychange', function(){ if (document.visibilityState === 'hidden') recordChatTimeOnExit(); });\n\n    async function initializeMCPContext() {\n      const threadId = localStorage.getItem('threadId');\n      if (!threadId) {\n        try {\n          const res = await fetch(window.apiURL + '?initThread=1');\n          const data = await res.json();\n          if (data.threadId) localStorage.setItem('threadId', data.threadId);\n        } catch (err) {\n          console.error('MCP init failed:', err);\n        }\n      }\n    }\n\n    async function startPage() {\n      await initializeMCPContext();\n      const script = document.createElement('script');\n      script.src = 'https:\/\/beams-experiments.com\/AI_HE\/chatbot\/chatbotBayesUG.js';\n      document.body.appendChild(script);\n    }\n    startPage();\n\n    \/\/ =========================\n    \/\/ Questionnaire logic (unchanged except for submit using chatTime)\n    \/\/ =========================\n    $(document).ready(function() {\n      function checkAllQuestionsAnswered() {\n        var allAnswered = true;\n        $('#postTaskQuestionnaire input[type=\"radio\"]').each(function() {\n          var name = $(this).attr('name');\n          if ($('input[name=\"' + name + '\"]:checked').length == 0) { allAnswered = false; return false; }\n        });\n        return allAnswered;\n      }\n\n      $('#postTaskQuestionnaire input[type=\"radio\"], #postTaskQuestionnaire textarea').on('change keyup', function() {\n        if (checkAllQuestionsAnswered()) {\n          $('#submitForm').removeAttr('disabled').css('cursor','pointer').css('opacity','1');\n        } else {\n          $('#submitForm').attr('disabled','disabled');\n        }\n      });\n\n      alert('Ensure you read the instructions first then answer all the questions before pressing \"Done\"');\n\n      if (localStorage.getItem('code')) {\n        \/\/ Already completed logic if needed\n      }\n\n      $('#submitForm').on('click', function() {\n        var formData = new FormData();\n\n        var attentionCheckAnswer = $('input[name=\"attentionCheck\"]:checked').val();\n        var attentionCheck = attentionCheckAnswer === '3' ? 1 : 0;\n        formData.append('attentionCheck', attentionCheck);\n\n        formData.append('helpfulness', $('[name=\"helpfulness\"]:checked').val());\n        formData.append('clarity_accuracy', $('[name=\"clarity_accuracy\"]:checked').val());\n        formData.append('reuse_likelihood', $('[name=\"reuse_likelihood\"]:checked').val());\n\n        \/\/ Ensure the most recent chatTime is recorded before submitting\n        (function ensureLatestChatTime(){\n          const ts = Number(localStorage.getItem('chatStartTs')) || 0;\n          if (ts > 0) {\n            const seconds = Math.max(0, Math.round((Date.now() - ts) \/ 1000));\n            localStorage.setItem('chatTime', String(seconds));\n          }\n        })();\n\n        var localStorageFields = ['groupID','studentCategory','gender','pathway','aiFamiliarity','aiUsage','chatLog','chatTime'];\n        localStorageFields.forEach(function(field){\n          var value = localStorage.getItem(field) || '0';\n          formData.append(field, value);\n        });\n\n        var xhr = new XMLHttpRequest();\n        xhr.open('POST','https:\/\/beams-experiments.com\/AI_HE\/chatbot\/sendAllDetailsChatbot.php',true);\n        xhr.onload = function(){\n          if (xhr.status === 200) {\n            var randomString = Math.random().toString(36).substring(2,6).toUpperCase();\n            var userID = xhr.responseText.trim();\n            var code = `Bayes-Chatbot-${randomString}-${userID}`;\n            localStorage.setItem('code', code);\n\n            var codeFormData = new FormData();\n            codeFormData.append('userID', userID);\n            codeFormData.append('code', code);\n\n            var codeXhr = new XMLHttpRequest();\n            codeXhr.open('POST','https:\/\/beams-experiments.com\/AI_HE\/chatbot\/sendCode2.php',true);\n            codeXhr.onload = function(){ if (codeXhr.status !== 200) { alert('An error occurred while sending the code. Please try again.'); } };\n            codeXhr.send(codeFormData);\n\n            window.location.href = 'https:\/\/beams-experiments.com\/index.php\/thank-you-chatbot\/';\n          } else {\n            alert('An error occurred. Please try again.');\n          }\n        };\n        xhr.send(formData);\n      });\n    });\n  <\/script>\n<\/body>\n<\/html>\n\n","protected":false},"excerpt":{"rendered":"<p>This pilot chatbot is designed for Bayes Business School undergraduate students working on their projects. Click on the chatbot icon on the left to access administrative support from ChatGPT. Please note that the chatbot is not intended for academic support or for feedback on your reports. To protect your privacy, avoid sharing any personal or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"footnotes":""},"class_list":["post-4639","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/pages\/4639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/comments?post=4639"}],"version-history":[{"count":33,"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/pages\/4639\/revisions"}],"predecessor-version":[{"id":6377,"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/pages\/4639\/revisions\/6377"}],"wp:attachment":[{"href":"https:\/\/beams-experiments.com\/index.php\/wp-json\/wp\/v2\/media?parent=4639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}