// let BASE_DIR = './data'; let BASE_DIR = 'https://github.com/csbench/csbench.github.io'; function create_number(data) { let question = make_qt(data.question, data.unit); // let hint = make_hint(data.hint) let image = ""; if (data.image !== -1) // image = make_img(`${BASE_DImetadataR}/${filters.dataset}/${data.image}`); image = make_img(`${BASE_DIR}/${data.image}`); let choices = ""; if (data.question_type === "multi_choice") choices = make_choices(data.choices); // if data has the answer attr. let answer = ""; if ("answer" in data) answer = make_answer(data.answer); html = make_box([question, image, choices, answer]); return html; } // creates a div with question text in it function make_qt(question, unit) { let html = ""; if (unit === null) html = `

Question

${question}

`; else html = `

Question

${question} (unit: ${unit})

`; return html; } function make_img(path) { if (path === null) return ""; let html = `number image`; return html; } function make_box(contents, cls = "") { if (contents.join("").length === 0) return ""; let html = `
${contents.join(" ")}
`; return html; } function make_choices(choices) { // console.log(choices); let temp = ""; let len = 0; for (each of choices) { let html = make_choice(each); temp += html; len += each.length; } let html = ""; if (len < 60) html = `

Choices

${temp}
`; else html = `

Choices

${temp}
`; return html; } function make_choice(choice) { let html = `

${choice}

`; return html; } function make_answer(answer) { let html = `

Answer

${answer}

`; return html; }