1
Fork 0

javascript(quizizz-hack): feat: image support

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2020-11-05 10:03:31 +02:00 committed by prescientmoon
parent 9de9482700
commit d886691a80
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4

View file

@ -42,7 +42,10 @@ function parseQuestions(fileObject) {
answer = question.structure.options.map((o) => removeTags(o.text)); answer = question.structure.options.map((o) => removeTags(o.text));
} }
const questionStr = removeTags(question.structure.query.text); const questionStr =
question.structure.query.text === ""
? question.structure.query.media[0].url
: removeTags(question.structure.query.text);
allAnswers[questionStr] = answer; allAnswers[questionStr] = answer;
} }
@ -65,6 +68,8 @@ async function main(id) {
const sorted = Object.entries(answers).sort(); const sorted = Object.entries(answers).sort();
console.log(answers);
render(renderQuestions(sorted), rootElement); render(renderQuestions(sorted), rootElement);
} }
@ -77,13 +82,15 @@ inputElement.addEventListener("keypress", (e) => {
} }
}); });
console.log("here");
const renderQuestions = (questions) => { const renderQuestions = (questions) => {
return html`${questions.map(([question, answer]) => { return html`${questions.map(([question, answer]) => {
return html` return html`
<div class="question-container"> <div class="question-container">
<div class="question">${question}</div> <div class="question">
${question.startsWith("http")
? html`<img src=${question} />`
: question}
</div>
${Array.isArray(answer) ${Array.isArray(answer)
? html` ? html`
<ul> <ul>