check_answer = attemptObj => {
let [key, attempt] = Object.entries(attemptObj)[0];
let result;
if (attempt === undefined) {
return html`${incorrect(key)}`;
}
let answer = answers[key];
if (typeof attempt.objects === "function") attempt = attempt.objects();
if (attempt instanceof Date) attempt = attempt.toISOString();
if (answer instanceof Date) answer = answer.toISOString();
if (Array.isArray(answer)) {
if (attempt[0] instanceof Date) {
attempt = attempt.map(d => d.toISOString());
}
if (answer[0] instanceof Date) {
answer = answer.map(d => d.toISOString());
}
result = arrays_are_equal(attempt, answer);
} else {
result = attempt === answer;
}
return html`${result ? correct(key) : incorrect(key)}`;
}