self-tester
Version:
A program for self-testing to memorse and test read material. It takes in an input file compraised of reading material arranged in lines, and each line is presented to you in from of Fill-in-the blank like questions.
45 lines (35 loc) • 1.18 kB
JavaScript
const flags = require('ray-flags');
const sucide = require('sucide');
if (flags.v) sucide('v1.0.5');
const {questionsHive} = require('./getArrayOfQuestions.js');
const {screen, box, showAnswerButton,
nextButton, defaultScreenContent} = require('./gui.js');
nextButton.on('click', function(data) {
currentQuestion.number++;
updateQuestion();
screen.render();
});
showAnswerButton.on('click', function(data) {
showAnswer();
screen.render();
});
let currentQuestion = {
number: 1,
};
updateQuestion(box, currentQuestion, questionsHive[currentQuestion.number-1].question);
function showAnswer() {
const oldText = box.getContent();
const newText = oldText + '\n\n'
+ `{center}Answer:{/center}` + '\n\n'
+ `{center}${questionsHive[currentQuestion.number-1].uncensord}{/center}`;
box.setContent(newText);
screen.render();
}
function updateQuestion() {
const newText = defaultScreenContent + '\n\n'
+ `{center}Question ${currentQuestion.number} out of ${questionsHive.length}{/center}`
+ '\n\n' + `{center}${questionsHive[currentQuestion.number -1].question}{/center}`;
box.setContent(newText);
screen.render();
}