Browse Source

Acrescentado filtro por função

master
Sesostris Vieira 11 years ago
parent
commit
dcdfc49ce3
  1. 54
      index.php
  2. 13
      report_form.php

54
index.php

@ -92,7 +92,6 @@ if ($group===0 && $course->groupmode==SEPARATEGROUPS) {
// Get data for user filtering // Get data for user filtering
$manager = new course_enrolment_manager($PAGE, $course); $manager = new course_enrolment_manager($PAGE, $course);
$mform = new filter_form($course->id, $filterfields);
$instances = $manager->get_enrolment_instances(); $instances = $manager->get_enrolment_instances();
$contextids = $context->get_parent_context_ids(true); $contextids = $context->get_parent_context_ids(true);
@ -106,6 +105,7 @@ if (!$role_confirmed or !$role_revoked) {
} }
$roles = array($role_confirmed=>$allroles[$role_confirmed], $role_revoked=>$allroles[$role_revoked]); $roles = array($role_confirmed=>$allroles[$role_confirmed], $role_revoked=>$allroles[$role_revoked]);
$mform = new filter_form($course->id, $filterfields, $roles);
// Generate where clause // Generate where clause
$where = array(); $where = array();
@ -134,6 +134,16 @@ if ($formdata = $mform->get_data()) {
} }
} }
// Role filter
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);
}
$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); 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_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); list($in_fields, $param_fields) = $DB->get_in_or_equal(array_keys($filterfields), SQL_PARAMS_NAMED);
@ -361,7 +371,7 @@ if ($total > ILBENROL_REPORT_PAGE) {
// Start of table // Start of table
if (!$csv) { if (!$csv) {
print '<br/>'; // ugh print '<br/>'; // ugh
echo $OUTPUT->box_start();
print $pagingbar; print $pagingbar;
if (!$total) { if (!$total) {
@ -486,32 +496,30 @@ print '</div>';
print $pagingbar; print $pagingbar;
// Bulk operations // Bulk operations
if (!$csv) { echo '<br /><div class="buttons">';
echo '<br /><div class="buttons">'; echo '<input type="button" id="checkall" value="'.get_string('selectall').'" /> ';
echo '<input type="button" id="checkall" value="'.get_string('selectall').'" /> '; echo '<input type="button" id="checknone" value="'.get_string('deselectall').'" /> ';
echo '<input type="button" id="checknone" value="'.get_string('deselectall').'" /> '; echo '</form>';
echo '</form>'; $module = array('name'=>'core_user', 'fullpath'=>'/user/module.js');
$module = array('name'=>'core_user', 'fullpath'=>'/user/module.js'); $PAGE->requires->js_init_call('M.core_user.init_participation', null, false, $module);
$PAGE->requires->js_init_call('M.core_user.init_participation', null, false, $module); $displaylist = array();
$displaylist = array(); $displaylist['confirmenrol'] = get_string('confirmenrol', 'report_ilbenrol');
$displaylist['confirmenrol'] = get_string('confirmenrol', 'report_ilbenrol'); $displaylist['revokeenrol'] = get_string('revokeenrol', 'report_ilbenrol');
$displaylist['revokeenrol'] = get_string('revokeenrol', 'report_ilbenrol'); echo $OUTPUT->help_icon('withselectedusers', 'report_ilbenrol');
echo $OUTPUT->help_icon('withselectedusers', 'report_ilbenrol'); echo html_writer::tag('label', get_string("withselectedusers"), array('for'=>'formactionid'));
echo html_writer::tag('label', get_string("withselectedusers"), array('for'=>'formactionid')); echo html_writer::select($displaylist, 'formaction', '', array(''=>'choosedots'), array('id'=>'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="id" value="'.$course->id.'" />'; echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; echo '<input type="hidden" name="returnto" value="'.s($PAGE->url->out(false)).'" />';
echo '<input type="hidden" name="returnto" value="'.s($PAGE->url->out(false)).'" />'; echo '<noscript style="display:inline">';
echo '<noscript style="display:inline">'; echo '<div><input type="submit" value="'.get_string('ok').'" /></div>';
echo '<div><input type="submit" value="'.get_string('ok').'" /></div>'; echo '</noscript>';
echo '</noscript>';
}
print '<ul class="progress-actions"><li><a href="index.php?course='.$course->id. print '<ul class="progress-actions"><li><a href="index.php?course='.$course->id.
'&amp;format=csv">'.get_string('csvdownload','completion').'</a></li> '&amp;format=csv">'.get_string('csvdownload','completion').'</a></li>
<li><a href="index.php?course='.$course->id.'&amp;format=excelcsv">'. <li><a href="index.php?course='.$course->id.'&amp;format=excelcsv">'.
get_string('excelcsvdownload','completion').'</a></li></ul>'; get_string('excelcsvdownload','completion').'</a></li></ul>';
echo $OUTPUT->box_end();
echo $OUTPUT->footer(); echo $OUTPUT->footer();

13
report_form.php

@ -35,10 +35,12 @@ require_once("$CFG->libdir/formslib.php");
class filter_form extends moodleform { class filter_form extends moodleform {
protected $_courseid; protected $_courseid;
protected $_filterfields; protected $_filterfields;
protected $_roles;
function filter_form($courseid, $filterfields, $action=null, $customdata=null, $method='get', $target='', $attributes=null, $editable=true) { function filter_form($courseid, $filterfields, $roles, $action=null, $customdata=null, $method='get', $target='', $attributes=null, $editable=true) {
$this->_filterfields = $filterfields; $this->_filterfields = $filterfields;
$this->_courseid = $courseid; $this->_courseid = $courseid;
$this->_roles = $roles;
parent::moodleform($action, $customdata, $method, $target, $attributes, $editable); parent::moodleform($action, $customdata, $method, $target, $attributes, $editable);
} }
@ -48,8 +50,13 @@ class filter_form extends moodleform {
$mform = $this->_form; // Don't forget the underscore! $mform = $this->_form; // Don't forget the underscore!
$courseid = $this->_courseid; $courseid = $this->_courseid;
$filterfields = $this->_filterfields; $filterfields = $this->_filterfields;
$roles = $this->_roles;
// $mform->addElement('header', 'filter', get_string('filter', 'report_ilbenrol')); // Role filter
$mform->addElement('header', 'filter', get_string('roles'));
foreach ($roles as $role) {
$mform->addElement('checkbox', "role[{$role->id}]", $role->localname);
}
foreach ($filterfields as $field) { foreach ($filterfields as $field) {
$mform->addElement('header', $field->shortname, $field->name); $mform->addElement('header', $field->shortname, $field->name);

Loading…
Cancel
Save