// const express = require('express');
const express = require("express");
const Ping = require("../api/apiTest");
const apiTest = require("../api/apiTest");
const topPerformers = require("../api/topPerformers");
const classMates = require("../api/classMates");
const continueLearning = require("../api/continueLearning");
const knowledgeQuests = require("../api/knowledgeQuests");
const quizzesScore = require("../api/quizzesScore");
const quizModuleData = require("../api/quizModuleData");
const knowledgeQuestsAllContent = require("../api/knowledgeQuestsAllContent");
const knowledgeQuestsCompleted = require("../api/knowledgeQuestsCompleted");
const quizModuleList = require("../api/quizModuleList");
const quizNewModule = require("../api/quizNewModule");
const newQuiz = require("../api/newQuiz");
const quizList = require("../api/quizList");
const savePostData = require("../api/savePostData");
// const signIn = require("../api/signIn");
const questionList = require("../api/questionList");
const newQuestion = require("../api/newQuestion");
const saveQuizResponse = require("../api/saveQuizResponse");
const getGameScore = require("../api/getGameScore");
const resultAfterQuizSubmit = require("../api/resultAfterQuizSubmit");
const generateQuestions = require("../api/generateQuestions");
// const saveGameScore = require("../api/saveGameScore");
const saveGameScore2 = require("../api/saveGameScore2");
const aiFeedbackOnReport = require("../api/aiFeedbackOnReport");
const aiFeedbackActionParent = require("../api/aiFeedbackActionParent");
const aiFollowupQuestion = require("../api/aiFollowupQuestion");
const aiMarkDrawing = require("../api/aiMarkDrawing");
const aiFeedbackOnReportWithFollowup = require("../api/aiFeedbackOnReportWithFollowup");
const aiTextToSpeech = require("../api/aiTextToSpeech");
const aiEvaluateImageToStar = require("../api/aiEvaluateImageToStar");
const getGameInfo = require("../api/getGameInfo");
const saveGalleryImage = require("../api/saveGalleryImage");
const getGalleryImage = require("../api/getGalleryImage");
const getGameData = require("../api/getGameData");
const imageToStar = require("../api/imageToStar");
// const aiTest = require("../api/aiTest");


const router = express.Router();
/* GET home page. */
router.get("/ping", (req, res) => {
    Ping(req, res);
  });
  
  /* GET home page. */
  router.get("/apiTest", (req, res) => {
    apiTest(req, res);
  });
  
  // Classmates Directory page top performers section data 
  router.get("/top-performers", (req, res) => {
    topPerformers(req, res);
  });
  
  // Classmates Directory page top class mates section data
  router.get("/class-mates", (req, res) => {
    classMates(req, res);
  });
  
  // Student Dashboard page Continue Learning section data
  router.get("/continue-learning", (req, res) => {
    continueLearning(req, res);
  });
  
  // Student Dashboard page knowledge-Quests section data
  router.get("/knowledge-quests", (req, res) => {
    knowledgeQuests(req, res);
  });
  
  // Progress Review page quiz details section data
  router.get("/quiz-score", (req, res) => {
    quizzesScore(req, res);
  });
  
  // Progress Review page quiz module section data
  router.get("/quiz-module", (req, res) => {
    quizModuleData(req, res);
  });
  
  // knowledge Quests page All Content section data
  router.get("/all-assesment", (req, res) => {
    knowledgeQuestsAllContent(req, res);
  });
  
  // knowledge Quests page Completed section data
  router.get("/complete-assesment", (req, res) => {
    knowledgeQuestsCompleted(req, res);
  });
  
  /* GET home page. */
  router.post("/savePostData", (req, res) => {
    savePostData(req, res);
  });
  
  // For Sign in
  // router.post("/signin", (req, res) => {
  //   signIn(req, res);
  // });
  
  // For Quiz Module list Data
  router.get("/quiz-module-list", (req, res) => {
    quizModuleList(req, res);
  });
  
  // For Create new module
  router.post("/create-module", (req, res) => {
    quizNewModule(req, res);
  });
  
  // For Create new Quiz
  router.post("/create-quiz", (req, res) => {
    newQuiz(req, res);
  });
  
  // For Quiz List data
  router.get("/quiz-list", (req, res) => {
    quizList(req, res);
  });
  
  // For Quiz Question List data
  router.get("/question-list", (req, res) => {
    questionList(req, res);
  });
  
  // For Quiz Question List data
  router.post("/create-question", (req, res) => {
    newQuestion(req, res);
  });
  
  // For Quiz Question List data
  router.post("/save-quiz-response", (req, res) => {
    saveQuizResponse(req, res);
  });
  
  // For Quiz Question List data
  router.post("/getGameScore", (req, res) => {
    getGameScore(req, res);
  });
  
  
  // For Quiz Result After Submit Quiz
  router.get("/quizresult-aftersubmit", (req, res) => {
    resultAfterQuizSubmit(req, res);
  });
  
  // For Quiz Result After Submit Quiz
  router.post("/generateQuestions", (req, res) => {
    generateQuestions(req, res);
  });
  
  // For Quiz Result After Submit Quiz
  // router.post("/saveGameScore", (req, res) => {
  //   saveGameScore(req, res);
  // });
  
  // For Quiz Result After Submit Quiz
  router.post("/saveGameScore2", (req, res) => {
    saveGameScore2(req, res);
  });
  
    
  // AI feedback for teacher on children's report card
  router.post("/aiFeedbackOnReport", (req, res) => {
    aiFeedbackOnReport(req, res);
  });
  // AI feedback for teacher on children's report card
  router.post("/aiFeedbackOnReportWithFollowup", (req, res) => {
    aiFeedbackOnReportWithFollowup(req, res);
  });
  
  // AI top ten action items for a parent of this child.
  router.post("/aiFeedbackActionParent", (req, res) => {
    aiFeedbackActionParent(req, res);
  });

  // AI to respond on initial and followup questions.
  router.post("/aiFollowupQuestion", (req, res) => {
    aiFollowupQuestion(req, res);
  });

  // AI to provide star for drawing.
  router.post("/aiMarkDrawing", (req, res) => {
    aiMarkDrawing(req, res);
  });

  // AI to provide star for drawing.
  router.post("/aiTextToSpeech", (req, res) => {
    aiTextToSpeech(req, res);
  });

  // AI to provide star for drawing.
  router.post("/aiEvaluateImageToStar", (req, res) => {
    aiEvaluateImageToStar(req, res);
  });

  // getGameInfo.
  router.get("/getGameInfo", (req, res) => {
    getGameInfo(req, res);
  });
  
  // Save Drawing Game Gallery Image
  router.post("/saveGalleryImage", (req, res) => {
    saveGalleryImage(req, res);
  });

  // Get Drawing Game Gallery Image
  router.get("/getGalleryImage", (req, res) => {
    getGalleryImage(req, res);
  });

  router.get("/getGameData", (req, res) => {
    getGameData(req, res);
  });

  // Image to Star
  router.post("/imageToStar", (req, res) => {
    imageToStar(req, res);
  });

  // Get Drawing Game Gallery Image
  // router.post("/aiTest", (req, res) => {
  //   aiTest(req, res);
  // });
  

module.exports = router;

/**
 * @swagger
 * tags:
 *   name: Users
 *   description: User management and retrieval
 */

/**
 * @swagger
 * /users:
 *   post:
 *     summary: Create a user
 *     description: Only admins can create other users.
 *     tags: [Users]
 *     security:
 *       - bearerAuth: []
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             required:
 *               - name
 *               - email
 *               - password
 *               - role
 *             properties:
 *               name:
 *                 type: string
 *               email:
 *                 type: string
 *                 format: email
 *                 description: must be unique
 *               password:
 *                 type: string
 *                 format: password
 *                 minLength: 8
 *                 description: At least one number and one letter
 *               role:
 *                  type: string
 *                  enum: [user, admin]
 *             example:
 *               name: fake name
 *               email: fake@example.com
 *               password: password1
 *               role: user
 *     responses:
 *       "201":
 *         description: Created
 *         content:
 *           application/json:
 *             schema:
 *                $ref: '#/components/schemas/User'
 *       "400":
 *         $ref: '#/components/responses/DuplicateEmail'
 *       "401":
 *         $ref: '#/components/responses/Unauthorized'
 *       "403":
 *         $ref: '#/components/responses/Forbidden'
 *
 *   get:
 *     summary: Get all users
 *     description: Only admins can retrieve all users.
 *     tags: [Users]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: query
 *         name: name
 *         schema:
 *           type: string
 *         description: User name
 *       - in: query
 *         name: role
 *         schema:
 *           type: string
 *         description: User role
 *       - in: query
 *         name: sortBy
 *         schema:
 *           type: string
 *         description: sort by query in the form of field:desc/asc (ex. name:asc)
 *       - in: query
 *         name: limit
 *         schema:
 *           type: integer
 *           minimum: 1
 *         default: 10
 *         description: Maximum number of users
 *       - in: query
 *         name: page
 *         schema:
 *           type: integer
 *           minimum: 1
 *           default: 1
 *         description: Page number
 *     responses:
 *       "200":
 *         description: OK
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 results:
 *                   type: array
 *                   items:
 *                     $ref: '#/components/schemas/User'
 *                 page:
 *                   type: integer
 *                   example: 1
 *                 limit:
 *                   type: integer
 *                   example: 10
 *                 totalPages:
 *                   type: integer
 *                   example: 1
 *                 totalResults:
 *                   type: integer
 *                   example: 1
 *       "401":
 *         $ref: '#/components/responses/Unauthorized'
 *       "403":
 *         $ref: '#/components/responses/Forbidden'
 */

/**
 * @swagger
 * /users/{id}:
 *   get:
 *     summary: Get a user
 *     description: Logged in users can fetch only their own user information. Only admins can fetch other users.
 *     tags: [Users]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: string
 *         description: User id
 *     responses:
 *       "200":
 *         description: OK
 *         content:
 *           application/json:
 *             schema:
 *                $ref: '#/components/schemas/User'
 *       "401":
 *         $ref: '#/components/responses/Unauthorized'
 *       "403":
 *         $ref: '#/components/responses/Forbidden'
 *       "404":
 *         $ref: '#/components/responses/NotFound'
 *
 *   patch:
 *     summary: Update a user
 *     description: Logged in users can only update their own information. Only admins can update other users.
 *     tags: [Users]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: string
 *         description: User id
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               name:
 *                 type: string
 *               email:
 *                 type: string
 *                 format: email
 *                 description: must be unique
 *               password:
 *                 type: string
 *                 format: password
 *                 minLength: 8
 *                 description: At least one number and one letter
 *             example:
 *               name: fake name
 *               email: fake@example.com
 *               password: password1
 *     responses:
 *       "200":
 *         description: OK
 *         content:
 *           application/json:
 *             schema:
 *                $ref: '#/components/schemas/User'
 *       "400":
 *         $ref: '#/components/responses/DuplicateEmail'
 *       "401":
 *         $ref: '#/components/responses/Unauthorized'
 *       "403":
 *         $ref: '#/components/responses/Forbidden'
 *       "404":
 *         $ref: '#/components/responses/NotFound'
 *
 *   delete:
 *     summary: Delete a user
 *     description: Logged in users can delete only themselves. Only admins can delete other users.
 *     tags: [Users]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: string
 *         description: User id
 *     responses:
 *       "200":
 *         description: No content
 *       "401":
 *         $ref: '#/components/responses/Unauthorized'
 *       "403":
 *         $ref: '#/components/responses/Forbidden'
 *       "404":
 *         $ref: '#/components/responses/NotFound'
 */
