feat(vocab): implement SRS features and enhance vocabulary management
All checks were successful
Deploy to production / deploy (push) Successful in 2m49s
All checks were successful
Deploy to production / deploy (push) Successful in 2m49s
- Added new endpoints in vocabController for retrieving SRS due items and reviewing SRS items, improving spaced repetition support. - Updated vocabService to handle SRS item creation and scheduling, ensuring effective tracking of vocabulary exposure. - Enhanced vocabRouter with new routes for SRS functionalities, facilitating user interaction with spaced repetition features. - Modified VocabPracticeDialog and VocabCourseView to integrate SRS due items, providing users with timely review opportunities. - Updated translations and UI elements to reflect new SRS features, enhancing user experience and accessibility.
This commit is contained in:
@@ -49,11 +49,23 @@
|
||||
<p>{{ $t('socialnetwork.vocab.courses.courseFlowIntro') }}</p>
|
||||
</div>
|
||||
<div class="course-flow__stats">
|
||||
<span class="course-flow__stat">{{ $t('socialnetwork.vocab.courses.srsDueStat', { count: srsDueCount }) }}</span>
|
||||
<span class="course-flow__stat">{{ $t('socialnetwork.vocab.courses.courseFlowReviewStat', { count: dueReviewLessons.length }) }}</span>
|
||||
<span class="course-flow__stat">{{ $t('socialnetwork.vocab.courses.courseFlowBlockStat', { block: currentBlockNumber || '—' }) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="srsDueCount > 0" class="course-srs-plan">
|
||||
<div>
|
||||
<span class="course-srs-plan__eyebrow">{{ $t('socialnetwork.vocab.courses.srsEyebrow') }}</span>
|
||||
<h4>{{ $t('socialnetwork.vocab.courses.srsTitle', { count: srsDueCount }) }}</h4>
|
||||
<p>{{ $t('socialnetwork.vocab.courses.srsIntro') }}</p>
|
||||
</div>
|
||||
<button type="button" class="course-today-plan__action" :disabled="srsLoading" @click="openSrsPractice">
|
||||
{{ srsLoading ? $t('general.loading') : $t('socialnetwork.vocab.courses.srsStart') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="todayRecommendedSteps.length > 0" class="course-today-plan">
|
||||
<h4 class="course-today-plan__title">{{ $t('socialnetwork.vocab.courses.courseTodayPlanTitle') }}</h4>
|
||||
<p class="course-today-plan__intro">
|
||||
@@ -325,6 +337,8 @@ export default {
|
||||
course: null,
|
||||
progress: [],
|
||||
chapters: [],
|
||||
srsDueItems: [],
|
||||
srsLoading: false,
|
||||
showAddLessonDialog: false,
|
||||
assistantSettings: null,
|
||||
lessonFormTouched: false,
|
||||
@@ -366,6 +380,9 @@ export default {
|
||||
currentBlockNumber() {
|
||||
return this.currentLesson?.pedagogy?.blockNumber || null;
|
||||
},
|
||||
srsDueCount() {
|
||||
return Array.isArray(this.srsDueItems) ? this.srsDueItems.length : 0;
|
||||
},
|
||||
dueReviewLessons() {
|
||||
return this.sortedLessons
|
||||
.filter((lesson) => {
|
||||
@@ -504,6 +521,7 @@ export default {
|
||||
const res = await apiClient.get(`/api/vocab/courses/${this.courseId}`);
|
||||
this.course = res.data;
|
||||
await this.loadProgress();
|
||||
await this.loadSrsDueItems();
|
||||
if (this.course.languageId) {
|
||||
await this.loadChapters();
|
||||
}
|
||||
@@ -522,6 +540,20 @@ export default {
|
||||
this.progress = [];
|
||||
}
|
||||
},
|
||||
async loadSrsDueItems() {
|
||||
this.srsLoading = true;
|
||||
try {
|
||||
const { data } = await apiClient.get(`/api/vocab/courses/${this.courseId}/srs/due`, {
|
||||
params: { limit: 40 }
|
||||
});
|
||||
this.srsDueItems = Array.isArray(data?.items) ? data.items : [];
|
||||
} catch (e) {
|
||||
console.warn('Konnte SRS-Fälligkeiten nicht laden:', e);
|
||||
this.srsDueItems = [];
|
||||
} finally {
|
||||
this.srsLoading = false;
|
||||
}
|
||||
},
|
||||
async loadChapters() {
|
||||
try {
|
||||
const res = await apiClient.get(`/api/vocab/languages/${this.course.languageId}/chapters`);
|
||||
@@ -814,6 +846,17 @@ export default {
|
||||
lessonId: lesson.id
|
||||
});
|
||||
},
|
||||
openSrsPractice() {
|
||||
if (!this.srsDueItems.length) {
|
||||
return;
|
||||
}
|
||||
this.$refs.practiceDialog?.open?.({
|
||||
courseId: this.courseId,
|
||||
initialPool: this.srsDueItems,
|
||||
srsMode: true,
|
||||
onClose: () => this.loadSrsDueItems()
|
||||
});
|
||||
},
|
||||
openLessonReview(lessonId) {
|
||||
this.$router.push(`/socialnetwork/vocab/courses/${this.courseId}/lessons/${lessonId}/review`);
|
||||
},
|
||||
@@ -1010,6 +1053,40 @@ export default {
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.course-srs-plan {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
padding: 16px 18px;
|
||||
border-radius: 14px;
|
||||
border: 1px solid rgba(102, 153, 126, 0.38);
|
||||
background: linear-gradient(135deg, rgba(232, 247, 238, 0.95), rgba(255, 251, 240, 0.8));
|
||||
}
|
||||
|
||||
.course-srs-plan__eyebrow {
|
||||
display: inline-flex;
|
||||
margin-bottom: 4px;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
color: #4f7b60;
|
||||
}
|
||||
|
||||
.course-srs-plan h4,
|
||||
.course-srs-plan p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.course-srs-plan p {
|
||||
margin-top: 6px;
|
||||
color: var(--color-text-secondary, #5c534c);
|
||||
font-size: 0.88rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.course-flow-card {
|
||||
padding: 16px;
|
||||
border: 1px solid var(--color-border);
|
||||
|
||||
@@ -3602,6 +3602,23 @@ export default {
|
||||
normalizeVocab(s) {
|
||||
return this.normalizeComparableText(s);
|
||||
},
|
||||
reportSrsReviewForCurrentQuestion(isCorrect) {
|
||||
if (!this.currentVocabQuestion?.vocab || !this.courseId) {
|
||||
return;
|
||||
}
|
||||
const vocab = this.currentVocabQuestion.vocab;
|
||||
apiClient.post('/api/vocab/srs/review', {
|
||||
courseId: this.courseId,
|
||||
lessonId: vocab.lessonId || this.lessonId,
|
||||
itemKey: vocab.itemKey || null,
|
||||
learning: vocab.learning,
|
||||
reference: vocab.reference,
|
||||
direction: this.vocabTrainerDirection,
|
||||
correct: Boolean(isCorrect)
|
||||
}).catch((error) => {
|
||||
console.warn('[VocabLessonView] SRS review could not be saved:', error);
|
||||
});
|
||||
},
|
||||
checkVocabAnswer() {
|
||||
if (!this.currentVocabQuestion) return;
|
||||
|
||||
@@ -3638,6 +3655,7 @@ export default {
|
||||
stats.wrong++;
|
||||
this.queueFailedVocab(this.currentVocabQuestion.vocab);
|
||||
}
|
||||
this.reportSrsReviewForCurrentQuestion(this.vocabTrainerLastCorrect);
|
||||
|
||||
this.vocabTrainerAnswered = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user