From 3c0b81049064321428b07b6a99a9d2dc1dfde5cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Isaac=20David=20S=C3=A1nchez=20S=C3=A1nchez?=
<158796340+IsaacDev2024@users.noreply.github.com>
Date: Wed, 7 Jan 2026 23:51:18 -0500
Subject: [PATCH 01/27] Refactor personality test block to use Mustache and AMD
Migrated block views to Mustache templates and moved visualization logic to AMD modules. Optimized database queries by selecting specific columns instead of using wildcards.
---
block_personality_test.php | 700 ++++++-------------------------------
1 file changed, 112 insertions(+), 588 deletions(-)
diff --git a/block_personality_test.php b/block_personality_test.php
index 1546952..675deba 100644
--- a/block_personality_test.php
+++ b/block_personality_test.php
@@ -1,4 +1,12 @@
';
- $slider .= $izq_val . " ↹ " . $der_val . " ";
- $slider .= '';
- $slider .= '';
- return $slider;
- }
-
function init()
{
$this->title = get_string('pluginname', 'block_personality_test');
@@ -79,9 +76,6 @@ function instance_allow_multiple()
return false;
}
-
- // Función para la vista del Profesor
-
/**
* Genera el contenido para la vista del profesor.
*
@@ -90,21 +84,12 @@ function instance_allow_multiple()
* @return stdClass Un objeto con las propiedades 'text' y 'footer' para el contenido del bloque.
*/
private function _get_teacher_content($DB, $COURSE) {
- // Necesitamos $OUTPUT global aquí para moodle_url si se usa directamente o para get_string
global $OUTPUT;
$content = new stdClass();
$content->text = '';
$content->footer = '';
- // Header with personality test icon for teacher/admin view.
- $content->text .= '
';
-
- return $output;
+ return $OUTPUT->render_from_template('block_personality_test/student_continue', $data);
}
- // Función para la vista del Profesor
-
-
-
function get_content()
{
// Declarar globales necesarios
@@ -628,8 +259,8 @@ function get_content()
// --- Validaciones Iniciales ---
// No mostrar en la página principal del sitio
if ($COURSE->id == SITEID) {
- $this->content = new stdClass; $this->content->text = ''; $this->content->footer = ''; // Necesario inicializar para evitar error
- return $this->content; // Devolver objeto vacío en lugar de nada
+ $this->content = new stdClass; $this->content->text = ''; $this->content->footer = '';
+ return $this->content;
}
// Si el contenido ya se generó, devolverlo
@@ -642,17 +273,12 @@ function get_content()
$this->content->text = '';
$this->content->footer = '';
- // Si la instancia del bloque no está configurada (?)
if (empty($this->instance)) {
- // Podría mostrar un error o mensaje aquí si fuera necesario
return $this->content;
}
- // Si el usuario no está logueado
if (!isloggedin()) {
- // No se devuelve nada explícitamente, pero el contenido estará vacío.
- // Considera añadir un mensaje como: $this->content->text = get_string('logintoview');
- return $this->content; // Devolver objeto vacío
+ return $this->content;
}
// --- Lógica Principal ---
@@ -663,7 +289,8 @@ function get_content()
if (has_capability('block/personality_test:viewreports', $context)) {
$teacher_content = $this->_get_teacher_content($DB, $COURSE);
$this->content = $teacher_content;
- // Agregar enlace a la vista administrativa en el footer para consistencia
+
+ // Agregar enlace a la vista administrativa
$admin_url = new moodle_url('/blocks/personality_test/admin_view.php', array('cid' => $COURSE->id));
$this->content->footer .= html_writer::div(
html_writer::link($admin_url,
@@ -677,9 +304,7 @@ function get_content()
// Si el usuario puede realizar el test, mostrar la vista del estudiante.
if (has_capability('block/personality_test:taketest', $context)) {
- // --- LÓGICA PARA EL ESTUDIANTE ---
-
- // Verificar si el estudiante ya tiene una entrada en la tabla (en cualquier curso)
+ // Verificar si el estudiante ya tiene una entrada en la tabla
$entry = $DB->get_record('personality_test', array('user' => $USER->id));
if (!$entry) {
@@ -714,42 +339,6 @@ function get_content()
$mbti_score .= ($scores["thinking"] >= $scores["feeling"]) ? "T" : "F";
$mbti_score .= ($scores["judging"] > $scores["perceptive"]) ? "J" : "P";
- // IMPORTANTE: El radar debe graficar los puntajes reales del estudiante,
- // no valores fijos por tipo MBTI.
-
- // Header con icono de éxito
- $this->content->text .= '
';
-
- // Definimos las etiquetas de las dimensiones para el gráfico usando strings de idioma
$mbti_labels = [
get_string('introversion', 'block_personality_test'),
get_string('feeling', 'block_personality_test'),
@@ -761,7 +350,6 @@ function get_content()
get_string('judging', 'block_personality_test')
];
- // El orden de los datos DEBE corresponder exactamente al orden de $mbti_labels.
$user_data = [
(float)$scores['introversion'],
(float)$scores['feeling'],
@@ -773,97 +361,33 @@ function get_content()
(float)$scores['judging'],
];
- // Creamos un ID único para el canvas del gráfico usando el ID del usuario
$chart_id = 'graficoRadar_' . $USER->id;
-
- // Insertamos el
';
-
- // Retornamos el contenido del bloque
return $this->content;
- } // Fin else (datos de entry existen)
- } // Fin else (entry existe)
+ }
+ }
}
- // Devolver el objeto de contenido construido
return $this->content;
- } // Fin get_content
+ }
}
From 635bdeb7dd21711012fcda619426f5825908ac32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mar=C3=ADa=20valentina=20serna=20Gonz=C3=A1lez?=
<162528525+serna0120@users.noreply.github.com>
Date: Wed, 7 Jan 2026 23:52:24 -0500
Subject: [PATCH 02/27] Add admin view template for personality test results
---
templates/admin_view.mustache | 306 ++++++++++++++++++++++++++++++++++
1 file changed, 306 insertions(+)
create mode 100644 templates/admin_view.mustache
diff --git a/templates/admin_view.mustache b/templates/admin_view.mustache
new file mode 100644
index 0000000..43e8c11
--- /dev/null
+++ b/templates/admin_view.mustache
@@ -0,0 +1,306 @@
+
-";
-
-$action_form = new moodle_url('/blocks/personality_test/save.php');
-?>
-
-
-
-
+$should_auto_scroll = ($existing_response && $answered_count > 0 && $answered_count < 72 && !$scroll_to_finish);
+$action_form = new moodle_url('/blocks/personality_test/save.php');
- (new moodle_url('/blocks/personality_test/pix/icon.svg'))->out(),
+ 'test_page_title' => get_string('test_page_title', 'block_personality_test'),
+ 'test_intro_p1' => get_string('test_intro_p1', 'block_personality_test'),
+ 'test_intro_p2' => get_string('test_intro_p2', 'block_personality_test'),
+ 'test_benefit_note' => get_string('test_benefit_note', 'block_personality_test'),
+ 'test_benefit_required' => get_string('test_benefit_required', 'block_personality_test'),
+ 'action_form' => $action_form->out(),
+ 'questions' => $questions,
+ 'hidden_answers' => $hidden_answers,
+ 'courseid' => $courseid,
+ 'page' => $page,
+ 'sesskey' => sesskey(),
+ 'show_previous' => ($page > 1),
+ 'show_next' => ($page < $total_pages),
+ 'show_finish' => ($page >= $total_pages),
+ 'btn_previous_label' => get_string('btn_previous', 'block_personality_test'),
+ 'btn_next_label' => get_string('btn_next', 'block_personality_test'),
+ 'btn_finish_label' => get_string('btn_finish', 'block_personality_test'),
+ 'wwwroot' => $CFG->wwwroot,
+ 'should_auto_scroll' => $should_auto_scroll,
+ 'scroll_to_finish' => $scroll_to_finish,
+];
+
+echo $OUTPUT->render_from_template('block_personality_test/test_view', $template_data);
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
From e56d01026f403debf21cc7b54036f03d53fec18f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Isaac=20David=20S=C3=A1nchez=20S=C3=A1nchez?=
<158796340+IsaacDev2024@users.noreply.github.com>
Date: Thu, 8 Jan 2026 00:15:49 -0500
Subject: [PATCH 22/27] Update CHANGELOG for version 2.0.2
Added version 2.0.2 release notes with significant updates.
---
CHANGELOG.md | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 19518ba..cbe7150 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,15 @@
Todas las modificaciones importantes del proyecto se documentarán en este archivo.
+## [2.0.2] — 2026-01-08
+- Paginación en la lista de estudiantes en el panel de administración.
+- Nueva forma de mostrar las estadísticas generales en el panel de administración.
+- Uso de arquitectura de plantillas Mustache para todas las vistas del bloque.
+- Refactorización completa del código para separar lógica de presentación.
+- Mejora en la mantenibilidad y escalabilidad del código.
+- Optimización del rendimiento en búsquedas.
+- Pequeñas mejoras de seguridad.
+
## [2.0.1] — 2025-12-22
- Correción de un error (al actualizar de la versión 1.x a 2.0.0) que causaba fallos en la base de datos.
- Lectura correcta del CHANGELOG en el flujo de trabajo de GitHub Actions.
From c943c487c56f2c2fedc9ee0e15125ed0b35a6bac Mon Sep 17 00:00:00 2001
From: Santiago Orejuela
Date: Thu, 8 Jan 2026 00:17:04 -0500
Subject: [PATCH 23/27] Fix changelog extraction command in release workflow
---
.github/workflows/release.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index d52ba35..ad10b53 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -97,7 +97,7 @@ jobs:
# Extraer changelog para la versión actual
if [ -f "CHANGELOG.md" ]; then
# Buscar la sección de la versión actual
- awk '/## \["'"${{ needs.check-version.outputs.version }}"'"\]/{flag=1; next} /## \[/{flag=0} flag' CHANGELOG.md > current_changelog.md
+ awk '/## \['"${{ needs.check-version.outputs.version }}"'\]/{flag=1; next} /## \[/{flag=0} flag' CHANGELOG.md > current_changelog.md
if [ -s current_changelog.md ]; then
echo "Found changelog entry for version ${{ needs.check-version.outputs.version }}"
From 43b481c115f9eaa9162e5d46240bbd3d4794f60b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mar=C3=ADa=20valentina=20serna=20Gonz=C3=A1lez?=
<162528525+serna0120@users.noreply.github.com>
Date: Thu, 8 Jan 2026 00:18:34 -0500
Subject: [PATCH 24/27] Change image source for admin panel
Updated the image source in the README.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index a0a5db1..0a16623 100644
--- a/README.md
+++ b/README.md
@@ -108,7 +108,7 @@ El profesor cuenta con una vista ejecutiva desde el bloque, donde puede monitori
Un panel de administración que centraliza el seguimiento grupal. Permite visualizar quiénes han completado el proceso, quiénes están en curso y gestionar los resultados colectivos para adaptar la estrategia pedagógica del aula.
-
+
**Seguimiento Individualizado y Detallado**
From 07eb08704f37d8211f29ef485e4383a9f207a570 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Isaac=20David=20S=C3=A1nchez=20S=C3=A1nchez?=
<158796340+IsaacDev2024@users.noreply.github.com>
Date: Thu, 8 Jan 2026 00:19:13 -0500
Subject: [PATCH 25/27] Update version to 2.0.2
---
version.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/version.php b/version.php
index 437b26a..6855bb5 100644
--- a/version.php
+++ b/version.php
@@ -1,17 +1,17 @@
version = 2025122200;
-$plugin->requires = 2022112800;
+$plugin->version = 2026010800;
+$plugin->requires = 2022041900; // Moodle 4.0+
$plugin->component = 'block_personality_test';
$plugin->maturity = MATURITY_STABLE;
-$plugin->release = '2.0.1';
+$plugin->release = '2.0.2';
From 3892910a66ffcf5d1fcb43ca92ed2f0710478b78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Isaac=20David=20S=C3=A1nchez=20S=C3=A1nchez?=
<158796340+IsaacDev2024@users.noreply.github.com>
Date: Fri, 9 Jan 2026 00:59:37 -0500
Subject: [PATCH 26/27] Change last action timestamp to 'updated_at'
Updated the last action timestamp to use 'updated_at' instead of 'last_action'.
---
download_csv.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/download_csv.php b/download_csv.php
index d0e9feb..74e8297 100644
--- a/download_csv.php
+++ b/download_csv.php
@@ -187,8 +187,8 @@
$mbti_score = block_personality_test_calculate_mbti($entry);
// Escribir fila en el CSV
- // Use last_action (guaranteed present)
- $lastaction = $entry->last_action;
+ // Use updated_at as the last action timestamp
+ $lastaction = $entry->updated_at;
fputcsv($output, [
$student_user->idnumber,
From 1656ea92df930413f66244f45dfda2b8c0d12594 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Isaac=20David=20S=C3=A1nchez=20S=C3=A1nchez?=
<158796340+IsaacDev2024@users.noreply.github.com>
Date: Fri, 9 Jan 2026 01:36:27 -0500
Subject: [PATCH 27/27] Fix radar chart initialization return statement
---
amd/src/results_radar.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/amd/src/results_radar.js b/amd/src/results_radar.js
index be0ca6b..58215c9 100644
--- a/amd/src/results_radar.js
+++ b/amd/src/results_radar.js
@@ -5,7 +5,7 @@ define(['core/chartjs'], function(Chart) {
if(!el) return;
var ctx = el.getContext('2d');
- new Chart(ctx, {
+ return new Chart(ctx, {
type: 'radar',
data: {
labels: labels,