text: const fs = require("fs");
  
  const checkDirectory = (quizId) => {
      if (!fs.existsSync(`img/quiz`)) {
          fs.mkdirSync(`img/quiz`);
      }
      if (!fs.existsSync(`img/quiz/${quizId}`)) {
          fs.mkdirSync(`img/quiz/${quizId}`);
          return false;
      }
      return true;
  }
  
  const generate_solve_quiz = (quiz_obj, images_obj) => {
      result = "";
      var readImages = false;
      var question_counter = 1;
  
      for (const question of quiz_obj.questions) {
          var odpowiedziDOMS = "";
          var litery = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
          var odpowiedzi = question[0].answers;
          var kody = question[0].answerCodes;
          for (var i = 0; i < odpowiedzi.length; i++) {
              odpowiedzi[i] = {
                  answer: odpowiedzi[i],
                  code: kody[i]
              }
          }
          odpowiedzi = odpowiedzi.sort((a, b) => 0.5 - Math.random());
          for (var i = 0; i < odpowiedzi.length; i++) {
              odpowiedzi[i].answer = `${litery[i]}. ${odpowiedzi[i].answer}`;
          }
          for (var i = 0; i < odpowiedzi.length; i++) {
              odpowiedziDOMS += `<div class="answer" data-code="${odpowiedzi[i].code}" onclick="selectAnswer(this)">${odpowiedzi[i].answer}</div>`
          }
  
          var image = "";
          if (question[0].placeholder == false) {
              imagePath = `img/quiz/${quiz_obj.siteId}/${question_counter}.jpg`;
              if(!checkDirectory(quiz_obj.siteId)) readImages = true;
              if (readImages) {
                  var baseData = images_obj.images[question_counter - 1];
                  // console.log(baseData);
                  fs.writeFile(imagePath, baseData, 'base64', (e) => {
                      console.log(e);
                  });
              }
              image = `quiz/${quiz_obj.siteId}/${question_counter}.jpg`;
          }
          else image = "placeholder1.png"
  
          questionDOM = 
          `
          <div class="questions-column">
              <div class="question">
                  <div class="question-title">
                      ${question[0].question}
                  </div>
                  <div class="question-image">
                      <div class="image-box">
                          <img src="/img/${image}" alt="placeholder">
                      </div>
                  </div>
                  <div class="question-answers" data-question="${question_counter}">
                      ${odpowiedziDOMS}
                  </div>
              </div>
          </div>
          `;
          question_counter++;
          result += questionDOM;
      }
      return result;
  }
  
  module.exports = generate_solve_quiz;