const mysql = require("mysql2");
const quizzesScore = (req, res) => {
    // res.send(req.query.doa); //get
    // res.send(req.body.doa);  //post

    const connection = mysql.createConnection({
      host: process.env.MARIA_HOST,
      user: process.env.MARIA_USER,
      password: process.env.MARIA_PASS,
      database: process.env.MARIA_DBNM
    });
  
      connection.connect((err) => {
        if(err) {
            console.error('Error connecting to the database:', err);
            return;
        }
          console.log('Connected to the MariaDB database.');
        });
  
        const data = req.body;
  
        const query = `SELECT * FROM quiz_score`;  
        connection.query(query, (err, results) => {
            if (err) {
            console.error('Error inserting data:', err);
            res.status(500).send('Internal Server Error');
            return;
            }
            res.status(200).json(results);
        });

  };
  
  module.exports = quizzesScore;


















// let quizData = [
//     {
//       quizId: 1,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 1",
//       percentage: "60"
//     },
//     {
//       quizId: 2,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 2",
//       percentage: "75"
//     },
//     {
//       quizId: 3,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 3",
//       percentage: "80"
//     },
//     {
//       quizId: 4,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 4",
//       percentage: "65"
//     },
//     {
//       quizId: 5,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 5",
//       percentage: "70"
//     },
//     {
//       quizId: 6,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 6",
//       percentage: "85"
//     },
//     {
//       quizId: 7,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 7",
//       percentage: "90"
//     },
//     {
//       quizId: 8,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 8",
//       percentage: "95"
//     },
//     {
//       quizId: 9,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 9",
//       percentage: "88"
//     },
//     {
//       quizId: 10,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 10",
//       percentage: "92"
//     },
//     {
//       quizId: 11,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 11",
//       percentage: "77"
//     },
//     {
//       quizId: 12,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 12",
//       percentage: "82"
//     },
//     {
//       quizId: 13,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 13",
//       percentage: "68"
//     },
//     {
//       quizId: 14,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 14",
//       percentage: "73"
//     },
//     {
//       quizId: 15,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 15",
//       percentage: "79"
//     },
//     {
//       quizId: 16,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 16",
//       percentage: "87"
//     },
//     {
//       quizId: 17,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 17",
//       percentage: "93"
//     },
//     {
//       quizId: 18,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 18",
//       percentage: "67"
//     },
//     {
//       quizId: 19,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 19",
//       percentage: "89"
//     },
//     {
//       quizId: 20,
//       quizType: "AI Quiz",
//       quizName: "Assessment on Special Education - 20",
//       percentage: "91"
//     }
// ]
// res.json(quizData);