🌊 Волна 7: frontend качество кода (8 багов)
Типизация: - untyped_any_in_useLocalized: generic <T extends Record<string, unknown>> (useLocalized.ts) - ANY_TYPES_IN_API + MISSING_RETURN_TYPES: интерфейсы для критичных функций (api.ts) - SENTRY_ERROR_FIELD_IN_SUCCESS: разделение success/error (api.ts) Производительность: - context_value_not_memoized: useMemo + useCallback (LanguageContext.tsx) Логика: - TESTVIEW_SAVEANSWER_MISSING_PARAMS: единая сигнатура saveAnswer (TestViewPage.tsx) - LESSON_HARDCODED_SKILL_TAG: optionsLanguage вместо хардкода (LessonViewPage.tsx) - silent_error_swallow_setLanguage: логирование ошибки (LanguageContext.tsx) Аудит: Issue #3, frontend 8/34 задач
This commit is contained in:
@@ -199,7 +199,16 @@ const LessonViewPage: React.FC = () => {
|
||||
const isLastQuestion = currentQuestionIndex === lesson.questions.length - 1;
|
||||
const isProduction = currentQuestion?.question.question_type === 'production';
|
||||
const isCurrentAnswered = currentQuestion ? !!selectedAnswers[currentQuestion.question.question_id] : false;
|
||||
const isTranslationQuestion = currentQuestion?.question.skill_tag === 'how_are_you';
|
||||
|
||||
// 🔧 ФИКС (23.09.2026): LESSON_HARDCODED_SKILL_TAG — используем optionsLanguage
|
||||
// из данных вопроса (как в TeacherChatPage), а не хардкод skill_tag.
|
||||
// Для любого навыка с optionsLanguage='user' варианты локализуются.
|
||||
const optionsLanguage = (currentQuestion?.question as any)?.options_language;
|
||||
// Fallback: если поле отсутствует — оставляем старое поведение
|
||||
const isTranslationQuestion =
|
||||
optionsLanguage === 'user' ||
|
||||
(optionsLanguage === undefined && currentQuestion?.question.skill_tag === 'how_are_you');
|
||||
|
||||
const isHintUsed = currentQuestion ? !!hintUsed[currentQuestion.question.question_id] : false;
|
||||
const correctOption = currentQuestion?.options.find(o => o.is_correct);
|
||||
|
||||
|
||||
@@ -91,13 +91,22 @@ const TestViewPage: React.FC = () => {
|
||||
}
|
||||
}, [topicId]);
|
||||
|
||||
const saveAnswer = async (questionId: string, answer: string) => {
|
||||
// 🔧 ФИКС (23.09.2026): TESTVIEW_SAVEANSWER_MISSING_PARAMS — сигнатура
|
||||
// приведена к общему виду (isFinalAnswer, usedHint) — как в LessonViewPage
|
||||
// и PracticeViewPage. Раньше тест не передавал usedHint, и статистика
|
||||
// по подсказкам в тесте не собиралась.
|
||||
const saveAnswer = async (
|
||||
questionId: string,
|
||||
answer: string,
|
||||
isFinalAnswer: boolean = true,
|
||||
usedHint: boolean = false,
|
||||
) => {
|
||||
const timeTaken = Date.now() - startTimeRef.current;
|
||||
startTimeRef.current = Date.now();
|
||||
|
||||
if (sessionId) {
|
||||
try {
|
||||
await saveLearningAnswer(sessionId, questionId, answer, timeTaken, true);
|
||||
await saveLearningAnswer(sessionId, questionId, answer, timeTaken, isFinalAnswer, usedHint);
|
||||
} catch (e) {
|
||||
console.error('Error saving answer:', e);
|
||||
}
|
||||
@@ -106,7 +115,8 @@ const TestViewPage: React.FC = () => {
|
||||
|
||||
const handleAnswerSelect = async (questionId: string, optionKey: string) => {
|
||||
setSelectedAnswers(prev => ({ ...prev, [questionId]: optionKey }));
|
||||
await saveAnswer(questionId, optionKey);
|
||||
// 🔧 ФИКС (23.09.2026): обычный ответ — isFinalAnswer=true, usedHint=false
|
||||
await saveAnswer(questionId, optionKey, true, false);
|
||||
};
|
||||
|
||||
const handleTextInputChange = async (questionId: string, value: string) => {
|
||||
@@ -116,7 +126,8 @@ const TestViewPage: React.FC = () => {
|
||||
|
||||
const handleTextInputBlur = async (questionId: string) => {
|
||||
if (textInputValue.trim()) {
|
||||
await saveAnswer(questionId, textInputValue.trim());
|
||||
// 🔧 ФИКС (23.09.2026): обычный ответ — isFinalAnswer=true, usedHint=false
|
||||
await saveAnswer(questionId, textInputValue.trim(), true, false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -135,7 +146,8 @@ const TestViewPage: React.FC = () => {
|
||||
if (answer && sessionId) {
|
||||
const timeTaken = Date.now() - startTimeRef.current;
|
||||
try {
|
||||
await saveLearningAnswer(sessionId, currentQ.question.question_id, answer, timeTaken, true);
|
||||
// 🔧 ФИКС (23.09.2026): TESTVIEW_SAVEANSWER_MISSING_PARAMS
|
||||
await saveLearningAnswer(sessionId, currentQ.question.question_id, answer, timeTaken, true, false);
|
||||
} catch (e) {
|
||||
console.error('Error saving final answer:', e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user