Reporte Finalización de actividad para usuarios con criterio en común (por ej. Ciudad) sin pertenecer al mismo grupo (Moodle: 2.8.3)

Reporte Finalización de actividad para usuarios con criterio en común (por ej. Ciudad) sin pertenecer al mismo grupo (Moodle: 2.8.3)

von Rodolfo Gallegos -
Anzahl Antworten: 0

En Moodle contamos con el reporte Finalización de actividad, accesible desde el Panel de Administración del curso -> Reportes -> Finalización de actividad. Este reporte nos permite observar el campo preestablecido de Nombre/Apellidos, así como el estado de finalizada o no cualquier actividad del curso. Una manera para poder agregar más campos a este reporte es indicarlo en el archivo config.php del directorio raíz de la instalación de Moodle, p. ej.

$CFG->showuseridentity='username,city';. Con esto estoy agregando los campos nombre de usuario y ciudad al reporte.

 

 

 

Si bien este reporte es muy útil, la información de los usuarios (estudiantes) que otorga siempre está en función del grupo o agrupamiento que hayamos creado. Sabemos que el administrador de la plataforma puede ver el total de los usuarios y filtrar precisamente por grupo y un profesor únicamente podrá observar a su grupo. En ocasiones surge la necesidad de que algún usuario con cierto rol (puede ser intermedio entre el profesor y el administrador) desee obtener información de dos o más grupos, pero únicamente de algunos estudiantes de cada uno de esos grupos que cumplan cierto criterio. Por ejemplo, tenemos un profesor para cada grupo y él únicamente debe observar el reporte para su grupo, el reporte precisamente está configurado para él. Si se contara con otro rol que tuviera la necesidad de llevar el seguimiento del desempeño de alumnos de dos grupos o más,  Moodle nos brinda la posibilidad de crear un agrupamiento de dos grupos o más y listo. Pero qué ocurre si se desea observar el seguimiento de sólo algunos de los alumnos de dos o más grupos, con base en un criterio común de alumnos de cada uno de esos grupos, por ejemplo edad, lugar de procedencia, género (masculino o femenino), etc. Pongamos de ejemplo un caso real que me ocurrió. Se tiene un rol que es el encargado de observar el seguimiento de los alumnos que corresponden a su Entidad Federativa (Estado) al cual llamaremos Responsable Estatal. Se tiene otro rol que es el encargado de observar el seguimiento de un cierto número de alumnos de diferente Estado al cual llamaremos Tutor. Si creamos grupos por Estado solucionamos la necesidad de los Responsables Estatales pero no la del Tutor (este podría observar el seguimiento de alumnos que no le fueron asignados generando  confusión e información innecesaria en el reporte). Si creamos grupos por alumnos asignamos a cada Tutor solucionamos la necesidad de este último pero no la del Responsable Estatal (este no podría observar el seguimiento de todos los alumnos de su Estado, además de que vería alumnos que no pertenecen a su Estado generando confusión e información innecesaria en el reporte). ¿Cómo podemos solucionar este inconveniente?.


Existen las consultas Ad-hoc que se pueden obtener instalando un plugin para ello por ejemplo el de Consultas ad-hoc a Base de datos. Este plugin nos permite definir consultas personalizadas directamente a la base de datos, sin embargo difícilmente podríamos obtener la misma información de un Reporte de Finalización de actividad. Esto es debido a que el módulo encargado de este último reporte genera el reporte en tiempo real con base en parámetros variables seleccionados por el usuario en cada consulta, por ejemplo por Nombre, Apellido, etc., adicionalmente la información que obtiene este módulo es manejada mediante matrices para desplegarla de forma adecuada en la pantalla. Es decir, no se trata de una simple sentencia SQL que genere el reporte y presente en pantalla.

Si de alguna manera pudiéramos medio adaptar alguna consulta con el plugin antes mencionado, tendríamos otro inconveniente: los permisos para restringir el acceso a este reporte y a la modificación de las propias sentencias SQL ya que este plugin presenta fallas en ese aspecto.

Para resolver de una manera más o menos decente el problema original es necesario emplear otra técnica, aunque esta es un poco más compleja es mucho más efectiva. La técnica que empleé implica los siguientes 3 puntos:

1.       Generar un recurso URL de Moodle.

2.       Editar el código fuente del módulo que genera el reporte (dos archivos php).

3.       Ajustar el rol que tendrá acceso a los informes.

La parte complicada es la que corresponde al segundo punto. Si vemos el código fuente mencionado veremos que tiene bastante complejidad. Sin embargo con la presente guía veremos cómo podemos proceder.

1.    Generar un recurso URL de Moodle.

Este recurso lo podemos crear en cualquier parte del curso, no importa su ubicación.

En la sección de Contenido estableceremos la URL de uno de los archivos que modificaremos en el siguiente punto, incluyendo al final de la URL el parámetro course con el valor numérico del curso en el cual se encuentren inscritos los usuarios a aparecer en el informe, por ejemplo course=38.

 

 

Lo que realmente aprovecharemos de este recurso la capacidad de añadir algún parámetro a la URL. En la sección Variables de URL podemos establecer hasta seis. En nuestro caso bastará con una.

 

Como nombre del parámetro he empleado estado y como valor de ese parámetro Ciudad. Estos valores vienen clasificados en Curso, URL, Misceláneos, Usuario y Roles. De estas categorías la que nos interesa es la de usuario, ya que los valores son campos de la tabla user y con alguno de ellos podemos filtrar el tipo de usuario que deseemos agrupar. En mi caso es Ciudad, porque deseo agrupar a los usuarios por zonas.

2.    Editar el código fuente del módulo que genera el reporte (dos archivos php).

 

Para este punto se requiere modificar dos archivos del módulo de reporte de Moodle: moodle/report/progress/index.php y moodle/report/customsql/locallib.php. Puedes ver el código fuente en línea del primer archivo en https://github.com/moodle/moodle/blob/master/report/progress/index.php. Recomiendo realizar una copia de cada uno de estos archivos para trabajar sobre estos.

La técnica empleada requiere de una copia del archivo index.php destinado específicamente al rol que queremos habilitar para el reporte. En mi caso lo nombré index_repc.php. En este archivo añadí código en siete lugares a lo largo de todo el código. A primera vista parece complicado sin embargo la mayor parte fueron sólo pequeñas adaptaciones a lo que ya estaba. A continuación muestro el código completo del archivo indicando claramente en color amarillo lo editado. Entre paréntesis indico qué y con qué fin hice en cada lugar:

<?php

// This file is part of Moodle - http://moodle.org/

//

// Moodle 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.

//

// Moodle 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 Moodle.  If not, see <http://www.gnu.org/licenses/>;.

 

/**

 * Activity progress reports

 *

 * @package    report

 * @subpackage progress

 * @copyright  2008 Sam Marshall

 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

 */

 

require('../../config.php');

require_once($CFG->libdir . '/completionlib.php');

 

define('COMPLETION_REPORT_PAGE', 25);

 

//RODOLFO (código añadido): Recuperamos la variable deseada y la cual enviamos en nuestra URL. En este caso se llama estado

$estado = required_param('estado',PARAM_RAW);

//echo $estado;

 

// Get course

$id = required_param('course',PARAM_INT);

$course = $DB->get_record('course',array('id'=>$id));

if (!$course) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    print_error('invalidcourseid');</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

$context = context_course::instance($course->id);

 

// Sort (default lastname, optionally firstname)

$sort = optional_param('sort','',PARAM_ALPHA);

$firstnamesort = $sort == 'firstname';

 

// CSV format

$format = optional_param('format','',PARAM_ALPHA);

$excel = $format == 'excelcsv';

$csv = $format == 'csv' || $excel;

 

// Paging

$start   = optional_param('start', 0, PARAM_INT);

$sifirst = optional_param('sifirst', 'all', PARAM_NOTAGS);

$silast  = optional_param('silast', 'all', PARAM_NOTAGS);

$start   = optional_param('start', 0, PARAM_INT);

 

// Whether to show extra user identity information

$extrafields = get_extra_user_fields($context);

$leftcols = 1 + count($extrafields);

 

function csv_quote($value) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    global $excel;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    if ($excel) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        return core_text::convert('"'.str_replace('"',"'",$value).'"','UTF-8','UTF-16LE');</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    } else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        return '"'.str_replace('"',"'",$value).'"';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    }

}

 

//RODOLFO (código editado): Añadimos parámetro estado a la URL que se manejará internamente.

$url = new moodle_url('/report/progress/index_repc.php', array('course'=>$id,'estado'=>$estado));

if ($sort !== '') {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $url->param('sort', $sort);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

if ($format !== '') {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $url->param('format', $format);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

if ($start !== 0) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $url->param('start', $start);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

$PAGE->set_url($url);

$PAGE->set_pagelayout('report');

 

require_login($course);

 

// Check basic permission

require_capability('report/progress:view',$context);

 

// Get group mode

$group = groups_get_course_group($course,true); // Supposed to verify group

if ($group===0 && $course->groupmode==SEPARATEGROUPS) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><b><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';color:#FFC000;" xml:lang="es-mx">      //RODOLFO (código comentado): Siguiente línea comentada</span></b></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="en-us" style="font-size:10pt;font-family:'Courier New';" xml:lang="en-us">    <b><span style="color:#FFC000;">//</span></b>require_capability('moodle/site:accessallgroups',$context);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

 

// Get data on activities and progress of all users, and give error if we've

// nothing to display (no users or no activities)

$reportsurl = $CFG->wwwroot.'/course/report.php?id='.$course->id;

$completion = new completion_info($course);

$activities = $completion->get_activities();

 

// Generate where clause

$where = array();

$where_params = array();

 

if ($sifirst !== 'all') {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $where[] = $DB->sql_like('u.firstname', ':sifirst', false);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $where_params['sifirst'] = $sifirst.'%';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

 

if ($silast !== 'all') {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $where[] = $DB->sql_like('u.lastname', ':silast', false);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $where_params['silast'] = $silast.'%';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

 

//RODOLFO (código añadido): Integré un if

//$estado = 'Morelos';

if ($estado !== '') {</span></b></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><b><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';color:#FFC000;" xml:lang="es-mx">    $where[] = $DB->sql_like('u.city', ':estado', false);</span></b></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><b><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';color:#FFC000;" xml:lang="es-mx">    $where_params['estado'] = $estado;</span></b></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><b><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';color:#FFC000;" xml:lang="es-mx">}

 

// Get user match count

$total = $completion->get_num_tracked_users(implode(' AND ', $where), $where_params, $group);

 

// Total user count

$grandtotal = $completion->get_num_tracked_users('', array(), $group);

 

// Get user data

$progress = array();

 

if ($total) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $progress = $completion->get_progress_all(</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        implode(' AND ', $where),</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $where_params,</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $group,</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $firstnamesort ? 'u.firstname ASC' : 'u.lastname ASC',</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $csv ? 0 : COMPLETION_REPORT_PAGE,</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $csv ? 0 : $start,</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $context</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    );</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

 

if ($csv && $grandtotal && count($activities)>0) { // Only show CSV if there are some users/actvs</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx"> </span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $shortname = format_string($course->shortname, true, array('context' => $context));</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    header('Content-Disposition: attachment; filename=progress.'.</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        preg_replace('/[^a-z0-9-]/','_',core_text::strtolower(strip_tags($shortname))).'.csv');</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    // Unicode byte-order mark for Excel</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    if ($excel) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        header('Content-Type: text/csv; charset=UTF-16LE');</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        print chr(0xFF).chr(0xFE);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $sep="\t".chr(0);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $line="\n".chr(0);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    } else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        header('Content-Type: text/csv; charset=UTF-8');</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $sep=",";</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $line="\n";</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    }

} else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx"> </span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    // Navigation and header</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $strreports = get_string("reports");</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $strcompletion = get_string('activitycompletion', 'completion');</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx"> </span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $PAGE->set_title($strcompletion);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $PAGE->set_heading($course->fullname);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    echo $OUTPUT->header();</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $PAGE->requires->js('/report/progress/textrotate.js');</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $PAGE->requires->js_function_call('textrotate_init', null, true);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx"> </span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    // Handle groups (if enabled)</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><b><span style="font-size:10pt;font-family:'Courier New';color:#FFC000;">/*RODOLFO (código comentado): Comentado</span></b></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    groups_print_course_menu($course,$CFG->wwwroot.'/report/progress/?course='.$course->id);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><b><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';color:#FFC000;" xml:lang="es-mx">*/</span></b></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

 

if (count($activities)==0) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    echo $OUTPUT->container(get_string('err_noactivities', 'completion'), 'errorbox errorboxcontent');</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    echo $OUTPUT->footer();</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    exit;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

 

// If no users in this course what-so-ever

if (!$grandtotal) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    echo $OUTPUT->container(get_string('err_nousers', 'completion'), 'errorbox errorboxcontent');</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    echo $OUTPUT->footer();</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    exit;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

 

// Build link for paging

//RODOLFO (código añadido): Agregué el parámetro estado a la URL. $link = $CFG->wwwroot.'/report/progress/index_repc.php?course='.$course->id.'&estado='.$estado;

if (strlen($sort)) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $link .= '&amp;sort='.$sort;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

$link .= '&amp;start=';

 

// Build the the page by Initial bar

$initials = array('first', 'last');

$alphabet = explode(',', get_string('alphabet', 'langconfig'));

 

$pagingbar = '';

foreach ($initials as $initial) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $var = 'si'.$initial;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx"> </span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $othervar = $initial == 'first' ? 'silast' : 'sifirst';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $othervar = $$othervar != 'all' ? "&amp;{$othervar}={$$othervar}" : '';

 

    $pagingbar .= ' <div class="initialbar '.$initial.'initial">';

    $pagingbar .= get_string($initial.'name').':&nbsp;';

 

    if ($$var == 'all') {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $pagingbar .= '<strong>'.get_string('all').'</strong> ';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    }

    else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $pagingbar .= "<a href=\"{$link}{$othervar}\">".get_string('all').'</a> ';

    }

 

    foreach ($alphabet as $letter) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        if ($$var === $letter) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            $pagingbar .= '<strong>'.$letter.'</strong> ';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        }

        else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            $pagingbar .= "<a href=\"$link&amp;$var={$letter}{$othervar}\">$letter</a> ";

        }

    }

 

    $pagingbar .= '</div>';

}

 

// Do we need a paging bar?

if ($total > COMPLETION_REPORT_PAGE) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx"> </span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    // Paging bar</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $pagingbar .= '<div class="paging">';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $pagingbar .= get_string('page').': ';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx"> </span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $sistrings = array();</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    if ($sifirst != 'all') {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $sistrings[] =  "sifirst={$sifirst}";

    }

    if ($silast != 'all') {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $sistrings[] =  "silast={$silast}";

    }

    $sistring = !empty($sistrings) ? '&amp;'.implode('&amp;', $sistrings) : '';

 

    // Display previous link

    if ($start > 0) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $pstart = max($start - COMPLETION_REPORT_PAGE, 0);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $pagingbar .= "(<a class=\"previous\" href=\"{$link}{$pstart}{$sistring}\">".get_string('previous').'</a>)&nbsp;';

    }

 

    // Create page links

    $curstart = 0;

    $curpage = 0;

    while ($curstart < $total) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $curpage++;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx"> </span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        if ($curstart == $start) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            $pagingbar .= '&nbsp;'.$curpage.'&nbsp;';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        } else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            $pagingbar .= "&nbsp;<a href=\"{$link}{$curstart}{$sistring}\">$curpage</a>&nbsp;";

        }

 

        $curstart += COMPLETION_REPORT_PAGE;

    }

 

    // Display next link

    $nstart = $start + COMPLETION_REPORT_PAGE;

    if ($nstart < $total) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $pagingbar .= "&nbsp;(<a class=\"next\" href=\"{$link}{$nstart}{$sistring}\">".get_string('next').'</a>)';

    }

 

    $pagingbar .= '</div>';

}

 

// Okay, let's draw the table of progress info,

 

// Start of table

if (!$csv) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    print '<br class="clearer"/>'; // ugh</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    print $pagingbar;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx"> </span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    if (!$total) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        echo $OUTPUT->heading(get_string('nothingtodisplay'));</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        echo $OUTPUT->footer();</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        exit;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    }

 

    print '<div id="completion-progress-wrapper" class="no-overflow">';

    print '<table id="completion-progress" class="generaltable flexible boxaligncenter" style="text-align:left"><thead><tr style="vertical-align:top">';

 

    // User heading / sort option

    print '<th scope="col" class="completion-sortchoice">';

 

    $sistring = "&amp;silast={$silast}&amp;sifirst={$sifirst}";

 

    if ($firstnamesort) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        print</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            get_string('firstname')." / <a href=\"./?course={$course->id}{$sistring}\">".

            get_string('lastname').'</a>';

    } else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        print "<a href=\"./?course={$course->id}&amp;sort=firstname{$sistring}\">".

            get_string('firstname').'</a> / '.

            get_string('lastname');

    }

    print '</th>';

 

    // Print user identity columns

    foreach ($extrafields as $field) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        echo '<th scope="col" class="completion-identifyfield">' .</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">                get_user_field_name($field) . '</th>';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    }

} else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    foreach ($extrafields as $field) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        echo $sep . csv_quote(get_user_field_name($field));</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    }

}

 

// Activities

$formattedactivities = array();

foreach($activities as $activity) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $datepassed = $activity->completionexpected && $activity->completionexpected <= time();</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    $datepassedclass = $datepassed ? 'completion-expired' : '';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx"> </span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    if ($activity->completionexpected) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $datetext=userdate($activity->completionexpected,get_string('strftimedate','langconfig'));</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    } else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $datetext='';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    }

 

    // Some names (labels) come URL-encoded and can be very long, so shorten them

    $displayname = shorten_text($activity->name);

 

    if ($csv) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        print $sep.csv_quote(strip_tags($displayname)).$sep.csv_quote($datetext);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    } else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        $formattedactivityname = format_string($displayname, true, array('context' => $activity->context));</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        print '<th scope="col" class="'.$datepassedclass.'">'.</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            '<a href="'.$CFG->wwwroot.'/mod/'.$activity->modname.</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            '/view.php?id='.$activity->id.'" title="' . $formattedactivityname . '">'.</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            '<img src="'.$OUTPUT->pix_url('icon', $activity->modname).'" alt="'.</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            get_string('modulename',$activity->modname).'" /> <span class="completion-activityname">'.</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            $formattedactivityname.'</span></a>';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        if ($activity->completionexpected) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            print '<div class="completion-expected"><span>'.$datetext.'</span></div>';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        }

        print '</th>';

    }

    $formattedactivities[$activity->id] = (object)array(

        'datepassedclass' => $datepassedclass,

        'displayname' => $displayname,

    );

}

 

if ($csv) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    print $line;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">} else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    print '</tr></thead><tbody>';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

 

// Row for each user

foreach($progress as $user) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    // User name</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    if ($csv) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        print csv_quote(fullname($user));</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        foreach ($extrafields as $field) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            echo $sep . csv_quote($user->{$field});

        }

    } else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        print '<tr><th scope="row"><a href="'.$CFG->wwwroot.'/user/view.php?id='.</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            $user->id.'&amp;course='.$course->id.'">'.fullname($user).'</a></th>';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        foreach ($extrafields as $field) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            echo '<td>' . s($user->{$field}) . '</td>';

        }

    }

 

    // Progress for each activity

    foreach($activities as $activity) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx"> </span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        // Get progress information and state</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        if (array_key_exists($activity->id,$user->progress)) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            $thisprogress=$user->progress[$activity->id];</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            $state=$thisprogress->completionstate;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            $date=userdate($thisprogress->timemodified);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        } else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            $state=COMPLETION_INCOMPLETE;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            $date='';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        }

 

        // Work out how it corresponds to an icon

        switch($state) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            case COMPLETION_INCOMPLETE : $completiontype='n'; break;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            case COMPLETION_COMPLETE : $completiontype='y'; break;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            case COMPLETION_COMPLETE_PASS : $completiontype='pass'; break;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            case COMPLETION_COMPLETE_FAIL : $completiontype='fail'; break;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        }

 

        $completionicon='completion-'.

            ($activity->completion==COMPLETION_TRACKING_AUTOMATIC ? 'auto' : 'manual').

            '-'.$completiontype;

 

        $describe = get_string('completion-' . $completiontype, 'completion');

        $a=new StdClass;

        $a->state=$describe;

        $a->date=$date;

        $a->user=fullname($user);

        $a->activity = format_string($formattedactivities[$activity->id]->displayname, true, array('context' => $activity->context));

        $fulldescribe=get_string('progress-title','completion',$a);

 

        if ($csv) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            print $sep.csv_quote($describe).$sep.csv_quote($date);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        } else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">            print '<td class="completion-progresscell '.$formattedactivities[$activity->id]->datepassedclass.'">'.</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">                '<img src="'.$OUTPUT->pix_url('i/'.$completionicon).</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">                '" alt="'.$describe.'" title="'.$fulldescribe.'" /></td>';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        }

    }

 

    if ($csv) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        print $line;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    } else {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">        print '</tr>';</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    }

}

 

if ($csv) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">    exit;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="es-mx" style="font-size:10pt;font-family:'Courier New';" xml:lang="es-mx">}

print '</tbody></table>';

print '</div>';

print $pagingbar;

 

//RODOLFO (código añadido): Agregué el parámetro estado a la URL en las 2 urls.

print '<ul class="progress-actions"><li><a href="index_repc.php?course='.$course->id.'&amp;estado='.$estado.

    '&amp;format=csv">'.get_string('csvdownload','completion').'</a></li>

    <li><a href="index_repc.php?course='.$course->id.'&amp;estado='.$estado.'&amp;format=excelcsv">'.

    get_string('excelcsvdownload','completion').'</a></li></ul>';

 

echo $OUTPUT->footer();

 

 

En el segundo archivo (moodle/report/customsql/locallib.php) como verán es un archivo bastante extenso ya que se trata de un archivo de funciones, sin embargo sólo tendremos que realizar un par de cambios en el código. Uno de ellos es para editar una función y el otro es para agregar una nueva función. No merece la pena replicar todo el archivo por lo que sólo agregaré la parte editada  indicándole como en el archivo anterior:

 

 

function report_customsql_prepare_sql($report, $timenow) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="en-us" style="font-size:10pt;font-family:'Courier New';" xml:lang="en-us">    global $USER;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="en-us" style="font-size:10pt;font-family:'Courier New';" xml:lang="en-us">    $sql = $report->querysql;</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="en-us" style="font-size:10pt;font-family:'Courier New';" xml:lang="en-us">    if ($report->runable != 'manual') {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="en-us" style="font-size:10pt;font-family:'Courier New';" xml:lang="en-us">        list($end, $start) = report_customsql_get_starts($report, $timenow);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="en-us" style="font-size:10pt;font-family:'Courier New';" xml:lang="en-us">        $sql = report_customsql_substitute_time_tokens($sql, $start, $end);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="en-us" style="font-size:10pt;font-family:'Courier New';" xml:lang="en-us">    }

    $sql = report_customsql_substitute_user_token($sql, $USER->id);

    // Rodolfo (código añadido): Agrego las siguientes líneas

    $city = optional_param('city', 'SIN CITY', PARAM_RAW);

    //$city = str_replace('%20',' ',$city);

    //echo $city;

    $sql = report_customsql_substitute_city_token($sql, $city);

    return $sql;

}

 

 

function report_customsql_substitute_user_token($sql, $userid) {</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="en-us" style="font-size:10pt;font-family:'Courier New';" xml:lang="en-us">    return str_replace('%%USERID%%', $userid, $sql);</span></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><span lang="en-us" style="font-size:10pt;font-family:'Courier New';" xml:lang="en-us">}

 

// Rodolfo (código añadido): Agrego la siguiente función.

function report_customsql_substitute_city_token($sql, $city) {</span></b></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><b><span lang="en-us" style="font-size:10pt;font-family:'Courier New';color:#FFC000;" xml:lang="en-us">    return str_replace('%%CITY%%', $city, $sql);</span></b></p> <p style="margin-bottom:0.0001pt;line-height:normal;"><b><span lang="en-us" style="font-size:10pt;font-family:'Courier New';color:#FFC000;" xml:lang="en-us">}

 

 

 

3.    Ajustar el rol que tendrá acceso a los informes.

Para que el rol deseado tenga acceso al informe es necesario matricularlo en el curso del cual se desprende el informe y que no tenga rol de estudiante. En mi caso cree un rol global con privilegios de profesor sin permiso de edición, con lo cual no es necesario asignarle rol en el curso matriculado y pasa desapercibido para los estudiantes y profesores.

 

Y esto es todo.