Browse Source

Merge pull request #17 from cedict/master

Fix missing language strings and enable groupings
MOODLE_26_STABLE
Dan Marsden 11 years ago
parent
commit
8f0afa1be8
  1. 4
      add_form.php
  2. 3
      lang/en/attendance.php
  3. 8
      lib.php
  4. 34
      locallib.php
  5. 17
      renderer.php

4
add_form.php

@ -78,9 +78,9 @@ class mod_attendance_add_form extends moodleform {
} }
if ($groupmode == SEPARATEGROUPS or $groupmode == VISIBLEGROUPS) { if ($groupmode == SEPARATEGROUPS or $groupmode == VISIBLEGROUPS) {
if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $modcontext)) { if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $modcontext)) {
$groups = groups_get_all_groups ($course->id, $USER->id); $groups = groups_get_all_groups ($course->id, $USER->id, $cm->groupingid);
} else { } else {
$groups = groups_get_all_groups($course->id); $groups = groups_get_all_groups($course->id, 0, $cm->groupingid);
} }
if ($groups) { if ($groups) {
$selectgroups = array(); $selectgroups = array();

3
lang/en/attendance.php

@ -96,6 +96,7 @@ $string['displaymode'] = 'Display mode';
$string['downloadexcel'] = 'Download in Excel format'; $string['downloadexcel'] = 'Download in Excel format';
$string['downloadooo'] = 'Download in OpenOffice format'; $string['downloadooo'] = 'Download in OpenOffice format';
$string['downloadtext'] = 'Download in text format'; $string['downloadtext'] = 'Download in text format';
$string['donotusepaging'] = 'Do not use paging';
$string['duration'] = 'Duration'; $string['duration'] = 'Duration';
$string['editsession'] = 'Edit Session'; $string['editsession'] = 'Edit Session';
$string['endtime'] = 'Session end time'; $string['endtime'] = 'Session end time';
@ -158,6 +159,8 @@ $string['required'] = 'Required*';
$string['resetdescription'] = 'Remember that deleting attendance data will erase information from database. You can just hide older sessions having changed start date of course!'; $string['resetdescription'] = 'Remember that deleting attendance data will erase information from database. You can just hide older sessions having changed start date of course!';
$string['resetstatuses'] = 'Reset statuses to default'; $string['resetstatuses'] = 'Reset statuses to default';
$string['restoredefaults'] = 'Restore defaults'; $string['restoredefaults'] = 'Restore defaults';
$string['resultsperpage'] = 'Results per page';
$string['resultsperpage_desc'] = 'Number of students displayed on a page';
$string['save'] = 'Save attendance'; $string['save'] = 'Save attendance';
$string['session'] = 'Session'; $string['session'] = 'Session';
$string['session_help'] = 'Session'; $string['session_help'] = 'Session';

8
lib.php

@ -35,14 +35,10 @@ function attendance_supports($feature) {
return true; return true;
case FEATURE_GROUPS: case FEATURE_GROUPS:
return true; return true;
// Artem Andreev: AFAIK it's not tested
// we need implement filtration of groups list by grouping.
case FEATURE_GROUPINGS: case FEATURE_GROUPINGS:
return false; return true;
// Artem Andreev: AFAIK it's not tested
// harder "All courses" report.
case FEATURE_GROUPMEMBERSONLY: case FEATURE_GROUPMEMBERSONLY:
return false; return true;
case FEATURE_MOD_INTRO: case FEATURE_MOD_INTRO:
return false; return false;
case FEATURE_BACKUP_MOODLE2: case FEATURE_BACKUP_MOODLE2:

34
locallib.php

@ -913,7 +913,7 @@ class attendance {
* MDL-27591 made this method obsolete. * MDL-27591 made this method obsolete.
*/ */
public function get_users($groupid = 0, $page = 1) { public function get_users($groupid = 0, $page = 1) {
global $DB; global $DB, $CFG;
// Fields we need from the user table. // Fields we need from the user table.
$userfields = user_picture::fields('u').',u.username'; $userfields = user_picture::fields('u').',u.username';
@ -925,12 +925,36 @@ class attendance {
} }
if ($page) { if ($page) {
$totalusers = count_enrolled_users($this->context, 'mod/attendance:canbelisted', $groupid);
$usersperpage = $this->pageparams->perpage; $usersperpage = $this->pageparams->perpage;
$startusers = ($page - 1) * $usersperpage; if (!empty($CFG->enablegroupmembersonly) and $this->cm->groupmembersonly) {
$users = get_enrolled_users($this->context, 'mod/attendance:canbelisted', $groupid, $userfields, $orderby, $startusers, $usersperpage); $startusers = ($page - 1) * $usersperpage;
if ($groupid == 0) {
$groups = array_keys(groups_get_all_groups($this->cm->course, 0, $this->cm->groupingid, 'g.id'));
} else {
$groups = $groupid;
}
$users = get_users_by_capability($this->context, 'mod/attendance:canbelisted',
$userfields.',u.id, u.firstname, u.lastname, u.email',
$orderby, $startusers, $usersperpage, $groups,
'', false, true);
} else {
$startusers = ($page - 1) * $usersperpage;
$users = get_enrolled_users($this->context, 'mod/attendance:canbelisted', $groupid, $userfields, $orderby, $startusers, $usersperpage);
}
} else { } else {
$users = get_enrolled_users($this->context, 'mod/attendance:canbelisted', $groupid, $userfields, $orderby); if (!empty($CFG->enablegroupmembersonly) and $this->cm->groupmembersonly) {
if ($groupid == 0) {
$groups = array_keys(groups_get_all_groups($this->cm->course, 0, $this->cm->groupingid, 'g.id'));
} else {
$groups = $groupid;
}
$users = get_users_by_capability($this->context, 'mod/attendance:canbelisted',
$userfields.',u.id, u.firstname, u.lastname, u.email',
$orderby, '', '', $groups,
'', false, true);
} else {
$users = get_enrolled_users($this->context, 'mod/attendance:canbelisted', $groupid, $userfields, $orderby);
}
} }
// Add a flag to each user indicating whether their enrolment is active. // Add a flag to each user indicating whether their enrolment is active.

17
renderer.php

@ -348,6 +348,8 @@ class mod_attendance_renderer extends plugin_renderer_base {
} }
private function construct_take_controls(attendance_take_data $takedata) { private function construct_take_controls(attendance_take_data $takedata) {
GLOBAL $CFG;
$controls = ''; $controls = '';
$group = 0; $group = 0;
@ -359,7 +361,20 @@ class mod_attendance_renderer extends plugin_renderer_base {
} }
} }
$totalusers = count_enrolled_users(get_context_instance(CONTEXT_MODULE, $takedata->cm->id), 'mod/attendance:canbelisted', $group); if (!empty($CFG->enablegroupmembersonly) and $takedata->cm->groupmembersonly) {
if ($group == 0) {
$groups = array_keys(groups_get_all_groups($takedata->cm->course, 0, $takedata->cm->groupingid, 'g.id'));
} else {
$groups = $group;
}
$users = get_users_by_capability(get_context_instance(CONTEXT_MODULE, $takedata->cm->id), 'mod/attendance:canbelisted',
'u.id, u.firstname, u.lastname, u.email',
'', '', '', $groups,
'', false, true);
$totalusers = count($users);
} else {
$totalusers = count_enrolled_users(get_context_instance(CONTEXT_MODULE, $takedata->cm->id), 'mod/attendance:canbelisted', $group);
}
$usersperpage = $takedata->pageparams->perpage; $usersperpage = $takedata->pageparams->perpage;
if (!empty($takedata->pageparams->page) && $takedata->pageparams->page && $totalusers && $usersperpage) { if (!empty($takedata->pageparams->page) && $takedata->pageparams->page && $totalusers && $usersperpage) {
$controls .= html_writer::empty_tag('br'); $controls .= html_writer::empty_tag('br');

Loading…
Cancel
Save