Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Edupets-Studio/Edu-pets/llms.txt

Use this file to discover all available pages before exploring further.

EduPets provides four dedicated exercise modes — addition, subtraction, multiplication, and division — each accessible from Pingüi’s game menu. Every session is self-contained: the player works through 10 randomly generated multiple-choice questions and has 3 lives before the session ends. Finishing an exercise that matches the active task instantly restores the corresponding pet stat, closing the loop between learning and pet care.

Exercise overview

ExerciseRouteJS fileQuestionsLives
Addition/ejercicio1Suma.js103
Subtraction/ejercicio2resta.js103
Multiplication/ejercicio3multiplicacion.js103
Division/ejercicio4division.js103
All four modes share the same page template (Ejercicios.css) and an identical answer-feedback loop; only the question generation logic differs per operation.

How questions are generated

Each question draws two random integers between 1 and 10 inclusive using:
function generarNumeroFacil() {
  return Math.floor(Math.random() * 10) + 1;
}
The full question-generation function from Suma.js illustrates the pattern for addition:
function generarPregunta() {
  mensajeDiv.innerHTML = "";
  if (preguntas >= totalPreguntas) {
    mensajeDiv.innerHTML = '<div class="message success">¡Excelente trabajo! Terminaste todas las sumas.</div>';
    aumentarOrbeSiCoincide("suma");
    setTimeout(() => window.location.href = "/mascota", 4000);
    return;
  }

  const a = generarNumeroFacil();
  const b = generarNumeroFacil();
  const respuesta = a + b;
  document.getElementById("titulo").textContent = `Suma: ejercicios con ${a}`;
  document.getElementById("pregunta").textContent = `¿Cuánto es ${a} + ${b}?`;
  // ... option generation follows
}
Operation-specific guardrails keep questions age-appropriate:
  • Subtraction — if b > a the two values are swapped ([a, b] = [b, a]) so the result is never negative.
  • Division — a divisor and a cociente (each 1–10) are generated first; the dividend shown to the student is divisor × cociente, guaranteeing a whole-number answer.

Answer options

Each question renders 3 clickable buttons — 1 correct answer and 2 distractors. Distractors are generated by randomly adding or subtracting a small offset from the correct answer, using a Set to avoid duplicates:
const opciones = new Set([respuesta]);

while (opciones.size < 3) {
  const diferencia = Math.floor(Math.random() * 4) + 1;
  const opcion = Math.random() < 0.5 ? respuesta + diferencia : respuesta - diferencia;
  if (opcion > 0) opciones.add(opcion);
}

Array.from(opciones).sort(() => Math.random() - 0.5).forEach((opcion) => {
  const btn = document.createElement("button");
  btn.textContent = opcion;
  btn.onclick = () => verificarRespuesta(opcion, respuesta, btn);
  opcionesDiv.appendChild(btn);
});
The distractor offset is 1–4 for addition and subtraction, 1–4 for multiplication, and 1–3 for division (tighter range because quotients are smaller). Buttons are shuffled before rendering so the correct answer is never in a predictable position.

Lives and feedback

Each exercise starts with 3 heart icons (vida1, vida2, vida3). Answering incorrectly replaces the highest-numbered remaining heart image with VidaMenos.png and decrements the vidas counter. All buttons are disabled immediately after a selection to prevent double-tapping.
  • Correct answer — the selected button turns green (#a8f5a8) and a success message appears. The next question loads after 1.2 seconds.
  • Wrong answer — the selected button turns red (#f8b0b0) and a retry message appears. After 1.5 seconds, either the next question loads (if lives remain) or a failure message is shown before redirecting to /mascota after 3.5 seconds.

Pet stat reward

When all 10 questions are answered (regardless of how many lives remain), aumentarOrbeSiCoincide is called with the exercise type. It checks whether the active task’s tipo matches the completed exercise. If it does, the linked stat (orbe) is raised by +20, capped at 100, and tareaActual is removed from localStorage so a fresh task is assigned on the next visit to /mascota.
function aumentarOrbeSiCoincide(tipoEjercicio) {
  const tarea = JSON.parse(localStorage.getItem("tareaActual"));
  if (!tarea || tarea.tipo !== tipoEjercicio) return;

  const niveles = JSON.parse(localStorage.getItem("niveles")) || { comida: 100, sueno: 100, felicidad: 100 };
  niveles[tarea.orbe] = Math.min(100, niveles[tarea.orbe] + 20);
  localStorage.setItem("niveles", JSON.stringify(niveles));
  localStorage.removeItem("tareaActual");
}
If no task is active, or the task type does not match the completed exercise, the function returns early and no stat change occurs.

Exit confirmation

Clicking the Volver back button mid-exercise does not navigate away immediately. Instead it calls confirmarSalida, which reveals a modal dialog asking:
“¿Estás seguro de que quieres salir de la prueba?”
The player can choose “Sí, volver” to return to /mascota (losing current progress) or “No, me quiero quedar” to dismiss the dialog and continue the exercise.
function confirmarSalida() {
  document.getElementById("confirm-exit").style.display = "block";
}
The exam page (/examenes) uses a plain <a> link for its back button and does not show this confirmation dialog.

Build docs developers (and LLMs) love