commit e831ee94c5de9063bd3dc275685b3ca4d0fbdd34 Author: Sesostris Vieira Date: Mon Jun 9 21:04:21 2014 -0300 first commit diff --git a/action.php b/action.php new file mode 100644 index 0000000..301ae03 --- /dev/null +++ b/action.php @@ -0,0 +1,96 @@ +. + +/** + * 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 "
'; + +echo "".get_string('return', 'report_ilbenrol').''; +echo $OUTPUT->footer(); diff --git a/db/access.php b/db/access.php new file mode 100644 index 0000000..c74456a --- /dev/null +++ b/db/access.php @@ -0,0 +1,43 @@ +. + +/** + * 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', + ) +); + + diff --git a/db/install.php b/db/install.php new file mode 100644 index 0000000..e195331 --- /dev/null +++ b/db/install.php @@ -0,0 +1,32 @@ +. + +/** + * 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; + +} + diff --git a/index.php b/index.php new file mode 100644 index 0000000..30920d0 --- /dev/null +++ b/index.php @@ -0,0 +1,480 @@ +. + +/** + * 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 .= '
'; + $pagingbar .= get_string($initial.'name').': '; + + if ($$var == 'all') { + $pagingbar .= ''.get_string('all').' '; + } + else { + $pagingbar .= "".get_string('all').' '; + } + + foreach ($alphabet as $letter) { + if ($$var === $letter) { + $pagingbar .= ''.$letter.' '; + } + else { + $pagingbar .= "$letter "; + } + } + + $pagingbar .= '
'; +} + +// Do we need a paging bar? +if ($total > ILBENROL_REPORT_PAGE) { + + // Paging bar + $pagingbar .= '
'; + $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 .= "(".get_string('previous').') '; + } + + // Create page links + $curstart = 0; + $curpage = 0; + while ($curstart < $total) { + $curpage++; + + if ($curstart == $start) { + $pagingbar .= ' '.$curpage.' '; + } else { + $pagingbar .= " $curpage "; + } + + $curstart += ILBENROL_REPORT_PAGE; + } + + // Display next link + $nstart = $start + ILBENROL_REPORT_PAGE; + if ($nstart < $total) { + $pagingbar .= " (".get_string('next').')'; + } + + $pagingbar .= '
'; +} + +// Okay, let's draw the table of user info, + +// Start of table +if (!$csv) { + print '
'; // ugh + + print $pagingbar; + + if (!$total) { + echo $OUTPUT->heading(get_string('nothingtodisplay')); + echo $OUTPUT->footer(); + exit; + } + + print '
'; + print '
'; + print ''; + + print ''; + + // User heading / sort option + print ''; + + if ($sort == 'timecreated') { + print ''; + } else { + print ''; + } + + print ''; + } +} + +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 ''; + print ''; + echo ''; + echo ''; + echo ''; + + foreach ($filterfields as $field) { + if (array_key_exists($field->shortname, $profile)) { + $data = $profile->{$field->shortname}; + } else { + $data = ''; + } + echo ''; + } + } + + if ($csv) { + print $line; + } else { + print ''; + } +} + +if ($csv) { + exit; +} + +print '
'.get_string('select').''; + + $sistring = "&silast={$silast}&sifirst={$sifirst}"; + + if ($sort == 'firstname') { + print get_string('firstname')." / id}&sort=lastname{$sistring}\">". + get_string('lastname').''; + } else if ($sort == 'lastname') { + print "id}&sort=firstname{$sistring}\">". + get_string('firstname').' / '. + get_string('lastname'); + } else { + print "id}&sort=firstname{$sistring}\">". + get_string('firstname')." / id}&sort=lastname{$sistring}\">". + get_string('lastname').''; + } + + print ''.get_user_field_name('email').''. + get_string('timecreated', 'report_ilbenrol').''. + "id}&sort=timecreated{$sistring}\">". + get_string('timecreated', 'report_ilbenrol').''.get_string('userroles', 'report_ilbenrol').''; +} 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 '' . $formattedname . '
'.fullname($user).'' . s($user->email) . '' . s(userdate($user->timecreated)) . '' . s($display_roles) . '' . s($data) . '
'; +print '
'; +print $pagingbar; + +// Bulk operations +if (!$csv) { + echo '
'; + echo ' '; + echo ' '; + echo ''; + $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 ''; + echo ''; + echo ''; + echo ''; + +} + +print ''; + +echo $OUTPUT->footer(); + diff --git a/lang/en/report_ilbenrol.php b/lang/en/report_ilbenrol.php new file mode 100644 index 0000000..462ae70 --- /dev/null +++ b/lang/en/report_ilbenrol.php @@ -0,0 +1,50 @@ +. + +/** + * 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 {$a->user} changed from role {$a->from} to {$a->to}'; +$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
+* 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'; diff --git a/lang/pt_br/report_ilbenrol.php b/lang/pt_br/report_ilbenrol.php new file mode 100644 index 0000000..598f5aa --- /dev/null +++ b/lang/pt_br/report_ilbenrol.php @@ -0,0 +1,46 @@ +. + +/** + * 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 {$a->user} alterado da função {$a->from} para {$a->to}'; +$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
+* 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'; diff --git a/lib.php b/lib.php new file mode 100644 index 0000000..8e2bdfa --- /dev/null +++ b/lib.php @@ -0,0 +1,67 @@ +. + +/** + * 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; +} diff --git a/report_form.php b/report_form.php new file mode 100644 index 0000000..64d42bc --- /dev/null +++ b/report_form.php @@ -0,0 +1,65 @@ +. + +/** + * 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); + } +} diff --git a/settings.php b/settings.php new file mode 100644 index 0000000..8093f4b --- /dev/null +++ b/settings.php @@ -0,0 +1,16 @@ +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)); +} diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..2c0350c --- /dev/null +++ b/styles.css @@ -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;} diff --git a/textrotate.js b/textrotate.js new file mode 100644 index 0000000..56ee2d7 --- /dev/null +++ b/textrotate.js @@ -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. + +/** + * 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)