const mysql = require("mysql2");
const quizModuleList = (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_modules WHERE moduleId = ?`;  
      const values = req.query.module_id;
      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 = quizModuleList;