Sesostris Vieira
11 years ago
commit
e831ee94c5
12 changed files with 1026 additions and 0 deletions
@ -0,0 +1,96 @@ |
|||
<?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/>. |
|||
|
|||
/** |
|||
* Wrapper script redirecting user operations to correct destination. |
|||
* |
|||
* @copyright 1999 Martin Dougiamas http://dougiamas.com |
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|||
* @package user |
|||
*/ |
|||
|
|||
require_once("../../config.php"); |
|||
require("{$CFG->dirroot}/enrol/locallib.php"); |
|||
|
|||
$action = required_param('formaction', PARAM_TEXT); |
|||
$id = required_param('id', PARAM_INT); |
|||
$users = optional_param_array('user', array(), PARAM_INT); |
|||
$returnto = required_param('returnto', PARAM_TEXT); |
|||
|
|||
if (!confirm_sesskey()) { |
|||
print_error('confirmsesskeybad'); |
|||
} |
|||
|
|||
if (count($users) == 0) { |
|||
print_error('invalidformdata', '', $returnto); |
|||
} |
|||
|
|||
$role_confirmed = get_config(null, 'report_ilbenrol_confirmed'); |
|||
$role_revoked = get_config(null, 'report_ilbenrol_revoked'); |
|||
|
|||
if (!$role_confirmed or !$role_revoked) { |
|||
print_error('invalidargorconf'); |
|||
} |
|||
|
|||
$course = $DB->get_record('course',array('id'=>$id)); |
|||
|
|||
if (!$course) { |
|||
print_error('invalidcourseid'); |
|||
} |
|||
|
|||
require_login($course); |
|||
|
|||
$context = context_course::instance($course->id); |
|||
$manager = new course_enrolment_manager($PAGE, $course); |
|||
$roles = $manager->get_all_roles(); |
|||
$PAGE->set_heading($course->fullname); |
|||
$PAGE->set_url('/user/action.php', array('action'=>$action,'id'=>$id)); |
|||
$PAGE->set_pagelayout('report'); |
|||
$PAGE->set_title(get_string('title','report_ilbenrol')); |
|||
$PAGE->set_heading($course->fullname); |
|||
|
|||
require_login($course); |
|||
require_capability('report/ilbenrol:view',$context); |
|||
|
|||
if (!array_key_exists($role_confirmed, $roles) or !array_key_exists($role_revoked, $roles)) { |
|||
print_error('invalidargorconf'); |
|||
} |
|||
|
|||
echo $OUTPUT->header(); |
|||
|
|||
if ($action === 'confirmenrol') { |
|||
$from_role = $roles[$role_revoked]; |
|||
$to_role = $roles[$role_confirmed]; |
|||
} else if ($action === 'revokeenrol') { |
|||
$from_role = $roles[$role_confirmed]; |
|||
$to_role = $roles[$role_revoked]; |
|||
} else { |
|||
print_error('unknownuseraction'); |
|||
} |
|||
|
|||
echo "<ul>"; |
|||
foreach ($users as $userid=>$nothing) { |
|||
$user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST); |
|||
echo '<li>' . get_string('changeduser', 'report_ilbenrol', array('user'=>fullname($user), 'from'=>$from_role->localname, 'to'=>$to_role->localname)) . '</li>'; |
|||
$manager->assign_role_to_user($to_role->id, $user->id); |
|||
$manager->unassign_role_from_user($user->id, $from_role->id); |
|||
} |
|||
|
|||
echo '</ul><br/>'; |
|||
|
|||
echo "<a href=\"{$returnto}\">".get_string('return', 'report_ilbenrol').'</a>'; |
|||
echo $OUTPUT->footer(); |
@ -0,0 +1,43 @@ |
|||
<?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/>. |
|||
|
|||
/** |
|||
* Capabilities |
|||
* |
|||
* @package report_progress |
|||
* @copyright 2008 Sam Marshall |
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|||
*/ |
|||
|
|||
defined('MOODLE_INTERNAL') || die(); |
|||
|
|||
$capabilities = array( |
|||
|
|||
'report/ilbenrol:view' => array( |
|||
'riskbitmask' => RISK_PERSONAL, |
|||
'captype' => 'read', |
|||
'contextlevel' => CONTEXT_COURSE, |
|||
'archetypes' => array( |
|||
'teacher' => CAP_ALLOW, |
|||
'editingteacher' => CAP_ALLOW, |
|||
'manager' => CAP_ALLOW |
|||
), |
|||
|
|||
'clonepermissionsfrom' => 'coursereport/progress:view', |
|||
) |
|||
); |
|||
|
|||
|
@ -0,0 +1,32 @@ |
|||
<?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/>. |
|||
|
|||
/** |
|||
* Post installation and migration code. |
|||
* |
|||
* @package report |
|||
* @subpackage progress |
|||
* @copyright 2011 Petr Skoda {@link http://skodak.org} |
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|||
*/ |
|||
|
|||
defined('MOODLE_INTERNAL') || die; |
|||
|
|||
function xmldb_report_ilbenrol_install() { |
|||
global $DB; |
|||
|
|||
} |
|||
|
@ -0,0 +1,480 @@ |
|||
<?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/>. |
|||
|
|||
/** |
|||
* ILB Enrol Confirmation reports |
|||
* |
|||
* @package report |
|||
* @subpackage ilbenrol |
|||
* @copyright 2008 Sam Marshall |
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|||
*/ |
|||
|
|||
require('../../config.php'); |
|||
require("{$CFG->dirroot}/enrol/locallib.php"); |
|||
require_once('report_form.php'); |
|||
require_once("$CFG->dirroot/user/profile/lib.php"); |
|||
|
|||
define('ILBENROL_REPORT_PAGE', 25); |
|||
|
|||
// Get course |
|||
$id = required_param('course',PARAM_INT); |
|||
$course = $DB->get_record('course',array('id'=>$id)); |
|||
|
|||
if (!$course) { |
|||
print_error('invalidcourseid'); |
|||
} |
|||
|
|||
$context = context_course::instance($course->id); |
|||
|
|||
// Sort (default lastname, optionally firstname) |
|||
$sort = optional_param('sort','timecreated',PARAM_ALPHA); |
|||
|
|||
// 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_ALPHA); |
|||
$silast = optional_param('silast', 'all', PARAM_ALPHA); |
|||
|
|||
// User profile fields to filter |
|||
$filterfields = explode(',', get_config(null, 'report_ilbenrol_filterfields')); |
|||
$filterfields = $DB->get_records_list('user_info_field', 'shortname', $filterfields); |
|||
|
|||
function csv_quote($value) { |
|||
global $excel; |
|||
if ($excel) { |
|||
return textlib::convert('"'.str_replace('"',"'",$value).'"','UTF-8','UTF-16LE'); |
|||
} else { |
|||
return '"'.str_replace('"',"'",$value).'"'; |
|||
} |
|||
} |
|||
|
|||
$url = new moodle_url('/report/ilbenrol/index.php', array('course'=>$id)); |
|||
if ($sort !== '') { |
|||
$url->param('sort', $sort); |
|||
} |
|||
if ($format !== '') { |
|||
$url->param('format', $format); |
|||
} |
|||
if ($start !== 0) { |
|||
$url->param('start', $start); |
|||
} |
|||
$PAGE->set_url($url); |
|||
$PAGE->set_pagelayout('report'); |
|||
|
|||
require_login($course); |
|||
|
|||
// Check basic permission |
|||
require_capability('report/ilbenrol:view',$context); |
|||
|
|||
// Get group mode |
|||
$group = groups_get_course_group($course,true); // Supposed to verify group |
|||
if ($group===0 && $course->groupmode==SEPARATEGROUPS) { |
|||
require_capability('moodle/site:accessallgroups',$context); |
|||
} |
|||
|
|||
// Get data for user filtering |
|||
$manager = new course_enrolment_manager($PAGE, $course); |
|||
$roles = $manager->get_all_roles(); |
|||
$mform = new filter_form($course->id, $filterfields); |
|||
$instances = $manager->get_enrolment_instances(); |
|||
$contextids = $context->get_parent_context_ids(true); |
|||
|
|||
// Generate where clause |
|||
$where = array(); |
|||
$where_params = array(); |
|||
|
|||
if ($sifirst !== 'all') { |
|||
$where[] = $DB->sql_like('u.firstname', ':sifirst', false); |
|||
$where_params['sifirst'] = $sifirst.'%'; |
|||
} |
|||
|
|||
if ($silast !== 'all') { |
|||
$where[] = $DB->sql_like('u.lastname', ':silast', false); |
|||
$where_params['silast'] = $silast.'%'; |
|||
} |
|||
|
|||
$whereors = array(); |
|||
|
|||
if ($formdata = $mform->get_data()) { |
|||
foreach ($filterfields as $field) { |
|||
$shortname = $field->shortname; |
|||
if (array_key_exists($shortname, $formdata)) { |
|||
list($in_options, $param_options) = $DB->get_in_or_equal(array_keys($formdata->$shortname), SQL_PARAMS_NAMED); |
|||
$whereors[] = "(uid.fieldid = {$field->id} AND uid.data {$in_options})"; |
|||
$where_params = $where_params + $param_options; |
|||
} |
|||
} |
|||
} |
|||
|
|||
list($in_instances, $param_instances) = $DB->get_in_or_equal(array_keys($instances), SQL_PARAMS_NAMED); |
|||
list($in_contexts, $param_contexts) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED); |
|||
list($in_fields, $param_fields) = $DB->get_in_or_equal(array_keys($filterfields), SQL_PARAMS_NAMED); |
|||
$params = $param_instances + $param_contexts + $param_fields; |
|||
|
|||
// Get data to summary table |
|||
$dados = $DB->get_records_sql_menu("SELECT uid.fieldid||'-'||ra.roleid||'-'||uid.data, count(distinct u.id) |
|||
FROM {user} u |
|||
JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid {$in_instances}) |
|||
JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid {$in_contexts}) |
|||
LEFT JOIN {user_info_data} uid ON (uid.userid = u.id AND uid.fieldid {$in_fields}) |
|||
GROUP BY uid.fieldid, ra.roleid, uid.data", $params); |
|||
|
|||
// Get data to User List table |
|||
$whereorstr = implode(' OR ', $whereors); |
|||
if ($whereorstr) { |
|||
$where[] = "({$whereorstr})"; |
|||
} |
|||
$wherestr = implode(' AND ', $where); |
|||
|
|||
$sql = "SELECT DISTINCT u.id, u.firstname, u.lastname, u.email, ue.timecreated |
|||
FROM {user} u |
|||
JOIN {user_enrolments} ue ON (ue.userid = u.id AND ue.enrolid {$in_instances}) |
|||
JOIN {role_assignments} ra ON (ra.userid = u.id AND ra.contextid {$in_contexts}) |
|||
LEFT JOIN {user_info_data} uid ON (uid.userid = u.id AND uid.fieldid {$in_fields})"; |
|||
|
|||
if ($wherestr) { |
|||
$sql .= " WHERE {$wherestr}"; |
|||
} |
|||
|
|||
if ($sort == 'timecreated') { |
|||
$sql .= ' ORDER BY ue.timecreated'; |
|||
} else { |
|||
$sql .= " ORDER BY u.{$sort}"; |
|||
} |
|||
|
|||
$userlist = $DB->get_records_sql($sql, $params + $where_params); |
|||
$total = count($userlist); |
|||
|
|||
if ($csv && $userlist) { // Only show CSV if there are some users |
|||
$shortname = format_string($course->shortname, true, array('context' => $context)); |
|||
header('Content-Disposition: attachment; filename=ilbenrol.'. |
|||
preg_replace('/[^a-z0-9-]/','_',textlib::strtolower(strip_tags($shortname))).'.csv'); |
|||
// Unicode byte-order mark for Excel |
|||
if ($excel) { |
|||
header('Content-Type: text/csv; charset=UTF-16LE'); |
|||
print chr(0xFF).chr(0xFE); |
|||
$sep="\t".chr(0); |
|||
$line="\n".chr(0); |
|||
} else { |
|||
header('Content-Type: text/csv; charset=UTF-8'); |
|||
$sep=","; |
|||
$line="\n"; |
|||
} |
|||
} else { |
|||
// Navigation and header |
|||
$PAGE->set_title(get_string('title','report_ilbenrol')); |
|||
$PAGE->set_heading($course->fullname); |
|||
echo $OUTPUT->header(); |
|||
// $PAGE->requires->js('/report/ilbenrol/textrotate.js'); |
|||
// $PAGE->requires->js_function_call('textrotate_init', null, true); |
|||
|
|||
// Handle groups (if enabled) |
|||
groups_print_course_menu($course,$CFG->wwwroot.'/report/ilbenrol/?course='.$course->id); |
|||
|
|||
// Print filter form |
|||
$mform->display(); |
|||
|
|||
// Print summary table |
|||
$thead = array(''); |
|||
$talign = array('left'); |
|||
foreach ($roles as $role) { |
|||
$thead[] = $role->localname; |
|||
$talign[] = 'right'; |
|||
} |
|||
|
|||
foreach ($filterfields as $field) { |
|||
$options = explode("\n", $field->param1); |
|||
$data = array(); |
|||
|
|||
foreach($options as $option) { |
|||
$row = array($option); |
|||
foreach ($roles as $role) { |
|||
if (isset($dados["{$field->id}-{$role->id}-{$option}"])) { |
|||
$row[] = $dados["{$field->id}-{$role->id}-{$option}"]; |
|||
} else { |
|||
$row[] = ""; |
|||
} |
|||
} |
|||
$data[] = $row; |
|||
} |
|||
|
|||
$thead[0] = $field->name; |
|||
$table = new html_table(); |
|||
$table->align = $talign; |
|||
$table->head = $thead; |
|||
$table->data = $data; |
|||
|
|||
echo html_writer::table($table); |
|||
} |
|||
} |
|||
|
|||
// If no users in this filter |
|||
if (!$userlist) { |
|||
echo $OUTPUT->container(get_string('err_nousers', 'completion'), 'errorbox errorboxcontent'); |
|||
echo $OUTPUT->footer(); |
|||
exit; |
|||
} |
|||
|
|||
// Build link for paging |
|||
$link = $CFG->wwwroot.'/report/ilbenrol/?course='.$course->id; |
|||
if (strlen($sort)) { |
|||
$link .= '&sort='.$sort; |
|||
} |
|||
$link .= '&start='; |
|||
|
|||
// Build the the page by Initial bar |
|||
$initials = array('first', 'last'); |
|||
$alphabet = explode(',', get_string('alphabet', 'langconfig')); |
|||
|
|||
$pagingbar = ''; |
|||
foreach ($initials as $initial) { |
|||
$var = 'si'.$initial; |
|||
|
|||
$othervar = $initial == 'first' ? 'silast' : 'sifirst'; |
|||
$othervar = $$othervar != 'all' ? "&{$othervar}={$$othervar}" : ''; |
|||
|
|||
$pagingbar .= ' <div class="initialbar '.$initial.'initial">'; |
|||
$pagingbar .= get_string($initial.'name').': '; |
|||
|
|||
if ($$var == 'all') { |
|||
$pagingbar .= '<strong>'.get_string('all').'</strong> '; |
|||
} |
|||
else { |
|||
$pagingbar .= "<a href=\"{$link}{$othervar}\">".get_string('all').'</a> '; |
|||
} |
|||
|
|||
foreach ($alphabet as $letter) { |
|||
if ($$var === $letter) { |
|||
$pagingbar .= '<strong>'.$letter.'</strong> '; |
|||
} |
|||
else { |
|||
$pagingbar .= "<a href=\"$link&$var={$letter}{$othervar}\">$letter</a> "; |
|||
} |
|||
} |
|||
|
|||
$pagingbar .= '</div>'; |
|||
} |
|||
|
|||
// Do we need a paging bar? |
|||
if ($total > ILBENROL_REPORT_PAGE) { |
|||
|
|||
// Paging bar |
|||
$pagingbar .= '<div class="paging">'; |
|||
$pagingbar .= get_string('page').': '; |
|||
|
|||
$sistrings = array(); |
|||
if ($sifirst != 'all') { |
|||
$sistrings[] = "sifirst={$sifirst}"; |
|||
} |
|||
if ($silast != 'all') { |
|||
$sistrings[] = "silast={$silast}"; |
|||
} |
|||
$sistring = !empty($sistrings) ? '&'.implode('&', $sistrings) : ''; |
|||
|
|||
// Display previous link |
|||
if ($start > 0) { |
|||
$pstart = max($start - ILBENROL_REPORT_PAGE, 0); |
|||
$pagingbar .= "(<a class=\"previous\" href=\"{$link}{$pstart}{$sistring}\">".get_string('previous').'</a>) '; |
|||
} |
|||
|
|||
// Create page links |
|||
$curstart = 0; |
|||
$curpage = 0; |
|||
while ($curstart < $total) { |
|||
$curpage++; |
|||
|
|||
if ($curstart == $start) { |
|||
$pagingbar .= ' '.$curpage.' '; |
|||
} else { |
|||
$pagingbar .= " <a href=\"{$link}{$curstart}{$sistring}\">$curpage</a> "; |
|||
} |
|||
|
|||
$curstart += ILBENROL_REPORT_PAGE; |
|||
} |
|||
|
|||
// Display next link |
|||
$nstart = $start + ILBENROL_REPORT_PAGE; |
|||
if ($nstart < $total) { |
|||
$pagingbar .= " (<a class=\"next\" href=\"{$link}{$nstart}{$sistring}\">".get_string('next').'</a>)'; |
|||
} |
|||
|
|||
$pagingbar .= '</div>'; |
|||
} |
|||
|
|||
// Okay, let's draw the table of user info, |
|||
|
|||
// Start of table |
|||
if (!$csv) { |
|||
print '<br class="clearer"/>'; // ugh |
|||
|
|||
print $pagingbar; |
|||
|
|||
if (!$total) { |
|||
echo $OUTPUT->heading(get_string('nothingtodisplay')); |
|||
echo $OUTPUT->footer(); |
|||
exit; |
|||
} |
|||
|
|||
print '<form action="action.php" method="post" id="participantsform">'; |
|||
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">'; |
|||
|
|||
print '<th scope="col" class="completion-identifyfield">'.get_string('select').'</th>'; |
|||
|
|||
// User heading / sort option |
|||
print '<th scope="col" class="completion-sortchoice">'; |
|||
|
|||
$sistring = "&silast={$silast}&sifirst={$sifirst}"; |
|||
|
|||
if ($sort == 'firstname') { |
|||
print get_string('firstname')." / <a href=\"./?course={$course->id}&sort=lastname{$sistring}\">". |
|||
get_string('lastname').'</a>'; |
|||
} else if ($sort == 'lastname') { |
|||
print "<a href=\"./?course={$course->id}&sort=firstname{$sistring}\">". |
|||
get_string('firstname').'</a> / '. |
|||
get_string('lastname'); |
|||
} else { |
|||
print "<a href=\"./?course={$course->id}&sort=firstname{$sistring}\">". |
|||
get_string('firstname')."</a> / <a href=\"./?course={$course->id}&sort=lastname{$sistring}\">". |
|||
get_string('lastname').'</a>'; |
|||
} |
|||
|
|||
print '</th><th scope="col" class="completion-identifyfield">'.get_user_field_name('email').'</th>'; |
|||
|
|||
if ($sort == 'timecreated') { |
|||
print '<th scope="col" class="completion-sortchoice">'. |
|||
get_string('timecreated', 'report_ilbenrol').'</th>'; |
|||
} else { |
|||
print '<th scope="col" class="completion-sortchoice">'. |
|||
"<a href=\"./?course={$course->id}&sort=timecreated{$sistring}\">". |
|||
get_string('timecreated', 'report_ilbenrol').'</a></th>'; |
|||
} |
|||
|
|||
print '<th scope="col" class="completion-sortchoice">'.get_string('userroles', 'report_ilbenrol').'</td>'; |
|||
} else { |
|||
echo csv_quote(get_user_field_name('fullname')); |
|||
echo $sep . csv_quote(get_user_field_name('email')); |
|||
echo $sep . csv_quote(get_string('timecreated', 'report_ilbenrol')); |
|||
echo $sep . csv_quote(get_string('userroles', 'report_ilbenrol')); |
|||
} |
|||
|
|||
// User fields header |
|||
|
|||
foreach ($filterfields as $field) { |
|||
if ($csv) { |
|||
print $sep.csv_quote(strip_tags($field->name)).$sep; |
|||
} else { |
|||
$formattedname = format_string($field->name, true, array('context' => $context)); |
|||
print '<th scope="col" class="completion-identifyfield">' . $formattedname . '</th>'; |
|||
} |
|||
} |
|||
|
|||
if ($csv) { |
|||
print $line; |
|||
} |
|||
|
|||
// Row for each user |
|||
foreach($userlist as $user) { |
|||
$profile = profile_user_record($user->id); |
|||
$user_roles = $manager->get_user_roles($user->id); |
|||
$display_roles = array(); |
|||
foreach ($user_roles as $rid=>$rassignable) { |
|||
$display_roles[] = $roles[$rid]->localname; |
|||
} |
|||
$display_roles = implode(', ', $display_roles); |
|||
|
|||
if ($csv) { |
|||
print csv_quote(fullname($user)); |
|||
echo $sep . csv_quote($user->email); |
|||
echo $sep . csv_quote(userdate($user->timecreated)); |
|||
echo $sep . csv_quote($display_roles); |
|||
|
|||
foreach ($filterfields as $field) { |
|||
if (array_key_exists($field->shortname, $profile)) { |
|||
$data = $profile->{$field->shortname}; |
|||
} else { |
|||
$data = ''; |
|||
} |
|||
echo $sep . csv_quote($data); |
|||
} |
|||
} else { |
|||
print '<tr><th><input type="checkbox" class="usercheckbox" name="user['.$user->id.']" /></th>'; |
|||
print '<th scope="row"><a href="'.$CFG->wwwroot.'/user/view.php?id='. |
|||
$user->id.'&course='.$course->id.'">'.fullname($user).'</a></th>'; |
|||
echo '<td>' . s($user->email) . '</td>'; |
|||
echo '<td>' . s(userdate($user->timecreated)) . '</td>'; |
|||
echo '<td>' . s($display_roles) . '</td>'; |
|||
|
|||
foreach ($filterfields as $field) { |
|||
if (array_key_exists($field->shortname, $profile)) { |
|||
$data = $profile->{$field->shortname}; |
|||
} else { |
|||
$data = ''; |
|||
} |
|||
echo '<td>' . s($data) . '</td>'; |
|||
} |
|||
} |
|||
|
|||
if ($csv) { |
|||
print $line; |
|||
} else { |
|||
print '</tr>'; |
|||
} |
|||
} |
|||
|
|||
if ($csv) { |
|||
exit; |
|||
} |
|||
|
|||
print '</tbody></table>'; |
|||
print '</div>'; |
|||
print $pagingbar; |
|||
|
|||
// Bulk operations |
|||
if (!$csv) { |
|||
echo '<br /><div class="buttons">'; |
|||
echo '<input type="button" id="checkall" value="'.get_string('selectall').'" /> '; |
|||
echo '<input type="button" id="checknone" value="'.get_string('deselectall').'" /> '; |
|||
echo '</form>'; |
|||
$module = array('name'=>'core_user', 'fullpath'=>'/user/module.js'); |
|||
$PAGE->requires->js_init_call('M.core_user.init_participation', null, false, $module); |
|||
$displaylist = array(); |
|||
$displaylist['confirmenrol'] = get_string('confirmenrol', 'report_ilbenrol'); |
|||
$displaylist['revokeenrol'] = get_string('revokeenrol', 'report_ilbenrol'); |
|||
echo $OUTPUT->help_icon('withselectedusers', 'report_ilbenrol'); |
|||
echo html_writer::tag('label', get_string("withselectedusers"), array('for'=>'formactionid')); |
|||
echo html_writer::select($displaylist, 'formaction', '', array(''=>'choosedots'), array('id'=>'formactionid')); |
|||
echo '<input type="hidden" name="id" value="'.$course->id.'" />'; |
|||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; |
|||
echo '<input type="hidden" name="returnto" value="'.s($PAGE->url->out(false)).'" />'; |
|||
echo '<noscript style="display:inline">'; |
|||
echo '<div><input type="submit" value="'.get_string('ok').'" /></div>'; |
|||
echo '</noscript>'; |
|||
|
|||
} |
|||
|
|||
print '<ul class="progress-actions"><li><a href="index.php?course='.$course->id. |
|||
'&format=csv">'.get_string('csvdownload','completion').'</a></li> |
|||
<li><a href="index.php?course='.$course->id.'&format=excelcsv">'. |
|||
get_string('excelcsvdownload','completion').'</a></li></ul>'; |
|||
|
|||
echo $OUTPUT->footer(); |
|||
|
@ -0,0 +1,50 @@ |
|||
<?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/>. |
|||
|
|||
/** |
|||
* Lang strings |
|||
* |
|||
* @package report |
|||
* @subpackage progress |
|||
* @copyright 2008 Sam Marshall |
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|||
*/ |
|||
|
|||
$string['pluginname'] = 'ILB Enrol Confirmation'; |
|||
$string['title'] = 'ILB Enrol Confirmation Report'; |
|||
$string['filter'] = 'Filters'; |
|||
$string['filterfields'] = 'Filter fields'; |
|||
$string['userroles'] = 'User roles'; |
|||
$string['confirmed'] = 'Role to confirmed enrollment'; |
|||
$string['confirmeddescription'] = 'Role to confirmed enrollments'; |
|||
$string['revoked'] = 'Role to revoked enrollment'; |
|||
$string['revokeddescription'] = 'Role to revoked enrollment'; |
|||
$string['changeduser'] = 'User <strong>{$a->user}</strong> changed from role <strong>{$a->from}</strong> to <strong>{$a->to}</strong>'; |
|||
$string['return'] = 'Return'; |
|||
$string['total'] = 'Totals'; |
|||
$string['applyfilter'] = 'Apply filters'; |
|||
$string['email'] = 'Email address'; |
|||
$string['timecreated'] = 'Enrol date'; |
|||
$string['confirmenrol'] = 'Confirm enrol'; |
|||
$string['revokeenrol'] = 'Revoke enrol'; |
|||
$string['withselectedusers'] = 'With selected users...'; |
|||
$string['withselectedusers_help'] = '* Confirm enrol - To define users role as students<br/> |
|||
* Revoke enrol - To reset the students back to unstudent status'; |
|||
$string['filterfieldsdescription'] = 'Profile fields that will be added to filter report form'; |
|||
$string['page-report-progress-x'] = 'Any activity completion report'; |
|||
$string['page-report-progress-index'] = 'Activity completion report'; |
|||
$string['page-report-progress-user'] = 'User activity completion report'; |
|||
$string['ilbenrol:view'] = 'View ILB Enrol Confirmation reports'; |
@ -0,0 +1,46 @@ |
|||
<?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/>. |
|||
|
|||
/** |
|||
* Lang strings |
|||
* |
|||
* @package report |
|||
* @subpackage progress |
|||
* @copyright 2008 Sam Marshall |
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|||
*/ |
|||
|
|||
$string['pluginname'] = 'Confirmação de matrícula ILB'; |
|||
$string['title'] = 'Relatório de confirmação de matrícula'; |
|||
$string['filter'] = 'Filtros'; |
|||
$string['filterfields'] = 'Campos de filtragem'; |
|||
$string['userroles'] = 'Funções'; |
|||
$string['confirmed'] = 'Função para matrícula confirmada'; |
|||
$string['confirmeddescription'] = 'Função para matrícula confirmada'; |
|||
$string['revoked'] = 'Função para matrícula revogada'; |
|||
$string['revokeddescription'] = 'Função para matrícula revogada'; |
|||
$string['changeduser'] = 'Usuário <strong>{$a->user}</strong> alterado da função <strong>{$a->from}</strong> para <strong>{$a->to}</strong>'; |
|||
$string['return'] = 'Voltar'; |
|||
$string['total'] = 'Totais'; |
|||
$string['applyfilter'] = 'Aplicar filtros'; |
|||
$string['timecreated'] = 'Data de inscrição'; |
|||
$string['confirmenrol'] = 'Confirmar matrícula'; |
|||
$string['revokeenrol'] = 'Revogar matrícula'; |
|||
$string['withselectedusers'] = 'Com usuários selecionados...'; |
|||
$string['withselectedusers_help'] = '* Confirmar matrícula - Para definir a função dos usuários como alunos<br/> |
|||
* Revogar matrícula - Para voltar os estudantes para o estado de pré-inscrição'; |
|||
$string['filterfieldsdescription'] = 'Campos de perfil que serão adicionados ao formulário de filtro do relatório'; |
|||
$string['ilbenrol:view'] = 'Ver relatórios de confirmation de matrículas do ILB'; |
@ -0,0 +1,67 @@ |
|||
<?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/>. |
|||
|
|||
/** |
|||
* This file contains functions used by the progress report |
|||
* |
|||
* @package report |
|||
* @subpackage progress |
|||
* @copyright 2009 Sam Hemelryk |
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|||
*/ |
|||
|
|||
defined('MOODLE_INTERNAL') || die; |
|||
|
|||
/** |
|||
* This function extends the navigation with the report items |
|||
* |
|||
* @param navigation_node $navigation The navigation node to extend |
|||
* @param stdClass $course The course to object for the report |
|||
* @param stdClass $context The context of the course |
|||
*/ |
|||
function report_ilbenrol_extend_navigation_course($navigation, $course, $context) { |
|||
global $CFG, $OUTPUT; |
|||
|
|||
$showonnavigation = has_capability('report/ilbenrol:view', $context); |
|||
$group = groups_get_course_group($course,true); // Supposed to verify group |
|||
if($group===0 && $course->groupmode==SEPARATEGROUPS) { |
|||
$showonnavigation = ($showonnavigation && has_capability('moodle/site:accessallgroups', $context)); |
|||
} |
|||
|
|||
$showonnavigation = ($showonnavigation && get_config(null, 'report_ilbenrol_filterfields') !== ""); |
|||
|
|||
if ($showonnavigation) { |
|||
$url = new moodle_url('/report/ilbenrol/index.php', array('course'=>$course->id)); |
|||
$navigation->add(get_string('pluginname','report_ilbenrol'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', '')); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Return a list of page types |
|||
* @param string $pagetype current page type |
|||
* @param stdClass $parentcontext Block's parent context |
|||
* @param stdClass $currentcontext Current context of block |
|||
* @return array |
|||
*/ |
|||
function report_ilbenrol_page_type_list($pagetype, $parentcontext, $currentcontext) { |
|||
$array = array( |
|||
'*' => get_string('page-x', 'pagetype'), |
|||
'report-*' => get_string('page-report-x', 'pagetype'), |
|||
'report-ilbenrol-*' => get_string('page-report-ilbenrol-x', 'report_ilbenrol'), |
|||
'report-ilbenrol-index' => get_string('page-report-ilbenrol-index', 'report_ilbenrol'), |
|||
); |
|||
return $array; |
|||
} |
@ -0,0 +1,65 @@ |
|||
<?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/>. |
|||
|
|||
/** |
|||
* This file defines the user filter form |
|||
* |
|||
* @package report-ilbenrol |
|||
* @copyrigth 2014 Interlegis (http://www.interlegis.leg.br) |
|||
* |
|||
* @author Sesostris Vieira |
|||
* |
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html |
|||
*/ |
|||
|
|||
if (!defined('MOODLE_INTERNAL')) { |
|||
die('Direct access to this script is forbidden.'); |
|||
} |
|||
|
|||
require_once("$CFG->libdir/formslib.php"); |
|||
|
|||
class filter_form extends moodleform { |
|||
protected $_courseid; |
|||
protected $_filterfields; |
|||
|
|||
function filter_form($courseid, $filterfields, $action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true) { |
|||
$this->_filterfields = $filterfields; |
|||
$this->_courseid = $courseid; |
|||
parent::moodleform($action, $customdata, $method, $target, $attributes, $editable); |
|||
} |
|||
|
|||
public function definition() { |
|||
global $CFG; |
|||
|
|||
$mform = $this->_form; // Don't forget the underscore! |
|||
$courseid = $this->_courseid; |
|||
$filterfields = $this->_filterfields; |
|||
|
|||
$mform->addElement('header', 'filter', get_string('filter', 'report_ilbenrol')); |
|||
|
|||
foreach ($filterfields as $field) { |
|||
$mform->addElement('static', $field->shortname, $field->name, ''); |
|||
$options = explode("\n", $field->param1); |
|||
foreach ($options as $option) { |
|||
$mform->addElement('checkbox', "{$field->shortname}[$option]", $option); |
|||
} |
|||
} |
|||
|
|||
$mform->addElement('submit', 'filterbutton', get_string('applyfilter', 'report_ilbenrol')); |
|||
$mform->addElement('hidden', 'course', $courseid); |
|||
} |
|||
} |
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
defined('MOODLE_INTERNAL') || die; |
|||
|
|||
if ($ADMIN->fulltree) { |
|||
$choices = $DB->get_records_menu('user_info_field', array('datatype'=>'menu'), 'name', 'shortname, name'); |
|||
$roles = role_fix_names(get_all_roles(), context_system::instance(), ROLENAME_ORIGINAL); |
|||
$rolechoices = array(); |
|||
foreach ($roles as $role) { |
|||
$rolechoices[$role->id] = $role->localname; |
|||
} |
|||
$settings->add(new admin_setting_configmulticheckbox('report_ilbenrol_filterfields', get_string('filterfields', 'report_ilbenrol'), get_string('filterfieldsdescription', 'report_ilbenrol'), '', $choices)); |
|||
|
|||
$settings->add(new admin_setting_configselect('report_ilbenrol_confirmed', get_string('confirmed', 'report_ilbenrol'), get_string('confirmeddescription', 'report_ilbenrol'), '', $rolechoices)); |
|||
$settings->add(new admin_setting_configselect('report_ilbenrol_revoked', get_string('revoked', 'report_ilbenrol'), get_string('revokeddescription', 'report_ilbenrol'), '', $rolechoices)); |
|||
} |
@ -0,0 +1,7 @@ |
|||
#page-report-progress-index #completion-progress th, |
|||
#page-report-progress-index #completion-progress td {padding:2px 4px;font-weight:normal;border-right: 1px solid #EEE;} |
|||
#page-report-progress-index .progress-actions {text-align:center;} |
|||
#page-report-progress-index .completion_pagingbar {margin:1em 0;text-align:center;} |
|||
#page-report-progress-index .completion_prev {display:inline;margin-right:2em;} |
|||
#page-report-progress-index .completion_pagingbar p {display:inline;margin:0;} |
|||
#page-report-progress-index .completion_next {display:inline;margin-left:2em;} |
@ -0,0 +1,94 @@ |
|||
var SVGNS='http://www.w3.org/2000/svg',XLINKNS='http://www.w3.org/1999/xlink'; |
|||
|
|||
function textrotate_make_svg(el) |
|||
{ |
|||
var string=el.firstChild.nodeValue; |
|||
|
|||
// Add absolute-positioned string (to measure length)
|
|||
var abs=document.createElement('div'); |
|||
abs.appendChild(document.createTextNode(string)); |
|||
abs.style.position='absolute'; |
|||
el.parentNode.insertBefore(abs,el); |
|||
var textWidth=abs.offsetWidth,textHeight=abs.offsetHeight; |
|||
el.parentNode.removeChild(abs); |
|||
|
|||
// Create SVG
|
|||
var svg=document.createElementNS(SVGNS,'svg'); |
|||
svg.setAttribute('version','1.1'); |
|||
var width=(textHeight*9)/8; |
|||
svg.setAttribute('width',width); |
|||
svg.setAttribute('height',textWidth+20); |
|||
|
|||
// Add text
|
|||
var text=document.createElementNS(SVGNS,'text'); |
|||
svg.appendChild(text); |
|||
text.setAttribute('x',textWidth); |
|||
text.setAttribute('y',-textHeight/4); |
|||
text.setAttribute('text-anchor','end'); |
|||
text.setAttribute('transform','rotate(90)'); |
|||
text.appendChild(document.createTextNode(string)); |
|||
|
|||
// Is there an icon near the text?
|
|||
var icon=el.parentNode.firstChild; |
|||
if(icon.nodeName.toLowerCase()=='img') { |
|||
el.parentNode.removeChild(icon); |
|||
var image=document.createElementNS(SVGNS,'image'); |
|||
var iconx=el.offsetHeight/4; |
|||
if(iconx>width-16) iconx=width-16; |
|||
image.setAttribute('x',iconx); |
|||
image.setAttribute('y',textWidth+4); |
|||
image.setAttribute('width',16); |
|||
image.setAttribute('height',16); |
|||
image.setAttributeNS(XLINKNS,'href',icon.src); |
|||
svg.appendChild(image); |
|||
} |
|||
|
|||
// Replace original content with this new SVG
|
|||
el.parentNode.insertBefore(svg,el); |
|||
el.parentNode.removeChild(el); |
|||
} |
|||
|
|||
function browser_supports_svg() { |
|||
return document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"); |
|||
} |
|||
|
|||
function textrotate_init() { |
|||
if (!browser_supports_svg()) { |
|||
// Feature detect, else bail.
|
|||
return; |
|||
} |
|||
|
|||
YUI().use('yui2-dom', function(Y) { |
|||
var elements= Y.YUI2.util.Dom.getElementsByClassName('completion-activityname', 'span'); |
|||
for(var i=0;i<elements.length;i++) |
|||
{ |
|||
var el=elements[i]; |
|||
el.parentNode.parentNode.parentNode.style.verticalAlign='bottom'; |
|||
textrotate_make_svg(el); |
|||
} |
|||
|
|||
elements= Y.YUI2.util.Dom.getElementsByClassName('completion-expected', 'div'); |
|||
for(var i=0;i<elements.length;i++) |
|||
{ |
|||
var el=elements[i]; |
|||
el.style.display='inline'; |
|||
var parent=el.parentNode; |
|||
parent.removeChild(el); |
|||
parent.insertBefore(el,parent.firstChild); |
|||
textrotate_make_svg(el.firstChild); |
|||
} |
|||
|
|||
elements= Y.YUI2.util.Dom.getElementsByClassName('rotateheaders', 'table'); |
|||
for(var i=0;i<elements.length;i++) |
|||
{ |
|||
var table=elements[i]; |
|||
var headercells = Y.YUI2.util.Dom.getElementsByClassName('header', 'th', table); |
|||
for(var j=0;j<headercells.length;j++) |
|||
{ |
|||
var el=headercells[j]; |
|||
textrotate_make_svg(el.firstChild); |
|||
} |
|||
} |
|||
}); |
|||
} |
|||
|
@ -0,0 +1,30 @@ |
|||
<?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/>. |
|||
|
|||
/** |
|||
* Version details |
|||
* |
|||
* @package report |
|||
* @subpackage progress |
|||
* @copyright 2008 Sam Marshall |
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|||
*/ |
|||
|
|||
defined('MOODLE_INTERNAL') || die; |
|||
|
|||
$plugin->version = 2013050100; // The current plugin version (Date: YYYYMMDDXX) |
|||
$plugin->requires = 2013050100; // Requires this Moodle version |
|||
$plugin->component = 'report_ilbenrol'; // Full name of the plugin (used for diagnostics) |
Loading…
Reference in new issue