let firstMessage = true;
let course_name = "Empty"; // init course_name value


// clear previous chat history
function clear_chat() {
  var chatBox = document.getElementById("chatbox_grid_container");
  while (chatBox.firstChild) {
    chatBox.removeChild(chatBox.firstChild);
  }
}

function init_firstmessage(message) {
  if (typeof message === 'undefined') {
    message = "Data Mining"; // default value to start with
  }

  clear_chat();
  course_name = message; // saves course name
  var chatBubble = document.createElement("span");
  chatBubble.classList.add("ai-chat-bubble");
  chatBubble.innerHTML = `Hi, I'm your CourseCompanion for ${message}! How can I assist you with understanding your class better? Whether you need clarification on the syllabus, assignment deadlines, or course policies, I'm here to assist you.`;
  var chatBox = document.getElementById("chatbox_grid_container");
  chatBox.appendChild(chatBubble);
}


function sendMessage() {
  var inputText = document.getElementById("userinput").value;
  console.log("User input: " + inputText);

  if (!inputText.trim()) {
    return;
  }

  var chatBubble = document.createElement("span");
  chatBubble.classList.add("chat-bubble");
  chatBubble.innerHTML = inputText;

  var chatBox = document.getElementById("chatbox_grid_container");
  chatBox.appendChild(chatBubble);

  var animationBubble = document.createElement("span");
  var animation = document.createElement("img");
  animation.setAttribute('src', '/images/ducky.gif');
  animation.setAttribute('alt', 'loading');
  animation.classList.add('send-animation');
  animationBubble.appendChild(animation);
  chatBox.appendChild(animationBubble);

  // Generate response based on course_name: Capstone II, Data Mining, Software Engineering II
  generateAiResponse(inputText, course_name);

  document.getElementById("userinput").value = "";
}

function generateAiResponse(inputText, course_name) {
  // Define prompts for different sections of the syllabus
  const data_mining_prompts = {
    "about": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Data Mining. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Data Mining. You must be direct, efficient, and professional in all of your communications. Course Description: \
    This is an undergraduate-level course which covers the fundamental principles and techniques of data mining (DM). As the course presents an insider's perspective on DM concepts, its techniques and algorithms, computer programming skills, as well as knowledge in fundamental concepts \
    of discrete mathematics and data structures/algorithms are expected. In particular, the course covers data mining applications, data preparation, data reduction, and various data mining techniques. This course will consist of 6 modules and will have assignments, discussions, quizzes, \
    midterm, and a final exam. Module availability is open and can be completed at the student’s individual pace within the set date and time limits. The assignments will be completed individually. Communication will take place primarily via email and professor announcements. \
    At the end of the course you will have learned fundamental concepts and techniques of the data mining field.",

    "course description": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Data Mining. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Data Mining. You must be direct, efficient, and professional in all of your communications. Course Description: \
    This is an undergraduate-level course which covers the fundamental principles and techniques of data mining (DM). As the course presents an insider's perspective on DM concepts, its techniques and algorithms, computer programming skills, as well as knowledge in fundamental concepts \
    of discrete mathematics and data structures/algorithms are expected. In particular, the course covers data mining applications, data preparation, data reduction, and various data mining techniques. This course will consist of 6 modules and will have assignments, discussions, quizzes, \
    midterm, and a final exam. Module availability is open and can be completed at the student’s individual pace within the set date and time limits. The assignments will be completed individually. Communication will take place primarily via email and professor announcements. \
    At the end of the course you will have learned fundamental concepts and techniques of the data mining field.",

    "expectations": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Data Mining. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Data Mining. You must be direct, efficient, and professional in all of your communications. Expectations/expects: \
    This is an online course, which means most (if not all) of the course work will be conducted online. Expectations for performance in an online course are the same for a traditional course. In fact, online courses require a degree of self-motivation, self-discipline, and technology skills which can make these courses more demanding for some students.Students are expected to:Review the how to get started information located in the course contentIntroduce yourself to the class during the first week by posting a self-introduction in the appropriate discussion forumTake the practice quiz to ensure that your computer is compatible with CanvasInteract online with instructor/s and peersReview and follow the course calendarLog in to the course at least 3 times per weekRespond to discussion boards within 3 daysRespond to emails within 2 daysSubmit assignments by the corresponding deadlineThe instructor will:Log in to the course at least 4 times per weekRespond to discussion boards within 3 daysRespond to emails within 2 daysGrade assignments within 2 weeks of the assignment deadline",

    "prerequisites": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Data Mining. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Data Mining. You must be direct, efficient, and professional in all of your communications. Prerequisites: \
    This course has a prerequisite(s), COP3530",

    "exam policy": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Data Mining. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Data Mining. You must be direct, efficient, and professional in all of your communications. Exam Policy: \
    Exam Option, Honorlock; Start Date, 4/22/2024; Start Time, 06:00 AM; End Date, 4/27/2024; End Time, 11:59 PM; Exam Duration, 120 minutes",

    "reference books": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Data Mining. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Data Mining. You must be direct, efficient, and professional in all of your communications. Resource Books: \
    Data Mining: Concepts and Techniques (Required)Jiawei Han, Micheline Kamber, Jian PeiMorgan Kaufmann; 3rd Edition; 2011ISBN-10: 0123814790ISBN-13: 978-0-12-381479-1 (Print)   |   978-0-12-381480-7 (eBook). You may purchase your textbook online at the FIU Bookstore and at Amazon.",

    "course communication": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Data Mining. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Data Mining. You must be direct, efficient, and professional in all of your communications. Course Communication: \
    Communication in this course will take place via the Inbox. Check out the Canvas Conversations Tutorial to learn how to communicate with your instructor and peers using Announcements, Discussions, and the Inbox.",

    "grading": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Data Mining. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Data Mining. You must be direct, efficient, and professional in all of your communications. Grading table: \
    Letter	Range %	Letter	Range %	Letter	Range %	95% or greater	B	83% or greater, and less than 87%	C	70% or greater, and less than 77% A-	90% or greater, and less than 95%	B-	80% or greater, and less than 83%	D	60% or greater, and less than 70% B+	87% or greater, and less than 90%	C+	77% or greater, and less than 80%	F	Less than 60%",

    "topics": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Data Mining. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Data Mining. You must be direct, efficient, and professional in all of your communications. Calendar/Topics: \
    Module 1 - Introduction to Data Mining and its Applications Supports Course Learning Objective(s):Examine the data mining processModule Learning Objective(s): Upon completion of this module, students should be able toexplain the foundations of data mining, including the importance of DM, applications, and basic concepts.examine the data mining process.Tasks:Post in the Introduce Yourself Discussion ForumRead Chapter 1 and View LecturePost in the Module 1 Discussion Available 1/8 - Due 1/21Start working on Module 1 \
    Assignment Available 1/8 - Due 1/28Module 2 - Understanding and Preprocessing DataSupports Course Learning Objective(s):Formulate the principles and theoretical foundations behind major data mining approachesModule Learning Objective(s): Upon completion of this module, students should be able todiscuss how to get familiar with data and how to preprocess the data. Elements that will be considered include data attributes, statistical measures, visualization techniques, data preprocessing.work with methods used to understand features of the data and methods to preprocess data to \
    improve its quality.Tasks:Post in the Introduce Yourself Discussion ForumRead Chapter 2 (Sections 2.1 – 2.4), Chapter 3 (Sections 3.1 – 3.5) and View LecturePost in the Module 2 Discussion Available 1/22 - Due 2/4Start working on Module 2 Assignment Available 1/22 - Due 2/11Module 3 - Data Warehouses and Data MiningSupports Course Learning Objective(s):Formulate the principles and theoretical foundations behind major data mining approachesUndertake the systematic and comparative evaluation of data mining proceduresModule Learning Objective(s): Upon completion of this module, students \
    should be able todiscuss on data warehouses, OLAP, and data mining. Elements that will be considered include differences between data warehouses and databases, the data cube, the concept description, and schemas the multidimensional data model can adopt.construct schema diagrams for given data warehouse problems, generate OLAP operations, and design a data warehouse for a problem modeled after a real-life situation.Tasks:Read Chapter 4 (Sections 4.1 – 4.5), Chapter 5 (Sections 5.1 – 5.2), and LecturePost in the Module 3 Discussion Available 2/5 - Due 2/18Take Module 3 Quiz Available 2/12\
     - Due 2/18Module 4 - Mining Frequent Patterns and AssociationsSupports Course Level Objective(s):Compare major data mining tasks and algorithms5. Undertake the systematic and comparative evaluation of data mining procedures6. Assess and apply data mining techniques to the solutions of real world problemsFormulate the principles and theoretical foundations behind major data mining approachesModule Level Objective(s):Upon completion of this module, students will be able to:discuss on frequent patterns and methods to mine them. Elements that will be considered in the discussions include itemsets, \
     association rules, pattern evaluation.measures, and the Apriori algorithm to mine frequent itemsets and association rules.given a problem with database transactions, students will be able to compute the support and the confidence of an association rule A ⇒ B, determine the occurrence.frequency of given itemsets, and run the Apriori algorithm to mine frequent patters and strong.Tasks:Read Chapter 6 (Sections 6.1 – 6.3) and LecturePost in the Module 4 Discussion Available 2/19 - Due 3/10Start working on Module 4 Assignment Available 2/19 - Due 3/10Module 5 - Cluster AnalysisSupports Course Level \
     Objective(s):Analyze various data mining applications4. Formulate the principles and theoretical foundations behind major data mining approaches5. Undertake the systematic and comparative evaluation of data mining procedures6. Assess and apply data mining techniques to the solutions of real world problemsCompare major data mining tasks and algorithmsModule Level Objective(s):Upon completion of this module, students will be able to:apply the k-means algorithm to partition a given set of data values into clusters with the k-means algorithm.investigate applications of clustering.use a software tool \
     to find a solution to a clustering problem, and analyze the results obtained.Tasks:Read Chapter 10 and LecturePost in the Module 5 Discussion Available 3/11 - Due 3/31Start working on Module 5 Assignment Available 3/18 - Due 4/7Take the Midterm Exam Available 3/11 - Due 3/17Module 6 - ClassificationSupports Course Level Objective(s):Analyze various data mining applications3. Compare major data mining tasks and algorithms4. Formulate the principles and theoretical foundations behind major data mining approaches5. Undertake the systematic and comparative evaluation of data mining procedures6. Assess \
     and apply data mining techniques to the solutions of real world problemsModule Level Objective(s):Upon completion of this module, students will be able to:discuss on classification and its phases. Elements that will be considered in the discussions include classification methods, attribute selection measures, and model evaluation.Evaluate the computational complexity of classification methods such as the decision tree algorithm, Bayesian classifiers, and rule-based classification.address problems in the two phases of classification.Tasks:Read Chapter 8 (Sections 8.1 – 8.6), Chapter 9 (Sections 9.2 – 9.3),  \
     and LecturePost in the Module 6 Discussion Available 4/8 - Due 4/21Take Module 6 Quiz Available 4/15 - Due 4/21Final Exam Available 4/22 - Due 4/27"
  };

  const capstone_II_prompts = {
    "about": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Capstone II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Capstone II. You must be direct, efficient, and professional in all of your communications. Course Description: \
    Students work on faculty supervised projects in teams of up to 9 members to design and implement solutions to problems utilizing knowledge obtained across the spectrum of Computer Science courses. The course is designed to provide students with the opportunity to apply the knowledge and skills they have acquired in their Computer Science courses to real-world problems.",

    "course description": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Capstone II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Capstone II. You must be direct, efficient, and professional in all of your communications. Course Description: \
    Students work on faculty supervised projects in teams of up to 9 members to design and implement solutions to problems utilizing knowledge obtained across the spectrum of Computer Science courses. The course is designed to provide students with the opportunity to apply the knowledge and skills they have acquired in their Computer Science courses to real-world problems.",

    "expectations": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Capstone II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Capstone II. You must be direct, efficient, and professional in all of your communications. Expectations/expects: \
    This is an online course, which means there is no need for any face-to-face meeting, except if there is an in-person showcase scheduled by the end of the semester. Students must check their fiu.edu emails on a daily basis and keep track of all their assignments and do make sure not to miss any deadlines. There will be no extension for any deadlines and there will be no exception to this rule. All the deadlines are final. You will get a chance to compensate for the points lost, but there would be no extensions. \
    Students are expected to: During the First Week (Preparation Week): Complete their Canvas Profile by uploading a recognizable picture of themselves and adding a short biography. Create a LinkedIn account, connect with the instructor on LinkedIn, and keep it updated throughout the semester. Join a team of students with at least one Capstone II student present to work on a project throughout the semester. Please do make sure that all your teammates are happy with your addition to the team. Note that the Capstone II \
    students on the project are expected to mentor Capstone I and Senior Project students with respect to the Scrum ceremonies, as they have gone through all the details while taking their Capstone I course. Reach out to the product owner of the project and schedule the first planning meeting. During the Second Week Until the Last Two Weeks (Sprints 1 to 6): Work hard on their assigned projects at least 3 hours per day for at least five days per week (or 10 days per sprint of two weeks) throughout the semester. \
    No work during holidays is expected. For example, if a week have one holiday, the number of days expected to work during that week would be at least 4 days instead of 5 days. Interact with your team members at least 1.5 hours per day for at least five days per week (10 days per sprint). Attend all the meetings (i.e., Sprint Planning, Daily, Backlog Grooming, Review, and Retrospective meetings) on time, stay alert and active during the whole meeting, contribute to the note-taking for the meeting minutes, and submit \
    the same copy of the meeting minutes developed and approved by everyone in the meeting right after each meeting via the designated quizzes/assignments before the deadline. Develop project artifacts over time and whenever needed (e.g., User Stories, Use Case Diagrams, Class Diagrams, Sequence Diagrams, Statechart Diagrams, Architectural Diagrams, Deployment Diagrams, Test Cases, Test Suites, etc.) that will eventually be included in the final project document by the end of the semester. During the Last Two Weeks of \
    the Semester (Sprint 7): Submit a Poster before the deadline. Create videos and project documentation for the virtual showcase. Present at the virtual showcase. Create videos to hand off the project to the next group of students. Wrap up the project and finalize the final project document. Create and submit the final deliverable zip file before the deadline.",

    "prerequisites": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Capstone II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Capstone II. You must be direct, efficient, and professional in all of your communications. Prerequisites: \
    CEN 4010 and Permission of the Senior Project Coordinator. This course should be taken during the semester in which the student completes all the CS courses required for the CS major. Prerequisites Topics: Software development process Basic project management concepts Domain specific knowledge (for project being developed)",

    "exam policy": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Capstone II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Capstone II. You must be direct, efficient, and professional in all of your communications. Exam Policy: \
    No mid-term nor final exam. There will be assignments for Scrum ceremonies due throughout the semester on a daily basis, a poster, a virtual showcase at the end, and a final deliverable zip file due at the end of the semester. There will be no extension on the due dates; no exceptions.",

    "reference books": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Capstone II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Capstone II. You must be direct, efficient, and professional in all of your communications. Resource Books: \
    Book Title: Essential Scrum: A Practical Guide to the Most Popular Agile Process: 1st Edition ISBN#: 9780137043293 Author: Kenneth S. Rubin Edition: 1 Publisher: Addison-Wesley Book Title: Object-Oriented Software Engineering Using UML, Patterns, and Java ISBN#: 9780136061250 Author: Bernd Bruegge and Allen H. Dutoit Edition: 3rd Publisher: Prentice Hall; 3 edition (August 8, 2009)",

    "course communication": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Capstone II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Capstone II. You must be direct, efficient, and professional in all of your communications. Course Communication: \
    All course communication in this course will take place via Canvas Announcements (you should receive an email notification at your fiu.edu email), the Canvas Inbox, and Nextcloud. Check out the Canvas Conversations Tutorial or Canvas Guide to learn how to communicate with your instructor and peers using Canvas Announcements, Discussions, Inbox, and Nextcloud.",

    "grading": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Capstone II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Capstone II. You must be direct, efficient, and professional in all of your communications. Grading table: \
    Course Requirements Weight Scrum Ceremonies 40% Showcase 30% Final Deliverable Zip File 30% Total 100%. Letter Range% Letter Range% Letter Range% A 90 or above B 80 - 83 C 70 - 73 A- 87 - 89 B- 77 - 79 D 50 - 69 B+ 84 - 86 C+ 74 - 76 F 49 or less (all numbers are in percentage)",

    "topics": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Capstone II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Capstone II. You must be direct, efficient, and professional in all of your communications. Calendar/Topics: \
    Date Details Due Mon Jan 8, 2024 Quiz Canvas Profile due by 11:59pm Tue Jan 9, 2024 Quiz LinkedIn Account due by 11:59pm Thu Jan 11, 2024 Quiz Project Team due by 11:59pm Fri Jan 12, 2024 Quiz Product Owner due by 11:59pm Mon Jan 15, 2024 Assignment Sprint Planning meeting due by 11:58pm Assignment Daily Standup - Day 1 due by 11:59pm Tue Jan 16, 2024 Assignment Daily Standup - Day 2 due by 11:59pm Wed Jan 17, 2024 Assignment Daily Standup - Day 3 due by 11:59pm Thu Jan 18, 2024 Assignment Daily Standup - Day 4 due by 11:59pm Fri Jan 19, 2024 Assignment Daily Standup - Day 5 due by 11:59pm Sat Jan 20, 2024 Assignment Daily Standup - Day 6 due by 11:59pm Sun Jan 21, 2024 Assignment Daily Standup - Day 7 due by 11:59pm Tue Jan 23, 2024 Assignment Backlog Grooming meeting due by 11:59pm Assignment Daily Standup - Day 9 due by 11:59pm Wed Jan 24, 2024 Assignment Daily Standup - Day 10 due by 11:59pm Thu Jan 25, 2024 Assignment Daily Standup - Day 11 due by 11:59pm Fri Jan 26, 2024 Assignment Daily Standup - Day 12 due by 11:59pm Sat Jan 27, 2024 Assignment Daily Standup - Day 13\
    due by 11:59pm Sun Jan 28, 2024 Assignment Daily Standup - Day 14 due by 11:59pm Assignment Sprint Retrospective meeting due by 11:59pm Assignment Sprint Review meeting due by 11:59pm Mon Jan 29, 2024 Assignment Sprint Planning meeting due by 11:58pm Assignment Daily Standup - Day 1 due by 11:59pm Tue Jan 30, 2024 Assignment Daily Standup - Day 2 due by 11:59pm Wed Jan 31, 2024 Assignment Daily Standup - Day 3 due by 11:59pm Thu Feb 1, 2024 Assignment Daily Standup - Day 4 due by 11:59pm Fri Feb 2, 2024 Assignment Daily Standup - Day 5 due by 11:59pm Sat Feb 3, 2024 Assignment Daily Standup - Day 6 due by 11:59pm Sun Feb 4, 2024 Assignment Daily Standup - Day 7 due by 11:59pm Mon Feb 5, 2024 Assignment Backlog Grooming meeting due by 11:59pm Assignment Daily Standup - Day 8 due by 11:59pm Tue Feb 6, 2024 Assignment Daily Standup - Day 9 due by 11:59pm Wed Feb 7, 2024 Assignment Daily Standup - Day 10 due by 11:59pm Thu Feb 8, 2024 Assignment Daily Standup - Day 11 due by 11:59pm Fri Feb 9, 2024 Assignment Daily Standup - Day 12 due by 11:59pm Sat Feb 10, 2024 Assignment Daily \
    Standup - Day 13 due by 11:59pm Sun Feb 11, 2024 Assignment Daily Standup - Day 14 due by 11:59pm Assignment Sprint Retrospective meeting due by 11:59pm Assignment Sprint Review meeting due by 11:59pm Mon Feb 12, 2024 Assignment Sprint Planning meeting due by 11:58pm Assignment Daily Standup - Day 1 due by 11:59pm Tue Feb 13, 2024 Assignment Daily Standup - Day 2 due by 11:59pm Wed Feb 14, 2024 Assignment Daily Standup - Day 3 due by 11:59pm Thu Feb 15, 2024 Assignment Daily Standup - Day 4 due by 11:59pm Fri Feb 16, 2024 Assignment Daily Standup - Day 5 due by 11:59pm Sat Feb 17, 2024 Assignment Daily Standup - Day 6 due by 11:59pm Sun Feb 18, 2024 Assignment Daily Standup - Day 7 due by 11:59pm Mon Feb 19, 2024 Assignment Backlog Grooming meeting due by 11:59pm Assignment Daily Standup - Day 8 due by 11:59pm Tue Feb 20, 2024 Assignment Daily Standup - Day 9 due by 11:59pm Wed Feb 21, 2024 Assignment Daily Standup - Day 10 due by 11:59pm Thu Feb 22, 2024 Assignment Daily Standup - Day 11 due by 11:59pm Fri Feb 23, 2024 Assignment Daily Standup - Day 12 due by 11:59pm Sat Feb 24,\
    2024 Assignment Daily Standup - Day 13 due by 11:59pm Sun Feb 25, 2024 Assignment Daily Standup - Day 14 due by 11:59pm Assignment Sprint Retrospective meeting due by 11:59pm Assignment Sprint Review meeting due by 11:59pm Mon Mar 4, 2024 Assignment Sprint Planning meeting due by 11:58pm Assignment Daily Standup - Day 1 due by 11:59pm Tue Mar 5, 2024 Assignment Daily Standup - Day 2 due by 11:59pm Wed Mar 6, 2024 Assignment Daily Standup - Day 3 due by 11:59pm Thu Mar 7, 2024 Assignment Daily Standup - Day 4 due by 11:59pm Fri Mar 8, 2024 Assignment Daily Standup - Day 5 due by 11:59pm Sat Mar 9, 2024 Assignment Daily Standup - Day 6 due by 11:59pm Sun Mar 10, 2024 Assignment Daily Standup - Day 7 due by 11:59pm Mon Mar 11, 2024 Assignment Daily Standup - Day 8 due by 11:59pm Tue Mar 12, 2024 Assignment Backlog Grooming meeting due by 12:59am Assignment Daily Standup - Day 9 due by 11:59pm Wed Mar 13, 2024 Assignment Daily Standup - Day 10 due by 11:59pm Thu Mar 14, 2024 Assignment Daily Standup - Day 11 due by 11:59pm Fri Mar 15, 2024 Assignment Daily Standup - Day 12 due by 11:59pm \
    Sat Mar 16, 2024 Assignment Daily Standup - Day 13 due by 11:59pm Sun Mar 17, 2024 Assignment Daily Standup - Day 14 due by 11:59pm Assignment Sprint Retrospective meeting due by 11:59pm Assignment Sprint Review meeting due by 11:59pm Mon Mar 18, 2024 Assignment Sprint Planning meeting due by 11:58pm Assignment Daily Standup - Day 1 due by 11:59pm Tue Mar 19, 2024 Assignment Daily Standup - Day 2 due by 11:59pm Wed Mar 20, 2024 Assignment Daily Standup - Day 3 due by 11:59pm Thu Mar 21, 2024 Assignment Daily Standup - Day 4 due by 11:59pm Fri Mar 22, 2024 Assignment Daily Standup - Day 5 due by 11:59pm Sat Mar 23, 2024 Assignment Daily Standup - Day 6 due by 11:59pm Sun Mar 24, 2024 Assignment Daily Standup - Day 7 due by 11:59pm Mon Mar 25, 2024 Assignment Backlog Grooming meeting due by 11:59pm Assignment Daily Standup - Day 8 due by 11:59pm Tue Mar 26, 2024 Assignment Daily Standup - Day 9 due by 11:59pm Wed Mar 27, 2024 Assignment Daily Standup - Day 10 due by 11:59pm Thu Mar 28, 2024 Assignment Daily Standup - Day 11 due by 11:59pm Fri Mar 29, 2024 Assignment Daily Standup - \
    Day 12 due by 11:59pm Sat Mar 30, 2024 Assignment Daily Standup - Day 13 due by 11:59pm Sun Mar 31, 2024 Assignment Daily Standup - Day 14 due by 11:59pm Assignment Sprint Retrospective meeting due by 11:59pm Assignment Sprint Review meeting due by 11:59pm Mon Apr 1, 2024 Assignment Sprint Planning meeting due by 11:58pm Assignment Daily Standup - Day 1 due by 11:59pm Tue Apr 2, 2024 Assignment Daily Standup - Day 2 due by 11:59pm Wed Apr 3, 2024 Assignment Daily Standup - Day 3 due by 11:59pm Thu Apr 4, 2024 Assignment Daily Standup - Day 4 due by 11:59pm Sat Apr 6, 2024 Assignment Daily Standup - Day 6 due by 11:59pm Sun Apr 7, 2024 Assignment Daily Standup - Day 7 due by 11:59pm Mon Apr 8, 2024 Assignment Backlog Grooming meeting due by 11:59pm Assignment Daily Standup - Day 8 due by 11:59pm Tue Apr 9, 2024 Assignment Daily Standup - Day 9 due by 11:59pm Wed Apr 10, 2024 Assignment Daily Standup - Day 10 due by 11:59pm Thu Apr 11, 2024 Assignment Daily Standup - Day 11 due by 11:59pm Fri Apr 12, 2024 Assignment Daily Standup - Day 12 due by 11:59pm Sat Apr 13, 2024 Assignment Daily\
    Standup - Day 13 due by 11:59pm Sun Apr 14, 2024 Assignment Daily Standup - Day 14 due by 11:59pm Assignment Sprint Retrospective meeting due by 11:59pm Assignment Sprint Review meeting due by 11:59pm Mon Apr 15, 2024 Assignment Poster due by 5pm Assignment Sprint Planning meeting due by 11:58pm Assignment Daily Standup - Day 1 due by 11:59pm Tue Apr 16, 2024 Assignment Daily Standup - Day 2 due by 11:59pm Wed Apr 17, 2024 Assignment Daily Standup - Day 3 due by 11:59pm Sat Apr 20, 2024 Assignment Daily Standup - Day 6 due by 11:59pm Sun Apr 21, 2024 Assignment Daily Standup - Day 7 due by 11:59pm Mon Apr 22, 2024 Assignment Backlog Grooming meeting due by 11:59pm Assignment Daily Standup - Day 8 due by 11:59pm Tue Apr 23, 2024 Assignment Daily Standup - Day 9 due by 11:59pm Wed Apr 24, 2024 Assignment Daily Standup - Day 10 due by 11:59pm Thu Apr 25, 2024 Assignment Daily Standup - Day 11 due by 11:59pm Fri Apr 26, 2024 Assignment Daily Standup - Day 12 due by 11:59pm Sat Apr 27, 2024 Assignment Daily Standup - Day 13 due by 11:59pm Sun Apr 28, 2024 Assignment Daily Standup - Day 14 \
    due by 11:59pm Assignment Sprint Retrospective meeting due by 11:59pm Assignment Sprint Review meeting due by 11:59pm Mon Apr 29, 2024 Assignment Final Deliverable Zip File due by 11:59pm Assignment Showcase Presentation "
  };

  const software_II_prompts = {
    "about": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Software Engineering II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Software Engineering II. You must be direct, efficient, and professional in all of your communications. Course Description: \
    CEN4021 Software Engineering II offers a focused exploration of vital aspects influencing the triumph of expansive software ventures. Covering including Software Requirements, Design & Architectures, Software Planning & Management, Software Reusability, Software Quality, and Configuration Management, course provides a comprehensive understanding of the crucial elements required to effectively navigate and excel in the realm of large-scale software development.",

    "course description": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Software Engineering II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Software Engineering II. You must be direct, efficient, and professional in all of your communications. Course Description: \
    CEN4021 Software Engineering II offers a focused exploration of vital aspects influencing the triumph of expansive software ventures. Covering including Software Requirements, Design & Architectures, Software Planning & Management, Software Reusability, Software Quality, and Configuration Management, course provides a comprehensive understanding of the crucial elements required to effectively navigate and excel in the realm of large-scale software development.",

    "expectations": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Software Engineering II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Software Engineering II. You must be direct, efficient, and professional in all of your communications. Expectations/expects: \
    This is an online course, which means most (if not all) of the course work will be conducted online. Expectations for performance in an online course are the same as a traditional course. In fact, online courses require a degree of self-motivation, self-discipline, and technology skills which can make these courses more demanding for some students. ",

    "prerequisites": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Software Engineering II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Software Engineering II. You must be direct, efficient, and professional in all of your communications. Prerequisites: \
    If the course has prerequisites: This course has a prerequisite(s). Review the Course Catalog webpage for prerequisites information. If the course does not have prerequisites: There are no prerequisites for this course.",

    "exam policy": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Software Engineering II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Software Engineering II. You must be direct, efficient, and professional in all of your communications. Exam Policy: \
    Please note that the information contained in this section applies only if your course requires a proctored exam. Through a careful examination of this syllabus, it is the student’s responsibility to determine whether this online course requires proctored exams. Please visit our Student Proctored Exam Instructions webpage for important information concerning proctored exams, proctoring centers, and important forms. Basically, make sure you look at the canvas section when I post it and the exam dates I chose.",

    "reference books": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Software Engineering II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Software Engineering II. You must be direct, efficient, and professional in all of your communications. \
    Textbook Title (Required): Software Engineering, Ian Sommerville. Publisher, Edition, Year: PEARSON, 10th Edition, 2016 ISBN 10: 1-292-09613-6 ISBN 13: 978-1-292-09613-1 You may purchase your textbook online at the FIU Bookstore. pressman.jpg Textbook Title (Required): Software Engineering A Practitioner's Approach Publisher, Edition, Year: McGrawHill, 9th Edition, 2020 ISBN 10: 1-259-87297-1 ISBN 13: 978-1-259-87297-6 You may purchase your textbook online at the FIU Bookstore",

    "course communication": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Software Engineering II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Software Engineering II. You must be direct, efficient, and professional in all of your communications. Course Communication: \
    Communication in this course will take place via the Canvas Inbox. Check out the Canvas Conversations Tutorial or Canvas Guide to learn how to communicate with your instructor and peers using Announcements, Discussions, and the Inbox. I will respond to all correspondences within 24 hours. Students are expected to: review the getting started page located in the course modules. introduce yourself to the class during the first week by posting a self-introduction in the appropriate discussion. take the practice quiz to ensure that your computer is compatible with the learning management system, Canvas. interact online with instructor and peers. review and follow the course calendar and weekly outlines. log in to the course 3 times per week. respond to discussions by the due date specified. No late work will be accepted. respond to emails within 2 days. submit assignments by the corresponding deadline. The instructor will: log in to the course 3 times per week. respond to emails within 2 days. grade assignments and/or provide feedback within 10-14 days of the assignment deadline. Netiquette \
    throughout the course: Be friendly, positive and self-reflective. Use proper language and titles. Use effective communication. Be professional. Ask for clarification. Project Communication Expectations All group members should do an equal amount of work. Have respect for each other. Be willing to cooperate with others on their ideas. Make sure everyone is able to be vocal about their ideas and problems. Discussion Board Communication Expectations Think before you write. Think of the discussion board as an in-between of a chat and a formal essay. In a formal essay, we slowly develop larger ideas at length. The discussion board falls in between. It is also a good idea to read what others in your class have said before you. It is important to be aware of what has already been said. Try to add a new dimension, a different slant, or another perspective. Just as when you are in a regular classroom, there is also a proper etiquette to the discussion board. This etiquette includes listening to (reading) everybody, providing thoughtful responses, maintaining decorum, criticizing politely, addressing\
    replies to people by name, signing your posts, etc.",

    "grading": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Software Engineering II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Software Engineering II. You must be direct, efficient, and professional in all of your communications. Grading table: \
    Course Grades Distribution Table Course Requirements Number of Items Points for Each Total Points Available Weight Quiz 1 50 50 10% Midterm 1 100 100 15% Assignment 2 100 200 35% Final Examination 1 100 100 40% Total 10 N/A 450 100% Letter Grade Distribution Table Letter Range% Letter Range% Letter Range% A 95 or above B 83 - 86 C 70 - 76 A- 90 - 94 B- 80 - 82 D 60 - 69 B+ 87 - 89 C+ 77 - 79 F 59 or less (the numbers represent percentages).",

    "topics": "CourseCompanion Prompt: You are developing a chatbot named CourseCompanion tailored for Software Engineering II. Each chatbot is designed to assist users with class-related inquiries not directly related to the course material but focused on the syllabus. \
    Your task is to create a prompt for the CourseCompanion chatbot for a specific class, such as Software Engineering II. You must be direct, efficient, and professional in all of your communications. Calendar/Topics: \
    The weekly coverage might change as it depends on the progress of the class. However, you must keep up with the reading assignments. Module Week Course Learning Outcome Contents/Topics Suggested Reading/Work 1 Requirement Engineering 1 1 Software Process Models Software Process Models Process Activities Change Management Process Improvement Chapter 2 Teacher Notes 2 1 Requirement Management and Specifications Requirement Gathering Requirement Characteristics Requirement Tracking Master Requirement Document Task Allocation & Management Software Specifications Chapter 4 Teacher Notes 2 Reusable Software 3 1 Software Evolution Evolution Processes Legacy Systems Software Maintenance Chapter 9 4 2 Software Reusability Reusability Concepts Application Frameworks Application System Reuse Software Integration Chapter 15 QUIZ Release of Assignment 1 3 Software Design 5 1,2 Requirements Modeling Requirements Analysis Scenario-Based Modeling Class-Based Modeling Functional Modeling Behavioral Modeling Chapter 8 (Pressman) 6 1,2 User Experience Design User Experience Design Elements UI Analysis & Design \
    User Experience Analysis User Experience Design UI Design Design Evaluation Usability and Accessibility Chapter 12 (Pressman) 4 Software Project Management 7 3 Software Project Management Software Project Management Team composition Managing people Communication Chapter 22 8 3 Risk Management Risk Management Risk Identification Risk Analysis Risk Planning Risk Monitoring Chapter 22 Submission of Assignment 1 9 3 Software Project Planning Software Pricing Plain-driven Development Project Scheduling Chapter 23 Teacher Notes 10 3 Agile Planning Estimation Techniques Cost Modeling Chapter 23 Release of Assignment 2 11 Midterm Test 5 Software Management 12 2,3 Quality Management Software Quality Software Standards Reviews and Inspections Chapter 24 13 2,3 Quality Management Quality and Agile Development Software Measurements Chapter 24 14 3 Configuration Management Version management System building Change management Release management Chapter 25 Submission of Assignment 2 15 Revision 16 Final Examination"
  };

  // Change prompt based on current course chosen by user
  var prompts = "Initialized prompts var";

  if (course_name == "Data Mining") {
    prompts = data_mining_prompts;
    console.log("Prompt: data mining");
  } else if (course_name == "Capstone II") {
    prompts = capstone_II_prompts;
    console.log("Prompt: capstone II");
  } else if (course_name == "Software Engineering II") {
    prompts = software_II_prompts;
    console.log("Prompt: software engineering II");
  } else {
    prompts = "Sorry, I don't have information on that course";
  }

  // Regex pattern to match the section in the input text
  const regexPattern = /\b(?:((course\s+description)|(about))|(?:expectations|expects)|prerequisites|exam\s+policy|reference\s+books|course\s+communication|grading|(?:calendar|topics)|school\s+policies|class\s+schedule|syllabus|office\s+hours|enrollment|registration|academic\s+calendar|tuition\s+fees|homework|assignments|lecture\s+notes|professor|instructor|teaching\s+assistant|school\s+events|extracurricular\s+activities|course\s+load|credits)\b/i;

  let matchedSection = "default value";
  let prompt = "default value";

  // make sure there is a match, if not, return a default message
  if (inputText.match(regexPattern)) {
    matchedSection = inputText.match(regexPattern)[0];
    prompt = prompts[matchedSection];
  } else {
    // make a variable that is a random selection between three strings. The first string says "string1 here" and another string that says "string 2 here", etc.
    var randomSelection = Math.floor(Math.random() * 3);
    if (randomSelection == 0) {
      suggestion = "What are the course expectations?";
    } else if (randomSelection == 1) {
      suggestion = "Could you give me the course description?";
    } else {
      suggestion = "What is the exam policy for this class?";
    }

    matchedSection = "Sorry, it seems your question is out of scope! I can help you better if you ask something related to your class or syllabus. Try something like: " + suggestion; // no match
    var aiChatBubble = document.createElement("span");
    aiChatBubble.classList.add("ai-chat-bubble");
    aiChatBubble.innerHTML = matchedSection;
    var chatBox = document.getElementById("chatbox_grid_container");
    chatBox.removeChild(chatBox.lastChild); // remove the animation element
    chatBox.appendChild(aiChatBubble);
    return; // Exit the function instead of using break
  }

  console.log("Matched section: " + matchedSection);
  // console.log("value of key: " + prompts[matchedSection])

  // If a matching section is found, use its prompt; otherwise, respond with a default message
  // const prompt = prompts[matchedSection];

  // console.log("PROMPTTTTT MATCHED: " + prompts[matchedSection]);
  // Construct parameters for ChatGPT API
  const apiKey = "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";
  const client = axios.create({
    headers: {
      Authorization: "Bearer " + apiKey,
    },
  });

  const params = {
    messages: [
      {
        role: "system",
        content: prompt,
      },
      {
        role: "user",
        content: inputText,
      },
    ],
    model: "gpt-3.5-turbo",
    max_tokens: Math.floor(Math.random() * (600 - 400 + 1) + 400),
    temperature: 0.7,
  };

  // Send request to ChatGPT API
  client
    .post("https://api.openai.com/v1/chat/completions", params)
    .then((result) => {
      // Process AI response and display it
      var aiChatBubble = document.createElement("span");
      aiChatBubble.classList.add("ai-chat-bubble");
      aiChatBubble.innerHTML = result.data.choices[0].message.content;
      var chatBox = document.getElementById("chatbox_grid_container");
      chatBox.removeChild(chatBox.lastChild); // remove the animation element
      chatBox.appendChild(aiChatBubble);
    })
    .catch((err) => {
      console.log("Error:", err.response ? err.response.data : err.message);
    });
}

function toggleSidebar() {
  document.getElementById("sidebar").classList.toggle("active");

  var sidebar = document.querySelector('.sidebar');
  var content = document.querySelector('.content');
  if (sidebar.classList.contains('sidebar-open')) {
    sidebar.classList.remove('sidebar-open');
    content.classList.remove('sidebar-closed');
  } else {
    sidebar.classList.add('sidebar-open');
    content.classList.add('sidebar-closed');
  }

}

