feat(haptic): вибрация на 7 страницах — уроки, тест, практика, учитель, лекции, произношение
- LessonsPage: selection() на выбор уровня/темы, кнопка назад - LessonViewPage: selection() на ответ, heavy() на завершение урока - TestViewPage: selection() на ответ, heavy() на завершение, medium() на примеры/практику - PracticeViewPage: selection() на ответ, heavy() на завершение практики - TeacherChatPage: medium() на старт, success()/error() на ответ учителя - LecturesPage: selection() на открытие, medium() на скачивание - PronunciationPage: selection() на тап по слову, light() на следующее Глобальный useGlobalHaptic в App.tsx вешает light() на все кнопки. На кнопках с явным haptic — data-no-haptic="true" против двойной вибрации.
This commit is contained in:
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import { Document, Page, pdfjs } from 'react-pdf';
|
import { Document, Page, pdfjs } from 'react-pdf';
|
||||||
import { useLanguage } from '../i18n/LanguageContext';
|
import { useLanguage } from '../i18n/LanguageContext';
|
||||||
import { fonts, radius } from '../styles/theme';
|
import { fonts, radius } from '../styles/theme';
|
||||||
|
import { haptic } from '../haptic';
|
||||||
import { getLectures, type LectureListItem } from '../api';
|
import { getLectures, type LectureListItem } from '../api';
|
||||||
|
|
||||||
// pdf.js worker + cMaps (для кириллицы и польских букв)
|
// pdf.js worker + cMaps (для кириллицы и польских букв)
|
||||||
@@ -78,6 +79,8 @@ const LecturesPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleOpenLecture = (lecture: LectureListItem) => {
|
const handleOpenLecture = (lecture: LectureListItem) => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_lectures — открытие лекции
|
||||||
|
haptic.selection();
|
||||||
setActiveLecture(lecture);
|
setActiveLecture(lecture);
|
||||||
setPageNumber(1);
|
setPageNumber(1);
|
||||||
setNumPages(0);
|
setNumPages(0);
|
||||||
@@ -94,6 +97,8 @@ const LecturesPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDownloadLecture = (lecture: LectureListItem) => {
|
const handleDownloadLecture = (lecture: LectureListItem) => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_lectures — скачивание
|
||||||
|
haptic.medium();
|
||||||
const url = getFileUrl(lecture);
|
const url = getFileUrl(lecture);
|
||||||
|
|
||||||
if (window.Telegram?.WebApp?.downloadFile) {
|
if (window.Telegram?.WebApp?.downloadFile) {
|
||||||
@@ -205,6 +210,7 @@ const LecturesPage: React.FC = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
|
data-no-haptic="true"
|
||||||
onClick={() => handleOpenLecture(lecture)}
|
onClick={() => handleOpenLecture(lecture)}
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@@ -238,6 +244,7 @@ const LecturesPage: React.FC = () => {
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
data-no-haptic="true"
|
||||||
onClick={() => handleDownloadLecture(lecture)}
|
onClick={() => handleDownloadLecture(lecture)}
|
||||||
style={{
|
style={{
|
||||||
width: '40px',
|
width: '40px',
|
||||||
@@ -320,6 +327,7 @@ const LecturesPage: React.FC = () => {
|
|||||||
{activeLecture.title}
|
{activeLecture.title}
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
data-no-haptic="true"
|
||||||
onClick={() => handleDownloadLecture(activeLecture)}
|
onClick={() => handleDownloadLecture(activeLecture)}
|
||||||
style={{
|
style={{
|
||||||
padding: '6px 12px',
|
padding: '6px 12px',
|
||||||
@@ -411,7 +419,12 @@ const LecturesPage: React.FC = () => {
|
|||||||
marginTop: '12px',
|
marginTop: '12px',
|
||||||
}}>
|
}}>
|
||||||
<button
|
<button
|
||||||
onClick={() => setPageNumber(p => Math.max(1, p - 1))}
|
data-no-haptic="true"
|
||||||
|
onClick={() => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_lectures — пагинация PDF
|
||||||
|
haptic.light();
|
||||||
|
setPageNumber(p => Math.max(1, p - 1));
|
||||||
|
}}
|
||||||
disabled={pageNumber <= 1}
|
disabled={pageNumber <= 1}
|
||||||
style={{
|
style={{
|
||||||
padding: '8px 16px',
|
padding: '8px 16px',
|
||||||
@@ -436,7 +449,12 @@ const LecturesPage: React.FC = () => {
|
|||||||
{pageNumber} / {numPages}
|
{pageNumber} / {numPages}
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={() => setPageNumber(p => Math.min(numPages, p + 1))}
|
data-no-haptic="true"
|
||||||
|
onClick={() => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_lectures — пагинация PDF
|
||||||
|
haptic.light();
|
||||||
|
setPageNumber(p => Math.min(numPages, p + 1));
|
||||||
|
}}
|
||||||
disabled={pageNumber >= numPages}
|
disabled={pageNumber >= numPages}
|
||||||
style={{
|
style={{
|
||||||
padding: '8px 16px',
|
padding: '8px 16px',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useNavigate, useParams } from 'react-router-dom';
|
|||||||
import { useLanguage } from '../i18n/LanguageContext';
|
import { useLanguage } from '../i18n/LanguageContext';
|
||||||
import { useLocalized } from '../hooks/useLocalized';
|
import { useLocalized } from '../hooks/useLocalized';
|
||||||
import { fonts, radius } from '../styles/theme';
|
import { fonts, radius } from '../styles/theme';
|
||||||
|
import { haptic } from '../haptic';
|
||||||
import { getLearningLesson, startLearningSession, saveLearningAnswer, completeLearningSession } from '../api';
|
import { getLearningLesson, startLearningSession, saveLearningAnswer, completeLearningSession } from '../api';
|
||||||
|
|
||||||
interface QuestionOption {
|
interface QuestionOption {
|
||||||
@@ -118,6 +119,8 @@ const LessonViewPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleAnswerSelect = async (questionId: string, optionKey: string) => {
|
const handleAnswerSelect = async (questionId: string, optionKey: string) => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_lesson_view — выбор варианта
|
||||||
|
haptic.selection();
|
||||||
setSelectedAnswers(prev => ({ ...prev, [questionId]: optionKey }));
|
setSelectedAnswers(prev => ({ ...prev, [questionId]: optionKey }));
|
||||||
// 🔧 ИСПРАВЛЕНО: обычный ответ — isFinalAnswer=true, hintUsed=false
|
// 🔧 ИСПРАВЛЕНО: обычный ответ — isFinalAnswer=true, hintUsed=false
|
||||||
await saveAnswer(questionId, optionKey, true, false);
|
await saveAnswer(questionId, optionKey, true, false);
|
||||||
@@ -159,6 +162,8 @@ const LessonViewPage: React.FC = () => {
|
|||||||
setTextInputValue('');
|
setTextInputValue('');
|
||||||
startTimeRef.current = Date.now();
|
startTimeRef.current = Date.now();
|
||||||
} else {
|
} else {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_lesson_view — завершение урока
|
||||||
|
haptic.heavy();
|
||||||
setIsCompleting(true);
|
setIsCompleting(true);
|
||||||
|
|
||||||
// 🔧 ФИКС (25.09.2026): LESSON_NEXT_NO_RESULTS —
|
// 🔧 ФИКС (25.09.2026): LESSON_NEXT_NO_RESULTS —
|
||||||
@@ -197,6 +202,8 @@ const LessonViewPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_lesson_view — вибрация возврата
|
||||||
|
haptic.light();
|
||||||
setShowHint(false);
|
setShowHint(false);
|
||||||
if (currentQuestionIndex > 0) {
|
if (currentQuestionIndex > 0) {
|
||||||
setCurrentQuestionIndex(prev => prev - 1);
|
setCurrentQuestionIndex(prev => prev - 1);
|
||||||
@@ -554,6 +561,7 @@ const LessonViewPage: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={option.option_key}
|
key={option.option_key}
|
||||||
|
data-no-haptic="true"
|
||||||
onClick={() => handleAnswerSelect(currentQuestion.question.question_id, option.option_key)}
|
onClick={() => handleAnswerSelect(currentQuestion.question.question_id, option.option_key)}
|
||||||
style={{
|
style={{
|
||||||
padding: '14px 16px',
|
padding: '14px 16px',
|
||||||
@@ -650,6 +658,7 @@ const LessonViewPage: React.FC = () => {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={handleNext}
|
onClick={handleNext}
|
||||||
|
data-no-haptic="true"
|
||||||
disabled={!isCurrentAnswered || isCompleting}
|
disabled={!isCurrentAnswered || isCompleting}
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useState, useEffect, useCallback } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useLanguage } from '../i18n/LanguageContext';
|
import { useLanguage } from '../i18n/LanguageContext';
|
||||||
import { fonts, radius } from '../styles/theme';
|
import { fonts, radius } from '../styles/theme';
|
||||||
|
import { haptic } from '../haptic';
|
||||||
import { getLearningLevels, getLearningTopics, getLearningProgress } from '../api';
|
import { getLearningLevels, getLearningTopics, getLearningProgress } from '../api';
|
||||||
|
|
||||||
interface LearningLevel {
|
interface LearningLevel {
|
||||||
@@ -152,6 +153,8 @@ const LessonsPage: React.FC = () => {
|
|||||||
}}>
|
}}>
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_lessons_page — вибрация навигации
|
||||||
|
haptic.selection();
|
||||||
if (selectedLevel) {
|
if (selectedLevel) {
|
||||||
setSelectedLevel(null);
|
setSelectedLevel(null);
|
||||||
} else {
|
} else {
|
||||||
@@ -193,7 +196,11 @@ const LessonsPage: React.FC = () => {
|
|||||||
{levels.map((level, index) => (
|
{levels.map((level, index) => (
|
||||||
<button
|
<button
|
||||||
key={level.code}
|
key={level.code}
|
||||||
onClick={() => handleLevelSelect(level.code)}
|
onClick={() => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_lessons_page — вибрация выбора уровня
|
||||||
|
haptic.selection();
|
||||||
|
handleLevelSelect(level.code);
|
||||||
|
}}
|
||||||
style={{
|
style={{
|
||||||
padding: '18px',
|
padding: '18px',
|
||||||
borderRadius: radius.lg,
|
borderRadius: radius.lg,
|
||||||
@@ -243,6 +250,8 @@ const LessonsPage: React.FC = () => {
|
|||||||
key={topic.topic_id}
|
key={topic.topic_id}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (isUnlocked) {
|
if (isUnlocked) {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_lessons_page — вибрация выбора темы
|
||||||
|
haptic.selection();
|
||||||
navigate(`/lessons/topic/${topic.topic_id}`);
|
navigate(`/lessons/topic/${topic.topic_id}`);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useNavigate, useLocation } from 'react-router-dom';
|
|||||||
import { useLanguage } from '../i18n/LanguageContext';
|
import { useLanguage } from '../i18n/LanguageContext';
|
||||||
import { useLocalized } from '../hooks/useLocalized';
|
import { useLocalized } from '../hooks/useLocalized';
|
||||||
import { fonts, radius } from '../styles/theme';
|
import { fonts, radius } from '../styles/theme';
|
||||||
|
import { haptic } from '../haptic';
|
||||||
import { saveLearningAnswer, completeLearningSession } from '../api';
|
import { saveLearningAnswer, completeLearningSession } from '../api';
|
||||||
|
|
||||||
interface PracticeQuestion {
|
interface PracticeQuestion {
|
||||||
@@ -96,6 +97,8 @@ const PracticeViewPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleAnswerSelect = async (questionId: string, optionKey: string) => {
|
const handleAnswerSelect = async (questionId: string, optionKey: string) => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_practice_view — выбор варианта
|
||||||
|
haptic.selection();
|
||||||
setSelectedAnswers(prev => ({ ...prev, [questionId]: optionKey }));
|
setSelectedAnswers(prev => ({ ...prev, [questionId]: optionKey }));
|
||||||
// 🔧 ИСПРАВЛЕНО: обычный ответ — isFinalAnswer=true, hintUsed=false
|
// 🔧 ИСПРАВЛЕНО: обычный ответ — isFinalAnswer=true, hintUsed=false
|
||||||
await saveAnswer(questionId, optionKey, true, false);
|
await saveAnswer(questionId, optionKey, true, false);
|
||||||
@@ -138,6 +141,8 @@ const PracticeViewPage: React.FC = () => {
|
|||||||
setTextInputValue('');
|
setTextInputValue('');
|
||||||
startTimeRef.current = Date.now();
|
startTimeRef.current = Date.now();
|
||||||
} else {
|
} else {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_practice_view — завершение практики
|
||||||
|
haptic.heavy();
|
||||||
setIsCompleting(true);
|
setIsCompleting(true);
|
||||||
|
|
||||||
// 🔧 ФИКС (24.09.2026): PRACTICE_DUPLICATE_SAVE —
|
// 🔧 ФИКС (24.09.2026): PRACTICE_DUPLICATE_SAVE —
|
||||||
@@ -160,6 +165,8 @@ const PracticeViewPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_practice_view — вибрация возврата
|
||||||
|
haptic.light();
|
||||||
setShowHint(false);
|
setShowHint(false);
|
||||||
if (currentIndex > 0) {
|
if (currentIndex > 0) {
|
||||||
setCurrentIndex(prev => prev - 1);
|
setCurrentIndex(prev => prev - 1);
|
||||||
@@ -495,6 +502,7 @@ const PracticeViewPage: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={option.option_key}
|
key={option.option_key}
|
||||||
|
data-no-haptic="true"
|
||||||
onClick={() => handleAnswerSelect(currentQuestion.question.question_id, option.option_key)}
|
onClick={() => handleAnswerSelect(currentQuestion.question.question_id, option.option_key)}
|
||||||
style={{
|
style={{
|
||||||
padding: '14px 16px',
|
padding: '14px 16px',
|
||||||
@@ -587,6 +595,7 @@ const PracticeViewPage: React.FC = () => {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={handleNext}
|
onClick={handleNext}
|
||||||
|
data-no-haptic="true"
|
||||||
disabled={!isCurrentAnswered || isCompleting}
|
disabled={!isCurrentAnswered || isCompleting}
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useState, useEffect, useCallback, useRef } from 'react';
|
|||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useLanguage } from '../i18n/LanguageContext';
|
import { useLanguage } from '../i18n/LanguageContext';
|
||||||
import { fonts, radius } from '../styles/theme';
|
import { fonts, radius } from '../styles/theme';
|
||||||
|
import { haptic } from '../haptic';
|
||||||
import { getNextPronunciationWord, trackPronunciationOpened, getTTS } from '../api';
|
import { getNextPronunciationWord, trackPronunciationOpened, getTTS } from '../api';
|
||||||
import RulesModal from '../components/RulesModal';
|
import RulesModal from '../components/RulesModal';
|
||||||
import { useAchievements } from '../hooks/useAchievements';
|
import { useAchievements } from '../hooks/useAchievements';
|
||||||
@@ -53,6 +54,9 @@ const PronunciationPage: React.FC = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const playWord = async (word: string) => {
|
const playWord = async (word: string) => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_pronunciation — тап по слову
|
||||||
|
haptic.selection();
|
||||||
|
|
||||||
// Останавливаем предыдущее аудио
|
// Останавливаем предыдущее аудио
|
||||||
if (audioRef.current) {
|
if (audioRef.current) {
|
||||||
audioRef.current.pause();
|
audioRef.current.pause();
|
||||||
@@ -293,7 +297,12 @@ const PronunciationPage: React.FC = () => {
|
|||||||
}}>
|
}}>
|
||||||
<div style={{ display: 'flex', gap: '8px', alignItems: 'center' }}>
|
<div style={{ display: 'flex', gap: '8px', alignItems: 'center' }}>
|
||||||
<button
|
<button
|
||||||
onClick={() => navigate('/menu')}
|
onClick={() => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_pronunciation — навигация
|
||||||
|
haptic.light();
|
||||||
|
navigate('/menu');
|
||||||
|
}}
|
||||||
|
data-no-haptic="true"
|
||||||
style={{
|
style={{
|
||||||
...glass({
|
...glass({
|
||||||
padding: '10px 18px',
|
padding: '10px 18px',
|
||||||
@@ -312,7 +321,12 @@ const PronunciationPage: React.FC = () => {
|
|||||||
← {t('back')}
|
← {t('back')}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowRules(true)}
|
onClick={() => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_pronunciation — открытие правил
|
||||||
|
haptic.light();
|
||||||
|
setShowRules(true);
|
||||||
|
}}
|
||||||
|
data-no-haptic="true"
|
||||||
style={{
|
style={{
|
||||||
...glass({
|
...glass({
|
||||||
width: '40px',
|
width: '40px',
|
||||||
@@ -374,25 +388,27 @@ const PronunciationPage: React.FC = () => {
|
|||||||
|
|
||||||
{/* Карточка со словом */}
|
{/* Карточка со словом */}
|
||||||
{currentWord && (
|
{currentWord && (
|
||||||
<div style={{
|
<div
|
||||||
flex: 1,
|
data-no-haptic="true"
|
||||||
...glass({
|
onClick={() => playWord(currentWord.word_pl)}
|
||||||
borderRadius: radius.lg,
|
style={{
|
||||||
padding: '32px',
|
flex: 1,
|
||||||
display: 'flex',
|
...glass({
|
||||||
flexDirection: 'column',
|
borderRadius: radius.lg,
|
||||||
justifyContent: 'center',
|
padding: '32px',
|
||||||
alignItems: 'center',
|
display: 'flex',
|
||||||
gap: '20px',
|
flexDirection: 'column',
|
||||||
minHeight: '300px',
|
justifyContent: 'center',
|
||||||
}),
|
alignItems: 'center',
|
||||||
border: `2px solid ${levelColor}30`,
|
gap: '20px',
|
||||||
animation: 'fadeInUp 0.3s ease 0.1s both',
|
minHeight: '300px',
|
||||||
cursor: 'pointer',
|
}),
|
||||||
}}
|
border: `2px solid ${levelColor}30`,
|
||||||
onClick={() => playWord(currentWord.word_pl)}
|
animation: 'fadeInUp 0.3s ease 0.1s both',
|
||||||
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.98)'; }}
|
cursor: 'pointer',
|
||||||
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
}}
|
||||||
|
onTouchStart={(e) => { e.currentTarget.style.transform = 'scale(0.98)'; }}
|
||||||
|
onTouchEnd={(e) => { e.currentTarget.style.transform = 'scale(1)'; }}
|
||||||
>
|
>
|
||||||
{/* Иконка динамика */}
|
{/* Иконка динамика */}
|
||||||
<div style={{
|
<div style={{
|
||||||
@@ -460,7 +476,14 @@ const PronunciationPage: React.FC = () => {
|
|||||||
|
|
||||||
{/* Кнопка Далее */}
|
{/* Кнопка Далее */}
|
||||||
<button
|
<button
|
||||||
onClick={fetchWord}
|
data-no-haptic="true"
|
||||||
|
onClick={() => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_pronunciation — следующее слово
|
||||||
|
// haptic ВНУТРИ onClick, а не в fetchWord,
|
||||||
|
// чтобы не было ложной вибрации при первом рендере.
|
||||||
|
haptic.light();
|
||||||
|
fetchWord();
|
||||||
|
}}
|
||||||
style={{
|
style={{
|
||||||
marginTop: '20px',
|
marginTop: '20px',
|
||||||
padding: '16px',
|
padding: '16px',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import { useLanguage } from '../i18n/LanguageContext';
|
import { useLanguage } from '../i18n/LanguageContext';
|
||||||
import { useLocalized } from '../hooks/useLocalized';
|
import { useLocalized } from '../hooks/useLocalized';
|
||||||
import { fonts, radius } from '../styles/theme';
|
import { fonts, radius } from '../styles/theme';
|
||||||
|
import { haptic } from '../haptic';
|
||||||
import {
|
import {
|
||||||
teacherStart,
|
teacherStart,
|
||||||
teacherResume,
|
teacherResume,
|
||||||
@@ -352,6 +353,8 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
|
|
||||||
// ============ HANDLERS ============
|
// ============ HANDLERS ============
|
||||||
const handleClearChat = () => {
|
const handleClearChat = () => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_teacher_chat — очистка чата
|
||||||
|
haptic.medium();
|
||||||
setMessages([]);
|
setMessages([]);
|
||||||
setScreen({ kind: 'start' });
|
setScreen({ kind: 'start' });
|
||||||
setSessionId(null);
|
setSessionId(null);
|
||||||
@@ -378,6 +381,9 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
const handleStart = async () => {
|
const handleStart = async () => {
|
||||||
if (isLoading) return;
|
if (isLoading) return;
|
||||||
|
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_teacher_chat — старт урока
|
||||||
|
haptic.medium();
|
||||||
|
|
||||||
setShowMenuModal(false);
|
setShowMenuModal(false);
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setSessionId(null);
|
setSessionId(null);
|
||||||
@@ -462,6 +468,13 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
try {
|
try {
|
||||||
const data = await teacherAnswer(sessionId, currentQuestionId, answer, timeTaken);
|
const data = await teacherAnswer(sessionId, currentQuestionId, answer, timeTaken);
|
||||||
|
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_teacher_chat — success/error на ответ
|
||||||
|
if (data.is_correct) {
|
||||||
|
haptic.success();
|
||||||
|
} else {
|
||||||
|
haptic.error();
|
||||||
|
}
|
||||||
|
|
||||||
let correctAnswerText = data.correct_answer || '';
|
let correctAnswerText = data.correct_answer || '';
|
||||||
|
|
||||||
if (!correctAnswerText) {
|
if (!correctAnswerText) {
|
||||||
@@ -538,6 +551,9 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
|
|
||||||
// Переход к следующему вопросу (после ответа)
|
// Переход к следующему вопросу (после ответа)
|
||||||
const handleNextQuestion = () => {
|
const handleNextQuestion = () => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_teacher_chat — переход к следующему вопросу
|
||||||
|
haptic.light();
|
||||||
|
|
||||||
// Ищем последний вопрос в messages (последний добавленный)
|
// Ищем последний вопрос в messages (последний добавленный)
|
||||||
const lastQuestion = [...messages].reverse().find(m => m.isQuestion);
|
const lastQuestion = [...messages].reverse().find(m => m.isQuestion);
|
||||||
|
|
||||||
@@ -613,6 +629,8 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
const handleSubmitAnswer = () => {
|
const handleSubmitAnswer = () => {
|
||||||
const text = inputValue.trim();
|
const text = inputValue.trim();
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_teacher_chat — отправка свободного ответа
|
||||||
|
haptic.light();
|
||||||
handleAnswer(text);
|
handleAnswer(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -861,6 +879,7 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
onClick={handleStart}
|
onClick={handleStart}
|
||||||
|
data-no-haptic="true"
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
style={{
|
style={{
|
||||||
padding: '16px 32px', borderRadius: radius.lg, border: 'none',
|
padding: '16px 32px', borderRadius: radius.lg, border: 'none',
|
||||||
@@ -1017,6 +1036,7 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
{currentQuestion.options.map((option) => (
|
{currentQuestion.options.map((option) => (
|
||||||
<button
|
<button
|
||||||
key={option.option_key}
|
key={option.option_key}
|
||||||
|
data-no-haptic="true"
|
||||||
onClick={() => handleOptionClick(option)}
|
onClick={() => handleOptionClick(option)}
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
style={{
|
style={{
|
||||||
@@ -1059,6 +1079,7 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
onClick={handleSubmitAnswer}
|
onClick={handleSubmitAnswer}
|
||||||
|
data-no-haptic="true"
|
||||||
disabled={isLoading || !inputValue.trim()}
|
disabled={isLoading || !inputValue.trim()}
|
||||||
style={{
|
style={{
|
||||||
padding: '12px 18px', borderRadius: radius.md, border: 'none',
|
padding: '12px 18px', borderRadius: radius.md, border: 'none',
|
||||||
@@ -1130,6 +1151,7 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
{/* Кнопка "Следующий вопрос" */}
|
{/* Кнопка "Следующий вопрос" */}
|
||||||
<button
|
<button
|
||||||
onClick={handleNextQuestion}
|
onClick={handleNextQuestion}
|
||||||
|
data-no-haptic="true"
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
style={{
|
style={{
|
||||||
padding: '16px 24px', borderRadius: radius.lg, border: 'none',
|
padding: '16px 24px', borderRadius: radius.lg, border: 'none',
|
||||||
@@ -1171,6 +1193,7 @@ const TeacherChatPage: React.FC = () => {
|
|||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={handleStart}
|
onClick={handleStart}
|
||||||
|
data-no-haptic="true"
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
style={{
|
style={{
|
||||||
padding: '16px 32px', borderRadius: radius.lg, border: 'none',
|
padding: '16px 32px', borderRadius: radius.lg, border: 'none',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { useNavigate, useParams } from 'react-router-dom';
|
|||||||
import { useLanguage } from '../i18n/LanguageContext';
|
import { useLanguage } from '../i18n/LanguageContext';
|
||||||
import { useLocalized } from '../hooks/useLocalized';
|
import { useLocalized } from '../hooks/useLocalized';
|
||||||
import { fonts, radius } from '../styles/theme';
|
import { fonts, radius } from '../styles/theme';
|
||||||
|
import { haptic } from '../haptic';
|
||||||
import { getTopicTest, startLearningSession, saveLearningAnswer, completeLearningSession, teacherExamples, getLearningAnalytics, startWeakSkillsPractice, getTTS } from '../api';
|
import { getTopicTest, startLearningSession, saveLearningAnswer, completeLearningSession, teacherExamples, getLearningAnalytics, startWeakSkillsPractice, getTTS } from '../api';
|
||||||
|
|
||||||
interface QuestionOption {
|
interface QuestionOption {
|
||||||
@@ -151,6 +152,8 @@ const TestViewPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleAnswerSelect = async (questionId: string, optionKey: string) => {
|
const handleAnswerSelect = async (questionId: string, optionKey: string) => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_test_view — выбор варианта
|
||||||
|
haptic.selection();
|
||||||
setSelectedAnswers(prev => ({ ...prev, [questionId]: optionKey }));
|
setSelectedAnswers(prev => ({ ...prev, [questionId]: optionKey }));
|
||||||
// 🔧 ФИКС (23.09.2026): обычный ответ — isFinalAnswer=true, usedHint=false
|
// 🔧 ФИКС (23.09.2026): обычный ответ — isFinalAnswer=true, usedHint=false
|
||||||
await saveAnswer(questionId, optionKey, true, false);
|
await saveAnswer(questionId, optionKey, true, false);
|
||||||
@@ -174,6 +177,8 @@ const TestViewPage: React.FC = () => {
|
|||||||
setTextInputValue('');
|
setTextInputValue('');
|
||||||
startTimeRef.current = Date.now();
|
startTimeRef.current = Date.now();
|
||||||
} else {
|
} else {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_test_view — завершение теста
|
||||||
|
haptic.heavy();
|
||||||
setIsCompleting(true);
|
setIsCompleting(true);
|
||||||
|
|
||||||
// 🔧 ФИКС (24.09.2026): TESTVIEW_DUPLICATE_SAVE —
|
// 🔧 ФИКС (24.09.2026): TESTVIEW_DUPLICATE_SAVE —
|
||||||
@@ -196,6 +201,8 @@ const TestViewPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_test_view — вибрация возврата
|
||||||
|
haptic.light();
|
||||||
if (currentIndex > 0) {
|
if (currentIndex > 0) {
|
||||||
setCurrentIndex(prev => prev - 1);
|
setCurrentIndex(prev => prev - 1);
|
||||||
setTextInputValue('');
|
setTextInputValue('');
|
||||||
@@ -410,7 +417,12 @@ const TestViewPage: React.FC = () => {
|
|||||||
{/* 🔧 НОВОЕ: Кнопки "Дай примеры" и "Потренировать слабые темы" */}
|
{/* 🔧 НОВОЕ: Кнопки "Дай примеры" и "Потренировать слабые темы" */}
|
||||||
<div style={{ marginTop: '20px', width: '100%', maxWidth: '300px', display: 'flex', flexDirection: 'column', gap: '10px' }}>
|
<div style={{ marginTop: '20px', width: '100%', maxWidth: '300px', display: 'flex', flexDirection: 'column', gap: '10px' }}>
|
||||||
<button
|
<button
|
||||||
onClick={handleLoadExamples}
|
onClick={() => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_test_view — вибрация загрузки примеров
|
||||||
|
haptic.medium();
|
||||||
|
handleLoadExamples();
|
||||||
|
}}
|
||||||
|
data-no-haptic="true"
|
||||||
disabled={isLoadingExamples}
|
disabled={isLoadingExamples}
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -436,7 +448,12 @@ const TestViewPage: React.FC = () => {
|
|||||||
💡 {t('testExamplesButton')}
|
💡 {t('testExamplesButton')}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={handleStartPractice}
|
onClick={() => {
|
||||||
|
// 🔧 ФИКС (01.10.2026): haptic_test_view — вибрация старта практики
|
||||||
|
haptic.medium();
|
||||||
|
handleStartPractice();
|
||||||
|
}}
|
||||||
|
data-no-haptic="true"
|
||||||
disabled={isStartingPractice}
|
disabled={isStartingPractice}
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -717,6 +734,7 @@ const TestViewPage: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={option.option_key}
|
key={option.option_key}
|
||||||
|
data-no-haptic="true"
|
||||||
onClick={() => handleAnswerSelect(currentQuestion.question.question_id, option.option_key)}
|
onClick={() => handleAnswerSelect(currentQuestion.question.question_id, option.option_key)}
|
||||||
style={{
|
style={{
|
||||||
padding: '14px 16px',
|
padding: '14px 16px',
|
||||||
@@ -786,6 +804,7 @@ const TestViewPage: React.FC = () => {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={handleNext}
|
onClick={handleNext}
|
||||||
|
data-no-haptic="true"
|
||||||
disabled={!isCurrentAnswered || isCompleting}
|
disabled={!isCurrentAnswered || isCompleting}
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user