refactor(VocabPracticeDialog): replace hard-coded consecutive correct threshold with constant
All checks were successful
Deploy to production / deploy (push) Successful in 1m56s
All checks were successful
Deploy to production / deploy (push) Successful in 1m56s
- Introduced a constant `HARD_REQUIRED_CONSECUTIVE_CORRECT` to define the required number of consecutive correct answers for hard vocabulary items, improving code maintainability and readability. - Updated relevant methods to utilize the new constant, ensuring consistent behavior across the component.
This commit is contained in:
@@ -159,6 +159,7 @@ import apiClient from '@/utils/axios.js';
|
||||
|
||||
const PRACTICE_MIN_EXPOSURES = 3;
|
||||
const SRS_SESSION_STORAGE_VERSION = 2;
|
||||
const HARD_REQUIRED_CONSECUTIVE_CORRECT = 5;
|
||||
|
||||
export default {
|
||||
name: 'VocabPracticeDialog',
|
||||
@@ -303,10 +304,9 @@ export default {
|
||||
return this.pool.filter((item) => Boolean(this.hardVocabMap[this.getHardKey(item)]));
|
||||
},
|
||||
hardRemainingCount() {
|
||||
const requiredConsecutiveCorrect = 2;
|
||||
return this.hardPoolItems.filter((item) => {
|
||||
const key = this.getHardKey(item);
|
||||
return (Number(this.hardMasteryByKey[key]) || 0) < requiredConsecutiveCorrect;
|
||||
return (Number(this.hardMasteryByKey[key]) || 0) < HARD_REQUIRED_CONSECUTIVE_CORRECT;
|
||||
}).length;
|
||||
}
|
||||
},
|
||||
@@ -782,10 +782,9 @@ export default {
|
||||
return items.find((it) => it.id === nextId) || null;
|
||||
}
|
||||
if (this.hardPhaseActive) {
|
||||
const requiredConsecutiveCorrect = 2;
|
||||
const hardItems = this.hardPoolItems.filter((item) => {
|
||||
const key = this.getHardKey(item);
|
||||
return (Number(this.hardMasteryByKey[key]) || 0) < requiredConsecutiveCorrect;
|
||||
return (Number(this.hardMasteryByKey[key]) || 0) < HARD_REQUIRED_CONSECUTIVE_CORRECT;
|
||||
});
|
||||
if (hardItems.length === 0) {
|
||||
this.hardPhaseActive = false;
|
||||
@@ -939,7 +938,7 @@ export default {
|
||||
if (this.hardPhaseActive && this.current) {
|
||||
const key = this.getHardKey(this.current);
|
||||
this.hardMasteryByKey[key] = Math.max(0, Number(this.hardMasteryByKey[key]) || 0) + 1;
|
||||
if ((Number(this.hardMasteryByKey[key]) || 0) >= 2 && this.hardVocabMap[key]) {
|
||||
if ((Number(this.hardMasteryByKey[key]) || 0) >= HARD_REQUIRED_CONSECUTIVE_CORRECT && this.hardVocabMap[key]) {
|
||||
const next = { ...this.hardVocabMap };
|
||||
delete next[key];
|
||||
this.hardVocabMap = next;
|
||||
|
||||
Reference in New Issue
Block a user