fix & feat: resolve user reports #1 through #8 (TTS voice & speed, modals, scrollbar, CEFR hint, SRS grammar exclusion, global word lookup)
This commit is contained in:
1 parent
8cffae46fa
commit
7871191c90
12 files changed
+385
-45
No files matched your search
@@ -12,7 +12,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
router = APIRouter(prefix="/api/feedback", tags=["Feedback & Bug Tracker"])
|
||||
|
||||
# Path to workspace memory file for seamless Antigravity AI reading
|
||||
# Paths to markdown reports files for seamless Antigravity AI reading
|
||||
DATA_REPORTS_FILE = Path(__file__).resolve().parent.parent.parent / "data" / "USER_REPORTS.md"
|
||||
MEMORY_REPORTS_FILE = Path("/home/ai-projects/memory/USER_REPORTS.md")
|
||||
|
||||
|
||||
@@ -97,8 +98,13 @@ def sync_reports_to_markdown(conn):
|
||||
lines.append(f"- [x] **#{r['id']} {cat_emoji} ({r['created_at']})**: {r['message'].strip()} *(Страница: {r['context_url'] or 'общая'})*")
|
||||
lines.append("")
|
||||
|
||||
MEMORY_REPORTS_FILE.parent.mkdir(parents=True, exist_ok=True)
|
||||
MEMORY_REPORTS_FILE.write_text("\n".join(lines), encoding="utf-8")
|
||||
content = "\n".join(lines)
|
||||
for target in [DATA_REPORTS_FILE, MEMORY_REPORTS_FILE]:
|
||||
try:
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_text(content, encoding="utf-8")
|
||||
except Exception as e:
|
||||
logger.debug(f"Could not write to {target}: {e}")
|
||||
except Exception as e:
|
||||
logger.warning(f"Could not sync reports to markdown: {e}")
|
||||
|
||||
|
||||
+18
-2
@@ -24,6 +24,7 @@ async def api_srs_queue(
|
||||
tag: Optional[str] = None,
|
||||
limit: int = 25,
|
||||
mix: bool = False,
|
||||
exclude_grammar: bool = True,
|
||||
user: dict = Depends(require_user),
|
||||
):
|
||||
"""
|
||||
@@ -46,6 +47,13 @@ async def api_srs_queue(
|
||||
col_filter += " AND tags LIKE ?"
|
||||
col_params.append(f"%{tag.strip()}%")
|
||||
|
||||
# Exclude grammar cards from standard SRS vocabulary training unless grammar collection/tag is specifically requested
|
||||
wants_grammar = (collection and ("грамматика" in collection.lower() or "grammar" in collection.lower())) or \
|
||||
(tag and "grammar" in tag.lower())
|
||||
if exclude_grammar and not wants_grammar:
|
||||
col_filter += " AND (collection IS NULL OR (collection != 'Грамматика Мерфи' AND collection NOT LIKE '%grammar%'))"
|
||||
col_filter += " AND (tags IS NULL OR tags NOT LIKE '%grammar%')"
|
||||
|
||||
if mix:
|
||||
# 1. New cards (up to 10)
|
||||
new_rows = conn.execute(
|
||||
@@ -117,6 +125,7 @@ async def api_srs_quiz(
|
||||
collection: Optional[str] = None,
|
||||
tag: Optional[str] = None,
|
||||
count: int = 10,
|
||||
exclude_grammar: bool = True,
|
||||
user: dict = Depends(require_user),
|
||||
):
|
||||
"""
|
||||
@@ -132,15 +141,22 @@ async def api_srs_quiz(
|
||||
col_filter += " AND tags LIKE ?"
|
||||
col_params.append(f"%{tag.strip()}%")
|
||||
|
||||
wants_grammar = (collection and ("грамматика" in collection.lower() or "grammar" in collection.lower())) or \
|
||||
(tag and "grammar" in tag.lower())
|
||||
if exclude_grammar and not wants_grammar:
|
||||
col_filter += " AND (collection IS NULL OR (collection != 'Грамматика Мерфи' AND collection NOT LIKE '%grammar%'))"
|
||||
col_filter += " AND (tags IS NULL OR tags NOT LIKE '%grammar%')"
|
||||
|
||||
rows = conn.execute(
|
||||
f"SELECT * FROM vocabulary_cards WHERE user_id = ?{col_filter} ORDER BY RANDOM() LIMIT ?",
|
||||
[user["id"]] + col_params + [count],
|
||||
).fetchall()
|
||||
target_cards = [dict(r) for r in rows]
|
||||
|
||||
# Fetch pool of all user cards for generating smart distractors
|
||||
# Fetch pool of user cards for generating smart distractors (exclude grammar)
|
||||
distractor_filter = " AND (collection IS NULL OR (collection != 'Грамматика Мерфи' AND collection NOT LIKE '%grammar%')) AND (tags IS NULL OR tags NOT LIKE '%grammar%')" if exclude_grammar and not wants_grammar else ""
|
||||
all_rows = conn.execute(
|
||||
"SELECT id, term, translation, part_of_speech FROM vocabulary_cards WHERE user_id = ?",
|
||||
f"SELECT id, term, translation, part_of_speech FROM vocabulary_cards WHERE user_id = ?{distractor_filter}",
|
||||
(user["id"],),
|
||||
).fetchall()
|
||||
all_cards = [dict(r) for r in all_rows]
|
||||
|
||||
@@ -347,6 +347,25 @@
|
||||
will-change: transform;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--border-color) transparent;
|
||||
}
|
||||
|
||||
.app-drawer::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.app-drawer::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.app-drawer::-webkit-scrollbar-thumb {
|
||||
background-color: var(--border-color);
|
||||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
.app-drawer::-webkit-scrollbar-thumb:hover {
|
||||
background-color: var(--text-muted);
|
||||
}
|
||||
|
||||
.app-drawer.active {
|
||||
@@ -684,9 +703,11 @@ body.drawer-open {
|
||||
border-radius: var(--radius-lg);
|
||||
width: 100%;
|
||||
max-width: 520px;
|
||||
max-height: min(90vh, 90dvh);
|
||||
box-shadow: var(--shadow-lg);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
@@ -695,6 +716,7 @@ body.drawer-open {
|
||||
align-items: center;
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.modal-header h3 {
|
||||
@@ -707,6 +729,19 @@ body.drawer-open {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--border-color) transparent;
|
||||
}
|
||||
|
||||
.modal-body::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.modal-body::-webkit-scrollbar-thumb {
|
||||
background-color: var(--border-color);
|
||||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
@@ -715,12 +750,44 @@ body.drawer-open {
|
||||
gap: 10px;
|
||||
padding: 14px 20px;
|
||||
border-top: 1px solid var(--border-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.modal-sm {
|
||||
max-width: 420px;
|
||||
}
|
||||
|
||||
/* Audio Control Group & Slow Speed Controls */
|
||||
.audio-ctrl-group {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.audio-slow-btn {
|
||||
font-size: 11px !important;
|
||||
font-weight: 600;
|
||||
padding: 2px 7px !important;
|
||||
height: 24px;
|
||||
line-height: 1;
|
||||
border-radius: 4px;
|
||||
background: var(--bg-hover);
|
||||
border: 1px solid var(--border-color);
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.audio-slow-btn:hover {
|
||||
background: var(--bg-surface-elevated);
|
||||
color: var(--text-main);
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
/* Navigation Additions */
|
||||
.nav-center {
|
||||
display: flex;
|
||||
|
||||
@@ -322,7 +322,10 @@
|
||||
<div class="fc-back-detail-box" id="fc-back-context-box">
|
||||
<div class="fc-detail-header-row" style="display: flex; align-items: center; justify-content: space-between;">
|
||||
<span class="detail-label">Контекст:</span>
|
||||
<button type="button" id="fc-back-context-audio-btn" class="icon-btn audio-xs-btn" title="Озвучить предложение контекста">🔊</button>
|
||||
<span class="audio-ctrl-group">
|
||||
<button type="button" id="fc-back-context-audio-btn" class="icon-btn audio-xs-btn" title="Озвучить пример (1.0x)">🔊</button>
|
||||
<button type="button" id="fc-back-context-audio-slow-btn" class="icon-btn audio-xs-btn audio-slow-btn" title="Озвучить медленно (0.7x)">🐢 0.7x</button>
|
||||
</span>
|
||||
</div>
|
||||
<p id="fc-back-context" class="detail-text"></p>
|
||||
</div>
|
||||
@@ -2017,9 +2020,12 @@
|
||||
<button type="button" id="popup-translate-sentence-btn" class="btn btn-xs btn-outline popup-sentence-btn" title="Перевести всё предложение через локальный ИИ">
|
||||
🌐 Перевести предложение
|
||||
</button>
|
||||
<button type="button" id="popup-audio-sentence-btn" class="btn btn-xs btn-outline popup-sentence-audio-btn" title="Озвучить всё предложение нейросетью">
|
||||
<button type="button" id="popup-audio-sentence-btn" class="btn btn-xs btn-outline popup-sentence-audio-btn" title="Озвучить всё предложение (1.0x)">
|
||||
🔊 Озвучить
|
||||
</button>
|
||||
<button type="button" id="popup-audio-sentence-slow-btn" class="btn btn-xs btn-outline popup-sentence-audio-btn audio-slow-btn" title="Озвучить предложение медленно (0.7x)">
|
||||
🐢 0.7x
|
||||
</button>
|
||||
<span id="popup-ai-source-badge" class="popup-ai-source-badge hidden">⚡ Local AI</span>
|
||||
</div>
|
||||
<div id="popup-sentence-loading" class="popup-sentence-loading hidden">
|
||||
|
||||
+63
-3
@@ -7,7 +7,7 @@ import { api } from './modules/api.js';
|
||||
import { initTheme, openModal, closeModal, showToast, playTextSpeech, switchView } from './modules/ui.js';
|
||||
import { initDictionary, loadInitialData } from './modules/dictionary.js';
|
||||
import { initSrs, startSrsTrainingSession, openStatsDashboard } from './modules/srs.js';
|
||||
import { initReader, loadBookshelf, openBook } from './modules/reader.js';
|
||||
import { initReader, loadBookshelf, openBook, openWordPopup, extractContextSentence } from './modules/reader.js';
|
||||
import { initCefr, loadCefrOverview, startCefrQuiz } from './modules/cefr.js';
|
||||
import { initGrammar, loadGrammarUnits, openGrammarUnit } from './modules/grammar.js';
|
||||
import { initLessonModule, openLessonConfigurator } from './modules/lesson.js';
|
||||
@@ -416,11 +416,71 @@ export function initNavigationDrawer() {
|
||||
if (drawerCloseBtn) drawerCloseBtn.addEventListener('click', closeDrawer);
|
||||
if (drawerBackdrop) drawerBackdrop.addEventListener('click', closeDrawer);
|
||||
|
||||
// Escape Key Support
|
||||
// Global Escape Key & Modal Dismiss Support
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape' && drawer && drawer.classList.contains('active')) {
|
||||
if (e.key === 'Escape') {
|
||||
// 1. If navigation drawer is open, close it
|
||||
if (drawer && drawer.classList.contains('active')) {
|
||||
closeDrawer();
|
||||
return;
|
||||
}
|
||||
// 2. Close any open modal backdrop (topmost visible modal)
|
||||
const openModals = Array.from(document.querySelectorAll('.modal-backdrop:not(.hidden)'));
|
||||
if (openModals.length > 0) {
|
||||
const topModal = openModals[openModals.length - 1];
|
||||
topModal.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Dismiss modals when clicking on dark backdrop outside modal window
|
||||
document.addEventListener('click', (e) => {
|
||||
if (e.target && e.target.classList && e.target.classList.contains('modal-backdrop')) {
|
||||
e.target.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Global Text Selection Lookup & Add-to-Dictionary (Anywhere on Page)
|
||||
// -----------------------------------------------------------------------
|
||||
function handleGlobalTextSelection(e) {
|
||||
if (e && e.target && e.target.closest('#reader-word-popup, button, input, textarea, select, .modal-window, #feedback-widget, .icon-btn, .opt-btn, .tab-item, .drawer-nav-item')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const selection = window.getSelection();
|
||||
if (!selection || selection.isCollapsed) return;
|
||||
const raw = selection.toString().trim();
|
||||
if (!raw || raw.length < 2 || raw.length > 50) return;
|
||||
|
||||
// Clean punctuation / quotes
|
||||
const clean = raw.replace(/^['"“«`\s\-_.,;:!?()[\]{}]+|['"”»`\s\-_.,;:!?()[\]{}]+$/g, '').trim();
|
||||
// Require Latin characters (English vocabulary)
|
||||
if (!clean || !/^[A-Za-z\s'-]+$/.test(clean)) return;
|
||||
|
||||
if (selection.rangeCount === 0) return;
|
||||
const range = selection.getRangeAt(0);
|
||||
const rect = range.getBoundingClientRect();
|
||||
if (rect.width === 0 && rect.height === 0) return;
|
||||
|
||||
const containerElem = range.startContainer?.nodeType === 1 ? range.startContainer : range.startContainer?.parentElement;
|
||||
// Avoid re-triggering if already inside reader word span (which handles its own click)
|
||||
if (containerElem?.closest('.reader-word')) return;
|
||||
|
||||
const fullText = containerElem?.innerText || containerElem?.textContent || '';
|
||||
const contextSentence = extractContextSentence(fullText, clean);
|
||||
|
||||
const virtualTarget = {
|
||||
getBoundingClientRect: () => range.getBoundingClientRect(),
|
||||
isConnected: true
|
||||
};
|
||||
|
||||
openWordPopup(clean, contextSentence, virtualTarget, fullText);
|
||||
}
|
||||
|
||||
document.addEventListener('mouseup', handleGlobalTextSelection);
|
||||
document.addEventListener('touchend', (e) => {
|
||||
setTimeout(() => handleGlobalTextSelection(e), 150);
|
||||
});
|
||||
|
||||
// Touch Swipe Left to Dismiss (Mobile & Tablet)
|
||||
|
||||
@@ -4,19 +4,22 @@
|
||||
// =======================================================================
|
||||
|
||||
import { api } from './api.js';
|
||||
import { showToast, escapeHtml } from './ui.js';
|
||||
import { showToast, escapeHtml, playTextSpeech } from './ui.js';
|
||||
|
||||
let currentLevel = 'A1';
|
||||
let currentMode = 'all';
|
||||
let currentQuiz = [];
|
||||
let currentQuestionIdx = 0;
|
||||
let isAnswered = false;
|
||||
let hintUsedThisQuestion = false;
|
||||
|
||||
const sessionStats = {
|
||||
total: 0,
|
||||
correct: 0,
|
||||
mistakes: 0,
|
||||
ingested: 0,
|
||||
score: 0,
|
||||
hintsUsed: 0,
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@@ -391,6 +394,8 @@ export async function startCefrQuiz(level = 'A1', mode = 'all') {
|
||||
sessionStats.correct = 0;
|
||||
sessionStats.mistakes = 0;
|
||||
sessionStats.ingested = 0;
|
||||
sessionStats.score = 0;
|
||||
sessionStats.hintsUsed = 0;
|
||||
|
||||
showCefrScreen('quiz');
|
||||
|
||||
@@ -459,6 +464,8 @@ function renderCurrentQuestion() {
|
||||
const cardContainer = document.getElementById('cefr-cloze-card');
|
||||
if (!cardContainer) return;
|
||||
|
||||
hintUsedThisQuestion = false;
|
||||
|
||||
// Stylize the sentence blank: replace ___ with a visible blank node
|
||||
const formattedSentence = escapeHtml(q.sentence).replace(/___/g, '<span class="cefr-blank" id="cefr-blank-target">_____</span>');
|
||||
|
||||
@@ -473,11 +480,16 @@ function renderCurrentQuestion() {
|
||||
<p class="cefr-sentence-text">${formattedSentence}</p>
|
||||
</div>
|
||||
|
||||
<div class="cefr-clue-box">
|
||||
<div class="cefr-clue-box" id="cefr-clue-box">
|
||||
<button type="button" class="btn btn-xs btn-outline cefr-hint-btn" id="cefr-hint-btn" title="Показать подсказку с переводом слова (-0.2 балла)">
|
||||
💡 Подсказка (-0.2 балла)
|
||||
</button>
|
||||
<div id="cefr-hint-content" class="cefr-hint-content hidden">
|
||||
<span class="clue-icon">💡</span>
|
||||
<span class="clue-label">Значение:</span>
|
||||
<strong class="clue-term">${escapeHtml(q.clue)}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cefr-options-grid" id="cefr-options-grid">
|
||||
${q.options.map((opt, idx) => `
|
||||
@@ -491,6 +503,17 @@ function renderCurrentQuestion() {
|
||||
<div id="cefr-feedback-box" class="cefr-feedback-box hidden"></div>
|
||||
`;
|
||||
|
||||
// Hook up hint toggle button
|
||||
const hintBtn = cardContainer.querySelector('#cefr-hint-btn');
|
||||
const hintContent = cardContainer.querySelector('#cefr-hint-content');
|
||||
if (hintBtn && hintContent) {
|
||||
hintBtn.addEventListener('click', () => {
|
||||
hintUsedThisQuestion = true;
|
||||
hintBtn.classList.add('hidden');
|
||||
hintContent.classList.remove('hidden');
|
||||
});
|
||||
}
|
||||
|
||||
// Attach click listeners to option buttons
|
||||
cardContainer.querySelectorAll('.cefr-opt-btn').forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
@@ -524,6 +547,10 @@ async function handleOptionTap(questionId, selectedOption, clickedBtn) {
|
||||
|
||||
if (res.correct) {
|
||||
sessionStats.correct++;
|
||||
const pts = hintUsedThisQuestion ? 0.8 : 1.0;
|
||||
sessionStats.score += pts;
|
||||
if (hintUsedThisQuestion) sessionStats.hintsUsed++;
|
||||
|
||||
clickedBtn.classList.add('opt-correct');
|
||||
if (blankTarget) {
|
||||
blankTarget.textContent = res.correct_option;
|
||||
@@ -533,16 +560,28 @@ async function handleOptionTap(questionId, selectedOption, clickedBtn) {
|
||||
if (feedbackBox) {
|
||||
feedbackBox.className = 'cefr-feedback-box feedback-correct';
|
||||
feedbackBox.innerHTML = `
|
||||
<div class="fb-title">✓ Верно! Отличный выбор.</div>
|
||||
<div class="fb-meta">
|
||||
<div class="fb-title">✓ Верно! ${pts === 0.8 ? 'Получено: <strong>+0.8 балла</strong> (с подсказкой)' : 'Получено: <strong>+1.0 балл</strong>'}</div>
|
||||
<div class="fb-meta" style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap;">
|
||||
<strong class="fb-term">${escapeHtml(res.correct_option)}</strong>
|
||||
${res.phonetic ? `<span class="res-phonetic">${escapeHtml(res.phonetic)}</span>` : ''}
|
||||
<span class="audio-ctrl-group">
|
||||
<button type="button" class="icon-btn audio-xs-btn play-cefr-word-audio-btn" title="Озвучить слово (1.0x)">🔊</button>
|
||||
<button type="button" class="icon-btn audio-xs-btn audio-slow-btn play-cefr-word-slow-btn" title="Озвучить медленно (0.7x)">🐢 0.7x</button>
|
||||
</span>
|
||||
</div>
|
||||
${res.source_book_title ? `<div class="fb-source-citation">📖 Пример из книги «${escapeHtml(res.source_book_title)}»${res.source_chapter_title ? ` (${escapeHtml(res.source_chapter_title)})` : ''}</div>` : ''}
|
||||
${res.explanation ? `<p class="fb-explanation">${escapeHtml(res.explanation)}</p>` : ''}
|
||||
${renderOptionsBreakdown(res.options_breakdown)}
|
||||
`;
|
||||
feedbackBox.classList.remove('hidden');
|
||||
feedbackBox.querySelector('.play-cefr-word-audio-btn')?.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
playTextSpeech(res.correct_option, 'en', 1.0);
|
||||
});
|
||||
feedbackBox.querySelector('.play-cefr-word-slow-btn')?.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
playTextSpeech(res.correct_option, 'en', 0.75);
|
||||
});
|
||||
attachBreakdownListeners(feedbackBox, sentence);
|
||||
}
|
||||
} else {
|
||||
@@ -550,6 +589,12 @@ async function handleOptionTap(questionId, selectedOption, clickedBtn) {
|
||||
// Two words were ingested: the correct target word and the clicked distractor
|
||||
sessionStats.ingested += 2;
|
||||
|
||||
// Automatically reveal clue on mistake so user sees the meaning
|
||||
const hBtn = document.getElementById('cefr-hint-btn');
|
||||
const hCnt = document.getElementById('cefr-hint-content');
|
||||
if (hBtn) hBtn.classList.add('hidden');
|
||||
if (hCnt) hCnt.classList.remove('hidden');
|
||||
|
||||
clickedBtn.classList.add('opt-wrong');
|
||||
|
||||
// Highlight the true correct option
|
||||
@@ -623,7 +668,8 @@ function renderQuizSummary() {
|
||||
const correct = sessionStats.correct;
|
||||
const mistakes = sessionStats.mistakes;
|
||||
const ingested = sessionStats.ingested;
|
||||
const pct = Math.round((correct / total) * 100);
|
||||
const earnedScore = Math.round(sessionStats.score * 10) / 10;
|
||||
const pct = Math.round((earnedScore / total) * 100);
|
||||
|
||||
const sumScore = document.getElementById('cefr-sum-score');
|
||||
const sumLead = document.getElementById('cefr-sum-lead');
|
||||
@@ -633,8 +679,8 @@ function renderQuizSummary() {
|
||||
const sumSrsBtn = document.getElementById('cefr-sum-srs-btn');
|
||||
|
||||
if (sumScore) sumScore.textContent = `${pct}%`;
|
||||
if (sumCorrect) sumCorrect.textContent = `${correct} / ${total}`;
|
||||
if (sumMistakes) sumMistakes.textContent = mistakes;
|
||||
if (sumCorrect) sumCorrect.textContent = `${earnedScore} / ${total} баллов (${correct} верных)`;
|
||||
if (sumMistakes) sumMistakes.innerHTML = `${mistakes} ${sessionStats.hintsUsed > 0 ? `<span style="font-size:12px;opacity:0.8;">(подсказок: ${sessionStats.hintsUsed})</span>` : ''}`;
|
||||
if (sumIngested) sumIngested.textContent = ingested;
|
||||
|
||||
if (sumLead) {
|
||||
|
||||
@@ -167,8 +167,7 @@ export function initDictionary() {
|
||||
audioPlayBtn.addEventListener('click', () => {
|
||||
const term = currentLookupData?.term || currentLookupData?.english_term;
|
||||
if (!term) return;
|
||||
const url = currentLookupData.audio_url || `/api/tts?text=${encodeURIComponent(term)}&lang=en`;
|
||||
playAudio(url);
|
||||
playTextSpeech(term, 'en');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -402,7 +401,10 @@ export function initDictionary() {
|
||||
${c.context_sentence ? `
|
||||
<div class="card-context">
|
||||
“${escapeHtml(c.context_sentence)}”
|
||||
<button class="icon-btn audio-play-btn play-context-audio-btn" data-id="${c.id}" title="Озвучить пример">🔊</button>
|
||||
<span class="audio-ctrl-group">
|
||||
<button class="icon-btn audio-play-btn play-context-audio-btn" data-id="${c.id}" title="Озвучить пример (1.0x)">🔊</button>
|
||||
<button class="icon-btn audio-slow-btn play-context-slow-btn" data-id="${c.id}" title="Озвучить медленно (0.7x)">🐢 0.7x</button>
|
||||
</span>
|
||||
</div>` : ''}
|
||||
<div class="card-bottom">
|
||||
<div class="card-tags">
|
||||
@@ -416,13 +418,17 @@ export function initDictionary() {
|
||||
// Audio buttons
|
||||
cardEl.querySelector('.play-term-audio-btn')?.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
if (c.audio_url) playAudio(c.audio_url);
|
||||
else playTextSpeech(c.term, 'en');
|
||||
playTextSpeech(c.term, 'en', 1.0);
|
||||
});
|
||||
|
||||
cardEl.querySelector('.play-context-audio-btn')?.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
playTextSpeech(c.context_sentence, 'en');
|
||||
playTextSpeech(c.context_sentence, 'en', 1.0);
|
||||
});
|
||||
|
||||
cardEl.querySelector('.play-context-slow-btn')?.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
playTextSpeech(c.context_sentence, 'en', 0.75);
|
||||
});
|
||||
|
||||
// Edit button
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// =======================================================================
|
||||
|
||||
import { api } from './api.js';
|
||||
import { escapeHtml, escapeRegex, slugify, showToast, playAudio } from './ui.js';
|
||||
import { escapeHtml, escapeRegex, slugify, showToast, playAudio, playTextSpeech } from './ui.js';
|
||||
import { getAllCards, fetchCards } from './dictionary.js';
|
||||
|
||||
// Reader State & Appearance Settings
|
||||
@@ -2251,6 +2251,7 @@ export function initReader() {
|
||||
|
||||
const popupAudioBtn = document.getElementById('popup-audio-btn');
|
||||
const popupAudioSentenceBtn = document.getElementById('popup-audio-sentence-btn');
|
||||
const popupAudioSentenceSlowBtn = document.getElementById('popup-audio-sentence-slow-btn');
|
||||
const popupAudioRuBtn = document.getElementById('popup-audio-ru-btn');
|
||||
const popupTranslateSentenceBtn = document.getElementById('popup-translate-sentence-btn');
|
||||
const popupUseContextMeaningBtn = document.getElementById('popup-use-context-meaning-btn');
|
||||
@@ -2265,9 +2266,7 @@ export function initReader() {
|
||||
popupAudioBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
if (!popupCurrentData || !popupCurrentData.term) return;
|
||||
const term = popupCurrentData.term;
|
||||
const url = popupCurrentData.audioUrl || `/api/tts?text=${encodeURIComponent(term)}&lang=en`;
|
||||
playAudio(url);
|
||||
playTextSpeech(popupCurrentData.term, 'en');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2275,9 +2274,15 @@ export function initReader() {
|
||||
popupAudioSentenceBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
if (!popupCurrentData || !popupCurrentData.contextSentence) return;
|
||||
const sentence = popupCurrentData.contextSentence;
|
||||
const url = `/api/tts?text=${encodeURIComponent(sentence)}&lang=en`;
|
||||
playAudio(url);
|
||||
playTextSpeech(popupCurrentData.contextSentence, 'en', 1.0);
|
||||
});
|
||||
}
|
||||
|
||||
if (popupAudioSentenceSlowBtn) {
|
||||
popupAudioSentenceSlowBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
if (!popupCurrentData || !popupCurrentData.contextSentence) return;
|
||||
playTextSpeech(popupCurrentData.contextSentence, 'en', 0.75);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2286,8 +2291,7 @@ export function initReader() {
|
||||
e.stopPropagation();
|
||||
const ruText = (popupSentenceRu && popupSentenceRu.textContent || '').trim();
|
||||
if (!ruText || ruText.startsWith('(') || ruText.startsWith('Ошибка')) return;
|
||||
const url = `/api/tts?text=${encodeURIComponent(ruText)}&lang=ru`;
|
||||
playAudio(url);
|
||||
playTextSpeech(ruText, 'ru', 1.0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// =======================================================================
|
||||
|
||||
import { api } from './api.js';
|
||||
import { escapeHtml, escapeRegex, shuffleArray, showToast, openModal, closeModal, playAudio, cleanPromptTranslation } from './ui.js';
|
||||
import { escapeHtml, escapeRegex, shuffleArray, showToast, openModal, closeModal, playAudio, playTextSpeech, cleanPromptTranslation } from './ui.js';
|
||||
import { getAllCards } from './dictionary.js';
|
||||
|
||||
let srsQueue = [];
|
||||
@@ -53,6 +53,7 @@ export function initSrs() {
|
||||
const fcBackContextBox = document.getElementById('fc-back-context-box');
|
||||
const fcBackContext = document.getElementById('fc-back-context');
|
||||
const fcBackContextAudioBtn = document.getElementById('fc-back-context-audio-btn');
|
||||
const fcBackContextAudioSlowBtn = document.getElementById('fc-back-context-audio-slow-btn');
|
||||
const fcBackNotesBox = document.getElementById('fc-back-notes-box');
|
||||
const fcBackNotes = document.getElementById('fc-back-notes');
|
||||
const fcFlipBtnWrap = document.getElementById('fc-flip-btn-wrap');
|
||||
@@ -352,6 +353,9 @@ export function initSrs() {
|
||||
if (fcBackContextAudioBtn) {
|
||||
fcBackContextAudioBtn.style.display = card.context_sentence ? 'inline-flex' : 'none';
|
||||
}
|
||||
if (fcBackContextAudioSlowBtn) {
|
||||
fcBackContextAudioSlowBtn.style.display = card.context_sentence ? 'inline-flex' : 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if (fcFrontAudioBtn) {
|
||||
@@ -359,8 +363,7 @@ export function initSrs() {
|
||||
e.stopPropagation();
|
||||
const card = srsQueue[srsCurrentIndex];
|
||||
if (!card) return;
|
||||
const url = card.audio_url || `/api/tts?text=${encodeURIComponent(card.term)}&lang=en`;
|
||||
playAudio(url);
|
||||
playTextSpeech(card.term, 'en', 1.0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -369,8 +372,7 @@ export function initSrs() {
|
||||
e.stopPropagation();
|
||||
const card = srsQueue[srsCurrentIndex];
|
||||
if (!card) return;
|
||||
const url = card.audio_url || `/api/tts?text=${encodeURIComponent(card.term)}&lang=en`;
|
||||
playAudio(url);
|
||||
playTextSpeech(card.term, 'en', 1.0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -379,8 +381,16 @@ export function initSrs() {
|
||||
e.stopPropagation();
|
||||
const card = srsQueue[srsCurrentIndex];
|
||||
if (!card || !card.context_sentence) return;
|
||||
const url = card.context_audio_url || `/api/tts?text=${encodeURIComponent(card.context_sentence)}&lang=en`;
|
||||
playAudio(url);
|
||||
playTextSpeech(card.context_sentence, 'en', 1.0);
|
||||
});
|
||||
}
|
||||
|
||||
if (fcBackContextAudioSlowBtn) {
|
||||
fcBackContextAudioSlowBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
const card = srsQueue[srsCurrentIndex];
|
||||
if (!card || !card.context_sentence) return;
|
||||
playTextSpeech(card.context_sentence, 'en', 0.75);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -491,7 +501,7 @@ export function initSrs() {
|
||||
}
|
||||
});
|
||||
|
||||
if (card.audio_url) playAudio(card.audio_url);
|
||||
playTextSpeech(card.term, 'en');
|
||||
|
||||
if (isCorrect) {
|
||||
quizFeedbackBox.className = 'trainer-feedback-box feedback-correct';
|
||||
@@ -523,8 +533,7 @@ export function initSrs() {
|
||||
e.stopPropagation();
|
||||
const card = srsQueue[srsCurrentIndex];
|
||||
if (!card) return;
|
||||
const url = card.audio_url || `/api/tts?text=${encodeURIComponent(card.term)}&lang=en`;
|
||||
playAudio(url);
|
||||
playTextSpeech(card.term, 'en', 1.0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -565,7 +574,7 @@ export function initSrs() {
|
||||
const target = card.term.trim().toLowerCase();
|
||||
const isMatch = userInput === target;
|
||||
|
||||
if (card.audio_url) playAudio(card.audio_url);
|
||||
playTextSpeech(card.term, 'en');
|
||||
typingInput.disabled = true;
|
||||
|
||||
if (isMatch) {
|
||||
@@ -611,7 +620,7 @@ export function initSrs() {
|
||||
const target = card.term.trim().toLowerCase();
|
||||
const isMatch = userInput === target;
|
||||
|
||||
if (card.audio_url) playAudio(card.audio_url);
|
||||
playTextSpeech(card.term, 'en');
|
||||
clozeInput.disabled = true;
|
||||
|
||||
if (isMatch) {
|
||||
@@ -640,7 +649,7 @@ export function initSrs() {
|
||||
dictationInput.value = '';
|
||||
dictationInput.disabled = false;
|
||||
|
||||
const play = () => { if (card.audio_url) playAudio(card.audio_url); };
|
||||
const play = () => { playTextSpeech(card.term, 'en'); };
|
||||
dictationBigPlayBtn.onclick = play;
|
||||
dictationReplayBtn.onclick = play;
|
||||
play();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# 📋 Пользовательские репорты & Запросы на доработку (study.qpid.pro)
|
||||
|
||||
> 🔄 Данный файл автоматически синхронизируется с виджетом обратной связи на сайте.
|
||||
> AI-ассистент (Antigravity) считывает этот файл для анализа найденных багов и планирования задач.
|
||||
|
||||
**Всего репортов:** 8 | **Последняя синхронизация:** сейчас
|
||||
|
||||
## 🔴 Активные репорты (Требуют внимания / В работе)
|
||||
|
||||
🎉 *Активных багов или задач нет! Все известные репорты закрыты.*
|
||||
|
||||
---
|
||||
|
||||
## ✅ Решенные / Закрытые задачи
|
||||
|
||||
- [x] **#8 💡 (2026-10-08 09:28:40)**: сделать кнопки при озвучивании предложения или текста 0.7-1 скорость. Предложения иногда неудобно слушать, так как диктор может сказать быстро, хочется замедлить *(Страница: #dictionary)*
|
||||
- [x] **#7 🐛 (2026-10-08 09:22:52)**: Проверить, верно ли применяется голос озвучки, после смены его в меню настройки. Такое чувство, что не везде применяется озвучка *(Страница: #lesson)*
|
||||
- [x] **#6 💡 (2026-10-08 09:21:19)**: в SRS тестах чтобы не было упражнений по грамматике, там должны быть карточки исключительно касающиеся слов. *(Страница: #dictionary)*
|
||||
- [x] **#5 💡 (2026-10-08 09:19:07)**: В тестах не показывать подсказку (русский перевод) но сделать кнопку "подсказка", тогда перевод показывается нужного слова, но за это снимается бал. Например за вопрос дается 1 бал, так я получу с подсказкой 0.8 или около того *(Страница: #cefr/A1)*
|
||||
- [x] **#4 💡 (2026-10-08 09:14:12)**: Чтобы можно было нажать на любой текст, будь то в тесте или еще где, (кроме элементов управление) и добавить в словарь. А то иногда встречаются места, где читаешь предложение и не понимаешь, что за слово там ... *(Страница: #cefr/A1)*
|
||||
- [x] **#3 💡 (2026-10-08 09:04:56)**: В меню боковом измени скролбар на нестандартный. В текущей цветовой палитре и оформлении, стандартный скролбар сильно выделяется *(Страница: #dictionary)*
|
||||
- [x] **#2 🐛 (2026-10-08 09:01:46)**: Вкладка "мой словарь", карандишик (изменить слово), окно открывается слишком большое, без масштабирования вкладки его невозможно закрыть. Еще бы добавить функцию закрытия окна по пустому месту или по кнопке Esc *(Страница: #dictionary)*
|
||||
- [x] **#1 🐛 (2026-10-08 09:00:18)**: Вкладка "мой словарь", звук слов не воспроизводится, но предложения озвучиваются без проблем. *(Страница: #dictionary)*
|
||||
@@ -0,0 +1,90 @@
|
||||
import sqlite3
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
DB_PATH = Path("/home/ai-projects/services/study.qpid.pro/data/notes.db")
|
||||
TARGET_MD = Path("/home/ai-projects/services/study.qpid.pro/data/USER_REPORTS.md")
|
||||
MEMORY_MD = Path("/home/ai-projects/memory/USER_REPORTS.md")
|
||||
|
||||
def sync():
|
||||
if not DB_PATH.exists():
|
||||
print("Database not found")
|
||||
return
|
||||
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
conn.row_factory = sqlite3.Row
|
||||
|
||||
rows = conn.execute("""
|
||||
SELECT f.id, f.category, f.message, f.context_url, f.context_data_json, f.status, f.created_at, f.updated_at, u.username
|
||||
FROM feedback_reports f
|
||||
JOIN users u ON f.user_id = u.id
|
||||
ORDER BY f.id DESC
|
||||
""").fetchall()
|
||||
|
||||
lines = [
|
||||
"# 📋 Пользовательские репорты & Запросы на доработку (study.qpid.pro)",
|
||||
"",
|
||||
"> 🔄 Данный файл автоматически синхронизируется с виджетом обратной связи на сайте.",
|
||||
"> AI-ассистент (Antigravity) считывает этот файл для анализа найденных багов и планирования задач.",
|
||||
"",
|
||||
f"**Всего репортов:** {len(rows)} | **Последняя синхронизация:** сейчас",
|
||||
"",
|
||||
"## 🔴 Активные репорты (Требуют внимания / В работе)",
|
||||
"",
|
||||
]
|
||||
|
||||
active_rows = [r for r in rows if r["status"] in ("new", "in_progress")]
|
||||
resolved_rows = [r for r in rows if r["status"] in ("resolved", "closed")]
|
||||
|
||||
if not active_rows:
|
||||
lines.append("🎉 *Активных багов или задач нет! Все известные репорты закрыты.*")
|
||||
lines.append("")
|
||||
else:
|
||||
for r in active_rows:
|
||||
cat_emoji = "🐛 БАГ" if r["category"] == "bug" else ("💡 ФИЧА" if r["category"] == "feature" else "📝 ЗАМЕТКА")
|
||||
status_icon = "🆕 Новый" if r["status"] == "new" else "⏳ В работе"
|
||||
|
||||
ctx_extra = ""
|
||||
if r["context_data_json"]:
|
||||
try:
|
||||
c_dict = json.loads(r["context_data_json"])
|
||||
parts = []
|
||||
if "screen" in c_dict:
|
||||
parts.append(f"Экран: {c_dict['screen']}")
|
||||
if "device" in c_dict:
|
||||
parts.append(f"Устройство: {c_dict['device']}")
|
||||
if parts:
|
||||
ctx_extra = f" ({', '.join(parts)})"
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
lines.append(f"### #{r['id']} [{cat_emoji}] — {status_icon} (`{r['created_at']}`)")
|
||||
lines.append(f"- **Пользователь**: `{r['username']}`")
|
||||
if r["context_url"]:
|
||||
lines.append(f"- **Раздел/Страница**: `{r['context_url']}`{ctx_extra}")
|
||||
lines.append(f"- **Текст**:\n> {r['message'].strip()}")
|
||||
lines.append("")
|
||||
|
||||
lines.extend([
|
||||
"---",
|
||||
"",
|
||||
"## ✅ Решенные / Закрытые задачи",
|
||||
"",
|
||||
])
|
||||
|
||||
if not resolved_rows:
|
||||
lines.append("*Пока нет закрытых репортов.*")
|
||||
lines.append("")
|
||||
else:
|
||||
for r in resolved_rows:
|
||||
cat_emoji = "🐛" if r["category"] == "bug" else ("💡" if r["category"] == "feature" else "📝")
|
||||
lines.append(f"- [x] **#{r['id']} {cat_emoji} ({r['created_at']})**: {r['message'].strip()} *(Страница: {r['context_url'] or 'общая'})*")
|
||||
lines.append("")
|
||||
|
||||
content = "\n".join(lines)
|
||||
TARGET_MD.write_text(content, encoding="utf-8")
|
||||
MEMORY_MD.write_text(content, encoding="utf-8")
|
||||
print(f"Synced {len(rows)} reports successfully!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
sync()
|
||||
@@ -2572,6 +2572,7 @@ def test_feedback_endpoints_workflow():
|
||||
login_resp = client.post("/api/login", json={"username": "testadmin", "password": "testpass12345"})
|
||||
assert login_resp.status_code == 200
|
||||
|
||||
try:
|
||||
# 3. Create a bug report
|
||||
bug_payload = {
|
||||
"category": "bug",
|
||||
@@ -2633,6 +2634,12 @@ def test_feedback_endpoints_workflow():
|
||||
content = reports_md.read_text(encoding="utf-8")
|
||||
assert "Пользовательские репорты" in content
|
||||
assert "Кнопка в читалке не нажимается" in content
|
||||
finally:
|
||||
try:
|
||||
from scripts.sync_reports import sync
|
||||
sync()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user