Browse Source

Adiciona filtro por método de inscrição

master
Sesostris Vieira 8 years ago
parent
commit
a5bdd50ae2
  1. 12
      index.php
  2. 14
      report_form.php

12
index.php

@ -105,7 +105,7 @@ if (!$role_confirmed or !$role_revoked) {
}
$roles = array($role_confirmed=>$allroles[$role_confirmed], $role_revoked=>$allroles[$role_revoked]);
$mform = new filter_form($course->id, $filterfields, $roles);
$mform = new filter_form($course->id, $filterfields, $roles, $instances);
// Generate where clause
$where = array();
@ -141,7 +141,7 @@ if ($formdata = $mform->get_data()) {
}
// Role filter
if ($formdata and array_key_exists('role', $formdata)) {
if (array_key_exists('role', $formdata)) {
list($in_roles, $param_roles) = $DB->get_in_or_equal(array_keys($formdata->role), SQL_PARAMS_NAMED);
} else {
list($in_roles, $param_roles) = $DB->get_in_or_equal(array_keys($roles), SQL_PARAMS_NAMED);
@ -150,7 +150,13 @@ if ($formdata and array_key_exists('role', $formdata)) {
$where[] = "ra.roleid {$in_roles}";
$where_params = $where_params + $param_roles;
list($in_instances, $param_instances) = $DB->get_in_or_equal(array_keys($instances), SQL_PARAMS_NAMED);
// Enrol instance filter
if (array_key_exists('instance', $formdata)) {
list($in_instances, $param_instances) = $DB->get_in_or_equal(array_keys($formdata->instance), SQL_PARAMS_NAMED);
} else {
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;

14
report_form.php

@ -36,11 +36,13 @@ class filter_form extends moodleform {
protected $_courseid;
protected $_filterfields;
protected $_roles;
protected $_instances;
function filter_form($courseid, $filterfields, $roles, $action=null, $customdata=null, $method='get', $target='', $attributes=null, $editable=true) {
function filter_form($courseid, $filterfields, $roles, $instances, $action=null, $customdata=null, $method='get', $target='', $attributes=null, $editable=true) {
$this->_filterfields = $filterfields;
$this->_courseid = $courseid;
$this->_roles = $roles;
$this->_instances = $instances;
parent::moodleform($action, $customdata, $method, $target, $attributes, $editable);
}
@ -51,6 +53,8 @@ class filter_form extends moodleform {
$courseid = $this->_courseid;
$filterfields = $this->_filterfields;
$roles = $this->_roles;
$instances = $this->_instances;
$plugins = enrol_get_plugins(false);
// User fields filter
$mform->addElement('text', 'email', get_string('email'));
@ -61,6 +65,14 @@ class filter_form extends moodleform {
$mform->addElement('checkbox', "role[{$role->id}]", $role->localname);
}
// Role instance filter
$mform->addElement('header', 'filter', get_string('enrolmentinstances', 'enrol'));
foreach ($instances as $instance) {
$plugin = $plugins[$instance->enrol];
$mform->addElement('checkbox', "instance[{$instance->id}]", $plugin->get_instance_name($instance));
}
// User fields
foreach ($filterfields as $field) {
$mform->addElement('header', $field->shortname, $field->name);
$options = explode("\n", $field->param1);

Loading…
Cancel
Save