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. 28
      locallib.php
  5. 15
      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 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 {
$groups = groups_get_all_groups($course->id);
$groups = groups_get_all_groups($course->id, 0, $cm->groupingid);
}
if ($groups) {
$selectgroups = array();

3
lang/en/attendance.php

@ -96,6 +96,7 @@ $string['displaymode'] = 'Display mode';
$string['downloadexcel'] = 'Download in Excel format';
$string['downloadooo'] = 'Download in OpenOffice format';
$string['downloadtext'] = 'Download in text format';
$string['donotusepaging'] = 'Do not use paging';
$string['duration'] = 'Duration';
$string['editsession'] = 'Edit Session';
$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['resetstatuses'] = 'Reset statuses to default';
$string['restoredefaults'] = 'Restore defaults';
$string['resultsperpage'] = 'Results per page';
$string['resultsperpage_desc'] = 'Number of students displayed on a page';
$string['save'] = 'Save attendance';
$string['session'] = 'Session';
$string['session_help'] = 'Session';

8
lib.php

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

28
locallib.php

@ -913,7 +913,7 @@ class attendance {
* MDL-27591 made this method obsolete.
*/
public function get_users($groupid = 0, $page = 1) {
global $DB;
global $DB, $CFG;
// Fields we need from the user table.
$userfields = user_picture::fields('u').',u.username';
@ -925,13 +925,37 @@ class attendance {
}
if ($page) {
$totalusers = count_enrolled_users($this->context, 'mod/attendance:canbelisted', $groupid);
$usersperpage = $this->pageparams->perpage;
if (!empty($CFG->enablegroupmembersonly) and $this->cm->groupmembersonly) {
$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 {
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.
if (!empty($users)) {

15
renderer.php

@ -348,6 +348,8 @@ class mod_attendance_renderer extends plugin_renderer_base {
}
private function construct_take_controls(attendance_take_data $takedata) {
GLOBAL $CFG;
$controls = '';
$group = 0;
@ -359,7 +361,20 @@ class mod_attendance_renderer extends plugin_renderer_base {
}
}
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;
if (!empty($takedata->pageparams->page) && $takedata->pageparams->page && $totalusers && $usersperpage) {
$controls .= html_writer::empty_tag('br');

Loading…
Cancel
Save