Repository navigation
Expand file tree
/
Copy pathLearnMentorWithoutAPI.html
More file actions
357 lines (311 loc) · 20 KB
/
Copy pathLearnMentorWithoutAPI.html
File metadata and controls
357 lines (311 loc) · 20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>📚 LearnMentor Pro | V3.0</title>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<style>
:root { --primary: #4f46e5; --secondary: #7c3aed; --bg: #f8fafc; --card: #ffffff; }
body { font-family: 'Inter', system-ui, sans-serif; background-color: var(--bg); color: #1e293b; padding: 20px; }
.container { max-width: 900px; margin: 0 auto; }
details.card, .card { border: none; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); border-radius: 16px; background: var(--card); margin-bottom: 20px; padding: 1px; }
details summary { padding: 25px; cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 10px; }
.card-content { padding: 0 25px 25px 25px; }
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 15px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
label { font-size: 0.8rem; font-weight: 600; color: #64748b; }
select, input, textarea { padding: 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1rem; }
.prompt-area { background: #1e293b; color: #f1f5f9; padding: 20px; border-radius: 10px; font-family: monospace; font-size: 0.85rem; white-space: pre-wrap; margin-bottom: 15px; border: 1px solid #334155; }
.btn { padding: 10px 18px; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: #059669; color: white; }
.btn-outline { border: 2px solid var(--primary); color: var(--primary); background: transparent; }
.question-item { background: #fff; padding: 25px; border-left: 5px solid var(--primary); margin-bottom: 20px; border-radius: 12px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.option-label { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid #e2e8f0; border-radius: 8px; cursor: pointer; margin-bottom: 8px; }
.option-correct { border-color: #22c55e !important; background-color: #f0fdf4 !important; }
.option-incorrect { border-color: #ef4444 !important; background-color: #fef2f2 !important; }
.justification-box { padding: 15px; background: #eff6ff; border-radius: 8px; margin-top: 15px; border: 1px solid #bfdbfe; color: #1e40af; font-size: 0.9rem; }
.result-msg { margin-top: 15px; padding: 12px; border-radius: 8px; font-weight: 600; display: none; }
.correct { background: #dcfce7; color: #166534; }
.incorrect { background: #fee2e2; color: #991b1b; }
.hidden { display: none !important; }
.ai-eval-box { background: #1e293b; color: white; padding: 30px; border-radius: 16px; text-align: center; margin-top: 40px; border: 2px solid var(--secondary); }
</style>
</head>
<body>
<div class="container">
<div class="header" style="text-align:center; margin-bottom:30px;">
<h1>📚 LearnMentor Pro <span style="font-size: 0.8rem; opacity: 0.5;">v3.0</span></h1>
</div>
<details class="card" id="configSection" open>
<summary>⚙️ 1. Configuración del Examen</summary>
<div class="card-content">
<div class="config-grid">
<div class="form-group"><label>Nivel Académico</label><select id="eduLevel">
<option value="Primaria">Primaria</option><option value="Secundaria">Secundaria</option><option value="Universitario" selected>Universitario</option>
</select></div>
<div class="form-group"><label>Desarrollo</label><input type="number" id="numDev" value="2"></div>
<div class="form-group"><label>Test Único</label><input type="number" id="numTest" value="2"></div>
<div class="form-group"><label>Huecos</label><input type="number" id="numFill" value="2"></div>
<div class="form-group"><label>Multiopción</label><input type="number" id="numMulti" value="1"></div>
</div>
</div>
</details>
<details class="card">
<summary>📝 2. Prompt para el Chatbot (Examen)</summary>
<div class="card-content">
<div class="prompt-area" id="promptDisplay"></div>
<button class="btn btn-primary" onclick="copyPrompt()" style="width:100%">📋 Copiar Prompt Inicial</button>
</div>
</details>
<div class="card" style="padding:25px;">
<h3>📥 3. Cargar JSON</h3>
<textarea id="jsonInput" style="width:100%; height: 80px; margin: 15px 0;" placeholder="Pega el código JSON aquí..."></textarea>
<div style="display: flex; gap: 10px;">
<button class="btn btn-primary" onclick="loadFromJsonArea()">🚀 Cargar Examen</button>
<button class="btn btn-outline" onclick="document.getElementById('jsonInput').value = ''">🗑️ Limpiar Área</button>
<button class="btn btn-outline" onclick="document.getElementById('fileLoader').click()">📂 Cargar .json</button>
<input type="file" id="fileLoader" class="hidden" accept=".json" onchange="loadFromFile(event)">
</div>
</div>
<div id="examContainer" class="hidden">
<div style="display:flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
<h2>✍️ Examen Interactivo</h2>
<div style="display:flex; gap:10px;">
<button class="btn btn-warning btn-sm" onclick="shuffleQuestions()">🔀 Mezclar</button>
<button class="btn btn-outline btn-sm" onclick="downloadExam()">💾 Guardar JSON</button>
</div>
</div>
<div id="questionsList"></div>
<div class="ai-eval-box">
<h3>🤖 ¡Hora de la Autocrítica Maestra!</h3>
<p style="margin-bottom: 20px; opacity: 0.8;">Generaremos un reporte ultra-detallado con tus respuestas y las soluciones para que la IA te ponga nota y te aconseje.</p>
<button class="btn btn-success" style="padding: 15px 40px; font-size: 1.1rem;" onclick="copyAiSelfCriticism()">
🚀 Copiar Reporte para Evaluación IA
</button>
</div>
</div>
</div>
<script>
let currentQuestions = [];
const LS_KEY = 'learnMentor_config_v3';
// CONFIGURACIÓN
function saveSettings() {
const config = {
level: document.getElementById('eduLevel').value,
dev: document.getElementById('numDev').value,
test: document.getElementById('numTest').value,
fill: document.getElementById('numFill').value,
multi: document.getElementById('numMulti').value
};
localStorage.setItem(LS_KEY, JSON.stringify(config));
updatePrompt();
}
function loadSettings() {
const saved = localStorage.getItem(LS_KEY);
if (saved) {
const c = JSON.parse(saved);
document.getElementById('eduLevel').value = c.level;
document.getElementById('numDev').value = c.dev;
document.getElementById('numTest').value = c.test;
document.getElementById('numFill').value = c.fill;
document.getElementById('numMulti').value = c.multi;
}
updatePrompt();
}
function updatePrompt() {
const level = document.getElementById('eduLevel').value;
const devCount = document.getElementById('numDev').value;
const testCount = document.getElementById('numTest').value;
const fillCount = document.getElementById('numFill').value;
const multiCount = document.getElementById('numMulti').value;
document.getElementById('promptDisplay').innerText = `Actúa como un profesor experto de nivel ${level}. Basándote estrictamente en el contenido que te proporcionaré, genera un examen en formato JSON puro.
REGLAS CRÍTICAS DE FORMATO:
1. Responde ÚNICAMENTE EN TU MARKDOWN CON UN BLOQUE DE CÓDIGO QUE CONTENGA un array JSON. Prohibido incluir texto introductorio, saludos o explicaciones.
2. Está TERMINANTEMENTE PROHIBIDO incluir etiquetas de citación, fuentes o metadatos (como, "cite: start", "source", etc.) dentro del JSON.
3. Los identificadores de tipo ("question_type") deben ser estrictamente en inglés: "development", "test", "fill_in_the_blanks", "multi_choice_test".
DISTRIBUCIÓN DEL EXAMEN:
- ${devCount} de tipo "development" (pregunta y respuesta ideal en "justification").
- ${testCount} de tipo "test" (test único con objeto "options" A,B,C,D y "correct_option" letra).
- ${fillCount} de tipo "fill_in_the_blanks" (completar huecos con array "text_parts" y array "solutions").
- ${multiCount} de tipo "multi_choice_test" (respuesta múltiple con objeto "options" y array "correct_options").
Asegúrate de que el campo "justification" contenga la explicación detallada para la corrección. Genera el JSON ahora:`;
}
// RENDERIZADO
function renderQuestions() {
const list = document.getElementById('questionsList');
list.innerHTML = '';
currentQuestions.forEach((q, i) => {
const card = document.createElement('div');
card.className = 'question-item';
let html = `<h3>${i+1}. ${q.question}</h3>`;
if(q.question_type === 'test') {
html += `<div class="options-grid">`;
for(let k in q.options) html += `<label class="option-label" id="L-${i}-${k}"><input type="radio" name="q${i}" value="${k}"> ${k}) ${q.options[k]}</label>`;
html += `</div><div class="actions-bar">
<button class="btn btn-primary btn-sm" onclick="checkTest(${i}, '${q.correct_option}')">Corregir</button>
<button class="btn btn-outline btn-sm" onclick="toggleJust(${i})">💡 Justificación</button>
</div>`;
}
else if(q.question_type === 'multi_choice_test') {
html += `<div class="options-grid">`;
for(let k in q.options) html += `<label class="option-label" id="L-${i}-${k}"><input type="checkbox" name="q${i}" value="${k}"> ${k}) ${q.options[k]}</label>`;
html += `</div><div class="actions-bar">
<button class="btn btn-primary btn-sm" onclick="checkMulti(${i})">Corregir</button>
<button class="btn btn-outline btn-sm" onclick="toggleJust(${i})">💡 Ver Solución</button>
</div>`;
}
else if(q.question_type === 'development') {
html += `<textarea id="dev-ans-${i}" style="width:100%; margin-top:10px; height:100px; border-radius:8px; padding:10px;" placeholder="Escribe aquí tu respuesta para que la IA la evalúe..."></textarea>
<div class="actions-bar" style="display:flex; gap:10px;">
<button class="btn btn-outline btn-sm" onclick="toggleJust(${i})">💡 Ver Respuesta Sugerida</button>
<button class="btn btn-primary btn-sm" onclick="copySingleDevPrompt(${i})">🤖 Corregir esta pregunta</button>
</div>`;
}
else if(q.question_type === 'fill_in_the_blanks') {
html += `<div style="line-height:2.8; margin-top:10px;">`;
q.text_parts.forEach((p, idx) => {
html += `<span>${p}</span>`;
if(idx < q.solutions.length) html += `<input type="text" id="fill-${i}-${idx}" style="width:120px; border:none; border-bottom:2px solid var(--primary); outline:none; text-align:center; background:transparent;">`;
});
html += `</div><div class="actions-bar">
<button class="btn btn-primary btn-sm" onclick="checkFill(${i})">Corregir</button>
<button class="btn btn-outline btn-sm" onclick="toggleJust(${i})">💡 Ver Solución</button>
</div>`;
}
let solBox = q.justification || "";
if(q.question_type === 'fill_in_the_blanks') solBox = "Soluciones: " + q.solutions.join(", ");
if(q.question_type === 'multi_choice_test') solBox = `Correctas: ${q.correct_options.join(", ")} | ${q.justification}`;
card.innerHTML = html + `
<div id="res-${i}" class="result-msg"></div>
<div id="just-${i}" class="justification-box hidden">${solBox}</div>
`;
list.appendChild(card);
});
document.getElementById('examContainer').classList.remove('hidden');
}
// CORRECCIONES
function toggleJust(id) { document.getElementById(`just-${id}`).classList.toggle('hidden'); }
function checkTest(id, correct) {
const sel = document.querySelector(`input[name="q${id}"]:checked`);
const q = currentQuestions[id];
Object.keys(q.options).forEach(k => document.getElementById(`L-${id}-${k}`).className = 'option-label');
if(!sel) return alert("Selecciona una.");
document.getElementById(`L-${id}-${correct}`).classList.add('option-correct');
if(sel.value !== correct) document.getElementById(`L-${id}-${sel.value}`).classList.add('option-incorrect');
const res = document.getElementById(`res-${id}`);
res.style.display = 'block';
res.className = `result-msg ${sel.value === correct ? 'correct' : 'incorrect'}`;
res.innerText = sel.value === correct ? "¡Correcto!" : "Incorrecto.";
}
function checkMulti(id) {
const q = currentQuestions[id];
const sels = Array.from(document.querySelectorAll(`input[name="q${id}"]:checked`)).map(e => e.value);
Object.keys(q.options).forEach(k => document.getElementById(`L-${id}-${k}`).className = 'option-label');
const isOk = sels.length === q.correct_options.length && sels.every(v => q.correct_options.includes(v));
q.correct_options.forEach(k => document.getElementById(`L-${id}-${k}`).classList.add('option-correct'));
sels.forEach(k => { if(!q.correct_options.includes(k)) document.getElementById(`L-${id}-${k}`).classList.add('option-incorrect'); });
const res = document.getElementById(`res-${id}`);
res.style.display = 'block';
res.className = `result-msg ${isOk ? 'correct' : 'incorrect'}`;
res.innerText = isOk ? "¡Correcto!" : "Hay errores.";
}
function checkFill(id) {
const q = currentQuestions[id];
q.solutions.forEach((s, idx) => {
const el = document.getElementById(`fill-${id}-${idx}`);
const isOk = el.value.trim().toLowerCase() === s.toLowerCase();
el.style.color = isOk ? "#16a34a" : "#dc2626";
el.style.fontWeight = "bold";
});
}
// --- 🚀 TUTORÍA IA V3.0 ---
function copyAiSelfCriticism() {
const level = document.getElementById('eduLevel').value;
let p = `Actúa como un profesor mentor experto de nivel ${level}. Evalúa mi examen pregunta a pregunta de forma rigurosa.
INSTRUCCIONES DE EVALUACIÓN:
1. Analiza cada pregunta individualmente, Poniendo el número, su enunciado y mi respuesta para identificarla mientras leo tu respuesta.
2. Asigna una NOTA del 0 al 10 (admite hasta 2 decimales).
3. Usa EMOJIS para diferenciar la nota:
- 0 a 4.9: 🔴 (Insuficiente)
- 5 a 6.9: 🟡 (Aprobado/Bien)
- 7 a 8.9: 🔵 (Notable)
- 9 a 10: 🟢 (Sobresaliente)
4. Por cada pregunta indica: Qué está mal, qué ha faltado y un CONSEJO específico para mejorar (especialmente en desarrollo)
5. MUY IMPORTANTE Si notas que no he entendido algún concepto explicaló otra vez como en el temario.
6. Al final, dame una nota media global del examen.
7. Referencia a las explicaciones del temario, y si en el propio chat no tienes el temario pideló en PDF
---
REPORTE DEL EXAMEN:`;
currentQuestions.forEach((q, i) => {
p += `\n\n[PREGUNTA ${i+1}] (${q.question_type.toUpperCase()})
Enunciado: ${q.question}`;
if(q.question_type === 'test' || q.question_type === 'multi_choice_test') {
p += `\nOpciones posibles:`;
for(let k in q.options) p += `\n ${k}) ${q.options[k]}`;
if(q.question_type === 'test') {
const sel = document.querySelector(`input[name="q${i}"]:checked`)?.value || "Ninguna";
p += `\nMi elección: ${sel} | Solución correcta: ${q.correct_option}`;
} else {
const sels = Array.from(document.querySelectorAll(`input[name="q${i}"]:checked`)).map(e => e.value).join(", ") || "Ninguna";
p += `\nMis elecciones: [${sels}] | Soluciones correctas: [${q.correct_options.join(", ")}]`;
}
}
else if(q.question_type === 'development') {
const ans = document.getElementById(`dev-ans-${i}`).value || "[VACÍO]";
p += `\nMi respuesta escrita: "${ans}"`;
}
else if(q.question_type === 'fill_in_the_blanks') {
const myFills = q.solutions.map((_, idx) => document.getElementById(`fill-${i}-${idx}`).value || "___").join(", ");
p += `\nMis respuestas: [${myFills}] | Soluciones originales: [${q.solutions.join(", ")}]`;
}
p += `\nReferencia/Justificación del sistema: ${q.justification || 'N/A'}`;
});
p += `\n\n---
Basándote en el nivel ${level}, empieza la evaluación pregunta a pregunta ahora:`;
navigator.clipboard.writeText(p);
alert("¡Reporte V3.0 copiado! Pégalo en tu Chatbot favorito para recibir la tutoría.");
}
// NUEVA FUNCIÓN: PROMPT INDIVIDUAL PARA DESARROLLO
function copySingleDevPrompt(i) {
const level = document.getElementById('eduLevel').value;
const q = currentQuestions[i];
const ans = document.getElementById(`dev-ans-${i}`).value || "[EL ESTUDIANTE NO HA ESCRITO NADA]";
const p = `Actúa como un profesor mentor experto de nivel ${level}. Evalúa de forma rigurosa mi respuesta a la siguiente pregunta de desarrollo.
PREGUNTA: ${q.question}
MI RESPUESTA: "${ans}"
REFERENCIA DE CORRECCIÓN (Justificación): ${q.justification || 'No proporcionada'}
INSTRUCCIONES:
1. Dame una nota del 0 al 10 basándote en la calidad y precisión.
2. Explica qué puntos clave he cubierto y qué me ha faltado mencionar.
3. Si la respuesta es incorrecta o incompleta, explícame el concepto de forma educativa.
4. Dame un consejo para que mi respuesta sea de 10 en un examen real.
5. Además menciona la página del temario donde puedo repasar este concepto.
Empieza tu evaluación directamente:`;
navigator.clipboard.writeText(p);
alert("¡Prompt de corrección individual copiado!");
}
// AUXILIARES
function processJson(raw) {
try {
const clean = raw.replace(/```json/g, "").replace(/```/g, "").trim();
currentQuestions = JSON.parse(clean);
renderQuestions();
document.getElementById('configSection').open = false;
} catch (e) { alert("JSON no válido."); }
}
function loadFromJsonArea() { processJson(document.getElementById('jsonInput').value); }
function loadFromFile(e) { const r = new FileReader(); r.onload = (ev) => processJson(ev.target.result); r.readAsText(e.target.files[0]); }
function downloadExam() {
const name = prompt("Nombre del archivo:", "mi_examen") || "examen";
const blob = new Blob([JSON.stringify(currentQuestions, null, 2)], {type: 'application/json'});
const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = `${name}.json`; a.click();
}
function shuffleQuestions() { currentQuestions.sort(() => Math.random() - 0.5); renderQuestions(); }
function copyPrompt() { navigator.clipboard.writeText(document.getElementById('promptDisplay').innerText); alert("Prompt copiado."); }
document.querySelectorAll('input, select').forEach(el => el.addEventListener('change', saveSettings));
window.onload = loadSettings;
</script>
</body>
</html>