summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.org>2025-07-19 17:17:26 -0400
committerJakob L. Kreuze <zerodaysfordays@sdf.org>2025-07-19 17:23:16 -0400
commit2c7f6643df243693035a38d2b407eb758f625b41 (patch)
treed23c73702cd2d140077807bb472ca3206a736442
parentd79ef14711c0c9c03c2373b823ecd55b4f7f5345 (diff)
Fix Qwen's errors
-rw-r--r--script.js31
1 files changed, 15 insertions, 16 deletions
diff --git a/script.js b/script.js
index d2004ad..86874d3 100644
--- a/script.js
+++ b/script.js
@@ -69,12 +69,11 @@ function clamp_d(d) {
}
function d_0(g) {
- const g_value = Grade[g];
- return clamp_d(W[4] - Math.exp(W[5] * (g_value - 1.0)) + 1.0);
+ return clamp_d(W[4] - Math.exp(W[5] * (g - 1.0)) + 1.0);
}
function difficulty(d, g) {
- return clamp_d(W[7] * d_0('easy') + (1.0 - W[7]) * dp(d, g));
+ return clamp_d(W[7] * d_0(Grade.easy) + (1.0 - W[7]) * dp(d, g));
}
function dp(d, g) {
@@ -82,8 +81,7 @@ function dp(d, g) {
}
function delta_d(g) {
- const g_value = Grade[g];
- return -W[6] * (g_value - 3.0);
+ return -W[6] * (g - 3.0);
}
function sim(grades) {
@@ -144,7 +142,7 @@ function flipCard() {
if (window.index >= window.cards.length) {
return;
}
-
+
window.card.revealed = true;
// Reveal the "back".
@@ -165,8 +163,8 @@ function endReview() {
window.statusInfo.innerHTML = "Session complete!";
window.flashcard.style.display = "none";
window.buttons.style.display = "none";
-
- // TODO: Update cards.
+ updateAllCards();
+ console.log(window.allCards);
}
function rateCard(difficulty) {
@@ -177,9 +175,9 @@ function rateCard(difficulty) {
const card = window.cards[window.index];
const r_d = 0.9;
- const s = card.s;
- const d = card.d;
- const i = card.i;
+ const s = card.scheduler.s;
+ const d = card.scheduler.d;
+ const i = card.scheduler.i;
const g = card.flagged ? Grade.forgot : Grade[difficulty];
let s_n = undefined, d_n = undefined, i_n = undefined;
@@ -194,8 +192,8 @@ function rateCard(difficulty) {
}
i_n = Math.max(Math.round(interval(r_d, s)), 1.0);
- const scheduled = new Date(card.scheduled);
- scheduled.setDate(scheduled + i);
+ let scheduled = today();
+ scheduled.setDate(scheduled.getDate() + i_n);
if (difficulty === "forgot") {
// Shift forgotten card to end.
@@ -205,9 +203,10 @@ function rateCard(difficulty) {
} else {
// Unflag and update scheduler parameters.
delete card.flagged;
- card.s = s_n;
- card.d = d_n;
- card.i = i_n;
+ card.scheduler.s = s_n;
+ card.scheduler.d = d_n;
+ card.scheduler.i = i_n;
+ card.scheduled = scheduled;
if (++window.index < window.cards.length) {
loadCard(window.cards[window.index]);