-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
176 lines (164 loc) · 9.29 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
var inquirer = require("inquirer");
var choiceAmt = 0;
var count = 0;
var game = 0;
var score = 0;
var questions = [];
var questions2 = [];
var answers = [];
phaseOne();
function BasicCard(front, back) {
this.front = front;
this.back = back;
};
function ClozeCard(questionCloze, answer) {
this.questionCloze = questionCloze;
this.answer = answer;
};
function phaseOne() {
inquirer.prompt([{
name: "howMany",
type: "input",
message: "How many cards would you like to create? (Max: 10)",
validate: function(value) {
if (isNaN(value) === false && parseInt(value) > 0 && parseInt(value) <= 10) {
return true;
}
return false;
}
}]).then(function(initialPhase) {
choiceAmt = initialPhase.howMany;
phaseTwo();
});
}
function phaseTwo() {
inquirer.prompt([{
name: "whatType",
message: "What type of flashcard would you like generated?",
type: "rawlist",
choices: ["Basic", "Cloze"]
}]).then(function(setupPhase) {
console.log(setupPhase.whatType + " chosen. Intializing. . .");
if (setupPhase.whatType === "Basic") {
phaseThreeBasic();
} else if (setupPhase.whatType === "Cloze") {
phaseThreeCloze();
}
});
}
function phaseThreeBasic() {
if (count < choiceAmt) {
inquirer.prompt([{
name: "frontQuestion",
type: "input",
message: "Please input the question for the flashcard's front side."
}, {
name: "backAnswer",
type: "input",
message: "Please input the answer for the flashcard's back side."
}]).then(function(basic) {
var basicQues = new BasicCard(basic.frontQuestion, basic.backAnswer);
count++;
questions.push(basic.frontQuestion);
answers.push(basic.backAnswer);
console.log(questions);
console.log("================")
console.log("================")
console.log("================")
console.log(answers);
phaseThreeBasic();
})
} else if (count == choiceAmt) {
console.log("All questions have been made!")
basicCardInit();
}
}
function basicCardInit() {
if (game < choiceAmt) {
inquirer.prompt([{
name: "answerHere",
type: "input",
message: questions[game]
}]).then(function(answerBasic) {
if (answerBasic.answerHere === answers[game]) {
console.log("Correct!" + "\n" + "The answer is: " + answers[game]);
score++;
} else {
console.log("Incorrect!" + "\n" + "The answer is: " + answers[game]);
}
game++;
basicCardInit();
});
} else {
console.log("You got " + score + " out of " + count + " correct!")
console.log('\x1b[5m' + "░░░░" + '\x1b[46m' + "█▐▄▒▒▒▌▌▒▒▌" + '\x1b[0m\x1b[5m' + "░" + '\x1b[46m' + "▌▒▐" + '\x1b[0m\x1b[5m' + "▐" + '\x1b[46m' + "▐▒▒▐▒▒▌▒▀▄▀▄" + '\x1b[0m\x1b[5m' + "░")
console.log('\x1b[5m' + "░░░" + '\x1b[46m' + "█▐▒▒▀▀▌" + '\x1b[0m\x1b[5m' + "░" + '\x1b[46m' + "▀▀▀" + '\x1b[0m\x1b[5m' + "░░" + '\x1b[46m' + "▀▀▀" + '\x1b[0m\x1b[5m' + "░░" + '\x1b[46m' + "▀▀▄▌▌▐▒▒▒▌▐" + '\x1b[0m\x1b[5m' + "░")
console.log('\x1b[5m' + "░░" + '\x1b[46m' + "▐▒▒▀▀▄▐" + '\x1b[0m\x1b[5m' + "░▀▀▄▄░░░░░░░░░░░" + '\x1b[46m' + "▐▒▌▒▒▐" + '\x1b[0m\x1b[5m' + "░" + '\x1b[46m' + "▌" + '\x1b[0m\x1b[5m' + "")
console.log('\x1b[5m' + "░░" + '\x1b[46m' + "▐▒▌▒▒▒▌" + '\x1b[0m\x1b[5m' + "░▄▄▄▄█▄░░░░░░░▄▄▄" + '\x1b[46m' + "▐▐▄▄▀" + '\x1b[0m\x1b[5m' + "░░")
console.log('\x1b[5m' + "░░" + '\x1b[46m' + "▌▐▒▒▒▐" + '\x1b[0m\x1b[5m' + "░░░░░░░░░░░░░▀█▄░░░░▌▌░░░")
console.log('\x1b[5m' + "" + '\x1b[46m' + "▄▀▒▒▌▒▒▐" + '\x1b[0m\x1b[5m' + "░░░░░░░" + '\x1b[31m' + "▄" + '\x1b[0m\x1b[5m' + "░░" + '\x1b[31m' + "▄" + '\x1b[0m\x1b[5m' + "░░░░░▀▀░░▌▌░░░")
console.log('\x1b[5m' + "" + '\x1b[46m' + "▄▄▀▒▐▒▒▐" + '\x1b[0m\x1b[5m' + "░░░░░░░" + '\x1b[31m' + "▐▀▀▀▄▄▀" + '\x1b[0m\x1b[5m' + "░░░░░░▌▌░░░")
console.log('\x1b[5m' + "░░░░" + '\x1b[46m' + "█▌▒▒▌" + '\x1b[0m\x1b[5m' + "░░░░░" + '\x1b[31m' + "▐▒▒▒▒▒▌" + '\x1b[0m\x1b[5m' + "░░░░░░▐▐▒▀▀▄")
console.log('\x1b[5m' + "░░" + '\x1b[46m' + "▄▀▒▒▒▒▐" + '\x1b[0m\x1b[5m' + "░░░░░" + '\x1b[31m' + "▐▒▒▒▒▐" + '\x1b[0m\x1b[5m' + "░░░░░▄█▄▒▐▒▒▒")
console.log('\x1b[5m' + "" + '\x1b[46m' + "▄▀▒▒▒▒▒▄██▀▄▄" + '\x1b[0m\x1b[5m' + "░░" + '\x1b[31m' + "▀▄▄▀" + '\x1b[0m\x1b[5m' + "░░▄▄▀█▄░█▀▒▒▒▒" + '\x1b[0m')
}
}
function phaseThreeCloze() {
if (count < choiceAmt) {
inquirer.prompt([{
name: "clozeQuestion",
type: "input",
message: "Please input the entire statement which includes the question and the answer in one argument."
}, {
name: "clozePortion",
type: "input",
message: "Please input the answer to the statement that will be partitioned for flashcard generation."
}]).then(function(cloze) {
var ClozeQues = new ClozeCard(cloze.clozeQuestion, cloze.clozePortion);
questions2.push(cloze.clozeQuestion);
count++;
var a = cloze.clozeQuestion.replace(cloze.clozePortion, "...")
questions.push(a);
answers.push(cloze.clozePortion);
console.log(questions);
console.log("================")
console.log("================")
console.log("================")
console.log(answers);
phaseThreeCloze();
})
} else if (count == choiceAmt) {
console.log("All questions have been made!")
clozeCardInit();
}
}
function clozeCardInit() {
if (game < choiceAmt) {
inquirer.prompt([{
name: "answerCl",
type: "input",
message: questions[game]
}]).then(function(answerCloze) {
if (answerCloze.answerCl === answers[game]) {
console.log("Correct!" + "\n" + "The answer is: " + questions2[game]);
score++;
} else {
console.log("Incorrect!");
}
game++;
clozeCardInit();
});
} else {
console.log("You got " + score + " out of " + count + " correct!")
console.log('\x1b[5m' + "░░░░" + '\x1b[46m' + "█▐▄▒▒▒▌▌▒▒▌" + '\x1b[0m\x1b[5m' + "░" + '\x1b[46m' + "▌▒▐" + '\x1b[0m\x1b[5m' + "▐" + '\x1b[46m' + "▐▒▒▐▒▒▌▒▀▄▀▄" + '\x1b[0m\x1b[5m' + "░")
console.log('\x1b[5m' + "░░░" + '\x1b[46m' + "█▐▒▒▀▀▌" + '\x1b[0m\x1b[5m' + "░" + '\x1b[46m' + "▀▀▀" + '\x1b[0m\x1b[5m' + "░░" + '\x1b[46m' + "▀▀▀" + '\x1b[0m\x1b[5m' + "░░" + '\x1b[46m' + "▀▀▄▌▌▐▒▒▒▌▐" + '\x1b[0m\x1b[5m' + "░")
console.log('\x1b[5m' + "░░" + '\x1b[46m' + "▐▒▒▀▀▄▐" + '\x1b[0m\x1b[5m' + "░▀▀▄▄░░░░░░░░░░░" + '\x1b[46m' + "▐▒▌▒▒▐" + '\x1b[0m\x1b[5m' + "░" + '\x1b[46m' + "▌" + '\x1b[0m\x1b[5m' + "")
console.log('\x1b[5m' + "░░" + '\x1b[46m' + "▐▒▌▒▒▒▌" + '\x1b[0m\x1b[5m' + "░▄▄▄▄█▄░░░░░░░▄▄▄" + '\x1b[46m' + "▐▐▄▄▀" + '\x1b[0m\x1b[5m' + "░░")
console.log('\x1b[5m' + "░░" + '\x1b[46m' + "▌▐▒▒▒▐" + '\x1b[0m\x1b[5m' + "░░░░░░░░░░░░░▀█▄░░░░▌▌░░░")
console.log('\x1b[5m' + "" + '\x1b[46m' + "▄▀▒▒▌▒▒▐" + '\x1b[0m\x1b[5m' + "░░░░░░░" + '\x1b[31m' + "▄" + '\x1b[0m\x1b[5m' + "░░" + '\x1b[31m' + "▄" + '\x1b[0m\x1b[5m' + "░░░░░▀▀░░▌▌░░░")
console.log('\x1b[5m' + "" + '\x1b[46m' + "▄▄▀▒▐▒▒▐" + '\x1b[0m\x1b[5m' + "░░░░░░░" + '\x1b[31m' + "▐▀▀▀▄▄▀" + '\x1b[0m\x1b[5m' + "░░░░░░▌▌░░░")
console.log('\x1b[5m' + "░░░░" + '\x1b[46m' + "█▌▒▒▌" + '\x1b[0m\x1b[5m' + "░░░░░" + '\x1b[31m' + "▐▒▒▒▒▒▌" + '\x1b[0m\x1b[5m' + "░░░░░░▐▐▒▀▀▄")
console.log('\x1b[5m' + "░░" + '\x1b[46m' + "▄▀▒▒▒▒▐" + '\x1b[0m\x1b[5m' + "░░░░░" + '\x1b[31m' + "▐▒▒▒▒▐" + '\x1b[0m\x1b[5m' + "░░░░░▄█▄▒▐▒▒▒")
console.log('\x1b[5m' + "" + '\x1b[46m' + "▄▀▒▒▒▒▒▄██▀▄▄" + '\x1b[0m\x1b[5m' + "░░" + '\x1b[31m' + "▀▄▄▀" + '\x1b[0m\x1b[5m' + "░░▄▄▀█▄░█▀▒▒▒▒" + '\x1b[0m')
}
}