// TODO: no leak to customer
const fs = require('fs');

const BASE_PATH = 'C:\\_carousell\\026_carry_on_quiz\\public\\data\\';

let quiz_content = genDummyContent(['Technology', 'Art', 'Nature', 'Workplace', 'Sports', 'News']);

fs.writeFileSync(BASE_PATH + 'Quiz\\ListeningPractice\\content.json', JSON.stringify(quiz_content, null, 2));

function genDummyContent(item_list) {
  return item_list.map(cat_name => {
    let content = [];

    let sample_word = genSampleWord;
    let n = Math.floor(Math.random() * (10 - 3 + 1)) + 3;
    for (let i = n; i > 1; i--) {
      content.push({ ...sample_word(i, cat_name) });
    }

    return {
      cat_name,
      cat_image: 'https://docs-demo.ionic.io/assets/madison.jpg',
      content
    };
  });
}

function genSampleWord(i, cat_name) {
  i = Math.max(i, 1);
  let zfill_i = (i + 1000).toString().substr(1, 2);
  let first_letter_cat_name = cat_name.charAt(0);
  return {
    image: `https://docs-demo.ionic.io/assets/madison.jpg`,
    sound: `/helloworld.mp3`,
    word: `keyboard`,
    word_c: `${first_letter_cat_name}_鍵盤 ${zfill_i}`,
    sample_e: `${first_letter_cat_name}_I buy a keyboard to type ${zfill_i}`,
    sample_c: `${first_letter_cat_name}_我買了一個<span className='bold'>鍵盤</span>來打字`
  };
}
//
//
//
