Last active
December 16, 2021 13:46
-
-
Save thanhdatpd/f81df050231672d234cd45770e9175b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.clear(); | |
| all = ""; | |
| allQuesAndAns= ""; | |
| replaceHTMLesc = (instr)=>{ | |
| return instr.replaceAll(""", "\"") | |
| .replaceAll("</br>", "\n") | |
| .replaceAll("&", "") | |
| .replaceAll("<", "") | |
| .replaceAll(">", '') | |
| .replaceAll(""","" ) | |
| .replaceAll("'",'' ) | |
| .replaceAll("<", "<") | |
| .replaceAll(">", ">") | |
| } | |
| copyToClipboard = (text)=> { | |
| var dummy = document.createElement("textarea"); | |
| document.body.appendChild(dummy); | |
| dummy.value = text; | |
| dummy.select(); | |
| document.execCommand("copy"); | |
| document.body.removeChild(dummy); | |
| } | |
| if (initState.quiz?.quiz_content) { | |
| for (part of initState.quiz.quiz_content) { | |
| for (ques of part.array_question) { | |
| let { question, array_answer } = ques; | |
| let ans = array_answer.filter(e => e.correct)?.[0]?.answer | |
| all += `${question} \n ${ans} \n` | |
| let allans = array_answer.map(e=>e.correct?`*${e.answer}`:e.answer); | |
| allans = allans.join("\n"); | |
| allQuesAndAns += `${question} \n ${allans}\n\n` | |
| } | |
| } | |
| } else { | |
| for (let i = 0; i < initState.quiz.questions.length; i++) { | |
| let q = initState.quiz.questions[i]; | |
| let title = q.title | |
| let rightAns = q.answers.filter(e => e.is_correct===1)?.[0]?.option | |
| all += `${title} \n\t${rightAns} \n` | |
| let allans = q.answers.map(e=>e.is_correct?`*${e.option}`:e.option); | |
| allans = allans.join("\n"); | |
| allQuesAndAns += `${title} \n ${allans}\n\n` | |
| } | |
| } | |
| getAnsOnly = () => replaceHTMLesc(all) | |
| getAns = () => replaceHTMLesc(allQuesAndAns) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment