Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Todas las modificaciones importantes del proyecto se documentarán en este archivo.

## [2.0.3] — 2026-01-18
- Se eliminaron las comprobaciones redundantes de administrador (`is_siteadmin()`) en varias vistas clave, mejorando la detección correcta de roles locales (profesores vs estudiantes) y el sistema de permisos basado en capacidades.
- Se agrega negrilla en el titulo del bloque para mejorar la visibilidad.
-
## [2.0.2] — 2026-01-18
- Opción para mostrar/ocultar las descripciones en el bloque principal.
- Adición del gráfico radar en resultados detallados y acceso permitido a los estudiantes a esta vista.
Expand Down
9 changes: 3 additions & 6 deletions admin_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}

// Friendly redirect for unauthorized users
if (!has_capability('block/learning_style:viewreports', $context) && !is_siteadmin()) {
if (!has_capability('block/learning_style:viewreports', $context)) {
redirect(new moodle_url('/course/view.php', array('id' => $courseid)));
}

Expand All @@ -53,11 +53,8 @@
if ($confirm) {
// 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)
)) {
if (!is_enrolled($context, $targetuser, 'block/learning_style:take_test', true)
|| has_capability('block/learning_style:viewreports', $context, $userid)) {
redirect(new moodle_url('/course/view.php', array('id' => $courseid)));
}

Expand Down
14 changes: 5 additions & 9 deletions block_learning_style.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,8 @@ public function get_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);
private function can_view_dashboard($context, $userid = null) {
return has_capability('block/learning_style:viewreports', $context, $userid);
}

/**
Expand Down Expand Up @@ -282,7 +280,7 @@ private function get_teacher_content($context) {
];

// Agregar botones al final (después del dashboard) para profesores/administradores
$is_teacher = has_capability('block/learning_style:viewreports', $context) || is_siteadmin();
$is_teacher = $this->can_view_dashboard($context);
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();
Expand All @@ -295,10 +293,8 @@ private function get_teacher_content($context) {
$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)) {

if ($this->can_view_dashboard($context, $candidateid)) {
continue;
}
$filtered_student_ids[] = $candidateid;
Expand Down
4 changes: 1 addition & 3 deletions download_results.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ function block_learning_style_csv_safe($value): string {
$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;
}
Expand Down
2 changes: 1 addition & 1 deletion templates/continue_test.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div style="text-align: center; margin: 0 auto;">
{{{icon}}}
</div>
<h6 class="mt-2 mb-1">{{#str}} pluginname, block_learning_style {{/str}}</h6>
<h6 class="mt-2 mb-1 font-weight-bold">{{#str}} pluginname, block_learning_style {{/str}}</h6>
<small class="text-muted">{{#str}} discover_your_style, block_learning_style {{/str}}</small>
</div>

Expand Down
4 changes: 2 additions & 2 deletions templates/results.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{{icon}}}
<i class="fa fa-check text-primary" style="position: absolute; top: -6px; right: -9px; font-size: 1.4em; background: white; border-radius: 50%; line-height: 1; text-shadow: 0 1px 2px rgba(0,0,0,0.1);"></i>
</div>
<h6 class="mt-2 mb-1">{{#str}} test_completed, block_learning_style {{/str}}</h6>
<h6 class="mt-2 mb-1 font-weight-bold">{{#str}} test_completed, block_learning_style {{/str}}</h6>
<small class="text-muted">{{#str}} your_results_here, block_learning_style {{/str}}</small>
</div>

Expand Down Expand Up @@ -33,7 +33,7 @@

<div class="text-center">
<a href="{{summary_url}}" class="btn btn-sm" style="background: linear-gradient(135deg, #1567f9 0%, #0054ce 100%); border: none; color: #fff; width: 100%; font-weight: 500;">
<i class="fa fa-chart-bar"></i> {{#str}} see_full_results, block_learning_style {{/str}}
<i class="fa fa-eye"></i> {{#str}} see_full_results, block_learning_style {{/str}}
</a>
</div>
</div>
2 changes: 1 addition & 1 deletion templates/test_invitation.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div style="text-align: center; margin: 0 auto;">
{{{icon}}}
</div>
<h6 class="mt-2 mb-1">{{#str}} pluginname, block_learning_style {{/str}}</h6>
<h6 class="mt-2 mb-1 font-weight-bold">{{#str}} pluginname, block_learning_style {{/str}}</h6>
<small class="text-muted">{{#str}} discover_your_style, block_learning_style {{/str}}</small>
</div>

Expand Down
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Learning Style Block Major Update
* Version 2.0.2 - Production Ready
* Version 2.0.3 - Production Ready
*
* @package block_learning_style
* @copyright 2026 Jairo Serrano, Yuranis Henriquez, Isaac Sanchez, Santiago Orejuela, Maria Valentina
Expand All @@ -10,8 +10,8 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2026011800; // YYYYMMDDXX (year, month, day, 2-digit version number).
$plugin->version = 2026011801; // YYYYMMDDXX (year, month, day, 2-digit version number).
$plugin->requires = 2022041900; // Moodle 4.0+
$plugin->component = 'block_learning_style';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '2.0.2';
$plugin->release = '2.0.3';
5 changes: 2 additions & 3 deletions view_individual.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@
// Security: Check permissions and enrollment
$is_own_results = ($USER->id == $userid);
$can_view_reports = has_capability('block/learning_style:viewreports', $context);
$is_siteadmin = is_siteadmin();

// Basic access check: If not owner, not teacher, and not admin -> Kick out
if (!$is_own_results && !$can_view_reports && !$is_siteadmin) {
if (!$is_own_results && !$can_view_reports) {
redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
}

// Cross-course privacy check: If teacher (not admin/owner), ensure target user is in this course
if (!$is_own_results && !$is_siteadmin && !is_enrolled($context, $user)) {
if (!$is_own_results && !$can_view_reports && !is_enrolled($context, $user)) {
redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
}

Expand Down