Add more question types
This commit is contained in:
parent
bb20d1b56a
commit
e6fb123eb7
2 changed files with 18 additions and 9 deletions
|
|
@ -141,8 +141,9 @@ async function ajaxLoad(type) {
|
||||||
// its correct answer, and report whether they got it right.
|
// its correct answer, and report whether they got it right.
|
||||||
function gradeQuestion(question) {
|
function gradeQuestion(question) {
|
||||||
var div = "#feladat" + question.id;
|
var div = "#feladat" + question.id;
|
||||||
var selected = `#question-${question.id}-answer-${question.correct}`;
|
var isCorrect = getAcceptedAnswers(question).some(function (answer) {
|
||||||
var isCorrect = $(selected).is(":checked");
|
return $(`#question-${question.id}-answer-${answer}`).is(":checked");
|
||||||
|
});
|
||||||
$(div).animate({ backgroundColor: isCorrect ? "#C6FF8C" : "#FF808C" }, 1100);
|
$(div).animate({ backgroundColor: isCorrect ? "#C6FF8C" : "#FF808C" }, 1100);
|
||||||
return isCorrect;
|
return isCorrect;
|
||||||
}
|
}
|
||||||
|
|
@ -183,11 +184,13 @@ function showCorrect() {
|
||||||
reviewMode = 1;
|
reviewMode = 1;
|
||||||
var percentage = scoreLoadedQuestions();
|
var percentage = scoreLoadedQuestions();
|
||||||
loadedQuestions.forEach(function (question) {
|
loadedQuestions.forEach(function (question) {
|
||||||
$(`label[for="question-${question.id}-answer-${question.correct}"]`).css(
|
getAcceptedAnswers(question).forEach(function (answer) {
|
||||||
|
$(`label[for="question-${question.id}-answer-${answer}"]`).css(
|
||||||
"background-color",
|
"background-color",
|
||||||
"#C6FF8C",
|
"#C6FF8C",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
$("#percentage").html("Eredmény: " + percentage + "%");
|
$("#percentage").html("Eredmény: " + percentage + "%");
|
||||||
$("#state").html("Helyes válaszok bejelölve!");
|
$("#state").html("Helyes válaszok bejelölve!");
|
||||||
$("#state2").show();
|
$("#state2").show();
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,10 @@ const QUESTION_COUNT_ERROR = `A feladatok mennyisége 1 és ${MAX_TOPIC_QUESTION
|
||||||
const isValidQuestionCount = (count) =>
|
const isValidQuestionCount = (count) =>
|
||||||
Number.isInteger(count) && count >= 1 && count <= MAX_TOPIC_QUESTIONS;
|
Number.isInteger(count) && count >= 1 && count <= MAX_TOPIC_QUESTIONS;
|
||||||
|
|
||||||
|
// Some official keys accept several choices, including withdrawn questions.
|
||||||
|
const getAcceptedAnswers = (question) =>
|
||||||
|
(question.acceptedAnswers || [question.correct]).map(Number);
|
||||||
|
|
||||||
// Auto-detect API base URL
|
// Auto-detect API base URL
|
||||||
const getApiBase = () => {
|
const getApiBase = () => {
|
||||||
const protocol = window.location.protocol;
|
const protocol = window.location.protocol;
|
||||||
|
|
@ -91,9 +95,10 @@ const loadQuestions = async (
|
||||||
// click handler; those were never removed, so they piled up across loads and
|
// click handler; those were never removed, so they piled up across loads and
|
||||||
// ended up grading stale (already-removed) questions, saving bogus 0%
|
// ended up grading stale (already-removed) questions, saving bogus 0%
|
||||||
// results over the user's history.
|
// results over the user's history.
|
||||||
loadedQuestions = currentQuestions.map(({ id, correct }) => ({
|
loadedQuestions = currentQuestions.map((question) => ({
|
||||||
id: Number(id),
|
id: Number(question.id),
|
||||||
correct: Number(correct),
|
correct: Number(question.correct),
|
||||||
|
acceptedAnswers: getAcceptedAnswers(question),
|
||||||
}));
|
}));
|
||||||
totalPoints = loadedQuestions.length;
|
totalPoints = loadedQuestions.length;
|
||||||
|
|
||||||
|
|
@ -326,6 +331,7 @@ const getMonthLabel = (monthValue) => {
|
||||||
const knownLabels = {
|
const knownLabels = {
|
||||||
1: "Május-Június",
|
1: "Május-Június",
|
||||||
"1ma": "Május-Június (magyar, mint idegen nyelv)",
|
"1ma": "Május-Június (magyar, mint idegen nyelv)",
|
||||||
|
"2ma": "Május-Június (idegen nyelvű vizsga magyar változata)",
|
||||||
2: "Október-November",
|
2: "Október-November",
|
||||||
3: "Harmadik időszak",
|
3: "Harmadik időszak",
|
||||||
m1: "1. Mintafeladatsor",
|
m1: "1. Mintafeladatsor",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue