function buildLearnEntry(term, definition, oncontinue) {
let html = `
${term}
${definition}
`
let obj = htmlToObj(html);
obj.querySelector('button').onclick = oncontinue;
return obj;
}
function buildMCEntry(term, definition, answers, onanswer) {
let html = `
${term}
`
let obj = htmlToObj(html);
let buttons = obj.querySelectorAll('.mc-answers > button');
buttons.forEach((button, index) => {
button.onclick = () => {
onanswer(index);
}
});
return obj;
}
function buildMasteryEntry(term, onanswer, onhint, trainMode=false) {
let html = `
${term}
`
let obj = htmlToObj(html);
obj.querySelector('#submit').onclick = () => {
onanswer(obj.querySelector('#mastery-input').value);
}
obj.querySelector('#hint').onclick = () => {
onhint(obj.querySelector('#mastery-input').value);
}
obj.querySelector('#mastery-input').onkeypress = (e) => {
if (e.key === 'Enter') {
onanswer(obj.querySelector('#mastery-input').value);
}
}
if (trainMode){
obj.querySelector('#hint').style.display = "none";
}
return obj;
}
function buildCompletionEntry(study_mode, oncontinue, onreset) {
let html = `
${study_mode} Complete!
You've completed ${study_mode}. You can continue with random questions or reset your progress and start over.
`
let obj = htmlToObj(html);
obj.querySelector('#continue').onclick = oncontinue;
obj.querySelector('#reset').onclick = onreset;
return obj;
}
function buildTrainCompletionEntry(){
let html = `
${study_mode} Complete!
You've completed ${study_mode}. You can reset your progress and start over, or return to the Studysheet page.
`
let obj = htmlToObj(html);
let url = window.location.href;
url = url.split("/")
let strurl = ""
for (let i = 0; i < url.length-1; i++){
strurl+=url[i]+'/';
}
strurl+="view"
obj.querySelector('#continue').onclick = `window.location.href=${strurl}`;
//obj.querySelector('#reset').onclick;
return obj;
}