Class_generator/tests/root-cleanup/drs-main.html
StillHammer 29bc112c0c Unify vocabulary persistence system - remove dual systems
- Simplified loadPersistedVocabularyData() to use only VocabularyProgressManager
- Updated calculateVocabularyProgress() to use unified data structure
- Removed old system references from knowledge panel data loading
- Fixed field names (drsDiscovered, drsMastered) for unified system
- Knowledge panel now displays vocabulary progress correctly

 TESTED: Vocabulary Knowledge panel working with unified system

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-30 13:39:00 +08:00

482 lines
15 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🎓 DRS Unifié - Class Generator 2.0</title>
<!-- Styles -->
<link rel="stylesheet" href="src/styles/base.css?v=3">
<link rel="stylesheet" href="src/styles/components.css?v=17">
<style>
body {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
margin: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.app-container {
max-width: 1000px;
margin: 0 auto;
padding: 20px;
}
.app-header {
background: white;
border-radius: 16px 16px 0 0;
padding: 24px;
text-align: center;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.app-header h1 {
margin: 0 0 8px 0;
color: #111827;
font-size: 2.5em;
}
.app-header p {
margin: 0;
color: #6b7280;
font-size: 1.1em;
}
.app-main {
background: white;
border-radius: 0 0 16px 16px;
padding: 24px;
min-height: 600px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.exercise-selector {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 16px;
margin-bottom: 32px;
}
.exercise-card {
background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
border: 2px solid #e5e7eb;
border-radius: 12px;
padding: 20px;
text-align: center;
cursor: pointer;
transition: all 0.2s ease;
position: relative;
overflow: hidden;
}
.exercise-card:hover {
border-color: #3b82f6;
transform: translateY(-2px);
box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.1);
}
.exercise-card.active {
border-color: #10b981;
background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
}
.exercise-icon {
font-size: 2.5em;
margin-bottom: 12px;
display: block;
}
.exercise-title {
font-size: 1.1em;
font-weight: 600;
color: #111827;
margin-bottom: 8px;
}
.exercise-description {
font-size: 0.9em;
color: #6b7280;
margin: 0;
}
.difficulty-selector {
display: flex;
gap: 8px;
justify-content: center;
margin-bottom: 24px;
}
.difficulty-btn {
padding: 8px 16px;
border: 2px solid #e5e7eb;
border-radius: 8px;
background: white;
cursor: pointer;
font-size: 14px;
font-weight: 500;
transition: all 0.2s ease;
}
.difficulty-btn.active {
border-color: #3b82f6;
background: #3b82f6;
color: white;
}
.difficulty-btn:hover:not(.active) {
border-color: #9ca3af;
background: #f9fafb;
}
.drs-workspace {
border: 2px dashed #e5e7eb;
border-radius: 12px;
padding: 24px;
min-height: 500px;
background: #fafafa;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.drs-workspace.active {
border-style: solid;
border-color: #10b981;
background: white;
text-align: left;
align-items: stretch;
}
.workspace-placeholder {
color: #9ca3af;
}
.workspace-placeholder h3 {
margin: 0 0 16px 0;
font-size: 1.3em;
}
.workspace-placeholder p {
margin: 0;
font-size: 1.1em;
line-height: 1.6;
}
.controls {
display: flex;
gap: 12px;
margin-bottom: 20px;
}
.status-bar {
background: #f8fafc;
border: 1px solid #e2e8f0;
border-radius: 8px;
padding: 12px 16px;
margin-bottom: 20px;
font-size: 14px;
color: #475569;
}
.status-bar.success {
background: #ecfdf5;
border-color: #10b981;
color: #065f46;
}
.status-bar.error {
background: #fef2f2;
border-color: #ef4444;
color: #991b1b;
}
.status-bar.loading {
background: #eff6ff;
border-color: #3b82f6;
color: #1e40af;
}
@media (max-width: 768px) {
.exercise-selector {
grid-template-columns: 1fr;
}
.controls {
flex-direction: column;
}
.difficulty-selector {
flex-wrap: wrap;
}
}
</style>
</head>
<body>
<div class="app-container">
<header class="app-header">
<h1>🎓 DRS Unifié</h1>
<p>Système d'apprentissage avec composants UI unifiés</p>
</header>
<main class="app-main">
<!-- Exercise Type Selector -->
<div class="exercise-selector">
<div class="exercise-card" data-type="text">
<span class="exercise-icon">📚</span>
<div class="exercise-title">Compréhension Écrite</div>
<p class="exercise-description">Lecture et analyse de texte</p>
</div>
<div class="exercise-card" data-type="audio">
<span class="exercise-icon">🎵</span>
<div class="exercise-title">Compréhension Orale</div>
<p class="exercise-description">Écoute et analyse audio</p>
</div>
<div class="exercise-card" data-type="image">
<span class="exercise-icon">🖼️</span>
<div class="exercise-title">Analyse d'Image</div>
<p class="exercise-description">Observation et description</p>
</div>
<div class="exercise-card" data-type="grammar">
<span class="exercise-icon">📝</span>
<div class="exercise-title">Grammaire</div>
<p class="exercise-description">Exercices grammaticaux</p>
</div>
</div>
<!-- Difficulty Selector -->
<div class="difficulty-selector">
<button class="difficulty-btn active" data-difficulty="easy">Facile</button>
<button class="difficulty-btn" data-difficulty="medium">Moyen</button>
<button class="difficulty-btn" data-difficulty="hard">Difficile</button>
</div>
<!-- Controls -->
<div class="controls">
<button id="startBtn" class="btn btn-primary" disabled>🚀 Démarrer l'exercice</button>
<button id="resetBtn" class="btn btn-outline">🔄 Réinitialiser</button>
</div>
<!-- Status Bar -->
<div id="statusBar" class="status-bar" style="display: none;">
Prêt à commencer...
</div>
<!-- DRS Workspace -->
<div id="drsWorkspace" class="drs-workspace">
<div class="workspace-placeholder">
<h3>👆 Choisissez un type d'exercice</h3>
<p>Sélectionnez un exercice ci-dessus, choisissez la difficulté, puis cliquez sur "Démarrer"</p>
</div>
</div>
</main>
</div>
<!-- Loading Application -->
<script type="module">
import app from './src/Application.js';
// Wait for application to be ready
console.log('🚀 Initializing DRS Main Application...');
let selectedType = null;
let selectedDifficulty = 'medium';
let unifiedDRS = null;
// DOM elements
const exerciseCards = document.querySelectorAll('.exercise-card');
const difficultyButtons = document.querySelectorAll('.difficulty-btn');
const startBtn = document.getElementById('startBtn');
const resetBtn = document.getElementById('resetBtn');
const statusBar = document.getElementById('statusBar');
const workspace = document.getElementById('drsWorkspace');
// Utility functions
function showStatus(message, type = 'loading') {
statusBar.textContent = message;
statusBar.className = `status-bar ${type}`;
statusBar.style.display = 'block';
}
function hideStatus() {
statusBar.style.display = 'none';
}
function updateWorkspace(active = false) {
if (active) {
workspace.classList.add('active');
workspace.innerHTML = '';
} else {
workspace.classList.remove('active');
workspace.innerHTML = `
<div class="workspace-placeholder">
<h3>👆 Choisissez un type d'exercice</h3>
<p>Sélectionnez un exercice ci-dessus, choisissez la difficulté, puis cliquez sur "Démarrer"</p>
</div>
`;
}
}
function updateStartButton() {
startBtn.disabled = !selectedType;
if (selectedType) {
startBtn.textContent = `🚀 Démarrer: ${getTypeLabel(selectedType)} (${getDifficultyLabel(selectedDifficulty)})`;
} else {
startBtn.textContent = '🚀 Démarrer l\'exercice';
}
}
function getTypeLabel(type) {
const labels = {
text: 'Lecture',
audio: 'Audio',
image: 'Image',
grammar: 'Grammaire'
};
return labels[type] || type;
}
function getDifficultyLabel(difficulty) {
const labels = {
easy: 'Facile',
medium: 'Moyen',
hard: 'Difficile'
};
return labels[difficulty] || difficulty;
}
// Exercise type selection
exerciseCards.forEach(card => {
card.addEventListener('click', () => {
// Remove active class from all cards
exerciseCards.forEach(c => c.classList.remove('active'));
// Add active class to clicked card
card.classList.add('active');
// Update selected type
selectedType = card.dataset.type;
updateStartButton();
console.log(`📋 Selected exercise type: ${selectedType}`);
});
});
// Difficulty selection
difficultyButtons.forEach(btn => {
btn.addEventListener('click', () => {
// Remove active class from all buttons
difficultyButtons.forEach(b => b.classList.remove('active'));
// Add active class to clicked button
btn.classList.add('active');
// Update selected difficulty
selectedDifficulty = btn.dataset.difficulty;
updateStartButton();
console.log(`🎯 Selected difficulty: ${selectedDifficulty}`);
});
});
// Start exercise
startBtn.addEventListener('click', async () => {
if (!selectedType || !unifiedDRS) {
showStatus('❌ Impossible de démarrer - système non prêt', 'error');
return;
}
try {
showStatus(`🚀 Démarrage de l'exercice ${getTypeLabel(selectedType)}...`, 'loading');
updateWorkspace(true);
await unifiedDRS.start(workspace, {
type: selectedType,
difficulty: selectedDifficulty
});
showStatus(`✅ Exercice ${getTypeLabel(selectedType)} démarré!`, 'success');
startBtn.disabled = true;
} catch (error) {
console.error('❌ Error starting exercise:', error);
showStatus(`❌ Erreur: ${error.message}`, 'error');
updateWorkspace(false);
}
});
// Reset
resetBtn.addEventListener('click', () => {
console.log('🔄 Resetting DRS...');
updateWorkspace(false);
hideStatus();
startBtn.disabled = false;
updateStartButton();
});
// Wait for application to initialize
try {
await app.start();
console.log('✅ Application started successfully');
// Get UnifiedDRS module
const moduleLoader = app.getCore().moduleLoader;
unifiedDRS = moduleLoader.getModule('unifiedDRS');
if (unifiedDRS) {
console.log('✅ UnifiedDRS module loaded');
showStatus('✅ Système DRS prêt - choisissez un exercice!', 'success');
// Auto-hide status after 3 seconds
setTimeout(() => {
hideStatus();
}, 3000);
} else {
throw new Error('UnifiedDRS module not found');
}
} catch (error) {
console.error('❌ Failed to initialize application:', error);
showStatus(`❌ Erreur d'initialisation: ${error.message}`, 'error');
}
// Set up event listeners for DRS events
if (app.getCore().eventBus) {
const eventBus = app.getCore().eventBus;
eventBus.registerModule({ name: 'drsMain' });
eventBus.on('drs:started', (event) => {
console.log('📢 Exercise started:', event.data);
showStatus(`🎯 Exercice en cours: étape 1/${event.data.steps}`, 'success');
}, 'drsMain');
eventBus.on('drs:step-completed', (event) => {
console.log('📢 Step completed:', event.data);
showStatus(`🎯 Étape ${event.data.step + 1}/${event.data.total} complétée`, 'success');
}, 'drsMain');
eventBus.on('drs:completed', (event) => {
console.log('📢 Exercise completed:', event.data);
showStatus(`🎉 Exercice terminé! Temps: ${Math.round(event.data.stats.timeSpent / 1000)}s`, 'success');
startBtn.disabled = false;
updateStartButton();
}, 'drsMain');
eventBus.on('drs:hint-used', (event) => {
console.log('📢 Hint used:', event.data);
showStatus(`💡 Indice utilisé pour l'étape ${event.data.step + 1}`, 'success');
}, 'drsMain');
}
console.log('🎓 DRS Main page initialized');
</script>
</body>
</html>