Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump version to v1.11.1.2 #42

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

## [1.11.1.2]

- merge master branch;
- fix: 当天新卡片复习后,当天无法再次复习 的问题;
- fix: 卡片统计表中,当天复习数据没有更新 的问题;

## [1.11.0.1]

- fix #34, untrack error;
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-spaced-repetition-recall",
"name": "Spaced Repetition Recall",
"version": "1.11.0.1",
"version": "1.11.1.2",
"minAppVersion": "0.15.4",
"description": "Fight the forgetting curve by reviewing flashcards & entire notes.",
"author": "Newdea",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-spaced-repetition",
"version": "1.11.0.1",
"version": "1.11.1.2",
"description": "Fight the forgetting curve by reviewing flashcards & entire notes.",
"main": "main.js",
"scripts": {
Expand Down
42 changes: 26 additions & 16 deletions src/CardSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ReviewResponse, schedule } from "./scheduling";
import { SRSettings } from "./settings";
import { formatDate_YYYY_MM_DD } from "./util/utils";
import { DateUtil, globalDateProvider } from "./util/DateProvider";
import { DateUtils } from "./util/utils_recall";

export class CardScheduleInfo {
dueDate: Moment;
Expand Down Expand Up @@ -37,18 +38,22 @@ export class CardScheduleInfo {
}

isDue(): boolean {
return this.dueDate.isSameOrBefore(globalDateProvider.today);
// return this.dueDate.isSameOrBefore(globalDateProvider.today);
return (
this.dueDate.isSameOrBefore(globalDateProvider.today) ||
(this.dueDate.isSameOrBefore(globalDateProvider.endofToday) && this.interval >= 1)
);
}

isDummyScheduleForNewCard(): boolean {
return this.formatDueDate() == CardScheduleInfo.dummyDueDateForNewCard;
}

static getDummyScheduleForNewCard(settings: SRSettings): CardScheduleInfo {
static getDummyScheduleForNewCard(baseEase: number): CardScheduleInfo {
return CardScheduleInfo.fromDueDateStr(
CardScheduleInfo.dummyDueDateForNewCard,
CardScheduleInfo.initialInterval,
settings.baseEase,
baseEase,
0,
);
}
Expand Down Expand Up @@ -186,19 +191,24 @@ export class NoteCardScheduleParser {
const result: CardScheduleInfo[] = [];
for (let i = 0; i < scheduling.length; i++) {
const match: RegExpMatchArray = scheduling[i];
const dueDateNum = parseInt(match[1]);
const interval = parseInt(match[2]);
const ease = parseInt(match[3]);
const dueDate: Moment = window.moment(dueDateNum);
const delayBeforeReviewTicks: number = dueDateNum - globalDateProvider.today.valueOf();

const info: CardScheduleInfo = new CardScheduleInfo(
dueDate,
interval,
ease,
delayBeforeReviewTicks,
);
result.push(info);
if (match == null) {
result.push(CardScheduleInfo.getDummyScheduleForNewCard(0));
} else {
const dueDateNum = parseInt(match[1]);
const interval = parseInt(match[2]);
const ease = parseInt(match[3]);
const dueDate: Moment = window.moment(dueDateNum);
const delayBeforeReviewTicks: number =
dueDateNum - globalDateProvider.today.valueOf();

const info: CardScheduleInfo = new CardScheduleInfo(
dueDate,
interval,
ease,
delayBeforeReviewTicks,
);
result.push(info);
}
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class Question {
const card: Card = this.cards[i];
const schedule: CardScheduleInfo = card.hasSchedule
? card.scheduleInfo
: CardScheduleInfo.getDummyScheduleForNewCard(settings);
: CardScheduleInfo.getDummyScheduleForNewCard(settings.baseEase);
result += schedule.formatSchedule();
}
result += SR_HTML_COMMENT_END;
Expand Down
2 changes: 2 additions & 0 deletions src/ReviewDeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export interface SchedNote {
note: TFile;
item?: RepetitionItem;
dueUnix?: number;
interval?: number;
ease?: number;
}

export class ReviewDeck {
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/balance/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function balance(
if (isChange) {
const msg = `balance: interval from ${beforeIntvl} balance to ${interval} days.`;
console.debug(msg);
new Notice(msg);
// new Notice(msg);
} else {
interval = beforeIntvl;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dataStore/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ export class DataStore {
if (item.isDue) {
if (this.settings.algorithm === algorithmNames.Fsrs) {
const data: FsrsData = item.data as FsrsData;
if (data.last_review < new Date(date)) {
if (new Date(data.last_review) < new Date(date)) {
rc[date].due++;
}
} else {
Expand Down
17 changes: 13 additions & 4 deletions src/dataStore/itemToDecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import { algorithmNames } from "src/algorithms/algorithms";
export class ItemToDecks {
settings: SRSettings;

static create(settings: SRSettings) {
return new ItemToDecks(settings);
}
constructor(settings: SRSettings) {
this.settings = settings;
}
Expand Down Expand Up @@ -155,8 +158,14 @@ export class ItemToDecks {
latterQue[fileid] = rdeck.deckName;
}

if (item.isDue) {
rdeck.scheduledNotes.push({ note, item, dueUnix: item.nextReview });
if (item.hasDue) {
rdeck.scheduledNotes.push({
note,
item,
dueUnix: item.nextReview,
interval: item.interval,
ease: item.ease,
});
if (item.nextReview <= now_number) {
rdeck.dueNotesCount++;
// console.debug(`${rdeck.deckName} isDue dueCnt: ${rdeck.dueNotesCount}`, item);
Expand Down Expand Up @@ -202,8 +211,8 @@ export class ItemToDecks {
carditem.itemIds
.map((id: number) => store.getItembyID(id).getSched())
.filter((sched) => {
// ignore new add card
if (sched != null && scheduling.length <= count) {
// ignore new add card sched != null &&
if (scheduling.length <= count) {
scheduling.push(sched);
return true;
}
Expand Down
17 changes: 13 additions & 4 deletions src/dataStore/location_switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class LocationSwitch {
public afternoteStats: Stats;
public beforecardStats: Stats;
public aftercardStats: Stats;
revTag: string;
private revTag: string;

constructor(plugin: SRPlugin, settings: SRSettings) {
this.plugin = plugin;
Expand Down Expand Up @@ -136,6 +136,15 @@ export class LocationSwitch {
topicPath = new TopicPath([deckname]);
fileText = delDefaultTag(fileText, this.revTag);
fileChanged = true;
} else if (
topicPath.path.length === 2 &&
settings.tagsToReview.includes(topicPath.path[1])
) {
deckname = topicPath.path[1];
topicPath = new TopicPath([deckname]);
const revtag = this.converteTag(deckname);
fileText = delDefaultTag(fileText, revtag);
fileChanged = true;
}
}

Expand Down Expand Up @@ -309,7 +318,7 @@ export class LocationSwitch {
// const citem = store.getItembyID(id);
// if (citem.isTracked) {
const sched = citem.getSchedDurAsStr();
if (citem.isDue && sched != null) {
if (citem.hasDue && sched != null) {
scheduling.push(sched);
dueIds.push(citem.ID);
}
Expand All @@ -332,7 +341,7 @@ export class LocationSwitch {
item?.isTracked &&
(tkfile.isDefault || Tags.isTagedNoteDeckName(item.deckName, this.settings))
) {
if (item?.isDue) {
if (item?.hasDue) {
// let due: str, ease: number, interval: number;
const ret = item.getSchedDurAsStr();
if (ret != null) {
Expand All @@ -353,7 +362,7 @@ export class LocationSwitch {
noteTag == null &&
this.settings.tagsToReview.includes(item.deckName)
) {
const tag = this.converteTag(item.deckName.substring(1));
const tag = this.converteTag(item.deckName);
fileText = addDefaultTagtoNote(fileText, tag);
fileChanged = true;
}
Expand Down
40 changes: 38 additions & 2 deletions src/dataStore/repetitionItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ export class RepetitionItem {
let ease: number;
let interval: number;

const isFsrs: boolean = Object.prototype.hasOwnProperty.call(this.data, "state");
if (isFsrs) {
if (this.isFsrs) {
const data = this.data as FsrsData;
interval = data.scheduled_days;
// ease just used for StatsChart, not review scheduling.
Expand All @@ -131,6 +130,10 @@ export class RepetitionItem {
return sched;
}

private isFsrs(): boolean {
return Object.prototype.hasOwnProperty.call(this.data, "state");
}

getSchedDurAsStr() {
const sched = this.getSched();
if (sched == null) return null;
Expand Down Expand Up @@ -163,6 +166,13 @@ export class RepetitionItem {
}
}

get interval(): number {
return Number(this.getSched()[2]);
}
get ease(): number {
return Number(this.getSched()[3]);
}

/**
* check if file id is just new add.
* @returns boolean
Expand All @@ -182,7 +192,33 @@ export class RepetitionItem {
}
}

/**
* check if item should be reviewed rightnow.
*/
get isDue() {
const now_number = Date.now();
if (this.hasDue) {
if (this.nextReview < now_number) {
return true;
}
if (this.nextReview < DateUtils.EndofToday) {
if (this.isFsrs) {
const data: FsrsData = this.data as FsrsData;
if (data.scheduled_days >= 1) {
return true;
}
} else {
const data: AnkiData = this.data as AnkiData;
if (data.lastInterval >= 1) {
return true;
}
}
}
}
return false;
}

get hasDue() {
try {
if (this.nextReview > 0 || this.timesReviewed > 0) {
return true;
Expand Down
8 changes: 7 additions & 1 deletion src/gui/flashcard-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Modal, App, Notice, Platform, setIcon, MarkdownView } from "obsidian";
import { Modal, App, Notice, Platform, setIcon, MarkdownView, TFile } from "obsidian";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import h from "vhtml";

Expand All @@ -24,6 +24,7 @@ import { DataLocation } from "src/dataStore/dataLocation";
import { SrTFile } from "src/SRFile";
import { RepetitionItem, RPITEMTYPE } from "src/dataStore/repetitionItem";
import { debug } from "src/util/utils_recall";
import { ItemInfoModal } from "./info";

export enum FlashcardModalMode {
DecksList,
Expand Down Expand Up @@ -369,6 +370,11 @@ export class FlashcardModal extends Modal {
notePath: this.currentQuestion.note.filePath,
});
new Notice(currentEaseStr + "\n" + currentIntervalStr + "\n" + generatedFromStr);
const srfile = this.currentNote.file as SrTFile;
const store = this.plugin.store;
const id = this.currentCard.Id;
const infoM = new ItemInfoModal(this.settings, srfile.file, store.getItembyID(id));
infoM.open();
}

createBackButton() {
Expand Down
14 changes: 10 additions & 4 deletions src/gui/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,33 @@ export class ItemInfoModal extends Modal {
store: DataStore;
settings: SRSettings;
file: TFile;
item: RepetitionItem;
nextReview: number;
lastInterval: number;

constructor(settings: SRSettings, file: TFile) {
constructor(settings: SRSettings, file: TFile, item: RepetitionItem = null) {
super(app);
// this.plugin = plugin;
this.store = DataStore.getInstance();
this.settings = settings;
this.file = file;
if (item == null) {
this.item = this.store.getItemsOfFile(this.file.path)[0];
} else {
this.item = item;
}
}

onOpen() {
const { contentEl } = this;
//TODO: Implement Item info.
const item = this.store.getItemsOfFile(this.file.path)[0];
// const item = this.store.getItemsOfFile(this.file.path)[0];
// const path = this.store.getFilePath(item);
// contentEl.createEl("p").setText("Item info of " + this.file.path);
const buttonDivAll = contentEl.createDiv("srs-flex-row");
const contentdiv = contentEl.createEl("div");

this.displayitem(contentdiv, item);
this.displayitem(contentdiv, this.item);

// new ButtonComponent(buttonDivAll).setButtonText("Current").onClick(() => {
// this.displayitem(contentdiv, item);
Expand Down Expand Up @@ -126,7 +132,7 @@ export class ItemInfoModal extends Modal {
}

submit() {
const item = this.store.getItemsOfFile(this.file.path)[0];
const item = this.item;
console.debug(this);
const algo = this.settings.algorithm;
if (this.nextReview) {
Expand Down
22 changes: 10 additions & 12 deletions src/lang/locale/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,16 @@ export default {
RESET_DEFAULT: "重置为默认",
CARD_MODAL_WIDTH_PERCENT: "卡片宽度百分比",
RANDOMIZE_CARD_ORDER: "复习时随机显示卡片?",
REVIEW_CARD_ORDER_WITHIN_DECK: "Order cards in a deck are displayed during review",
REVIEW_CARD_ORDER_NEW_FIRST_SEQUENTIAL: "Sequentially within a deck (All new cards first)",
REVIEW_CARD_ORDER_DUE_FIRST_SEQUENTIAL: "Sequentially within a deck (All due cards first)",
REVIEW_CARD_ORDER_NEW_FIRST_RANDOM: "Randomly within a deck (All new cards first)",
REVIEW_CARD_ORDER_DUE_FIRST_RANDOM: "Randomly within a deck (All due cards first)",
REVIEW_CARD_ORDER_RANDOM_DECK_AND_CARD: "Random card from random deck",
REVIEW_DECK_ORDER: "Order decks are displayed during review",
REVIEW_DECK_ORDER_PREV_DECK_COMPLETE_SEQUENTIAL:
"Sequentially (once all cards in previous deck reviewed)",
REVIEW_DECK_ORDER_PREV_DECK_COMPLETE_RANDOM:
"Randomly (once all cards in previous deck reviewed)",
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "Random card from random deck",
REVIEW_CARD_ORDER_WITHIN_DECK: "复习时卡片组内的卡片排序",
REVIEW_CARD_ORDER_NEW_FIRST_SEQUENTIAL: "卡片组内顺序 (全部新卡片优先)",
REVIEW_CARD_ORDER_DUE_FIRST_SEQUENTIAL: "卡片组内顺序 (全部到期卡片优先)",
REVIEW_CARD_ORDER_NEW_FIRST_RANDOM: "卡片组内乱序 (全部新卡片优先)",
REVIEW_CARD_ORDER_DUE_FIRST_RANDOM: "卡片组内乱序 (全部到期卡片优先)",
REVIEW_CARD_ORDER_RANDOM_DECK_AND_CARD: "卡片组及卡片都乱序",
REVIEW_DECK_ORDER: "复习时卡片组的排序",
REVIEW_DECK_ORDER_PREV_DECK_COMPLETE_SEQUENTIAL: "顺序 (在前一卡片组内卡片都复习完后)",
REVIEW_DECK_ORDER_PREV_DECK_COMPLETE_RANDOM: "乱序 (在前一卡片组内卡片都复习完后)",
REVIEW_DECK_ORDER_RANDOM_DECK_AND_CARD: "卡片组及卡片都乱序",
DISABLE_CLOZE_CARDS: "不进行完形填空?",
CONVERT_HIGHLIGHTS_TO_CLOZES: "将 ==高亮== 转换为完形填空?",
CONVERT_BOLD_TEXT_TO_CLOZES: "将 **粗体** 转换为完形填空?",
Expand Down
Loading