feat(VocabService, VocabPracticeDialog, VocabLessonView): enhance vocabulary training logic and UI feedback
All checks were successful
Deploy to production / deploy (push) Successful in 2m17s
All checks were successful
Deploy to production / deploy (push) Successful in 2m17s
- Introduced methods for improved text analysis and validation in VocabService, including `_wordCount` and `_looksLikeFragmentMismatch`, to better assess learning and reference pairs. - Updated VocabPracticeDialog to display submitted answers and correct solutions, enhancing user feedback during practice sessions. - Enhanced VocabLessonView to ensure only trainable vocabulary pairs are processed, improving the quality of vocabulary training. - Added localization entries for new UI elements in both English and German, ensuring clarity in user interactions.
This commit is contained in:
@@ -92,9 +92,35 @@ export default class VocabService {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this._looksLikeFragmentMismatch(learning, reference)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !this._isInstructionLikeText(learning) && !this._isInstructionLikeText(reference);
|
||||
}
|
||||
|
||||
_wordCount(value) {
|
||||
return String(value || '')
|
||||
.trim()
|
||||
.replace(/[\p{P}\p{S}]+/gu, ' ')
|
||||
.split(/\s+/)
|
||||
.filter(Boolean)
|
||||
.length;
|
||||
}
|
||||
|
||||
_looksLikeFragmentMismatch(left, right) {
|
||||
const leftWords = this._wordCount(left);
|
||||
const rightWords = this._wordCount(right);
|
||||
const leftText = String(left || '').trim();
|
||||
const rightText = String(right || '').trim();
|
||||
const leftLooksSentence = leftWords >= 3 || /[?!.].+\S/.test(leftText);
|
||||
const rightLooksSentence = rightWords >= 3 || /[?!.].+\S/.test(rightText);
|
||||
const leftLooksShortFragment = leftWords <= 1 && leftText.length <= 12;
|
||||
const rightLooksShortFragment = rightWords <= 1 && rightText.length <= 12;
|
||||
|
||||
return (leftLooksShortFragment && rightLooksSentence) || (rightLooksShortFragment && leftLooksSentence);
|
||||
}
|
||||
|
||||
_calculateSrsSchedule(item, { correct, rating = null } = {}) {
|
||||
const now = new Date();
|
||||
const previousStage = Math.max(0, Number(item?.stage) || 0);
|
||||
|
||||
Reference in New Issue
Block a user