update,
This commit is contained in:
65
task1/source/mobile/tools/01_gen_json.cjs
Executable file
65
task1/source/mobile/tools/01_gen_json.cjs
Executable file
@@ -0,0 +1,65 @@
|
||||
// TODO: no leak to customer
|
||||
const fs = require('fs');
|
||||
|
||||
const BASE_PATH = 'C:\\_carousell\\026_carry_on_quiz\\public\\data\\';
|
||||
|
||||
let lesson_categories = [
|
||||
{ name: 'vocabulary', path: 'vocabulary' },
|
||||
{ name: 'Connectives', path: 'connectives' }
|
||||
];
|
||||
|
||||
fs.writeFileSync('lesson_categories.json', JSON.stringify(lesson_categories));
|
||||
|
||||
let lesson_content = [
|
||||
{
|
||||
name: 'vocabulary',
|
||||
path: 'vocabulary',
|
||||
content: genDummyContent(['Technology', 'Art', 'Nature', 'Workplace', 'Sports', 'News'])
|
||||
},
|
||||
{
|
||||
name: 'connectives',
|
||||
path: 'connectives',
|
||||
content: genDummyContent(['Sequencing', 'Comparing', 'Time', 'Couse & Effect', 'Emphasizing', 'Making conclusion'])
|
||||
}
|
||||
];
|
||||
|
||||
fs.writeFileSync(BASE_PATH + 'Lesson\\content.json', JSON.stringify(lesson_content, null, 2));
|
||||
|
||||
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: `${first_letter_cat_name}_keyboard ${zfill_i}`,
|
||||
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>來打字`
|
||||
};
|
||||
}
|
||||
//
|
||||
//
|
||||
//
|
Reference in New Issue
Block a user