From ee8655be4c232e4cd94a6fd5cc7d2631fa2df66f 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:14:52 -0500 Subject: [PATCH 01/30] Refactor block rendering to use Mustache templates Modularized view logic into separate methods and moved inline HTML to Mustache templates. Migrated radar chart initialization to an AMD module for better maintainability. --- block_learning_style.php | 576 +++++++++++++++------------------------ 1 file changed, 218 insertions(+), 358 deletions(-) diff --git a/block_learning_style.php b/block_learning_style.php index 48ca17d1e91..0a871258911 100644 --- a/block_learning_style.php +++ b/block_learning_style.php @@ -81,9 +81,11 @@ public function my_slider($value, $izq_val, $der_val, $izq_title, $der_title) { return $slider; } - public function get_content() - { - global $CFG, $DB, $USER, $COURSE; + /** + * Main content generator + */ + public function get_content() { + global $COURSE; if ($this->content !== NULL) { return $this->content; @@ -108,275 +110,213 @@ public function get_content() $context = context_course::instance($COURSE->id); $this->page->requires->css('/blocks/learning_style/styles.css'); - // Dashboard viewers (teacher/admin) must never be treated as students. - $can_view_dashboard = is_siteadmin() + if ($this->can_view_dashboard($context)) { + $this->content->text = $this->get_teacher_content($context); + } else if ($this->is_student($context)) { + $this->content->text = $this->get_student_content(); + } + + return $this->content; + } + + /** + * Check if user can view dashboard + */ + private function can_view_dashboard($context) { + return is_siteadmin() || has_capability('block/learning_style:viewreports', $context) || has_capability('moodle/course:viewhiddensections', $context); + } - // Determine if the user has a student role in this course - $is_student = !$can_view_dashboard && has_capability('block/learning_style:take_test', $context); - - //Check if user is student - if ($is_student) { - //check if user already have the learning style (in any course) - $entry = $DB->get_record('learning_style', array('user' => $USER->id)); - - if (!$entry) { - // Mostrar invitación al test sin redirigir - $this->content->text .= $this->get_test_invitation(); - } else if ($entry && isset($entry->is_completed) && $entry->is_completed == 0) { - // Test in progress - show continue option - $answered = 0; - for ($i = 1; $i <= 44; $i++) { - $field = "q{$i}"; - if (isset($entry->$field) && $entry->$field !== null) { - $answered++; - } - } - $this->content->text .= $this->get_continue_test_card($answered); - } else { - $final_style = []; - - $izq_title = get_string('active_recommendations', 'block_learning_style'); - $der_title = get_string('reflexive_recommendations', 'block_learning_style'); - - // Si Activo es mayor, el resultado es negativo y la barra se va a la izquierda. - $diff_active = $entry->ap_reflexivo - $entry->ap_active; - $final_style[abs($diff_active) . "ar"] = $this->my_slider($diff_active, get_string("active", 'block_learning_style'), get_string("reflexive", 'block_learning_style'),$izq_title,$der_title); - - $izq_title = get_string('sensorial_recommendations', 'block_learning_style'); - $der_title = get_string('intuitive_recommendations', 'block_learning_style'); - - // Intuitivo (der) - Sensorial (izq) - $diff_sensorial = $entry->ap_intuitivo - $entry->ap_sensorial; - $final_style[abs($diff_sensorial) . "si"] = $this->my_slider($diff_sensorial, get_string("sensorial", 'block_learning_style'), get_string("intuitive", 'block_learning_style'),$izq_title,$der_title); - - $izq_title = get_string('visual_recommendations', 'block_learning_style'); - $der_title = get_string('verbal_recommendations', 'block_learning_style'); - - // Verbal (der) - Visual (izq) - $diff_visual = $entry->ap_verbal - $entry->ap_visual; - $final_style[abs($diff_visual) . "vv"] = $this->my_slider($diff_visual, get_string("visual", 'block_learning_style'), get_string("verbal", 'block_learning_style'),$izq_title,$der_title); - - $izq_title = get_string('sequential_recommendations', 'block_learning_style'); - $der_title = get_string('global_recommendations', 'block_learning_style'); - - // Global (der) - Secuencial (izq) - $diff_secuencial = $entry->ap_global - $entry->ap_secuencial; - $final_style[abs($diff_secuencial) . "sg"] = $this->my_slider($diff_secuencial, get_string("sequential", 'block_learning_style'), get_string("global", 'block_learning_style'),$izq_title,$der_title); - krsort($final_style); - - // Header con icono de éxito - $this->content->text .= '
'; - $this->content->text .= '
'; - $this->content->text .= '
'; - $this->content->text .= $this->get_learning_style_icon('4em', 'display: block;', false); - $this->content->text .= ''; - $this->content->text .= '
'; - $this->content->text .= '
' . get_string('test_completed', 'block_learning_style') . '
'; - $this->content->text .= '' . get_string('your_learning_style', 'block_learning_style') . ''; - $this->content->text .= '
'; - - // Test description - $this->content->text .= '
'; - $this->content->text .= ''; - $this->content->text .= ' '; - $this->content->text .= get_string('test_description', 'block_learning_style'); - $this->content->text .= ''; - $this->content->text .= '
'; - - $this->content->text .= "

" . get_string('felder_soloman_intro', 'block_learning_style') . "

"; - $this->content->text .= html_writer::start_tag('ul', ['class' => 'lsorder']); - foreach ($final_style as $key => $val) { - $this->content->text .= html_writer::tag('li', $val); + /** + * Check if user is a student + */ + private function is_student($context) { + return has_capability('block/learning_style:take_test', $context); + } + + /** + * Generate content for students + */ + private function get_student_content() { + global $DB, $USER; + + $entry = $DB->get_record('learning_style', array('user' => $USER->id)); + + if (!$entry) { + return $this->get_test_invitation(); + } + + if (isset($entry->is_completed) && $entry->is_completed == 0) { + $answered = 0; + for ($i = 1; $i <= 44; $i++) { + $field = "q{$i}"; + if (isset($entry->$field) && $entry->$field !== null) { + $answered++; } - $this->content->text .= html_writer::end_tag('ul'); - - // Inicializar popovers de forma segura - // Initialize popovers using an AMD module that assumes Bootstrap is provided by Moodle/theme. - $this->page->requires->js_call_amd('block_learning_style/popoverinit', 'init'); - - // Mensaje final - $this->content->text .= html_writer::tag('p', get_string('click_bold_for_recommendations', 'block_learning_style'), ['class' => 'alpyintro', 'style' => 'margin: 0;']); - $json_style = [ - "act" => intval($entry->ap_active), - "ref" => intval($entry->ap_reflexivo), - "sen" => intval($entry->ap_sensorial), - "int" => intval($entry->ap_intuitivo), - "vis" => intval($entry->ap_visual), - "vrb" => intval($entry->ap_verbal), - "seq" => intval($entry->ap_secuencial), - "glo" => intval($entry->ap_global) - ]; - $json_encode = json_encode($json_style); - // Canvas del gráfico radar (sin width ni height, lo controla CSS) - $this->content->text .= ""; - - $chartjs_code = " - var data = $json_encode; - - require(['core/chartjs'], function(Chart) { - var canvas = document.getElementById('radarstyle'); - if (!canvas) { return; } - var ctx = canvas.getContext('2d'); - new Chart(ctx, { - type: 'radar', - data: { - labels: [ - '" . get_string('chart_visual', 'block_learning_style') . "', - '" . get_string('chart_sensorial', 'block_learning_style') . "', - '" . get_string('chart_active', 'block_learning_style') . "', - '" . get_string('chart_global', 'block_learning_style') . "', - '" . get_string('chart_verbal', 'block_learning_style') . "', - '" . get_string('chart_intuitive', 'block_learning_style') . "', - '" . get_string('chart_reflexive', 'block_learning_style') . "', - '" . get_string('chart_sequential', 'block_learning_style') . "' - ], - datasets: [{ - label: '" . get_string('learning_style_label', 'block_learning_style') . "', - data: [ - data.vis, - data.sen, - data.act, - data.glo, - data.vrb, - data.int, - data.ref, - data.seq - ], - backgroundColor: 'rgba(21, 103, 249, 0.2)', - borderColor: 'rgba(21, 103, 249, 1)', - borderWidth: 2, - pointBackgroundColor: 'rgba(21, 103, 249, 1)' - }] - }, - options: { - responsive: true, - scales: { - r: { - min: 0, - max: 11, - angleLines: { - display: true, - color: 'rgba(0, 0, 0, 0.1)' - }, - grid: { - // AQUÍ QUITAMOS LAS LÍNEAS PARES - color: function(context) { - if (context.tick.value % 2 === 1) { - return 'transparent'; - } - return 'rgba(0, 0, 0, 0.1)'; - }, - lineWidth: 1 - }, - ticks: { - stepSize: 1, - display: true, - backdropColor: 'transparent', - // TAMBIÉN QUITAMOS LOS NÚMEROS PARES DE LAS ETIQUETAS - callback: function(value) { - return value % 2 !== 0 ? value : ''; - }, - font: { - size: 12 - } - }, - pointLabels: { - font: {size: 14} - } - } - }, - plugins: { - legend: { display: false } - } - } - }); - }); - "; - $this->page->requires->js_init_code($chartjs_code); - $this->content->text .= '
'; // Cerrar learning-results-block } + return $this->get_continue_test_card($answered); + } + + return $this->render_results($entry); + } + + /** + * Render results and chart + */ + private function render_results($entry) { + global $OUTPUT; + $final_style = []; + $sliders_data = []; + + $izq_title = get_string('active_recommendations', 'block_learning_style'); + $der_title = get_string('reflexive_recommendations', 'block_learning_style'); + + // Si Activo es mayor, el resultado es negativo y la barra se va a la izquierda. + $diff_active = $entry->ap_reflexivo - $entry->ap_active; + $final_style[abs($diff_active) . "ar"] = $this->my_slider($diff_active, get_string("active", 'block_learning_style'), get_string("reflexive", 'block_learning_style'),$izq_title,$der_title); + + $izq_title = get_string('sensorial_recommendations', 'block_learning_style'); + $der_title = get_string('intuitive_recommendations', 'block_learning_style'); + + // Intuitivo (der) - Sensorial (izq) + $diff_sensorial = $entry->ap_intuitivo - $entry->ap_sensorial; + $final_style[abs($diff_sensorial) . "si"] = $this->my_slider($diff_sensorial, get_string("sensorial", 'block_learning_style'), get_string("intuitive", 'block_learning_style'),$izq_title,$der_title); + + $izq_title = get_string('visual_recommendations', 'block_learning_style'); + $der_title = get_string('verbal_recommendations', 'block_learning_style'); + + // Verbal (der) - Visual (izq) + $diff_visual = $entry->ap_verbal - $entry->ap_visual; + $final_style[abs($diff_visual) . "vv"] = $this->my_slider($diff_visual, get_string("visual", 'block_learning_style'), get_string("verbal", 'block_learning_style'),$izq_title,$der_title); + + $izq_title = get_string('sequential_recommendations', 'block_learning_style'); + $der_title = get_string('global_recommendations', 'block_learning_style'); + + // Global (der) - Secuencial (izq) + $diff_secuencial = $entry->ap_global - $entry->ap_secuencial; + $final_style[abs($diff_secuencial) . "sg"] = $this->my_slider($diff_secuencial, get_string("sequential", 'block_learning_style'), get_string("global", 'block_learning_style'),$izq_title,$der_title); + krsort($final_style); + + foreach ($final_style as $html) { + $sliders_data[] = ['html' => $html]; + } + + // Inicializar popovers de forma segura + $this->page->requires->js_call_amd('block_learning_style/popoverinit', 'init'); + + $json_style = [ + "act" => intval($entry->ap_active), + "ref" => intval($entry->ap_reflexivo), + "sen" => intval($entry->ap_sensorial), + "int" => intval($entry->ap_intuitivo), + "vis" => intval($entry->ap_visual), + "vrb" => intval($entry->ap_verbal), + "seq" => intval($entry->ap_secuencial), + "glo" => intval($entry->ap_global) + ]; + + $chart_labels = [ + get_string('chart_visual', 'block_learning_style'), + get_string('chart_sensorial', 'block_learning_style'), + get_string('chart_active', 'block_learning_style'), + get_string('chart_global', 'block_learning_style'), + get_string('chart_verbal', 'block_learning_style'), + get_string('chart_intuitive', 'block_learning_style'), + get_string('chart_reflexive', 'block_learning_style'), + get_string('chart_sequential', 'block_learning_style') + ]; + + $dataset_label = get_string('learning_style_label', 'block_learning_style'); + + $params = [ + 'canvasId' => 'radarstyle', + 'data' => $json_style, + 'labels' => $chart_labels, + 'datasetLabel' => $dataset_label + ]; + + $this->page->requires->js_call_amd('block_learning_style/radar_handler', 'init', [$params]); + + $template_data = [ + 'icon' => $this->get_learning_style_icon('4em', 'display: block;', false), + 'sliders' => $sliders_data, + 'instanceid' => $this->instance->id + ]; + + return $OUTPUT->render_from_template('block_learning_style/results', $template_data); + } + + /** + * Generate content for teachers/admins + */ + private function get_teacher_content($context) { + global $CFG, $COURSE, $DB, $OUTPUT; + + // Header with learning style icon for teacher/admin view. + $icon = $this->get_learning_style_icon('4em', '', true); + + // Assets for embedded dashboard. + $this->page->requires->css('/blocks/learning_style/dashboard/css/style.css'); + $this->page->requires->js('/blocks/learning_style/dashboard/js/main.js'); + + // Render dashboard HTML fragment. + $embedded_file = $CFG->dirroot . '/blocks/learning_style/dashboard/embedded.php'; + $dashboard_html = ''; + + if (file_exists($embedded_file)) { + ob_start(); + $courseid = $COURSE->id; + include_once($embedded_file); + $dashboard_html = ob_get_clean(); } else { - if ($can_view_dashboard) { - // Embed the dashboard UI inside the block. - // IMPORTANT: The embedded fragment must not call require_login() or output header/footer. - - // Header with learning style icon for teacher/admin view. - $this->content->text .= '
'; - $this->content->text .= $this->get_learning_style_icon('4em', '', true); - $this->content->text .= '
' . get_string('management_title', 'block_learning_style') . '
'; - $this->content->text .= '' . get_string('course_overview', 'block_learning_style') . ''; - $this->content->text .= '
'; - - // Assets for embedded dashboard. - $this->page->requires->css('/blocks/learning_style/dashboard/css/style.css'); - $this->page->requires->js('/blocks/learning_style/dashboard/js/main.js'); - - // Render dashboard HTML fragment. - $embedded_file = $CFG->dirroot . '/blocks/learning_style/dashboard/embedded.php'; - if (file_exists($embedded_file)) { - ob_start(); - $courseid = $COURSE->id; - include_once($embedded_file); - $this->content->text .= ob_get_clean(); - } else { - $this->content->text .= '

' . get_string('dashboard_not_found', 'block_learning_style') . '

'; - } + $dashboard_html = '

' . get_string('dashboard_not_found', 'block_learning_style') . '

'; + } - // Agregar botones al final (después del dashboard) para profesores/administradores - $is_teacher = has_capability('block/learning_style:viewreports', $context) || is_siteadmin(); - if ($is_teacher) { - // Determinar si hay tests completados en este curso (solo estudiantes) - $student_users = get_enrolled_users($context, 'block/learning_style:take_test', 0, 'u.id'); - $student_ids = array_keys($student_users); - - // Defensive: exclude any teacher/manager-type user even if misconfigured. - $filtered_student_ids = array(); - foreach ($student_ids as $candidateid) { - $candidateid = (int)$candidateid; - if (is_siteadmin($candidateid)) { - continue; - } - if (has_capability('block/learning_style:viewreports', $context, $candidateid)) { - continue; - } - $filtered_student_ids[] = $candidateid; - } - $student_ids = $filtered_student_ids; + $template_data = [ + 'icon' => $icon, + 'dashboard_html' => $dashboard_html, + 'show_buttons' => false + ]; - $has_completed = false; - if (!empty($student_ids)) { - list($insql, $params) = $DB->get_in_or_equal($student_ids, SQL_PARAMS_NAMED, 'user'); - $completed_count = $DB->count_records_sql("SELECT COUNT(*) FROM {learning_style} WHERE user $insql AND is_completed = 1", $params); - $has_completed = ($completed_count > 0); + // Agregar botones al final (después del dashboard) para profesores/administradores + $is_teacher = has_capability('block/learning_style:viewreports', $context) || is_siteadmin(); + if ($is_teacher) { + $template_data['show_buttons'] = true; + $template_data['admin_url'] = (new moodle_url('/blocks/learning_style/admin_view.php', array('courseid' => $COURSE->id)))->out(); + + // Determinar si hay tests completados en este curso (solo estudiantes) + $student_users = get_enrolled_users($context, 'block/learning_style:take_test', 0, 'u.id'); + $student_ids = array_keys($student_users); + + // Defensive: exclude any teacher/manager-type user even if misconfigured. + $filtered_student_ids = array(); + foreach ($student_ids as $candidateid) { + $candidateid = (int)$candidateid; + if (is_siteadmin($candidateid)) { + continue; } - - // URLs - $download_url = new moodle_url('/blocks/learning_style/download_results.php', array('courseid' => $COURSE->id, 'sesskey' => sesskey())); - $admin_url = new moodle_url('/blocks/learning_style/admin_view.php', array('courseid' => $COURSE->id)); - - // Construir contenedor de botones - $buttons_container = html_writer::start_div('text-center', array('style' => 'margin: 10px 0;')); - $buttons_container .= html_writer::link($admin_url, - get_string('view_admin_results', 'block_learning_style'), - array('class' => 'btn btn-primary btn-sm', 'style' => 'margin: 2px; background: linear-gradient(135deg, #1567f9 0%, #0054ce 100%); border: none;', 'title' => get_string('view_admin_results', 'block_learning_style'))); - - // Mostrar botón de descarga solo si hay tests completados - if ($has_completed) { - $buttons_container .= html_writer::link($download_url, - get_string('download_results', 'block_learning_style'), - array('class' => 'btn btn-sm', 'style' => 'margin: 2px; background-color: #1e7e34; color: #ffffff; text-decoration: none; border: none;', 'title' => get_string('download_results', 'block_learning_style'))); + if (has_capability('block/learning_style:viewreports', $context, $candidateid)) { + continue; } + $filtered_student_ids[] = $candidateid; + } + $student_ids = $filtered_student_ids; - $buttons_container .= html_writer::end_div(); - - $this->content->text .= $buttons_container; + $has_completed = false; + if (!empty($student_ids)) { + list($insql, $params) = $DB->get_in_or_equal($student_ids, SQL_PARAMS_NAMED, 'user'); + $completed_count = $DB->count_records_sql("SELECT COUNT(*) FROM {learning_style} WHERE user $insql AND is_completed = 1", $params); + $has_completed = ($completed_count > 0); } + + $template_data['show_download'] = $has_completed; + if ($has_completed) { + $template_data['download_url'] = (new moodle_url('/blocks/learning_style/download_results.php', array('courseid' => $COURSE->id, 'sesskey' => sesskey())))->out(false); } } - return $this->content; + return $OUTPUT->render_from_template('block_learning_style/teacher_dashboard', $template_data); } /** @@ -384,7 +324,7 @@ public function get_content() */ private function get_learning_style_icon($size = '1.8em', $additional_style = '', $centered = false) { global $CFG; - $iconurl = new moodle_url('/blocks/learning_style/pix/learning_style_icon.svg'); + $iconurl = new moodle_url('/blocks/learning_style/pix/icon.svg'); // NOTE: styles.css has a legacy rule that floats all images in the block. // This icon must never float, otherwise it cannot be centered. $style = 'width: ' . $size . '; height: ' . $size . '; vertical-align: middle; float: none !important;'; @@ -401,116 +341,31 @@ private function get_learning_style_icon($size = '1.8em', $additional_style = '' * Método para mostrar la invitación al test de estilos de aprendizaje */ private function get_test_invitation() { - global $COURSE, $CFG, $SESSION; - - $output = ''; - $output .= '
'; - - // Header with learning style icon - $output .= '
'; - $output .= '
'; - $output .= $this->get_learning_style_icon('4em', '', true); - $output .= '
'; - $output .= '
' . get_string('test_title', 'block_learning_style') . '
'; - $output .= '' . get_string('discover_your_style', 'block_learning_style') . ''; - $output .= '
'; + global $COURSE, $OUTPUT; - // Test description card - $output .= '
'; - $output .= '
'; - $output .= '
'; - $output .= '
'; - $output .= ' '; - $output .= get_string('what_is_felder', 'block_learning_style'); - $output .= '
'; - $output .= '

' . get_string('test_description', 'block_learning_style') . '

'; - $output .= '
    '; - $output .= '
  • ' . get_string('feature_44_questions', 'block_learning_style') . '
  • '; - $output .= '
  • ' . get_string('feature_4_dimensions', 'block_learning_style') . '
  • '; - $output .= '
  • ' . get_string('feature_instant_results', 'block_learning_style') . '
  • '; - $output .= '
'; - $output .= '
'; - $output .= '
'; - $output .= '
'; - - // Action button - $output .= '
'; - $url = new moodle_url('/blocks/learning_style/view.php', array('cid' => $COURSE->id)); - $output .= ''; - $output .= ' ' . get_string('start_test', 'block_learning_style') . ''; - $output .= ''; - $output .= '
'; - - $output .= '
'; + $template_data = [ + 'icon' => $this->get_learning_style_icon('4em', '', true), + 'url' => (new moodle_url('/blocks/learning_style/view.php', array('cid' => $COURSE->id)))->out() + ]; - return $output; + return $OUTPUT->render_from_template('block_learning_style/test_invitation', $template_data); } /** * Display continue test card for students with test in progress - * Design matches CHASIDE block for consistency */ private function get_continue_test_card($answered_count) { - global $COURSE; + global $COURSE, $OUTPUT; - $output = ''; $progress_percentage = ($answered_count / 44) * 100; $all_answered = ($answered_count == 44); - $output .= '
'; - - // Header with learning style icon - $output .= '
'; - $output .= '
'; - $output .= $this->get_learning_style_icon('4em', 'filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));', true); - $output .= '
'; - $output .= '
' . get_string('test_title', 'block_learning_style') . '
'; - $output .= '' . get_string('discover_your_style', 'block_learning_style') . ''; - $output .= '
'; - - // Description section - $output .= '
'; - $output .= ''; - $output .= ' '; - $output .= get_string('test_description', 'block_learning_style'); - $output .= ''; - $output .= '
'; - - // Special alert when all questions are answered but not submitted - if ($all_answered) { - $output .= '
'; - $output .= '
'; - $output .= ''; - $output .= '
'; - $output .= '' . get_string('all_answered_title', 'block_learning_style') . '
'; - $output .= '' . get_string('all_answered_message', 'block_learning_style') . ''; - $output .= '
'; - $output .= '
'; - $output .= '
'; - } - - // Progress section - $output .= '
'; - $output .= '
'; - $output .= '' . get_string('your_progress', 'block_learning_style') . ''; - $output .= '' . $answered_count . '/44'; - $output .= '
'; - $output .= '
'; - $output .= '
'; - $output .= '
'; - $output .= '' . number_format($progress_percentage, 1) . '% ' . get_string('completed', 'block_learning_style') . ''; - $output .= '
'; - - // Call to action button - $output .= '
'; - // Change button text, icon and URL based on completion status if ($all_answered) { $button_text = get_string('finish_test', 'block_learning_style'); $button_icon = 'fa-flag-checkered'; $button_class = 'btn-success'; - // Jump to the last page (where the real finish button exists) and highlight it. $questions_per_page = 11; $total_questions = 44; $last_page = (int)ceil($total_questions / $questions_per_page); @@ -526,14 +381,19 @@ private function get_continue_test_card($answered_count) { $button_class = 'btn-warning'; $url = new moodle_url('/blocks/learning_style/view.php', array('cid' => $COURSE->id)); } + + $template_data = [ + 'icon' => $this->get_learning_style_icon('4em', 'filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));', true), + 'answered_count' => $answered_count, + 'progress_percentage' => $progress_percentage, + 'formatted_percentage' => number_format($progress_percentage, 1), + 'all_answered' => $all_answered, + 'url' => $url->out(false), + 'button_text' => $button_text, + 'button_icon' => $button_icon, + 'button_class' => $button_class + ]; - $output .= ''; - $output .= ' ' . $button_text; - $output .= ''; - $output .= '
'; - - $output .= '
'; - - return $output; + return $OUTPUT->render_from_template('block_learning_style/continue_test', $template_data); } } From 6b0d4895d85f30cb048700b1efa312fa4ab957b0 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:16:15 -0500 Subject: [PATCH 02/30] Create admin_view.mustache for learning styles Add admin view template for learning styles management with dynamic search and participant listing. --- templates/admin_view.mustache | 302 ++++++++++++++++++++++++++++++++++ 1 file changed, 302 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 00000000000..a01ad131f8c --- /dev/null +++ b/templates/admin_view.mustache @@ -0,0 +1,302 @@ +
+ + +

+ Learning Style Icon + {{title}} +

+
+ {{{ description }}} +
+ + {{#delete_confirmation}} +
+

{{#str}}confirm_delete_learning_style, block_learning_style{{/str}}

+

{{confirm_message}}

+ +
+ {{/delete_confirmation}} + + {{^delete_confirmation}} +
+
+
+
+ +
{{#str}}total_students, block_learning_style{{/str}}
+

{{total_enrolled}}

+
+
+
+ +
+
+
+ +
{{#str}}completed_tests, block_learning_style{{/str}}
+

{{total_completed}}

+
+
+
+ +
+
+
+ +
{{#str}}in_progress_tests, block_learning_style{{/str}}
+

{{total_in_progress}}

+
+
+
+ +
+
+
+ +
{{#str}}completion_rate, block_learning_style{{/str}}
+

{{completion_rate}}%

+
+
+
+
+ + {{#has_completed}} +
+
+
+
+
{{#str}}general_statistics, block_learning_style{{/str}}
+
+
+
+ +
+
{{#str}}most_common_types, block_learning_style{{/str}}
+
+ {{#top_styles}} +
+
+ +
+ {{rank}} +
+ +
+ {{percentage}}% +
+
+
{{label}}
+ {{count}} +
+
+
+ {{/top_styles}} +
+ {{^top_styles}} +

{{#str}}no_data_available, block_learning_style{{/str}}

+ {{/top_styles}} +
+ + +
+
{{#str}}average_dimensions, block_learning_style{{/str}}
+
+ {{#dimension_stats}} +
+
    +
  • + {{left_label}} + {{left_avg}} +
  • +
  • + {{right_label}} + {{right_avg}} +
  • +
+
+ {{/dimension_stats}} +
+
+
+
+
+
+
+ {{/has_completed}} + +
+ {{#show_table}} +
+
+
{{#str}}participants_list, block_learning_style{{/str}}
+
+
+ + +
+ + + + + + + + + + + + + {{#list}} + + + + + + + + + {{/list}} + {{^list}} + + + + {{/list}} + +
{{#str}}participant, block_learning_style{{/str}}{{#str}}email{{/str}}{{#str}}status, block_learning_style{{/str}}{{#str}}learning_profile, block_learning_style{{/str}}{{#str}}completion_date, block_learning_style{{/str}}{{#str}}actions, block_learning_style{{/str}}
+
+ {{{userpicture}}} + {{fullname}} +
+
{{email}} + {{#is_completed}} + {{#str}}status_completed, block_learning_style{{/str}} + {{/is_completed}} + {{^is_completed}} + {{#str}}status_in_progress, block_learning_style{{/str}} +
{{#str}}progress_questions, block_learning_style, {"answered": {{answered}}, "total": {{total_questions}}}{{/str}} + {{/is_completed}} +
+ {{#profile_summary}} + {{.}} + {{/profile_summary}} + {{^profile_summary}}-{{/profile_summary}} + {{completion_date}} + + {{#str}}view_details, block_learning_style{{/str}} + + + {{#str}}delete{{/str}} + +
+
+ {{#str}}no_results_search, block_learning_style, {{search_term}}{{/str}} +
+
+
+ + +
+ {{{pagination}}} +
+
+
+ {{/show_table}} + {{^show_table}} +
+ +
{{#str}}no_participants, block_learning_style{{/str}}
+

{{#str}}no_participants_message, block_learning_style{{/str}}

+
+ {{/show_table}} +
+ {{/delete_confirmation}} + +
+ + {{#str}}back_to_course, block_learning_style{{/str}} + +
+
+ +{{#js}} +require(['jquery'], function($) { + var timeout = null; + var container = $('#learning-style-results-region'); + + // Dynamic Search (AJAX) Delegated + container.on('input', '#searchInput', function() { + var input = $(this); + if (timeout) clearTimeout(timeout); + var searchTerm = input.val(); + + timeout = setTimeout(function() { + loadResults(searchTerm, 0); + }, 300); + }); + + container.on('click', '.pagination a', function(e) { + e.preventDefault(); + var href = $(this).attr('href'); + if (!href) return; + + var urlParams = new URLSearchParams(href.split('?')[1]); + var page = urlParams.get('page') || 0; + var searchTerm = container.find('#searchInput').val() || ''; + + loadResults(searchTerm, page); + }); + + function loadResults(search, page) { + var url = '{{admin_url}}'; + var data = { + courseid: {{courseid}}, + search: search, + page: page, + action: 'list' + }; + + container.css('opacity', '0.6'); + + $.get(url, data, function(response) { + var responseObj = $('
').html(response); + var newContent = responseObj.find('#learning-style-results-region').html(); + + if (newContent) { + container.html(newContent); + var input = container.find('#searchInput'); + if (input.length) { + input.focus(); + var tmpStr = input.val(); + input.val(''); + input.val(tmpStr); + } + } + container.css('opacity', '1'); + }); + } +}); +{{/js}} From a9029c343183636dd09052e143061ac959aa7130 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:16:34 -0500 Subject: [PATCH 03/30] Add continue_test.mustache template --- templates/continue_test.mustache | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 templates/continue_test.mustache diff --git a/templates/continue_test.mustache b/templates/continue_test.mustache new file mode 100644 index 00000000000..188915c16e7 --- /dev/null +++ b/templates/continue_test.mustache @@ -0,0 +1,45 @@ +
+
+
+ {{{icon}}} +
+
{{#str}} test_title, block_learning_style {{/str}}
+ {{#str}} discover_your_style, block_learning_style {{/str}} +
+ +
+ + + {{#str}} test_description, block_learning_style {{/str}} + +
+ + {{#all_answered}} +
+
+ +
+ {{#str}} all_answered_title, block_learning_style {{/str}}
+ {{#str}} all_answered_message, block_learning_style {{/str}} +
+
+
+ {{/all_answered}} + +
+
+ {{#str}} your_progress, block_learning_style {{/str}} + {{answered_count}}/44 +
+
+
+
+ {{formatted_percentage}}% {{#str}} completed, block_learning_style {{/str}} +
+ + +
From ed9db404fa02a95f5eedda9881915b4b20c5aebe 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:16:53 -0500 Subject: [PATCH 04/30] Add results template with learning styles and JS logic --- templates/results.mustache | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 templates/results.mustache diff --git a/templates/results.mustache b/templates/results.mustache new file mode 100644 index 00000000000..f77d5b942f9 --- /dev/null +++ b/templates/results.mustache @@ -0,0 +1,50 @@ +
+
+
+ {{{icon}}} + +
+
{{#str}} test_completed, block_learning_style {{/str}}
+ {{#str}} your_learning_style, block_learning_style {{/str}} +
+ +
+ + + {{#str}} test_description, block_learning_style {{/str}} + +
+ +

{{#str}} felder_soloman_intro, block_learning_style {{/str}}

+ + + +

{{#str}} click_bold_for_recommendations, block_learning_style {{/str}}

+ + +
+{{#js}} +require(['jquery'], function($) { + var instanceId = "{{instanceid}}"; + /* Check if instanceId is valid before proceeding */ + if (instanceId && window.location.hash) { + var targetHash = "#inst" + instanceId; + if (window.location.hash === targetHash) { + /* Add a small delay to ensure rendering is complete */ + setTimeout(function() { + var $target = $(targetHash); + if ($target.length) { + /* Scroll to element with some top offset (e.g. 100px for header) */ + $('html, body').animate({ + scrollTop: $target.offset().top - 100 + }, 500); + } + }, 300); + } + } +}); +{{/js}} From e53138b75fc74d5d0a34e66e2174303cc4539b1b 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:17:09 -0500 Subject: [PATCH 05/30] Create teacher_dashboard.mustache template Add teacher dashboard template with management title and buttons --- templates/teacher_dashboard.mustache | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 templates/teacher_dashboard.mustache diff --git a/templates/teacher_dashboard.mustache b/templates/teacher_dashboard.mustache new file mode 100644 index 00000000000..e252fa688af --- /dev/null +++ b/templates/teacher_dashboard.mustache @@ -0,0 +1,21 @@ +
+ {{{icon}}} +
{{#str}} management_title, block_learning_style {{/str}}
+ {{#str}} course_overview, block_learning_style {{/str}} +
+ +{{{dashboard_html}}} + +{{#show_buttons}} +
+ + {{#str}} view_admin_results, block_learning_style {{/str}} + + + {{#show_download}} + + {{#str}} download_results, block_learning_style {{/str}} + + {{/show_download}} +
+{{/show_buttons}} From 9e82e1918336a3029c822fa72bc13f6f33d0c427 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:17:30 -0500 Subject: [PATCH 06/30] Create test_invitation.mustache template Added a new Mustache template for test invitations with structured HTML content. --- templates/test_invitation.mustache | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 templates/test_invitation.mustache diff --git a/templates/test_invitation.mustache b/templates/test_invitation.mustache new file mode 100644 index 00000000000..4f0959d9f2c --- /dev/null +++ b/templates/test_invitation.mustache @@ -0,0 +1,32 @@ +
+
+
+ {{{icon}}} +
+
{{#str}} test_title, block_learning_style {{/str}}
+ {{#str}} discover_your_style, block_learning_style {{/str}} +
+ +
+
+
+
+ + {{#str}} what_is_felder, block_learning_style {{/str}} +
+

{{#str}} test_description, block_learning_style {{/str}}

+
    +
  • {{#str}} feature_44_questions, block_learning_style {{/str}}
  • +
  • {{#str}} feature_4_dimensions, block_learning_style {{/str}}
  • +
  • {{#str}} feature_instant_results, block_learning_style {{/str}}
  • +
+
+
+
+ + +
From 81d95cd53986a3c75eaca69608c7ed4b8e022ff9 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:17:49 -0500 Subject: [PATCH 07/30] Add view_individual_progress.mustache template --- templates/view_individual_progress.mustache | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 templates/view_individual_progress.mustache diff --git a/templates/view_individual_progress.mustache b/templates/view_individual_progress.mustache new file mode 100644 index 00000000000..70d85b061dc --- /dev/null +++ b/templates/view_individual_progress.mustache @@ -0,0 +1,32 @@ +
+ +
+ +
+ + {{#str}} back_to_admin, block_learning_style {{/str}} + + + {{#str}} back_to_course, block_learning_style {{/str}} + +
From 26792cdf5c75ac1864a473247928bc7c374c50d0 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:18:10 -0500 Subject: [PATCH 08/30] Implement individual results view layout Added a detailed layout for individual learning style results, including user information, learning dimensions, and technical data. --- templates/view_individual_results.mustache | 129 +++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 templates/view_individual_results.mustache diff --git a/templates/view_individual_results.mustache b/templates/view_individual_results.mustache new file mode 100644 index 00000000000..1370f2054c9 --- /dev/null +++ b/templates/view_individual_results.mustache @@ -0,0 +1,129 @@ +
+
+
+
+

{{fullname}}

+

+ {{#str}} completed_on, block_learning_style {{/str}}: {{completion_date}} +

+
+
+
+ + + {{#str}} test_completed, block_learning_style {{/str}} + +
+
+ +

{{#str}} learning_dimensions, block_learning_style {{/str}}

+ +
+ {{#dimensions}} +
+
+
+
{{name}}
+
+
+ +
+
{{active_label}}
+
+ {{active_count}} ({{active_percentage}}%) +
+
+ +
{{reflexive_label}}
+
+ {{reflexive_count}} ({{reflexive_percentage}}%) +
+
+
+ +
+ + {{#str}} dominant_style, block_learning_style {{/str}}: + {{dominant_style_label}} ({{dominant_percentage}}%) +
+ +
+
+
+ {{/dimensions}} +
+ +
+
+ +

{{#str}} learning_profile_summary, block_learning_style {{/str}}

+
+
    + {{#profile_characteristics}} +
  • + + {{.}} +
  • + {{/profile_characteristics}} +
+
+ +
+
+ +
{{#str}} technical_data, block_learning_style {{/str}}
+
+
+
+ {{#technical_data}} +
+
{{#str}} dimension_active, block_learning_style {{/str}}
+ {{active}} +
+
+
{{#str}} dimension_reflexive, block_learning_style {{/str}}
+ {{reflexive}} +
+
+
{{#str}} dimension_sensorial, block_learning_style {{/str}}
+ {{sensorial}} +
+
+
{{#str}} dimension_intuitive, block_learning_style {{/str}}
+ {{intuitive}} +
+ {{/technical_data}} +
+ +
+ {{#technical_data}} +
+
{{#str}} dimension_visual, block_learning_style {{/str}}
+ {{visual}} +
+
+
{{#str}} dimension_verbal, block_learning_style {{/str}}
+ {{verbal}} +
+
+
{{#str}} dimension_sequential, block_learning_style {{/str}}
+ {{sequential}} +
+
+
{{#str}} dimension_global, block_learning_style {{/str}}
+ {{global}} +
+ {{/technical_data}} +
+
+
+
+ +
+ + {{#str}} back_to_admin, block_learning_style {{/str}} + + + {{#str}} back_to_course, block_learning_style {{/str}} + +
From 37ae1eee2c42c040e1134a8d18fede2b13d2e951 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:18:28 -0500 Subject: [PATCH 09/30] Add learning style questionnaire template --- templates/view.mustache | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 templates/view.mustache diff --git a/templates/view.mustache b/templates/view.mustache new file mode 100644 index 00000000000..9e22a5f5370 --- /dev/null +++ b/templates/view.mustache @@ -0,0 +1,67 @@ +
+ Learning Style Icon +
+ +

{{#str}}test_page_title, block_learning_style{{/str}}

+ +
+
+ {{#str}}test_intro_p1, block_learning_style{{/str}} + {{#str}}test_intro_p2, block_learning_style{{/str}} +
+
+
+ {{#str}}test_note, block_learning_style{{/str}} {{#str}}test_all_required, block_learning_style{{/str}} (*) +
+
+ +
+
+
    + {{#questions}} +
  1. +
    {{question_text}}
    + +
  2. + {{/questions}} +
+ +
+ + + + +
+ + + + +
+ +
From 994badbc6b91e4c121aacf5a719e6aae88b63ebd Mon Sep 17 00:00:00 2001 From: Santiago Orejuela Date: Wed, 7 Jan 2026 23:23:28 -0500 Subject: [PATCH 10/30] Add radar_handler.min.js for radar chart functionality --- amd/build/radar_handler.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 amd/build/radar_handler.min.js diff --git a/amd/build/radar_handler.min.js b/amd/build/radar_handler.min.js new file mode 100644 index 00000000000..93d163526ba --- /dev/null +++ b/amd/build/radar_handler.min.js @@ -0,0 +1 @@ +define(["core/chartjs"],(function(a){"use strict";return{init:function(t){var e=document.getElementById(t.canvasId);if(e){var r=e.getContext("2d");new a(r,{type:"radar",data:{labels:t.labels,datasets:[{label:t.datasetLabel,data:[t.data.vis,t.data.sen,t.data.act,t.data.glo,t.data.vrb,t.data.int,t.data.ref,t.data.seq],backgroundColor:"rgba(21, 103, 249, 0.2)",borderColor:"rgba(21, 103, 249, 1)",borderWidth:2,pointBackgroundColor:"rgba(21, 103, 249, 1)"}]},options:{responsive:!0,scales:{r:{min:0,max:11,angleLines:{display:!0,color:"rgba(0, 0, 0, 0.1)"},grid:{color:function(a){return a.tick.value%2==1?"transparent":"rgba(0, 0, 0, 0.1)"},lineWidth:1},ticks:{stepSize:1,display:!0,backdropColor:"transparent",callback:function(a){return a%2!=0?a:""},font:{size:12}},pointLabels:{font:{size:14}}}},plugins:{legend:{display:!1}}}})}}}})); From a0008ff1e9eaa0dd1a96350a0a0a25621e9dc59e Mon Sep 17 00:00:00 2001 From: Santiago Orejuela Date: Wed, 7 Jan 2026 23:23:45 -0500 Subject: [PATCH 11/30] Add view_handler.min.js for form handling --- amd/build/view_handler.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 amd/build/view_handler.min.js diff --git a/amd/build/view_handler.min.js b/amd/build/view_handler.min.js new file mode 100644 index 00000000000..f02b6ea84f7 --- /dev/null +++ b/amd/build/view_handler.min.js @@ -0,0 +1 @@ +define(["jquery","core/ajax"],(function(o,e){"use strict";return{init:function(e){var t=null,r=!1,n=e.formUrl;function i(){if(!r){r=!0;var o=new FormData(document.getElementById("learningStyleForm"));o.set("action","autosave"),fetch(n,{method:"POST",body:o}).then((function(o){return o.json()})).then((function(o){r=!1})).catch((function(o){r=!1}))}}o(".select-q").on("change",(function(){var e=o(this).closest(".learning_style_item");e.hasClass("question-error-highlight")&&(e.css({border:"","background-color":"","border-radius":"",padding:"","margin-bottom":"","box-shadow":""}),e.removeClass("question-error-highlight")),t&&clearTimeout(t),t=setTimeout(i,2e3)})),o("#learningStyleForm").on("submit",(function(e){var t=e.originalEvent.submitter,r=t?t.value:"next";if("previous"===r)return!0;if("next"!==r&&"finish"!==r)return!0;var n=o(".select-q"),i=!0,s=null;return n.each((function(){if(""===o(this).val()){i=!1;var e=o(this).closest(".learning_style_item");e.length&&(e.css({border:"3px solid #d32f2f","background-color":"#ffebee","border-radius":"10px",padding:"24px 28px","margin-bottom":"1.5rem","box-shadow":"0 4px 8px rgba(211, 47, 47, 0.3)"}),e.addClass("question-error-highlight"),s||(s=e))}})),i?void 0:(e.preventDefault(),s&&s[0].scrollIntoView({behavior:"smooth",block:"center"}),!1)})),e.shouldAutoScroll&&setTimeout((function(){var e=!1;o(".select-q").each((function(){if(!e&&""===o(this).val()){var t=o(this).closest(".learning_style_item");t.length&&(t.css({border:"3px solid #28a745","background-color":"#d4edda","border-radius":"10px",padding:"24px 28px","margin-bottom":"1.5rem","box-shadow":"0 4px 8px rgba(40, 167, 69, 0.3)",transition:"all 0.3s ease"}),t[0].scrollIntoView({behavior:"smooth",block:"center"}),setTimeout((function(){t.css({border:"","background-color":"","border-radius":"",padding:"","margin-bottom":"","box-shadow":""})}),5e3)),e=!0}}))}),300),e.scrollToFinish&&setTimeout((function(){var e=o("#submitBtn");e.length&&(e[0].scrollIntoView({behavior:"smooth",block:"center"}),e.css({"box-shadow":"0 0 20px rgba(40, 167, 69, 0.8)",transition:"all 0.3s ease"}),setTimeout((function(){e.css("box-shadow","")}),5e3))}),300)}}})); From 797e0012eb5458bc67d224502c1c3829a3698a88 Mon Sep 17 00:00:00 2001 From: Santiago Orejuela Date: Wed, 7 Jan 2026 23:24:44 -0500 Subject: [PATCH 12/30] Add radar chart handler with initialization logic --- amd/src/radar_handler.js | 74 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 amd/src/radar_handler.js diff --git a/amd/src/radar_handler.js b/amd/src/radar_handler.js new file mode 100644 index 00000000000..fb5c42dbb2f --- /dev/null +++ b/amd/src/radar_handler.js @@ -0,0 +1,74 @@ +define(['core/chartjs'], function(Chart) { + "use strict"; + + return { + init: function(params) { + var canvas = document.getElementById(params.canvasId); + if (!canvas) { return; } + var ctx = canvas.getContext('2d'); + + new Chart(ctx, { + type: 'radar', + data: { + labels: params.labels, + datasets: [{ + label: params.datasetLabel, + data: [ + params.data.vis, + params.data.sen, + params.data.act, + params.data.glo, + params.data.vrb, + params.data.int, + params.data.ref, + params.data.seq + ], + backgroundColor: 'rgba(21, 103, 249, 0.2)', + borderColor: 'rgba(21, 103, 249, 1)', + borderWidth: 2, + pointBackgroundColor: 'rgba(21, 103, 249, 1)' + }] + }, + options: { + responsive: true, + scales: { + r: { + min: 0, + max: 11, + angleLines: { + display: true, + color: 'rgba(0, 0, 0, 0.1)' + }, + grid: { + color: function(context) { + if (context.tick.value % 2 === 1) { + return 'transparent'; + } + return 'rgba(0, 0, 0, 0.1)'; + }, + lineWidth: 1 + }, + ticks: { + stepSize: 1, + display: true, + backdropColor: 'transparent', + callback: function(value) { + return value % 2 !== 0 ? value : ''; + }, + font: { + size: 12 + } + }, + pointLabels: { + font: {size: 14} + } + } + }, + plugins: { + legend: { display: false } + } + } + }); + } + }; +}); From 0e8fa081b5525b1ac28c3c74a997d8967b7aa9a8 Mon Sep 17 00:00:00 2001 From: Santiago Orejuela Date: Wed, 7 Jan 2026 23:25:03 -0500 Subject: [PATCH 13/30] Add auto-save and validation to learning style form This file implements an auto-save feature for a form, validates user input, and handles form submission with visual feedback for unanswered questions. --- amd/src/view_handler.js | 195 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 amd/src/view_handler.js diff --git a/amd/src/view_handler.js b/amd/src/view_handler.js new file mode 100644 index 00000000000..51ddfdb1a0b --- /dev/null +++ b/amd/src/view_handler.js @@ -0,0 +1,195 @@ +define(['jquery', 'core/ajax'], function($, Ajax) { + "use strict"; + + return { + init: function(params) { + + // Auto-save functionality (silent, no visual feedback) + var autoSaveTimer = null; + var isSaving = false; + var formUrl = params.formUrl; + + function autoSaveProgress() { + if (isSaving) return; + + isSaving = true; + var formData = new FormData(document.getElementById('learningStyleForm')); + formData.set('action', 'autosave'); + + fetch(formUrl, { + method: 'POST', + body: formData + }) + .then(function(response) { return response.json(); }) + .then(function(data) { + // Silent save - no visual feedback + isSaving = false; + }) + .catch(function(error) { + // console.error('Auto-save error:', error); + isSaving = false; + }); + } + + // Listen to changes in selects for auto-save + $('.select-q').on('change', function() { + // Remove red highlight when user answers the question + var select = $(this); + var listItem = select.closest('.learning_style_item'); + + // Remove error styling if present + if (listItem.hasClass('question-error-highlight')) { + listItem.css({ + 'border': '', + 'background-color': '', + 'border-radius': '', + 'padding': '', + 'margin-bottom': '', + 'box-shadow': '' + }); + listItem.removeClass('question-error-highlight'); + } + + // Clear previous timer + if (autoSaveTimer) { + clearTimeout(autoSaveTimer); + } + + // Auto-save after 2 seconds of inactivity + autoSaveTimer = setTimeout(autoSaveProgress, 2000); + }); + + // Handle form submission for navigation + $('#learningStyleForm').on('submit', function(e) { + // Determine which button triggered the submit + // Note: e.originalEvent.submitter is supported in modern browsers + var submitter = e.originalEvent.submitter; + var action = submitter ? submitter.value : 'next'; + + // For "previous" button, always allow navigation without validation + if (action === 'previous') { + return true; + } + + // Only validate for "next" and "finish" actions + if (action !== 'next' && action !== 'finish') { + return true; + } + + // Validate current page for next/finish + var selectsOnPage = $('.select-q'); + var allAnswered = true; + var firstUnanswered = null; + + selectsOnPage.each(function() { + if ($(this).val() === '') { + allAnswered = false; + var listItem = $(this).closest('.learning_style_item'); + + if (listItem.length) { + listItem.css({ + 'border': '3px solid #d32f2f', + 'background-color': '#ffebee', + 'border-radius': '10px', + 'padding': '24px 28px', + 'margin-bottom': '1.5rem', + 'box-shadow': '0 4px 8px rgba(211, 47, 47, 0.3)' + }); + listItem.addClass('question-error-highlight'); + + if (!firstUnanswered) { + firstUnanswered = listItem; + } + } + } + }); + + if (!allAnswered) { + e.preventDefault(); + + // Scroll to first unanswered question (card) + if (firstUnanswered) { + firstUnanswered[0].scrollIntoView({ + behavior: 'smooth', + block: 'center' + }); + } + + return false; + } + }); + + // Auto-scroll to first unanswered question when continuing test + if (params.shouldAutoScroll) { + // Wait a bit for the page to fully render + setTimeout(function() { + // Find first unanswered question on current page + var found = false; + $('.select-q').each(function() { + if (found) return; + + if ($(this).val() === '') { + var listItem = $(this).closest('.learning_style_item'); + + // Add green highlight to the entire card + if (listItem.length) { + listItem.css({ + 'border': '3px solid #28a745', + 'background-color': '#d4edda', + 'border-radius': '10px', + 'padding': '24px 28px', + 'margin-bottom': '1.5rem', + 'box-shadow': '0 4px 8px rgba(40, 167, 69, 0.3)', + 'transition': 'all 0.3s ease' + }); + + // Scroll to it + listItem[0].scrollIntoView({ + behavior: 'smooth', + block: 'center' + }); + + // Remove highlight after 5 seconds + setTimeout(function() { + listItem.css({ + 'border': '', + 'background-color': '', + 'border-radius': '', + 'padding': '', + 'margin-bottom': '', + 'box-shadow': '' + }); + }, 5000); + } + found = true; + } + }); + }, 300); + } + + // Scroll to finish button when coming from block with all questions answered + if (params.scrollToFinish) { + setTimeout(function() { + var finishBtn = $('#submitBtn'); + if (finishBtn.length) { + finishBtn[0].scrollIntoView({ + behavior: 'smooth', + block: 'center' + }); + + // Add green pulsing highlight to the button + finishBtn.css({ + 'box-shadow': '0 0 20px rgba(40, 167, 69, 0.8)', + 'transition': 'all 0.3s ease' + }); + + // Remove highlight after 5 seconds + setTimeout(function() { + finishBtn.css('box-shadow', ''); + }, 5000); + } + }, 300); + } + } + }; +}); From fad6469e451c8180fbe02ddd7e42c590b02a0708 Mon Sep 17 00:00:00 2001 From: Santiago Orejuela Date: Wed, 7 Jan 2026 23:26:40 -0500 Subject: [PATCH 14/30] Update participant terminology to 'Student' --- lang/en/block_learning_style.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lang/en/block_learning_style.php b/lang/en/block_learning_style.php index f58885aa821..6d8aab537c1 100644 --- a/lang/en/block_learning_style.php +++ b/lang/en/block_learning_style.php @@ -226,8 +226,8 @@ $string['admin_access_denied'] = 'Access denied. Only teachers and administrators can view this page.'; $string['admin_statistics'] = 'General Statistics'; $string['total_participants'] = 'Total Participants'; -$string['participants_list'] = 'Participants List'; -$string['participant'] = 'Participant'; +$string['participants_list'] = 'Student Responses'; +$string['participant'] = 'Student'; $string['learning_profile'] = 'Learning Profile'; $string['actions'] = 'Actions'; $string['view_details'] = 'View'; @@ -439,7 +439,8 @@ // Admin view UI $string['most_common_types'] = 'Most Common Learning Styles'; -$string['search_participant_placeholder'] = 'Search participant...'; +$string['search_participant_placeholder'] = 'Search student or email...'; +$string['no_results_search'] = 'No name or email contains "{$a}"'; $string['export_csv'] = 'Export CSV'; $string['status_completed'] = 'Completed'; $string['status_in_progress'] = 'In progress'; From 841409774de71fc05039f0080c7a55c1395445bc Mon Sep 17 00:00:00 2001 From: Santiago Orejuela Date: Wed, 7 Jan 2026 23:27:08 -0500 Subject: [PATCH 15/30] Update participant terminology in Spanish language file --- lang/es/block_learning_style.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lang/es/block_learning_style.php b/lang/es/block_learning_style.php index 68f43790533..399e79c4f66 100644 --- a/lang/es/block_learning_style.php +++ b/lang/es/block_learning_style.php @@ -226,8 +226,8 @@ $string['admin_access_denied'] = 'Acceso denegado. Solo profesores y administradores pueden ver esta página.'; $string['admin_statistics'] = 'Estadísticas Generales'; $string['total_participants'] = 'Total de Participantes'; -$string['participants_list'] = 'Lista de Participantes'; -$string['participant'] = 'Participante'; +$string['participants_list'] = 'Respuestas de Estudiantes'; +$string['participant'] = 'Estudiante'; $string['learning_profile'] = 'Perfil de Aprendizaje'; $string['actions'] = 'Acciones'; $string['view_details'] = 'Ver'; @@ -439,7 +439,8 @@ // Admin view UI $string['most_common_types'] = 'Estilos de Aprendizaje más comunes'; -$string['search_participant_placeholder'] = 'Buscar participante...'; +$string['search_participant_placeholder'] = 'Buscar estudiante o correo...'; +$string['no_results_search'] = 'Ningún nombre o correo contiene "{$a}"'; $string['export_csv'] = 'Exportar CSV'; $string['status_completed'] = 'Completado'; $string['status_in_progress'] = 'En progreso'; From 91faa1ddabdcfb6bd473d4fd3e78ef5a8ae20251 Mon Sep 17 00:00:00 2001 From: Santiago Orejuela Date: Wed, 7 Jan 2026 23:27:29 -0500 Subject: [PATCH 16/30] Rename learning_style_icon.svg to icon.svg --- pix/{learning_style_icon.svg => icon.svg} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pix/{learning_style_icon.svg => icon.svg} (100%) diff --git a/pix/learning_style_icon.svg b/pix/icon.svg similarity index 100% rename from pix/learning_style_icon.svg rename to pix/icon.svg From fefa27aa60fad5e6e20d1170433b0fdb5bfd74ce Mon Sep 17 00:00:00 2001 From: Santiago Orejuela Date: Wed, 7 Jan 2026 23:28:10 -0500 Subject: [PATCH 17/30] Change RELEASES.md to CHANGELOG.md in workflow --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dd053730f96..b6bc960f05b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -95,9 +95,9 @@ jobs: id: changelog run: | # Extraer changelog para la versión actual - if [ -f "RELEASES.md" ]; then + 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' RELEASES.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 }}" @@ -106,7 +106,7 @@ jobs: else echo "No specific changelog entry found, using default message" echo "### Cambios en esta versión" > current_changelog.md - echo "- Consultar RELEASES.md para detalles completos" >> current_changelog.md + echo "- Consultar CHANGELOG.md para detalles completos" >> current_changelog.md echo "- Version: ${{ needs.check-version.outputs.version }}" >> current_changelog.md fi else From 0b7ca1013383e7c7552e8d2e23c26838af00c4b7 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:35:03 -0500 Subject: [PATCH 18/30] Modernize admin view with templates and optimized SQL Refactored the admin dashboard to use Mustache templates. Optimized statistics calculation using aggregate SQL queries and implemented server-side pagination and search functionality. --- admin_view.php | 712 +++++++++++++++++-------------------------------- 1 file changed, 245 insertions(+), 467 deletions(-) diff --git a/admin_view.php b/admin_view.php index b88212bfc94..a33e632d51d 100644 --- a/admin_view.php +++ b/admin_view.php @@ -1,5 +1,15 @@ libdir . '/tablelib.php'); $courseid = optional_param('courseid', 0, PARAM_INT); if (!$courseid) { @@ -17,511 +27,279 @@ require_login($course); -// Friendly redirect for students/unauthorized users (instead of showing a nopermissions error page). +// Check if the block is added to the course +if (!$DB->record_exists('block_instances', array('blockname' => 'learning_style', 'parentcontextid' => $context->id))) { + redirect(new moodle_url('/course/view.php', array('id' => $courseid))); +} + +// Friendly redirect for unauthorized users if (!has_capability('block/learning_style:viewreports', $context) && !is_siteadmin()) { - $redirecturl = new moodle_url('/course/view.php', array('id' => $courseid)); - redirect($redirecturl); + redirect(new moodle_url('/course/view.php', array('id' => $courseid))); } +// Parameters $action = optional_param('action', '', PARAM_ALPHA); $userid = optional_param('userid', 0, PARAM_INT); +$page = optional_param('page', 0, PARAM_INT); +$perpage = optional_param('perpage', 20, PARAM_INT); +$search = optional_param('search', '', PARAM_NOTAGS); -// Procesar acciones +$admin_url = new moodle_url('/blocks/learning_style/admin_view.php', array('courseid' => $courseid)); +$PAGE->set_url($admin_url); + +// Handle Delete Action if ($action === 'delete' && $userid && confirm_sesskey()) { $confirm = optional_param('confirm', 0, PARAM_INT); if ($confirm) { - // PRIVACY: Teachers can only delete results for users enrolled in THIS course. + // Privacy check $targetuser = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST); if (!is_siteadmin() && ( !is_enrolled($context, $targetuser, 'block/learning_style:take_test', true) || has_capability('block/learning_style:viewreports', $context, $userid) || is_siteadmin($userid) )) { - $redirecturl = new moodle_url('/course/view.php', array('id' => $courseid)); - redirect($redirecturl); + redirect(new moodle_url('/course/view.php', array('id' => $courseid))); } - // Eliminar registro global del test del usuario + $DB->delete_records('learning_style', array('user' => $userid)); - redirect(new moodle_url('/blocks/learning_style/admin_view.php', array('courseid' => $courseid)), - get_string('learning_style_deleted', 'block_learning_style')); + redirect($admin_url, get_string('learning_style_deleted', 'block_learning_style')); } } -$PAGE->set_url('/blocks/learning_style/admin_view.php', array('courseid' => $courseid)); $title = get_string('admin_title', 'block_learning_style'); $PAGE->set_pagelayout('standard'); $PAGE->set_title($title . " : " . $course->fullname); $PAGE->set_heading($title . " : " . $course->fullname); - -// CSS del plugin: usar el sistema de Moodle (evita romper el theme). -$PAGE->requires->css(new moodle_url('/blocks/learning_style/styles.css')); - -echo $OUTPUT->header(); -echo "
"; - -// Header con icono SVG en línea con el título -$iconurl = new moodle_url('/blocks/learning_style/pix/learning_style_icon.svg'); -echo "

"; -echo "Learning Style Icon"; -echo get_string('admin_title', 'block_learning_style'); -echo "

"; - -// Confirmación de eliminación -if ($action === 'delete' && $userid) { - $user = $DB->get_record('user', array('id' => $userid), 'firstname, lastname'); - if ($user) { - echo "
"; - echo "

" . get_string('confirm_delete_learning_style', 'block_learning_style') . "

"; - echo "

" . s(fullname($user)) . "

"; - echo ""; - echo "
"; - } -} else { - // Description banner (match other admin dashboards) - echo "
"; - echo format_text(get_string('admin_dashboard_description', 'block_learning_style'), FORMAT_HTML); - echo "
"; - - // Obtener estadísticas - // Get enrolled students in this course (capability-based) - $enrolled_users = get_enrolled_users($context, 'block/learning_style:take_test', 0, 'u.id'); - $enrolled_ids = array_keys($enrolled_users); - - // Defensive: ensure only students show in admin tables (exclude report-capable users). - $student_ids = array(); - foreach ($enrolled_ids as $candidateid) { - $candidateid = (int)$candidateid; - if (is_siteadmin($candidateid)) { - continue; - } - if (has_capability('block/learning_style:viewreports', $context, $candidateid)) { - continue; - } - $student_ids[] = $candidateid; - } - $enrolled_ids = $student_ids; - - // Total students in course - $total_students = count($enrolled_ids); - - // Obtener participantes con información del usuario PRIMERO (antes de calcular estadísticas) - $userfields = \core_user\fields::for_name()->with_userpic()->get_sql('u', false, '', '', false)->selects; - $participants = array(); - if (!empty($enrolled_ids)) { - list($insql, $params) = $DB->get_in_or_equal($enrolled_ids, SQL_PARAMS_NAMED); - $sql = "SELECT ls.*, {$userfields} - FROM {learning_style} ls - JOIN {user} u ON ls.user = u.id - WHERE ls.user $insql - ORDER BY ls.created_at DESC"; - - $participants = $DB->get_records_sql($sql, $params); - } +$PAGE->requires->css('/blocks/learning_style/styles.css'); + +// Template Data Construction +$data = [ + 'title' => $title, + 'plugin_icon_url' => (new moodle_url('/blocks/learning_style/pix/icon.svg'))->out(), + 'description' => format_text(get_string('admin_dashboard_description', 'block_learning_style'), FORMAT_HTML), + 'courseid' => $courseid, + 'admin_url' => $admin_url->out(false), + 'export_url' => (new moodle_url('/blocks/learning_style/download_results.php', ['courseid' => $courseid, 'sesskey' => sesskey()]))->out(false), + 'course_url' => (new moodle_url('/course/view.php', ['id' => $courseid]))->out(false), + 'search_term' => $search +]; + +$user = $DB->get_record('user', array('id' => $userid), 'firstname, lastname'); +if ($user) { + $data['delete_confirmation'] = true; + $data['confirm_message'] = get_string('confirm_delete_learning_style', 'block_learning_style') . ' ' . fullname($user); + $data['confirm_url'] = (new moodle_url('/blocks/learning_style/admin_view.php', [ + 'courseid' => $courseid, + 'action' => 'delete', + 'userid' => $userid, + 'confirm' => 1, + 'sesskey' => sesskey() + ]))->out(false); + $data['cancel_url'] = $admin_url->out(false); - // Count participants who are enrolled in this course - $completed_tests = 0; - $in_progress_tests = 0; - if (!empty($enrolled_ids)) { - list($insql, $params) = $DB->get_in_or_equal($enrolled_ids, SQL_PARAMS_NAMED); - - // Count completed tests - $params_completed = $params; - $params_completed['completed'] = 1; - $completed_tests = $DB->count_records_select('learning_style', "user $insql AND is_completed = :completed", $params_completed); - - // Count in-progress tests - $params_progress = $params; - $params_progress['completed'] = 0; - $in_progress_tests = $DB->count_records_select('learning_style', "user $insql AND is_completed = :completed", $params_progress); - } - - echo "
"; - - // Total students card - echo "
"; - echo "
"; - echo "
"; - echo ""; - echo "
" . get_string('total_students', 'block_learning_style') . "
"; - echo "

" . $total_students . "

"; - echo "
"; - echo "
"; - echo "
"; - - // Completed tests card - echo "
"; - echo "
"; - echo "
"; - echo ""; - echo "
" . get_string('completed_tests', 'block_learning_style') . "
"; - echo "

" . $completed_tests . "

"; - echo "
"; - echo "
"; - echo "
"; - - // In progress tests card - echo "
"; - echo "
"; - echo "
"; - echo ""; - echo "
" . get_string('in_progress_tests', 'block_learning_style') . "
"; - echo "

" . $in_progress_tests . "

"; - echo "
"; - echo "
"; - echo "
"; - - // Completion rate card - $completion_rate = $total_students > 0 ? round(($completed_tests / $total_students) * 100, 1) : 0; - echo "
"; - echo "
"; - echo "
"; - echo ''; - echo "
" . get_string('completion_rate', 'block_learning_style') . "
"; - echo "

" . $completion_rate . "%

"; - echo "
"; - echo "
"; - echo "
"; - - echo "
"; - - // General statistics section (only meaningful when there are completed tests) - if ($completed_tests > 0) { - echo "
"; - echo "
"; - echo "
"; - echo "
"; - echo "
" . get_string('general_statistics', 'block_learning_style') . "
"; - echo "
"; - echo "
"; - echo "
"; - - // Calculate learning style distribution - $style_distribution = array( - 'Active' => 0, - 'Reflexive' => 0, - 'Sensorial' => 0, - 'Intuitive' => 0, - 'Visual' => 0, - 'Verbal' => 0, - 'Sequential' => 0, - 'Global' => 0 - ); - - if (!empty($participants)) { - foreach ($participants as $p) { - if ($p->is_completed == 1) { - // Determinate dominant style on each dimension - // Processing Dimension - if ($p->ap_active > $p->ap_reflexivo) { - $style_distribution['Active']++; - } else { - $style_distribution['Reflexive']++; - } - - // Perceiving Dimension - if ($p->ap_sensorial > $p->ap_intuitivo) { - $style_distribution['Sensorial']++; - } else { - $style_distribution['Intuitive']++; - } - - // Receiving Dimension - if ($p->ap_visual > $p->ap_verbal) { - $style_distribution['Visual']++; - } else { - $style_distribution['Verbal']++; - } - - // Understanding Dimension - if ($p->ap_secuencial > $p->ap_global) { - $style_distribution['Sequential']++; - } else { - $style_distribution['Global']++; - } - } - } - } - - // Display most common learning styles (localized) - arsort($style_distribution); - $top_styles = array_slice($style_distribution, 0, 4, true); - - // Map internal keys to language strings to support multiple languages - $style_labels = array( - 'Active' => get_string('active', 'block_learning_style'), - 'Reflexive' => get_string('reflexive', 'block_learning_style'), - 'Sensorial' => get_string('sensorial', 'block_learning_style'), - 'Intuitive' => get_string('intuitive', 'block_learning_style'), - 'Visual' => get_string('visual', 'block_learning_style'), - 'Verbal' => get_string('verbal', 'block_learning_style'), - 'Sequential' => get_string('sequential', 'block_learning_style'), - 'Global' => get_string('global', 'block_learning_style') - ); - - echo "
"; - echo "
" . get_string('most_common_types', 'block_learning_style') . "
"; - if (!empty($top_styles) && $completed_tests > 0) { - echo "
    "; - foreach ($top_styles as $style => $count) { - if ($count > 0) { - $percentage = round(($count / $completed_tests) * 100, 1); - $label = isset($style_labels[$style]) ? $style_labels[$style] : $style; - echo "
  • "; - echo "" . s($label) . ""; - echo "" . $count . " (" . $percentage . "%)"; - echo "
  • "; - } - } - echo "
"; - } else { - echo "

" . get_string('no_data_available', 'block_learning_style') . "

"; - } - echo "
"; - - // Average dimension scores - Mostrar las 8 dimensiones por separado - echo "
"; - echo "
" . get_string('average_dimensions', 'block_learning_style') . "
"; - if ($completed_tests > 0) { - $avg_active = 0; - $avg_reflexivo = 0; - $avg_sensorial = 0; - $avg_intuitivo = 0; - $avg_visual = 0; - $avg_verbal = 0; - $avg_secuencial = 0; - $avg_global = 0; - - foreach ($participants as $p) { - if ($p->is_completed == 1) { - $avg_active += $p->ap_active; - $avg_reflexivo += $p->ap_reflexivo; - $avg_sensorial += $p->ap_sensorial; - $avg_intuitivo += $p->ap_intuitivo; - $avg_visual += $p->ap_visual; - $avg_verbal += $p->ap_verbal; - $avg_secuencial += $p->ap_secuencial; - $avg_global += $p->ap_global; - } - } + echo $OUTPUT->header(); + echo $OUTPUT->render_from_template('block_learning_style/admin_view', $data); + echo $OUTPUT->footer(); + exit; +} + +// 1. Get Enrolled Users Helper +list($esql, $params) = get_enrolled_sql($context, 'block/learning_style:take_test', 0, true); + +// 2. Statistics (Count only) +$sql_enrolled = "SELECT COUNT(DISTINCT u.id) FROM {user} u JOIN ($esql) je ON je.id = u.id WHERE u.deleted = 0"; +$total_enrolled = $DB->count_records_sql($sql_enrolled, $params); + +// SQL for completed/in-progress +$sql_completed_count = "SELECT COUNT(ls.id) FROM {learning_style} ls JOIN ($esql) je ON je.id = ls.user WHERE ls.is_completed = 1"; +$total_completed = $DB->count_records_sql($sql_completed_count, $params); + +$sql_all_responses = "SELECT COUNT(ls.id) FROM {learning_style} ls JOIN ($esql) je ON je.id = ls.user"; +$count_responses = $DB->count_records_sql($sql_all_responses, $params); +$total_in_progress = $count_responses - $total_completed; + +$completion_rate = $total_enrolled > 0 ? round(($total_completed / $total_enrolled) * 100, 1) : 0; + +$data['total_enrolled'] = $total_enrolled; +$data['total_completed'] = $total_completed; +$data['total_in_progress'] = $total_in_progress; +$data['completion_rate'] = $completion_rate; +$data['has_completed'] = ($total_completed > 0); + +// 3. Stats Optimization (SQL instead of Loop) +if ($total_completed > 0) { + // Single Query for Averages and Distribution Counts + $sql_stats = "SELECT + AVG(ap_active) as avg_active, + AVG(ap_reflexivo) as avg_reflexivo, + AVG(ap_sensorial) as avg_sensorial, + AVG(ap_intuitivo) as avg_intuitivo, + AVG(ap_visual) as avg_visual, + AVG(ap_verbal) as avg_verbal, + AVG(ap_secuencial) as avg_secuencial, + AVG(ap_global) as avg_global, - $avg_active = round($avg_active / $completed_tests, 1); - $avg_reflexivo = round($avg_reflexivo / $completed_tests, 1); - $avg_sensorial = round($avg_sensorial / $completed_tests, 1); - $avg_intuitivo = round($avg_intuitivo / $completed_tests, 1); - $avg_visual = round($avg_visual / $completed_tests, 1); - $avg_verbal = round($avg_verbal / $completed_tests, 1); - $avg_secuencial = round($avg_secuencial / $completed_tests, 1); - $avg_global = round($avg_global / $completed_tests, 1); + SUM(CASE WHEN ap_active > ap_reflexivo THEN 1 ELSE 0 END) as count_active, + SUM(CASE WHEN ap_reflexivo >= ap_active THEN 1 ELSE 0 END) as count_reflexivo, - echo "
"; + SUM(CASE WHEN ap_sensorial > ap_intuitivo THEN 1 ELSE 0 END) as count_sensorial, + SUM(CASE WHEN ap_intuitivo >= ap_sensorial THEN 1 ELSE 0 END) as count_intuitivo, - // Primera subcolumna - 4 dimensiones - echo "
"; - echo "
    "; - echo "
  • "; - echo "" . get_string('active', 'block_learning_style') . ":"; - echo $avg_active; - echo "
  • "; - echo "
  • "; - echo "" . get_string('reflexive', 'block_learning_style') . ":"; - echo $avg_reflexivo; - echo "
  • "; - echo "
  • "; - echo "" . get_string('sensorial', 'block_learning_style') . ":"; - echo $avg_sensorial; - echo "
  • "; - echo "
  • "; - echo "" . get_string('intuitive', 'block_learning_style') . ":"; - echo $avg_intuitivo; - echo "
  • "; - echo "
"; - echo "
"; + SUM(CASE WHEN ap_visual > ap_verbal THEN 1 ELSE 0 END) as count_visual, + SUM(CASE WHEN ap_verbal >= ap_visual THEN 1 ELSE 0 END) as count_verbal, - // Segunda subcolumna - 4 dimensiones - echo "
"; - echo "
    "; - echo "
  • "; - echo "" . get_string('visual', 'block_learning_style') . ":"; - echo $avg_visual; - echo "
  • "; - echo "
  • "; - echo "" . get_string('verbal', 'block_learning_style') . ":"; - echo $avg_verbal; - echo "
  • "; - echo "
  • "; - echo "" . get_string('sequential', 'block_learning_style') . ":"; - echo $avg_secuencial; - echo "
  • "; - echo "
  • "; - echo "" . get_string('global', 'block_learning_style') . ":"; - echo $avg_global; - echo "
  • "; - echo "
"; - echo "
"; + SUM(CASE WHEN ap_secuencial > ap_global THEN 1 ELSE 0 END) as count_secuencial, + SUM(CASE WHEN ap_global >= ap_secuencial THEN 1 ELSE 0 END) as count_global - echo "
"; // Cierra row de subcolumnas - } else { - echo "

" . get_string('no_data_available', 'block_learning_style') . "

"; + FROM {learning_style} ls + JOIN ($esql) je ON je.id = ls.user + WHERE ls.is_completed = 1"; + + $stats = $DB->get_record_sql($sql_stats, $params); + + // Process Most Common Types + $top_styles_list = [ + 'Active' => ['count' => $stats->count_active, 'label' => get_string('active', 'block_learning_style'), 'color_hex' => '#e74c3c'], + 'Reflexive' => ['count' => $stats->count_reflexivo, 'label' => get_string('reflexive', 'block_learning_style'), 'color_hex' => '#3498db'], + 'Sensorial' => ['count' => $stats->count_sensorial, 'label' => get_string('sensorial', 'block_learning_style'), 'color_hex' => '#27ae60'], + 'Intuitive' => ['count' => $stats->count_intuitivo, 'label' => get_string('intuitive', 'block_learning_style'), 'color_hex' => '#f39c12'], + 'Visual' => ['count' => $stats->count_visual, 'label' => get_string('visual', 'block_learning_style'), 'color_hex' => '#9b59b6'], + 'Verbal' => ['count' => $stats->count_verbal, 'label' => get_string('verbal', 'block_learning_style'), 'color_hex' => '#e67e22'], + 'Sequential' => ['count' => $stats->count_secuencial, 'label' => get_string('sequential', 'block_learning_style'), 'color_hex' => '#1abc9c'], + 'Global' => ['count' => $stats->count_global, 'label' => get_string('global', 'block_learning_style'), 'color_hex' => '#34495e'] + ]; + + uasort($top_styles_list, function($a, $b) { + return $b['count'] - $a['count']; + }); + + $top_4_styles = array_slice($top_styles_list, 0, 4); + $formatted_top_styles = []; + $rank_counter = 1; + foreach ($top_4_styles as $key => $style) { + if ($style['count'] > 0) { + $formatted_top_styles[] = [ + 'rank' => $rank_counter++, + 'label' => $style['label'], + 'count' => $style['count'], + 'percentage' => round(($style['count'] / $total_completed) * 100, 1), + 'color_hex' => $style['color_hex'] + ]; } - echo "
"; - - echo "
"; // Cierra row de estadísticas - echo "
"; // Cierra card-body - echo "
"; // Cierra card - echo "
"; // Cierra col-12 - echo "
"; // Cierra row mt-4 } - - // Sección de Participants List - if (empty($participants)) { - echo "
"; - echo " "; - echo "
" . get_string('no_participants', 'block_learning_style') . "
"; - echo "

" . get_string('no_participants_message', 'block_learning_style') . "

"; - echo "
"; - } else { - echo "
"; - echo "
"; - echo "
" . get_string('participants_list', 'block_learning_style') . "
"; - echo "
"; - echo "
"; + $data['top_styles'] = $formatted_top_styles; + + // Process Dimension Stats (Averages) + // Structure: Pairs + $helper_dim = function($avg1, $avg2, $color1, $color2, $l1, $l2) { + $val1 = round($avg1, 1); + $val2 = round($avg2, 1); + $total = $val1 + $val2; + // avoid div by zero + $pct1 = $total > 0 ? ($val1 / $total) * 100 : 50; + $pct2 = $total > 0 ? ($val2 / $total) * 100 : 50; - // Filtros y búsqueda - echo "
"; - echo "
"; - echo ""; - echo "
"; - echo "
"; - echo ""; - echo "
"; - echo "
"; - - // Tabla de participantes - echo "
"; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - - foreach ($participants as $participant) { - echo ""; - echo ""; - echo ""; - - // Estado y Progreso - echo ""; - - // Learning Profile (solo si está completado) - echo ""; - - $date_to_show = $participant->updated_at > 0 ? $participant->updated_at : $participant->created_at; - echo ""; - echo ""; - echo ""; - } + return [ + 'left_label' => $l1, + 'right_label' => $l2, + 'left_avg' => $val1, + 'right_avg' => $val2, + 'left_pct' => $pct1, + 'right_pct' => $pct2, + 'left_color' => $color1, + 'right_color' => $color2 + ]; + }; - echo ""; - echo "
" . get_string('participant', 'block_learning_style') . "" . get_string('email') . "" . get_string('status', 'block_learning_style') . "" . get_string('learning_profile', 'block_learning_style') . "" . get_string('completion_date', 'block_learning_style') . "" . get_string('actions', 'block_learning_style') . "
"; - echo "
"; - $userpicture = new user_picture($participant); - $userpicture->size = 35; - echo $OUTPUT->render($userpicture); - echo "" . s(fullname($participant)) . ""; - echo "
"; - echo "
" . $participant->email . ""; - if ($participant->is_completed == 1) { - echo "" . get_string('status_completed', 'block_learning_style') . ""; - } else { - // Calcular progreso - contar respuestas no nulas (q1 a q44) - $answered = 0; - for ($i = 1; $i <= 44; $i++) { - $field = 'q' . $i; - if (isset($participant->$field) && $participant->$field !== null && $participant->$field !== '') { - $answered++; - } - } - echo "" . get_string('status_in_progress', 'block_learning_style') . ""; - echo "
" . get_string('progress_questions', 'block_learning_style', ['answered' => $answered, 'total' => 44]) . ""; - } - echo "
"; - if ($participant->is_completed == 1) { - $profile = array(); - $profile[] = ($participant->ap_active > $participant->ap_reflexivo) ? get_string('active', 'block_learning_style') : get_string('reflexive', 'block_learning_style'); - $profile[] = ($participant->ap_sensorial > $participant->ap_intuitivo) ? get_string('sensorial', 'block_learning_style') : get_string('intuitive', 'block_learning_style'); - $profile[] = ($participant->ap_visual > $participant->ap_verbal) ? get_string('visual', 'block_learning_style') : get_string('verbal', 'block_learning_style'); - $profile[] = ($participant->ap_secuencial > $participant->ap_global) ? get_string('sequential', 'block_learning_style') : get_string('global', 'block_learning_style'); - echo "" . implode(', ', $profile) . ""; - } else { - echo "-"; - } - echo "" . date('d/m/Y H:i', $date_to_show) . ""; - echo " $participant->user, 'courseid' => $courseid)) . - "' class='btn btn-sm btn-info mr-2 mt-1 mb-1' title='" . get_string('view_details', 'block_learning_style') . "'>"; - echo " " . get_string('view_details', 'block_learning_style'); - echo ""; - echo " $courseid, 'action' => 'delete', 'userid' => $participant->user, 'sesskey' => sesskey())) . - "' class='btn btn-sm btn-danger' title='" . get_string('delete') . "'>"; - echo " " . get_string('delete'); - echo ""; - echo "
"; - echo "
"; - echo "
"; - echo "
"; - } + $data['dimension_stats'] = [ + $helper_dim($stats->avg_active, $stats->avg_reflexivo, '#e74c3c', '#3498db', get_string('active', 'block_learning_style'), get_string('reflexive', 'block_learning_style')), + $helper_dim($stats->avg_sensorial, $stats->avg_intuitivo, '#27ae60', '#f39c12', get_string('sensorial', 'block_learning_style'), get_string('intuitive', 'block_learning_style')), + $helper_dim($stats->avg_visual, $stats->avg_verbal, '#9b59b6', '#e67e22', get_string('visual', 'block_learning_style'), get_string('verbal', 'block_learning_style')), + $helper_dim($stats->avg_secuencial, $stats->avg_global, '#1abc9c', '#34495e', get_string('sequential', 'block_learning_style'), get_string('global', 'block_learning_style')) + ]; } -// Botón para regresar al curso -echo ""; +// 4. Participants Table (Paginated & Search) +$userfields = \core_user\fields::for_name()->with_userpic()->get_sql('u', false, '', '', false)->selects; +$where_search = ""; +$search_params = []; + +if (!empty($search)) { + $where_search = " AND (" . $DB->sql_like('u.firstname', ':s1', false) . " OR " . $DB->sql_like('u.lastname', ':s2', false) . " OR " . $DB->sql_like('u.email', ':s3', false) . ")"; + $search_params = ['s1' => "%$search%", 's2' => "%$search%", 's3' => "%$search%"]; +} -echo "
"; +$sql_count_participants = "SELECT COUNT(ls.id) + FROM {learning_style} ls + JOIN {user} u ON ls.user = u.id + JOIN ($esql) je ON je.id = ls.user + WHERE 1=1 $where_search"; -// JavaScript para funcionalidad -echo ""; + + $list[] = $row; + } +} +$data['list'] = $list; +// Pagination Bar +$baseurl = new moodle_url('/blocks/learning_style/admin_view.php', ['courseid' => $courseid]); +if ($search) { + $baseurl->param('search', $search); +} +$data['pagination'] = $OUTPUT->render(new paging_bar($total_participants, $page, $perpage, $baseurl, 'page')); + +// 5. Render +echo $OUTPUT->header(); +echo $OUTPUT->render_from_template('block_learning_style/admin_view', $data); echo $OUTPUT->footer(); From bfd4053123d3620b6b710f2f9eeddbf659c9962b 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:40:02 -0500 Subject: [PATCH 19/30] Modernize layout and refactor view_individual.php Refactor view_individual.php to modernize layout and improve code structure, including updating copyright year and consolidating repeated logic. --- view_individual.php | 389 +++++++++++--------------------------------- 1 file changed, 99 insertions(+), 290 deletions(-) diff --git a/view_individual.php b/view_individual.php index daa281fd2ae..20783ce973c 100644 --- a/view_individual.php +++ b/view_individual.php @@ -3,7 +3,7 @@ * Individual Learning Style View * * @package block_learning_style - * @copyright 2025 SAVIO - Sistema de Aprendizaje Virtual Interactivo (UTB) + * @copyright 2026 SAVIO - Sistema de Aprendizaje Virtual Interactivo (UTB) * @author SAVIO Development Team * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -19,6 +19,11 @@ require_login($course); +// Check if the block is added to the course +if (!$DB->record_exists('block_instances', array('blockname' => 'learning_style', 'parentcontextid' => $context->id))) { + redirect(new moodle_url('/course/view.php', array('id' => $course->id))); +} + // Verificar permisos de administrador o profesor (redirect amigable al curso si no puede ver). $canview = is_siteadmin() || has_capability('block/learning_style:viewreports', $context) @@ -42,16 +47,17 @@ throw new moodle_exception('learning_style_not_found', 'block_learning_style'); } +$PAGE->set_url('/blocks/learning_style/view_individual.php', array('courseid' => $courseid, 'userid' => $userid)); +$PAGE->set_context($context); +$PAGE->set_course($course); +$PAGE->set_title(get_string('individual_results_title', 'block_learning_style')); +$PAGE->set_heading(get_string('individual_results_title', 'block_learning_style')); +$PAGE->requires->css('/blocks/learning_style/styles.css'); + +echo $OUTPUT->header(); + // Check if test is completed if (!$learning_style->is_completed) { - $PAGE->set_url('/blocks/learning_style/view_individual.php', array('courseid' => $courseid, 'userid' => $userid)); - $PAGE->set_context($context); - $PAGE->set_course($course); - $PAGE->set_title(get_string('individual_results_title', 'block_learning_style')); - $PAGE->set_heading(get_string('individual_results_title', 'block_learning_style')); - - echo $OUTPUT->header(); - // Count answered questions $answered = 0; for ($i = 1; $i <= 44; $i++) { @@ -63,321 +69,124 @@ $progress_percentage = round(($answered / 44) * 100, 1); - echo '
'; - echo ''; - - echo '
'; - - // Navigation buttons (match personality_test pattern) - echo html_writer::start_div('mt-5 text-center d-flex gap-3 justify-content-center'); - echo html_writer::link( - new moodle_url('/blocks/learning_style/admin_view.php', array('courseid' => $courseid)), - '' . get_string('back_to_admin', 'block_learning_style'), - array('class' => 'btn btn-secondary btn-modern mr-3') - ); - echo html_writer::link( - new moodle_url('/course/view.php', array('id' => $courseid)), - '' . get_string('back_to_course', 'block_learning_style'), - array('class' => 'btn btn-modern', 'style' => 'background: linear-gradient(135deg, #1567f9 0%, #0054ce 100%); border: none; color: white;') - ); - echo html_writer::end_div(); + $template_data = [ + 'user_fullname' => fullname($user), + 'progress_percentage' => $progress_percentage, + 'answered_count' => $answered, + 'all_answered' => ($answered == 44), + 'admin_view_url' => (new moodle_url('/blocks/learning_style/admin_view.php', array('courseid' => $courseid)))->out(false), + 'course_url' => (new moodle_url('/course/view.php', array('id' => $courseid)))->out(false) + ]; + + echo $OUTPUT->render_from_template('block_learning_style/view_individual_progress', $template_data); echo $OUTPUT->footer(); exit; } -$PAGE->set_url('/blocks/learning_style/view_individual.php', array('courseid' => $courseid, 'userid' => $userid)); -$PAGE->set_context($context); -$PAGE->set_course($course); -$PAGE->set_title(get_string('individual_results_title', 'block_learning_style')); -$PAGE->set_heading(get_string('individual_results_title', 'block_learning_style')); -$PAGE->requires->css('/blocks/learning_style/styles.css'); - -echo $OUTPUT->header(); -echo html_writer::start_div('learning-style-individual-container'); - -// Información del estudiante con diseño moderno +// Completed Results Logic $fullname = fullname($user); $completion_date = userdate($learning_style->updated_at, get_string('strftimedaydatetime')); -echo "
"; -echo "
"; -echo "
"; -echo "

" . s($fullname) . "

"; -echo "

"; -echo "" . get_string('completed_on', 'block_learning_style') . ': ' . $completion_date; -echo "

"; -echo "
"; -echo "
"; -echo "
"; -echo ""; -echo ""; -echo "" . get_string('test_completed', 'block_learning_style') . ""; -echo ""; -echo "
"; -echo "
"; - -// Dimensiones del estilo de aprendizaje -$dimensions = array( - array( - 'name' => get_string('processing_dimension', 'block_learning_style'), - 'active' => $learning_style->ap_active, - 'reflexive' => $learning_style->ap_reflexivo, - 'active_label' => get_string('active_learner', 'block_learning_style'), - 'reflexive_label' => get_string('reflexive_learner', 'block_learning_style'), - 'color_active' => '#e74c3c', - 'color_reflexive' => '#3498db' +// Helper function to calculate percentage and label +$calculate_dimension_data = function($active, $reflexive, $label_active, $label_reflexive, $color_active, $color_reflexive, $name) { + $total = $active + $reflexive; + $active_pct = $total > 0 ? round(($active / $total) * 100, 1) : 0; + $reflexive_pct = $total > 0 ? round(($reflexive / $total) * 100, 1) : 0; + + // Class logic for label positioning + // 0% -> center-all + // < 18% -> outside + // >= 18% -> inside + $class_active = $active_pct == 0 ? 'progress-value center-all' : ($active_pct < 18 ? 'progress-value outside' : 'progress-value inside'); + $class_reflexive = $reflexive_pct == 0 ? 'progress-value center-all' : ($reflexive_pct < 18 ? 'progress-value outside' : 'progress-value inside'); + + $is_active_dominant = $active > $reflexive; + + return [ + 'name' => $name, + 'active_label' => $label_active, + 'reflexive_label' => $label_reflexive, + 'active_count' => $active, + 'reflexive_count' => $reflexive, + 'active_percentage' => $active_pct, + 'reflexive_percentage' => $reflexive_pct, + 'color_active' => $color_active, + 'color_reflexive' => $color_reflexive, + 'progress_label_class_active' => $class_active, + 'progress_label_class_reflexive' => $class_reflexive, + 'dominant_style_label' => $is_active_dominant ? $label_active : $label_reflexive, + 'dominant_percentage' => $total > 0 ? round((max($active, $reflexive) / $total) * 100, 1) : 0, + 'dominant_color' => $is_active_dominant ? $color_active : $color_reflexive + ]; +}; + +$dimensions = [ + $calculate_dimension_data( + $learning_style->ap_active, $learning_style->ap_reflexivo, + get_string('active_learner', 'block_learning_style'), get_string('reflexive_learner', 'block_learning_style'), + '#e74c3c', '#3498db', get_string('processing_dimension', 'block_learning_style') ), - array( - 'name' => get_string('perception_dimension', 'block_learning_style'), - 'active' => $learning_style->ap_sensorial, - 'reflexive' => $learning_style->ap_intuitivo, - 'active_label' => get_string('sensorial_learner', 'block_learning_style'), - 'reflexive_label' => get_string('intuitive_learner', 'block_learning_style'), - 'color_active' => '#27ae60', - 'color_reflexive' => '#f39c12' + $calculate_dimension_data( + $learning_style->ap_sensorial, $learning_style->ap_intuitivo, + get_string('sensorial_learner', 'block_learning_style'), get_string('intuitive_learner', 'block_learning_style'), + '#27ae60', '#f39c12', get_string('perception_dimension', 'block_learning_style') ), - array( - 'name' => get_string('input_dimension', 'block_learning_style'), - 'active' => $learning_style->ap_visual, - 'reflexive' => $learning_style->ap_verbal, - 'active_label' => get_string('visual_learner', 'block_learning_style'), - 'reflexive_label' => get_string('verbal_learner', 'block_learning_style'), - 'color_active' => '#9b59b6', - 'color_reflexive' => '#e67e22' + $calculate_dimension_data( + $learning_style->ap_visual, $learning_style->ap_verbal, + get_string('visual_learner', 'block_learning_style'), get_string('verbal_learner', 'block_learning_style'), + '#9b59b6', '#e67e22', get_string('input_dimension', 'block_learning_style') ), - array( - 'name' => get_string('understanding_dimension', 'block_learning_style'), - 'active' => $learning_style->ap_secuencial, - 'reflexive' => $learning_style->ap_global, - 'active_label' => get_string('sequential_learner', 'block_learning_style'), - 'reflexive_label' => get_string('global_learner', 'block_learning_style'), - 'color_active' => '#1abc9c', - 'color_reflexive' => '#34495e' + $calculate_dimension_data( + $learning_style->ap_secuencial, $learning_style->ap_global, + get_string('sequential_learner', 'block_learning_style'), get_string('global_learner', 'block_learning_style'), + '#1abc9c', '#34495e', get_string('understanding_dimension', 'block_learning_style') ) -); +]; -// Gráficos de barras para cada dimensión con diseño moderno -echo "

" . get_string('learning_dimensions', 'block_learning_style') . "

"; -echo html_writer::start_div('row g-4'); +// Profile Characteristics Strings +$profile_characteristics = []; -foreach ($dimensions as $index => $dimension) { - $total = $dimension['active'] + $dimension['reflexive']; - $active_percentage = $total > 0 ? round(($dimension['active'] / $total) * 100, 1) : 0; - $reflexive_percentage = $total > 0 ? round(($dimension['reflexive'] / $total) * 100, 1) : 0; - - echo html_writer::start_div('col-lg-6 mt-5'); - echo html_writer::start_div('dimension-card card'); - echo html_writer::start_div('card-header', array('style' => 'background: linear-gradient(135deg, #e3f2fd 0%, #f8f9fa 100%) !important; color: #0054ce;')); - echo html_writer::tag('h5', '' . $dimension['name'], array('class' => 'mb-0', 'style' => 'font-size: 1.1rem;')); - echo html_writer::end_div(); - echo html_writer::start_div('card-body p-4'); - - // Gráfico de barras horizontal moderno - echo html_writer::start_div('mb-4'); - echo html_writer::tag('div', $dimension['active_label'], - array('class' => 'fw-bold mb-2', 'style' => 'font-size: 0.95rem; color: #495057;')); - echo html_writer::start_div('progress-wrapper', array('data-percentage' => $active_percentage)); - $active_text = $dimension['active'] . ' (' . $active_percentage . '%)'; - $label_class = $active_percentage == 0 ? 'progress-value center-all' : ($active_percentage < 18 ? 'progress-value outside' : 'progress-value inside'); - echo html_writer::tag('span', $active_text, array( - 'class' => $label_class, - 'style' => '--bar-width: ' . $active_percentage . '%;' - )); - echo html_writer::tag('div', '', array( - 'class' => 'progress-bar-modern', - 'style' => 'width: ' . $active_percentage . '%; background-color: ' . $dimension['color_active'] . '; position: absolute; left: 0; top: 0; height: 100%; border-radius: 8px;' - )); - echo html_writer::end_div(); - - echo html_writer::tag('div', $dimension['reflexive_label'], - array('class' => 'fw-bold mb-2', 'style' => 'font-size: 0.95rem; color: #495057;')); - echo html_writer::start_div('progress-wrapper', array('data-percentage' => $reflexive_percentage)); - $reflexive_text = $dimension['reflexive'] . ' (' . $reflexive_percentage . '%)'; - $label_class_ref = $reflexive_percentage == 0 ? 'progress-value center-all' : ($reflexive_percentage < 18 ? 'progress-value outside' : 'progress-value inside'); - echo html_writer::tag('span', $reflexive_text, array( - 'class' => $label_class_ref, - 'style' => '--bar-width: ' . $reflexive_percentage . '%;' - )); - echo html_writer::tag('div', '', array( - 'class' => 'progress-bar-modern', - 'style' => 'width: ' . $reflexive_percentage . '%; background-color: ' . $dimension['color_reflexive'] . '; position: absolute; left: 0; top: 0; height: 100%; border-radius: 8px;' - )); - echo html_writer::end_div(); - echo html_writer::end_div(); - - // Interpretación moderna - $dominant_style = $dimension['active'] > $dimension['reflexive'] ? - $dimension['active_label'] : $dimension['reflexive_label']; - $dominant_value = max($dimension['active'], $dimension['reflexive']); - $total_dimension = $dimension['active'] + $dimension['reflexive']; - $dominant_percentage = $total_dimension > 0 ? round(($dominant_value / $total_dimension) * 100, 1) : 0; - - echo html_writer::start_div('alert', array('style' => 'background-color: #f0f8ff; border-left: 4px solid ' . ($dimension['active'] > $dimension['reflexive'] ? $dimension['color_active'] : $dimension['color_reflexive']) . '; border-radius: 8px;')); - echo ''; - echo html_writer::tag('strong', get_string('dominant_style', 'block_learning_style') . ': '); - echo html_writer::tag('span', $dominant_style . ' (' . $dominant_percentage . '%)', - array('style' => 'color: ' . ($dimension['active'] > $dimension['reflexive'] ? $dimension['color_active'] : $dimension['color_reflexive']) . '; font-weight: 600;')); - echo html_writer::end_div(); - - echo html_writer::end_div(); - echo html_writer::end_div(); - echo html_writer::end_div(); -} - -echo html_writer::end_div(); - -// Resumen del perfil de aprendizaje con diseño moderno -echo html_writer::start_div('profile-summary-card card mt-5 p-4'); -echo "
"; -echo ""; -echo html_writer::tag('h4', get_string('learning_profile_summary', 'block_learning_style'), array('class' => 'mb-0')); -echo "
"; - -$profile_characteristics = array(); - -// Procesamiento if ($learning_style->ap_active > $learning_style->ap_reflexivo) { $profile_characteristics[] = get_string('profile_active_description', 'block_learning_style'); } else { $profile_characteristics[] = get_string('profile_reflexive_description', 'block_learning_style'); } - -// Percepción if ($learning_style->ap_sensorial > $learning_style->ap_intuitivo) { $profile_characteristics[] = get_string('profile_sensorial_description', 'block_learning_style'); } else { $profile_characteristics[] = get_string('profile_intuitive_description', 'block_learning_style'); } - -// Entrada if ($learning_style->ap_visual > $learning_style->ap_verbal) { $profile_characteristics[] = get_string('profile_visual_description', 'block_learning_style'); } else { $profile_characteristics[] = get_string('profile_verbal_description', 'block_learning_style'); } - -// Comprensión if ($learning_style->ap_secuencial > $learning_style->ap_global) { $profile_characteristics[] = get_string('profile_sequential_description', 'block_learning_style'); } else { $profile_characteristics[] = get_string('profile_global_description', 'block_learning_style'); } -echo html_writer::start_tag('ul', array('class' => 'list-unstyled mb-0')); -foreach ($profile_characteristics as $characteristic) { - echo "
  • "; - echo ""; - echo $characteristic; - echo "
  • "; -} -echo html_writer::end_tag('ul'); - -echo html_writer::end_div(); - -// Datos técnicos con diseño moderno -echo html_writer::start_div('card mt-4', array('style' => 'border-radius: 12px; overflow: hidden;')); -echo html_writer::start_div('card-header', array('style' => 'background: linear-gradient(135deg, #e3f2fd 0%, #f8f9fa 100%) !important; color: #0054ce;')); -echo ""; -echo html_writer::tag('h5', get_string('technical_data', 'block_learning_style'), array('class' => 'mb-0 d-inline ', 'style' => 'color: #0054ce !important;')); -echo html_writer::end_div(); -echo html_writer::start_div('card-body p-4'); - -echo html_writer::start_div('row g-4'); - -// Active -echo html_writer::start_div('col-6 col-md-3 text-center mb-4'); -echo html_writer::tag('div', get_string('dimension_active', 'block_learning_style'), array('style' => 'font-weight: 600; color: #6c757d;')); -echo html_writer::tag('span', $learning_style->ap_active, array('class' => 'technical-badge', 'style' => 'background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%); color: white;')); -echo html_writer::end_div(); - -// Reflexive -echo html_writer::start_div('col-6 col-md-3 text-center mb-4'); -echo html_writer::tag('div', get_string('dimension_reflexive', 'block_learning_style'), array('style' => 'font-weight: 600; color: #6c757d;')); -echo html_writer::tag('span', $learning_style->ap_reflexivo, array('class' => 'technical-badge', 'style' => 'background: linear-gradient(135deg, #3498db 0%, #2980b9 100%); color: white;')); -echo html_writer::end_div(); - -// Sensorial -echo html_writer::start_div('col-6 col-md-3 text-center mb-4'); -echo html_writer::tag('div', get_string('dimension_sensorial', 'block_learning_style'), array('style' => 'font-weight: 600; color: #6c757d;')); -echo html_writer::tag('span', $learning_style->ap_sensorial, array('class' => 'technical-badge', 'style' => 'background: linear-gradient(135deg, #27ae60 0%, #229954 100%); color: white;')); -echo html_writer::end_div(); - -// Intuitive -echo html_writer::start_div('col-6 col-md-3 text-center mb-4'); -echo html_writer::tag('div', get_string('dimension_intuitive', 'block_learning_style'), array('style' => 'font-weight: 600; color: #6c757d;')); -echo html_writer::tag('span', $learning_style->ap_intuitivo, array('class' => 'technical-badge', 'style' => 'background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%); color: white;')); -echo html_writer::end_div(); - -echo html_writer::end_div(); - -echo html_writer::start_div('row g-4 mt-2'); - -// Visual -echo html_writer::start_div('col-6 col-md-3 text-center mb-4'); -echo html_writer::tag('div', get_string('dimension_visual', 'block_learning_style'), array('style' => 'font-weight: 600; color: #6c757d;')); -echo html_writer::tag('span', $learning_style->ap_visual, array('class' => 'technical-badge', 'style' => 'background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%); color: white;')); -echo html_writer::end_div(); - -// Verbal -echo html_writer::start_div('col-6 col-md-3 text-center mb-4'); -echo html_writer::tag('div', get_string('dimension_verbal', 'block_learning_style'), array('style' => 'font-weight: 600; color: #6c757d;')); -echo html_writer::tag('span', $learning_style->ap_verbal, array('class' => 'technical-badge', 'style' => 'background: linear-gradient(135deg, #e67e22 0%, #d35400 100%); color: white;')); -echo html_writer::end_div(); - -// Sequential -echo html_writer::start_div('col-6 col-md-3 text-center mb-4'); -echo html_writer::tag('div', get_string('dimension_sequential', 'block_learning_style'), array('style' => 'font-weight: 600; color: #6c757d;')); -echo html_writer::tag('span', $learning_style->ap_secuencial, array('class' => 'technical-badge', 'style' => 'background: linear-gradient(135deg, #1abc9c 0%, #16a085 100%); color: white;')); -echo html_writer::end_div(); - -// Global -echo html_writer::start_div('col-6 col-md-3 text-center mb-4'); -echo html_writer::tag('div', get_string('dimension_global', 'block_learning_style'), array('style' => 'font-weight: 600; color: #6c757d;')); -echo html_writer::tag('span', $learning_style->ap_global, array('class' => 'technical-badge', 'style' => 'background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%); color: white;')); -echo html_writer::end_div(); - -echo html_writer::end_div(); - -echo html_writer::end_div(); -echo html_writer::end_div(); - -echo html_writer::end_div(); - -echo html_writer::end_div(); - -// Botones de navegación con diseño moderno -echo html_writer::start_div('mt-5 text-center d-flex gap-3 justify-content-center'); -echo html_writer::link( - new moodle_url('/blocks/learning_style/admin_view.php', array('courseid' => $courseid)), - '' . get_string('back_to_admin', 'block_learning_style'), - array('class' => 'btn btn-secondary mr-3') -); -echo html_writer::link( - new moodle_url('/course/view.php', array('id' => $courseid)), - '' . get_string('back_to_course', 'block_learning_style'), - array('class' => 'btn', 'style' => 'background: linear-gradient(135deg, #1567f9 0%, #0054ce 100%); border: none; color: white;') -); +$template_data = [ + 'fullname' => $fullname, + 'completion_date' => $completion_date, + 'dimensions' => $dimensions, + 'profile_characteristics' => $profile_characteristics, + 'technical_data' => [ + 'active' => $learning_style->ap_active, + 'reflexive' => $learning_style->ap_reflexivo, + 'sensorial' => $learning_style->ap_sensorial, + 'intuitive' => $learning_style->ap_intuitivo, + 'visual' => $learning_style->ap_visual, + 'verbal' => $learning_style->ap_verbal, + 'sequential' => $learning_style->ap_secuencial, + 'global' => $learning_style->ap_global + ], + 'admin_view_url' => (new moodle_url('/blocks/learning_style/admin_view.php', array('courseid' => $courseid)))->out(false), + 'course_url' => (new moodle_url('/course/view.php', array('id' => $courseid)))->out(false) +]; + +echo $OUTPUT->render_from_template('block_learning_style/view_individual_results', $template_data); echo $OUTPUT->footer(); From c74df6cef61c67d51829a7fd7fc2d437808eb9ca 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:41:41 -0500 Subject: [PATCH 20/30] Refactor response handling and enhance navigation logic Refactor save logic to use a helper function for collecting responses. Update result calculation to store actual counts instead of differences. Improve page navigation logic and enhance user experience with auto-save and validation features. --- view.php | 497 ++++++++++++------------------------------------------- 1 file changed, 106 insertions(+), 391 deletions(-) diff --git a/view.php b/view.php index fabe54c4e7b..e8b3ecd7fce 100644 --- a/view.php +++ b/view.php @@ -1,4 +1,13 @@ record_exists('block_instances', array('blockname' => 'learning_style', 'parentcontextid' => $context->id))) { + redirect(new moodle_url('/course/view.php', array('id' => $courseid))); +} + // Redirect teachers/admins to admin page if (has_capability('block/learning_style:viewreports', $context)) { $manage_url = new moodle_url('/blocks/learning_style/admin_view.php', array('cid' => $courseid)); @@ -51,7 +65,19 @@ $total_questions = 44; $total_pages = ceil($total_questions / $questions_per_page); -// Save logic +// Save logic helper +function get_answers_from_post() { + $responses = array(); + // We don't check all_answered here, just return what is present + for ($i = 1; $i <= 44; $i++) { + $response_raw = optional_param('q' . $i, null, PARAM_RAW); + if ($response_raw !== null && $response_raw !== '') { + $responses["q{$i}"] = (int)$response_raw; + } + } + return $responses; +} + $action = optional_param('action', '', PARAM_ALPHA); // 'autosave', 'previous', 'next', 'finish' $ispost = ($_SERVER['REQUEST_METHOD'] ?? '') === 'POST'; @@ -65,24 +91,7 @@ redirect($redirect_url, get_string('redirect_accept_exist', 'block_learning_style'), null, \core\output\notification::NOTIFY_INFO); } - // Collect all 44 responses (only current page will be present; others stay null). - $responses = array(); - $learning_style_a = array(); - $all_answered = true; - - for ($i = 1; $i <= 44; $i++) { - // Use PARAM_RAW to distinguish between '0' and '' (Unanswered) - $response_raw = optional_param('q' . $i, null, PARAM_RAW); - - if ($response_raw !== null && $response_raw !== '') { - $response = (int)$response_raw; - $learning_style_a[$i] = $response; - $responses["q{$i}"] = $response; - } else { - $learning_style_a[$i] = null; - $all_answered = false; - } - } + $responses = get_answers_from_post(); // For autosave, allow partial data if ($action === 'autosave') { @@ -97,8 +106,7 @@ if ($existing_response) { $data->id = $existing_response->id; $data->created_at = $existing_response->created_at; - - // Copy all existing answers + // Copy all existing answers from DB first for ($i = 1; $i <= 44; $i++) { $field = "q{$i}"; if (isset($existing_response->$field) && $existing_response->$field !== null) { @@ -109,7 +117,7 @@ $data->created_at = time(); } - // Add/Update only answered questions from current page + // Update with answered questions from current POST foreach ($responses as $field => $value) { $data->$field = $value; } @@ -137,7 +145,6 @@ if ($existing_response) { $data->id = $existing_response->id; $data->created_at = $existing_response->created_at; - // Copy all existing answers for ($i = 1; $i <= 44; $i++) { $field = "q{$i}"; @@ -163,6 +170,10 @@ // Calculate new page $new_page = ($action === 'previous') ? $page - 1 : $page + 1; + // Boundary checks + if ($new_page < 1) $new_page = 1; + if ($new_page > $total_pages) $new_page = $total_pages; + $redirect_url = new moodle_url('/blocks/learning_style/view.php', array('cid' => $courseid, 'page' => $new_page)); redirect($redirect_url, get_string('progress_saved', 'block_learning_style'), null, \core\output\notification::NOTIFY_SUCCESS); } catch (Exception $e) { @@ -173,30 +184,38 @@ } // For finish, validate all questions are answered and calculate results - // SECURITY: Always validate ALL 44 questions are answered before finishing if ($action === 'finish') { // Double check: validate from DB + current submission $existing = $DB->get_record('learning_style', array('user' => $USER->id)); + $learning_style_a = array(); + + // Populate full answer set + $final_responses = []; // Merge all answers (DB + current submission) for ($i = 1; $i <= 44; $i++) { $field = "q{$i}"; + $val = null; // Use current submission if available - if (!isset($responses[$field]) || $responses[$field] === null) { - // Otherwise, try from DB - if ($existing && isset($existing->$field) && $existing->$field !== null) { - $responses[$field] = $existing->$field; - $learning_style_a[$i] = $existing->$field; - } + if (isset($responses[$field])) { + $val = $responses[$field]; + } + // Otherwise, try from DB + elseif ($existing && isset($existing->$field) && $existing->$field !== null) { + $val = $existing->$field; + } + + if ($val !== null) { + $final_responses[$field] = $val; + $learning_style_a[$i] = $val; } } // Find first unanswered question $first_unanswered = null; for ($i = 1; $i <= 44; $i++) { - $field = "q{$i}"; - if (!isset($responses[$field]) || $responses[$field] === null) { + if (!isset($learning_style_a[$i])) { $first_unanswered = $i; break; } @@ -204,12 +223,12 @@ // If any question is unanswered, redirect to that page if ($first_unanswered !== null) { - $redirect_page = ceil($first_unanswered / 11); + $redirect_page = ceil($first_unanswered / $questions_per_page); $redirect_url = new moodle_url('/blocks/learning_style/view.php', array('cid' => $courseid, 'page' => $redirect_page)); redirect($redirect_url, get_string('all_questions_required', 'block_learning_style'), null, \core\output\notification::NOTIFY_ERROR); } - // Calculate results - CORRECTED TO SAVE ACTUAL COUNTS, NOT DIFFERENCES + // Calculate results logic $act_ref_eval = [1,5,9,13,17,21,25,29,33,37,41]; $act_ref = ["a" => 0, "b" => 0, "result" => ""]; @@ -222,97 +241,25 @@ $seq_glo_eval = [4,8,12,16,20,24,28,32,36,40,44]; $seq_glo = ["a" => 0, "b" => 0, "result" => ""]; - /** - * Evaluando Activo/Reflexivo (Active/Reflexive) - * Questions: 1,5,9,13,17,21,25,29,33,37,41 (11 questions total) - */ foreach($act_ref_eval as $item){ - if ($learning_style_a[$item] == 0){ - $act_ref["a"]++; // Active - }else{ - $act_ref["b"]++; // Reflexive - } - } - - // Validation: sum must be 11 - if (($act_ref["a"] + $act_ref["b"]) != 11) { - error_log("Learning Style ERROR: Active/Reflexive dimension sum is not 11. Got: " . ($act_ref["a"] + $act_ref["b"])); - } - - if ($act_ref["a"] > $act_ref["b"]) { - $act_ref["result"] = ($act_ref["a"] - $act_ref["b"]) . "a"; - } else { - $act_ref["result"] = ($act_ref["b"] - $act_ref["a"]) . "b"; + if ($learning_style_a[$item] == 0) $act_ref["a"]++; else $act_ref["b"]++; } + $act_ref["result"] = ($act_ref["a"] > $act_ref["b"]) ? ($act_ref["a"] - $act_ref["b"]) . "a" : ($act_ref["b"] - $act_ref["a"]) . "b"; - /** - * Evaluando Sensorial/Intuitivo (Sensorial/Intuitive) - * Questions: 2,6,10,14,18,22,26,30,34,38,42 (11 questions total) - */ foreach($sen_int_eval as $item){ - if ($learning_style_a[$item] == 0){ - $sen_int["a"]++; // Sensorial - }else{ - $sen_int["b"]++; // Intuitive - } + if ($learning_style_a[$item] == 0) $sen_int["a"]++; else $sen_int["b"]++; } + $sen_int["result"] = ($sen_int["a"] > $sen_int["b"]) ? ($sen_int["a"] - $sen_int["b"]) . "a" : ($sen_int["b"] - $sen_int["a"]) . "b"; - // Validation: sum must be 11 - if (($sen_int["a"] + $sen_int["b"]) != 11) { - error_log("Learning Style ERROR: Sensorial/Intuitive dimension sum is not 11. Got: " . ($sen_int["a"] + $sen_int["b"])); - } - - if ($sen_int["a"] > $sen_int["b"]) { - $sen_int["result"] = ($sen_int["a"] - $sen_int["b"]) . "a"; - } else { - $sen_int["result"] = ($sen_int["b"] - $sen_int["a"]) . "b"; - } - - /** - * Evaluando Visual/Verbal (Visual/Verbal) - * Questions: 3,7,11,15,19,23,27,31,35,39,43 (11 questions total) - */ foreach($vis_vrb_eval as $item){ - if ($learning_style_a[$item] == 0){ - $vis_vrb["a"]++; // Visual - }else{ - $vis_vrb["b"]++; // Verbal - } - } - - // Validation: sum must be 11 - if (($vis_vrb["a"] + $vis_vrb["b"]) != 11) { - error_log("Learning Style ERROR: Visual/Verbal dimension sum is not 11. Got: " . ($vis_vrb["a"] + $vis_vrb["b"])); + if ($learning_style_a[$item] == 0) $vis_vrb["a"]++; else $vis_vrb["b"]++; } + $vis_vrb["result"] = ($vis_vrb["a"] > $vis_vrb["b"]) ? ($vis_vrb["a"] - $vis_vrb["b"]) . "a" : ($vis_vrb["b"] - $vis_vrb["a"]) . "b"; - if ($vis_vrb["a"] > $vis_vrb["b"]) { - $vis_vrb["result"] = ($vis_vrb["a"] - $vis_vrb["b"]) . "a"; - } else { - $vis_vrb["result"] = ($vis_vrb["b"] - $vis_vrb["a"]) . "b"; - } - - /** - * Evaluando Secuencial/Global (Sequential/Global) - * Questions: 4,8,12,16,20,24,28,32,36,40,44 (11 questions total) - */ foreach($seq_glo_eval as $item){ - if ($learning_style_a[$item] == 0){ - $seq_glo["a"]++; // Sequential - }else{ - $seq_glo["b"]++; // Global - } - } - - // Validation: sum must be 11 - if (($seq_glo["a"] + $seq_glo["b"]) != 11) { - error_log("Learning Style ERROR: Sequential/Global dimension sum is not 11. Got: " . ($seq_glo["a"] + $seq_glo["b"])); - } - - if ($seq_glo["a"] > $seq_glo["b"]) { - $seq_glo["result"] = ($seq_glo["a"] - $seq_glo["b"]) . "a"; - } else { - $seq_glo["result"] = ($seq_glo["b"] - $seq_glo["a"]) . "b"; + if ($learning_style_a[$item] == 0) $seq_glo["a"]++; else $seq_glo["b"]++; } + $seq_glo["result"] = ($seq_glo["a"] > $seq_glo["b"]) ? ($seq_glo["a"] - $seq_glo["b"]) . "a" : ($seq_glo["b"] - $seq_glo["a"]) . "b"; // Prepare data object $data = new stdClass(); @@ -320,41 +267,34 @@ $data->is_completed = 1; $data->updated_at = time(); - // Add individual question responses - foreach ($responses as $field => $value) { + foreach ($final_responses as $field => $value) { $data->$field = $value; } - // Add calculated results - CORRECTED: Store actual counts, not differences $data->act_ref = $act_ref["result"]; $data->sen_int = $sen_int["result"]; $data->vis_vrb = $vis_vrb["result"]; $data->seq_glo = $seq_glo["result"]; - // Store ACTUAL COUNTS for each dimension (not differences) - $data->ap_active = $act_ref["a"]; // Count of Active answers (0-11) - $data->ap_reflexivo = $act_ref["b"]; // Count of Reflexive answers (0-11) - $data->ap_sensorial = $sen_int["a"]; // Count of Sensorial answers (0-11) - $data->ap_intuitivo = $sen_int["b"]; // Count of Intuitive answers (0-11) - $data->ap_visual = $vis_vrb["a"]; // Count of Visual answers (0-11) - $data->ap_verbal = $vis_vrb["b"]; // Count of Verbal answers (0-11) - $data->ap_secuencial = $seq_glo["a"]; // Count of Sequential answers (0-11) - $data->ap_global = $seq_glo["b"]; // Count of Global answers (0-11) + $data->ap_active = $act_ref["a"]; + $data->ap_reflexivo = $act_ref["b"]; + $data->ap_sensorial = $sen_int["a"]; + $data->ap_intuitivo = $sen_int["b"]; + $data->ap_visual = $vis_vrb["a"]; + $data->ap_verbal = $vis_vrb["b"]; + $data->ap_secuencial = $seq_glo["a"]; + $data->ap_global = $seq_glo["b"]; $redirect_url = new moodle_url('/course/view.php', array('id' => $courseid)); try { if ($existing_response) { - // Update existing record $data->id = $existing_response->id; $data->created_at = $existing_response->created_at; - $data->updated_at = time(); $DB->update_record('learning_style', $data); redirect($redirect_url, get_string('redirect_accept_success', 'block_learning_style')); } else { - // Insert new record $data->created_at = time(); - $data->updated_at = time(); $DB->insert_record('learning_style', $data); redirect($redirect_url, get_string('redirect_accept_success', 'block_learning_style')); } @@ -367,9 +307,7 @@ // SECURITY: Validate that user cannot skip pages without completing previous ones if ($existing_response && $page > 1) { - // Check all questions from page 1 to current page - 1 $max_allowed_page = 1; - for ($p = 1; $p < $page; $p++) { $page_start = ($p - 1) * $questions_per_page + 1; $page_end = min($p * $questions_per_page, $total_questions); @@ -390,9 +328,7 @@ } } - // If trying to access a page beyond allowed, redirect to max allowed if ($page > $max_allowed_page) { - // Silent redirect (no notification). Client-side UX handles visual guidance. redirect(new moodle_url('/blocks/learning_style/view.php', array('cid' => $courseid, 'page' => $max_allowed_page))); } @@ -400,7 +336,6 @@ // If coming from "continue test" link, calculate which page to show if ($existing_response && !isset($_GET['page'])) { - // Find first unanswered question $first_unanswered = null; for ($i = 1; $i <= $total_questions; $i++) { $field = "q{$i}"; @@ -409,8 +344,6 @@ break; } } - - // Calculate page for first unanswered question if ($first_unanswered !== null) { $page = ceil($first_unanswered / $questions_per_page); } @@ -433,265 +366,47 @@ echo $OUTPUT->header(); echo $OUTPUT->box_start('generalbox'); -// Header con icono SVG -echo "
    "; -$iconurl = new moodle_url('/blocks/learning_style/pix/learning_style_icon.svg'); -echo "Learning Style Icon"; -echo "
    "; - -echo "

    ".get_string('test_page_title', 'block_learning_style')."

    "; - -echo "
    "; -echo " -
    -".get_string('test_intro_p1', 'block_learning_style')." -".get_string('test_intro_p2', 'block_learning_style')." -
    -
    -
    - ".get_string('test_note', 'block_learning_style')." ".get_string('test_all_required', 'block_learning_style')." (*) -
    -"; -echo "
    "; - -$action_form = $PAGE->url; -?> - -
    -
    -
      - $field)) ? $existing_response->$field : null; - ?> -
    1. -
      - -
    2. - -
    - -
    - - - - -
    - - - - -
    - -
    - - +$PAGE->requires->js_call_amd('block_learning_style/view_handler', 'init', [$js_params]); -"; +echo $OUTPUT->box_end(); echo $OUTPUT->footer(); ?> -
    From 81b78672dea205ca26966d7f3bbf63c41698a65b 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:42:39 -0500 Subject: [PATCH 21/30] Add PHPDoc comments to lib.php Added documentation for Learning Style Library functions. --- lib.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib.php b/lib.php index 618dc5c744a..9acec0026b2 100644 --- a/lib.php +++ b/lib.php @@ -1,4 +1,13 @@ Date: Wed, 7 Jan 2026 23:43:49 -0500 Subject: [PATCH 22/30] Add PHPDoc comments to download_results.php Added PHPDoc comments for the download_results.php file. --- download_results.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/download_results.php b/download_results.php index c333f249430..9baf99fa686 100644 --- a/download_results.php +++ b/download_results.php @@ -1,4 +1,12 @@ Date: Wed, 7 Jan 2026 23:44:33 -0500 Subject: [PATCH 23/30] Add documentation header to block_learning_style.php Added header documentation for the Learning Style block. --- block_learning_style.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block_learning_style.php b/block_learning_style.php index 0a871258911..0beae206df5 100644 --- a/block_learning_style.php +++ b/block_learning_style.php @@ -1,4 +1,12 @@ Date: Wed, 7 Jan 2026 23:45:04 -0500 Subject: [PATCH 24/30] Update CHANGELOG for version 2.0.1 Added details for version 2.0.1, including pagination, new statistics display, Mustache template architecture, code refactoring, performance optimization, and security improvements. --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8acf0259d6b..917c0793e28 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.1] — 2026-01-06 +- 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.0] — Inicio de registro - A partir de la versión 2.0.0 se comienza a documentar este CHANGELOG. - Renovación completa y moderna de la UI/UX del bloque, test, panel de administración y vistas individuales (Todas con diseño responsivo). From 23dfb462e86cd9c0f2f9a1ce12efc706cc7bbd6d 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:45:24 -0500 Subject: [PATCH 25/30] Update release date for version 2.0.1 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 917c0793e28..99de0908af7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ Todas las modificaciones importantes del proyecto se documentarán en este archivo. -## [2.0.1] — 2026-01-06 +## [2.0.1] — 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. From 97c34035846b773ae7c7d7ad62a11a62c8561527 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:46:59 -0500 Subject: [PATCH 26/30] Change image source in README Updated the image link in the README to a new source. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ee7f93b6d89..3c5c5677802 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,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.

    - Panel de Administración + Panel de Administración

    **Seguimiento Individualizado y Detallado** From 344df11f0fac463cea91aeaf9b98123c4146bde8 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:47:41 -0500 Subject: [PATCH 27/30] Update version to 2.0.1 and adjust copyright year --- version.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/version.php b/version.php index e809f503029..23e4a60409b 100644 --- a/version.php +++ b/version.php @@ -1,16 +1,17 @@ version = 2025122000; +$plugin->version = 2026010800; $plugin->requires = 2022041900; // Moodle 4.0+ $plugin->component = 'block_learning_style'; -$plugin->release = '2.0.0'; +$plugin->maturity = MATURITY_STABLE; +$plugin->release = '2.0.1'; From 5040c1d1692fadf09bf51b47a5fb1cfaa6d30421 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:39:45 -0500 Subject: [PATCH 28/30] Add GNU General Public License v3 to LICENSE file This commit adds the full text of the GNU General Public License version 3 to the LICENSE file, ensuring compliance with open-source distribution requirements. --- LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..f288702d2fa --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 4138b464c6c96fc82383ef39728bef6dd465dccf 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:44:02 -0500 Subject: [PATCH 29/30] Add LICENSE file From a0543007a3ba99055f8fd924d239d0f9540cfcbb 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:31:56 -0500 Subject: [PATCH 30/30] Return Chart instance from radar_handler --- amd/src/radar_handler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd/src/radar_handler.js b/amd/src/radar_handler.js index fb5c42dbb2f..d0cc097d632 100644 --- a/amd/src/radar_handler.js +++ b/amd/src/radar_handler.js @@ -7,7 +7,7 @@ define(['core/chartjs'], function(Chart) { if (!canvas) { return; } var ctx = canvas.getContext('2d'); - new Chart(ctx, { + return new Chart(ctx, { type: 'radar', data: { labels: params.labels,