Spaces:
Running
Running
Update index.html
Browse files- index.html +51 -12
index.html
CHANGED
@@ -19,6 +19,30 @@
|
|
19 |
.answer-btn:hover{background:#005a9e;color:#f0f0f0}
|
20 |
.answer-btn.disabled{background:#ccc;color:#666;cursor:not-allowed}
|
21 |
.feedback{margin-top:10px;font-size:18px;font-weight:bold}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
</style>
|
23 |
</head>
|
24 |
<body>
|
@@ -42,7 +66,7 @@
|
|
42 |
"Functions"
|
43 |
];
|
44 |
|
45 |
-
//
|
46 |
const questions = [
|
47 |
// Variables & Data Structures
|
48 |
[
|
@@ -173,9 +197,11 @@
|
|
173 |
return arr;
|
174 |
})();
|
175 |
|
176 |
-
//
|
177 |
-
const
|
178 |
|
|
|
|
|
179 |
function qIndex(category, difficulty) {
|
180 |
return category * 3 + difficulty; // 0..14
|
181 |
}
|
@@ -198,7 +224,7 @@
|
|
198 |
|
199 |
const q = questions[category][difficulty];
|
200 |
const baseChoices = q.a.slice(); // already length 3
|
201 |
-
const origCorrect = q.correct;
|
202 |
|
203 |
// Start with a random permutation
|
204 |
const idxs = [0, 1, 2];
|
@@ -211,7 +237,6 @@
|
|
211 |
const targetPos = correctPositions[qIndex(category, difficulty)];
|
212 |
const currentPosOfCorrect = idxs.indexOf(origCorrect);
|
213 |
if (currentPosOfCorrect !== targetPos) {
|
214 |
-
// swap positions
|
215 |
const swapIdx = idxs[targetPos];
|
216 |
idxs[targetPos] = origCorrect;
|
217 |
idxs[currentPosOfCorrect] = swapIdx;
|
@@ -220,7 +245,11 @@
|
|
220 |
const choices = idxs.map(i => baseChoices[i]);
|
221 |
const correctIndex = targetPos;
|
222 |
|
223 |
-
|
|
|
|
|
|
|
|
|
224 |
questionMeta.set(key, meta);
|
225 |
return meta;
|
226 |
}
|
@@ -229,17 +258,26 @@
|
|
229 |
if (cardElement.classList.contains("disabled")) return;
|
230 |
|
231 |
const q = questions[category][difficulty];
|
232 |
-
const
|
|
|
|
|
|
|
|
|
|
|
233 |
|
234 |
const answerHtml = choices
|
235 |
-
.map((answer,
|
236 |
-
`<button class="answer-btn" onclick="checkAnswer(${category}, ${difficulty}, ${
|
237 |
)
|
238 |
.join("");
|
239 |
|
|
|
|
|
|
|
240 |
questionDisplay.innerHTML = `
|
241 |
-
|
242 |
-
<
|
|
|
243 |
<div class="answer-container">${answerHtml}</div>`;
|
244 |
|
245 |
cardElement.classList.add("disabled");
|
@@ -251,7 +289,8 @@
|
|
251 |
const key = `${category}-${difficulty}`;
|
252 |
const meta = questionMeta.get(key);
|
253 |
const isCorrect = selectedIndex === meta.correctIndex;
|
254 |
-
const
|
|
|
255 |
|
256 |
document.querySelectorAll(".answer-btn").forEach(btn => {
|
257 |
btn.disabled = true;
|
|
|
19 |
.answer-btn:hover{background:#005a9e;color:#f0f0f0}
|
20 |
.answer-btn.disabled{background:#ccc;color:#666;cursor:not-allowed}
|
21 |
.feedback{margin-top:10px;font-size:18px;font-weight:bold}
|
22 |
+
|
23 |
+
/* Bigger, clearer question text */
|
24 |
+
.question-text{
|
25 |
+
font-size: 24px;
|
26 |
+
line-height: 1.5;
|
27 |
+
text-align: left;
|
28 |
+
background:#fff;
|
29 |
+
border:1px solid #ddd;
|
30 |
+
padding:14px;
|
31 |
+
border-radius:8px;
|
32 |
+
white-space:pre-wrap;
|
33 |
+
}
|
34 |
+
|
35 |
+
/* Daily Double flair */
|
36 |
+
.dd-badge{
|
37 |
+
display:inline-block;
|
38 |
+
margin-bottom:10px;
|
39 |
+
padding:6px 12px;
|
40 |
+
font-weight:bold;
|
41 |
+
border-radius:999px;
|
42 |
+
border:2px solid #ff9800;
|
43 |
+
color:#ff9800;
|
44 |
+
background:#fff6e6;
|
45 |
+
}
|
46 |
</style>
|
47 |
</head>
|
48 |
<body>
|
|
|
66 |
"Functions"
|
67 |
];
|
68 |
|
69 |
+
// Clean, verified Q&A set (3 choices each)
|
70 |
const questions = [
|
71 |
// Variables & Data Structures
|
72 |
[
|
|
|
197 |
return arr;
|
198 |
})();
|
199 |
|
200 |
+
// 🎯 DAILY DOUBLE: pick exactly one card index (0..14)
|
201 |
+
const dailyDoubleIndex = Math.floor(Math.random() * totalCards);
|
202 |
|
203 |
+
// Memo for per-question permuted choices
|
204 |
+
const questionMeta = new Map(); // "c-d" -> { choices:[...3], correctIndex, isDailyDouble, valueMultiplier }
|
205 |
function qIndex(category, difficulty) {
|
206 |
return category * 3 + difficulty; // 0..14
|
207 |
}
|
|
|
224 |
|
225 |
const q = questions[category][difficulty];
|
226 |
const baseChoices = q.a.slice(); // already length 3
|
227 |
+
const origCorrect = q.correct;
|
228 |
|
229 |
// Start with a random permutation
|
230 |
const idxs = [0, 1, 2];
|
|
|
237 |
const targetPos = correctPositions[qIndex(category, difficulty)];
|
238 |
const currentPosOfCorrect = idxs.indexOf(origCorrect);
|
239 |
if (currentPosOfCorrect !== targetPos) {
|
|
|
240 |
const swapIdx = idxs[targetPos];
|
241 |
idxs[targetPos] = origCorrect;
|
242 |
idxs[currentPosOfCorrect] = swapIdx;
|
|
|
245 |
const choices = idxs.map(i => baseChoices[i]);
|
246 |
const correctIndex = targetPos;
|
247 |
|
248 |
+
// Daily Double flag and value multiplier for this card
|
249 |
+
const isDD = qIndex(category, difficulty) === dailyDoubleIndex;
|
250 |
+
const valueMultiplier = isDD ? 2 : 1;
|
251 |
+
|
252 |
+
const meta = { choices, correctIndex, isDailyDouble: isDD, valueMultiplier };
|
253 |
questionMeta.set(key, meta);
|
254 |
return meta;
|
255 |
}
|
|
|
258 |
if (cardElement.classList.contains("disabled")) return;
|
259 |
|
260 |
const q = questions[category][difficulty];
|
261 |
+
const idx = qIndex(category, difficulty);
|
262 |
+
const { choices, isDailyDouble } = prepareChoices(category, difficulty);
|
263 |
+
|
264 |
+
const ddBadge = isDailyDouble
|
265 |
+
? `<div class="dd-badge">🔥 DAILY DOUBLE!</div>`
|
266 |
+
: "";
|
267 |
|
268 |
const answerHtml = choices
|
269 |
+
.map((answer, idxChoice) =>
|
270 |
+
`<button class="answer-btn" onclick="checkAnswer(${category}, ${difficulty}, ${idxChoice})">${answer}</button>`
|
271 |
)
|
272 |
.join("");
|
273 |
|
274 |
+
const value = (difficulty + 1) * 100;
|
275 |
+
const displayValue = isDailyDouble ? value * 2 : value;
|
276 |
+
|
277 |
questionDisplay.innerHTML = `
|
278 |
+
${ddBadge}
|
279 |
+
<h2>${categories[category]} for $${displayValue}</h2>
|
280 |
+
<div class="question-text">${q.q}</div>
|
281 |
<div class="answer-container">${answerHtml}</div>`;
|
282 |
|
283 |
cardElement.classList.add("disabled");
|
|
|
289 |
const key = `${category}-${difficulty}`;
|
290 |
const meta = questionMeta.get(key);
|
291 |
const isCorrect = selectedIndex === meta.correctIndex;
|
292 |
+
const baseValue = (difficulty + 1) * 100;
|
293 |
+
const value = baseValue * meta.valueMultiplier;
|
294 |
|
295 |
document.querySelectorAll(".answer-btn").forEach(btn => {
|
296 |
btn.disabled = true;
|