# Cursos Temas Contenido (1, 2, 3, 4, 5, 6, 7) - [temas_contenido]

## 🧾 Descripción

*Obtiene **todo el contenido asociado a un Tema de Capacitación**, enriqueciendo la información con:*

- URL del **video** (si el contenido es Video)
- Texto o enlace procesado del **artículo** (si el contenido es Article)
- Cantidad de intentos realizados en un **quiz** por un estudiante (si corresponde)

*El servicio puede opcionalmente recibir el **DNI del estudiante**, para verificar su progreso (intentos de quiz).*

*Este servicio integra información desde varios recursos del ERP:*

- **Topic**
- **Video**
- **Article**
- **Student**
- **Quiz Activity**

---

# 🚀 Endpoint

### **GET /temas-contenido**

📌 **Parámetros vía request:**

<div class="_tableContainer_1rjym_1" id="bkmrk-par%C3%A1metro-tipo-oblig"><div class="group _tableWrapper_1rjym_13 flex w-fit flex-col-reverse" tabindex="-1"><table class="w-fit min-w-(--thread-content-width)" data-end="1068" data-start="846"><thead data-end="894" data-start="846"><tr data-end="894" data-start="846"><th data-col-size="sm" data-end="858" data-start="846">Parámetro</th><th data-col-size="sm" data-end="865" data-start="858">Tipo</th><th data-col-size="sm" data-end="879" data-start="865">Obligatorio</th><th data-col-size="md" data-end="894" data-start="879">Descripción</th></tr></thead><tbody data-end="1068" data-start="943"><tr data-end="996" data-start="943"><td data-col-size="sm" data-end="950" data-start="943">tema</td><td data-col-size="sm" data-end="959" data-start="950">string</td><td data-col-size="sm" data-end="964" data-start="959">✔️</td><td data-col-size="md" data-end="996" data-start="964">Nombre del Topic a consultar</td></tr><tr data-end="1068" data-start="997"><td data-col-size="sm" data-end="1003" data-start="997">dni</td><td data-col-size="sm" data-end="1012" data-start="1003">string</td><td data-col-size="sm" data-end="1016" data-start="1012">❌</td><td data-col-size="md" data-end="1068" data-start="1016">DNI del estudiante para obtener intentos de quiz</td></tr></tbody></table>

</div></div>---

# 🔐 Seguridad

Requiere autenticación interna vía:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%24this-%3Egeneral-%3Eserv"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs">  
</div></div></div><div class="overflow-y-auto p-4" dir="ltr">`<span class="hljs-variable language_">$this</span>->general-><span class="hljs-title function_ invoke__">ServiceErp</span>(...)`</div></div>No necesita token del cliente, se usa credencial del backend.

---

# 🧠 Flujo del Servicio (Resumen real)

### 1️⃣ Si viene DNI → Obtener datos del estudiante

Consulta:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-get-student-%3Flimit%3Dn"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-keyword">GET</span> Student?<span class="hljs-keyword">limit</span>=<span class="hljs-keyword">None</span>&fields=["name","puesto"]&filters=[["enabled","=",<span class="hljs-number">1</span>],["dni","like","%{dni}%"]]`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>Guarda `name` del estudiante si existe.

---

### 2️⃣ Obtener el tema solicitado

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-get-topic%2F%7Btema%7D"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs">  
</div></div></div><div class="overflow-y-auto p-4" dir="ltr">`<span class="hljs-keyword">GET</span> Topic/{tema}`</div></div>Debe existir; si no, devuelve: `<span class="hljs-punctuation">{</span> <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span> <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"No se encontró el tema del curso"</span> <span class="hljs-punctuation">}</span>`

---

### 3️⃣ Recorrer cada elemento de “topic\_content”

Para cada ítem:

#### **📽 Si es Video:**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-get-video%2F%7Bcontent_i"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs">  
</div></div></div><div class="overflow-y-auto p-4" dir="ltr">`GET <span class="hljs-selector-tag">Video</span>/{content_id}`</div></div>Agrega: `<span class="hljs-attr">"url"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"<url del video>"</span>`

---

#### **📄 Si es Article:**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-get-article%2F%7Bcontent"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs">  
</div></div></div><div class="overflow-y-auto p-4" dir="ltr">`GET <span class="hljs-selector-tag">Article</span>/{content_id}`</div></div>- Se extrae contenido sin HTML (`strip_tags`)
- Si dentro del texto hay un link, se devuelve solo ese link
- Se agrega:

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%22url%22%3A-%22%3Ctexto-proce"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%; height: 29.6px;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr style="height: 29.6px;"><td style="height: 29.6px;">`<span class="hljs-attr">"url"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"<texto procesado o link>"</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>---

#### **❓ Si es Quiz y hay estudiante:**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-get-quiz-activity-%3Ff"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`GET Quiz Activity?filters=<span class="hljs-string">[["quiz","=",content_id],["student","=", estudiante]]</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>Agrega: `<span class="hljs-attr">"quiz_attempts"</span><span class="hljs-punctuation">:</span> <numero_de_intentos>`

Si no hay estudiante o no es quiz: `<span class="hljs-attr">"quiz_attempts"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">0</span>`

---

### 4️⃣ Retornar todos los contenidos enriquecidos

---

# 📥 Request Body (ejemplo)

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22tema%22%3A-%22topic-001"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"tema"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"TOPIC-001"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"dni"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"12345678"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>---

# 📤 Response 200 – Ejemplo

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22valor%22%3A-true%2C-%22da"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"data"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>    <span class="hljs-punctuation">{</span>      <span class="hljs-attr">"content_type"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Video"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"content"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"VID-01"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"url"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"https://erp/video1.mp4"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"quiz_attempts"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">0</span>    <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>    <span class="hljs-punctuation">{</span>      <span class="hljs-attr">"content_type"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Article"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"content"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"ART-01"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"url"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"https://articulo.com/content"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"quiz_attempts"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">0</span>    <span class="hljs-punctuation">}</span><span class="hljs-punctuation">,</span>    <span class="hljs-punctuation">{</span>      <span class="hljs-attr">"content_type"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Quiz"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"content"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"QUIZ-01"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"quiz_attempts"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">2</span>    <span class="hljs-punctuation">}</span>  <span class="hljs-punctuation">]</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>---

# ❗ Posibles Errores

### 1. Tema no encontrado

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22valor%22%3A-false%2C-%22m"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"No se encontró el tema del curso"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>### 2. Estudiante no existe (cuando se envía DNI)

No genera error, simplemente no agrega intentos de quiz.

### 3. Contenido sin URL o datos incompletos

El servicio ignora valores faltantes y continúa procesando.

### 4. Error del servidor

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22valor%22%3A-false%2C-%22m-1"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Error del servidor"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"data"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"<detalle>"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>---

# 📚 Recursos / Esquemas usados

### **Topic**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22topic_content%22%3A-%5B"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"topic_content"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span>    <span class="hljs-punctuation">{</span>      <span class="hljs-attr">"content_type"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Video | Article | Quiz"</span><span class="hljs-punctuation">,</span>      <span class="hljs-attr">"content"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span>    <span class="hljs-punctuation">}</span>  <span class="hljs-punctuation">]</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>### **Video**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22url%22%3A-%22string%22-%7D"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span> <span class="hljs-attr">"url"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span> <span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>### **Article**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22content%22%3A-%22html%7Cs"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span> <span class="hljs-attr">"content"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"html|string"</span> <span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>### **Student**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22name%22%3A-%22string%22%2C-"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"name"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"dni"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"puesto"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>### **Quiz Activity**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22quiz%22%3A-%22string%22%2C-"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"quiz"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"student"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>---

# 🗃 Pseudocódigo del servicio

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-if-dni%3A-estudiante-%3D"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-attr">if DNI:</span>    <span class="hljs-string">estudiante</span> <span class="hljs-string">=</span> <span class="hljs-string">GET</span> <span class="hljs-string">Student</span> <span class="hljs-string">by</span> <span class="hljs-string">DNI</span><span class="hljs-string">topic</span> <span class="hljs-string">=</span> <span class="hljs-string">GET</span> <span class="hljs-string">Topic/{tema}</span><span class="hljs-attr">foreach content in topic.topic_content:</span>    <span class="hljs-string">if</span> <span class="hljs-string">content_type</span> <span class="hljs-string">==</span> <span class="hljs-attr">Video:</span>        <span class="hljs-string">obtener</span> <span class="hljs-string">url</span> <span class="hljs-string">del</span> <span class="hljs-string">video</span>    <span class="hljs-string">if</span> <span class="hljs-string">content_type</span> <span class="hljs-string">==</span> <span class="hljs-attr">Article:</span>        <span class="hljs-string">obtener</span> <span class="hljs-string">contenido,</span> <span class="hljs-string">limpiar</span> <span class="hljs-string">html,</span> <span class="hljs-string">buscar</span> <span class="hljs-string">link</span>    <span class="hljs-string">if</span> <span class="hljs-string">content_type</span> <span class="hljs-string">==</span> <span class="hljs-attr">Quiz and estudiante existe:</span>        <span class="hljs-string">obtener</span> <span class="hljs-string">intentos</span> <span class="hljs-string">realizados</span><span class="hljs-string">return</span> <span class="hljs-string">lista</span> <span class="hljs-string">enriquecida</span> <span class="hljs-string">de</span> <span class="hljs-string">contenidos</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr">  
</div></div>