Compare commits

...

12 Commits

  1. 6
      .travis.yml
  2. 6
      absentee.php
  3. 6
      classes/structure.php
  4. 8
      coursesummary.php
  5. 4
      export.php
  6. 1
      lang/en/attendance.php
  7. 21
      locallib.php
  8. 16
      renderer.php

6
.travis.yml

@ -9,6 +9,9 @@ addons:
packages: packages:
- openjdk-8-jre-headless - openjdk-8-jre-headless
services:
- mysql
cache: cache:
directories: directories:
- $HOME/.composer/cache - $HOME/.composer/cache
@ -19,7 +22,7 @@ php:
env: env:
global: global:
- MOODLE_BRANCH=master - MOODLE_BRANCH=MOODLE_36_STABLE
- MUSTACHE_IGNORE_NAMES=mobile_teacher_form.mustache - MUSTACHE_IGNORE_NAMES=mobile_teacher_form.mustache
matrix: matrix:
- DB=pgsql - DB=pgsql
@ -32,6 +35,7 @@ before_install:
- cd ../.. - cd ../..
- composer create-project -n --no-dev --prefer-dist blackboard-open-source/moodle-plugin-ci ci ^2 - composer create-project -n --no-dev --prefer-dist blackboard-open-source/moodle-plugin-ci ci ^2
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH" - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
- PATH=$(echo "$PATH" | sed -e 's/:\/usr\/local\/lib\/jvm\/openjdk11\/bin//') JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
install: install:
- moodle-plugin-ci install - moodle-plugin-ci install

6
absentee.php

@ -101,6 +101,12 @@ $table->setup();
$sortcolumns = $table->get_sort_columns(); $sortcolumns = $table->get_sort_columns();
// Now do sorting if specified. // Now do sorting if specified.
// Sanity check $sort var before including in sql. Make sure it matches a known column.
$allowedsort = array_diff(array_keys($table->columns), $table->column_nosort);
if (!in_array($sort, $allowedsort)) {
$sort = '';
}
$orderby = ' ORDER BY percent ASC'; $orderby = ' ORDER BY percent ASC';
if (!empty($sort)) { if (!empty($sort)) {
$direction = ' DESC'; $direction = ' DESC';

6
classes/structure.php

@ -23,7 +23,9 @@
*/ */
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
global $CFG; // This class is included inside existing functions.
require_once(dirname(__FILE__) . '/calendar_helpers.php'); require_once(dirname(__FILE__) . '/calendar_helpers.php');
require_once($CFG->libdir .'/filelib.php');
/** /**
* Main class with all Attendance related info. * Main class with all Attendance related info.
@ -806,7 +808,7 @@ class mod_attendance_structure {
$groups = $groupid; $groups = $groupid;
} }
$users = get_users_by_capability($this->context, 'mod/attendance:canbelisted', $users = get_users_by_capability($this->context, 'mod/attendance:canbelisted',
$userfields.',u.id, u.firstname, u.lastname, u.email', $userfields,
$orderby, $startusers, $usersperpage, $groups, $orderby, $startusers, $usersperpage, $groups,
'', false, true); '', false, true);
} else { } else {
@ -822,7 +824,7 @@ class mod_attendance_structure {
$groups = $groupid; $groups = $groupid;
} }
$users = get_users_by_capability($this->context, 'mod/attendance:canbelisted', $users = get_users_by_capability($this->context, 'mod/attendance:canbelisted',
$userfields.',u.id, u.firstname, u.lastname, u.email', $userfields,
$orderby, '', '', $groups, $orderby, '', '', $groups,
'', false, true); '', false, true);
} else { } else {

8
coursesummary.php

@ -94,8 +94,14 @@ $table->setup();
// Work out direction of sort required. // Work out direction of sort required.
$sortcolumns = $table->get_sort_columns(); $sortcolumns = $table->get_sort_columns();
// Now do sorting if specified.
// Sanity check $sort var before including in sql. Make sure it matches a known column.
$allowedsort = array_diff(array_keys($table->columns), $table->column_nosort);
if (!in_array($sort, $allowedsort)) {
$sort = '';
}
// Now do sorting if specified.
$orderby = ' ORDER BY percentage ASC'; $orderby = ' ORDER BY percentage ASC';
if (!empty($sort)) { if (!empty($sort)) {
$direction = ' DESC'; $direction = ' DESC';

4
export.php

@ -79,7 +79,9 @@ if ($formdata = $mform->get_data()) {
$reportdata = new attendance_report_data($att); $reportdata = new attendance_report_data($att);
if ($reportdata->users) { if ($reportdata->users) {
$filename = clean_filename($course->shortname.'_Attendances_'.userdate(time(), '%Y%m%d-%H%M')); $filename = clean_filename($course->shortname.'_'.
get_string('modulenameplural', 'attendance').
'_'.userdate(time(), '%Y%m%d-%H%M'));
$group = $formdata->group ? $reportdata->groups[$formdata->group] : 0; $group = $formdata->group ? $reportdata->groups[$formdata->group] : 0;
$data = new stdClass; $data = new stdClass;

1
lang/en/attendance.php

@ -332,6 +332,7 @@ $string['oversessionstaken_help'] = 'Shows statistics for sessions where attenda
<li><strong>Points</strong>: points awarded based on the taken sessions.</li> <li><strong>Points</strong>: points awarded based on the taken sessions.</li>
<li><strong>Percentage</strong>: percentage of points awarded over the maxium possible points of the taken sessions.</li> <li><strong>Percentage</strong>: percentage of points awarded over the maxium possible points of the taken sessions.</li>
</ul>'; </ul>';
$string['pageof'] = 'Page {$a->page} of {$a->numpages}';
$string['participant'] = 'Participant'; $string['participant'] = 'Participant';
$string['password'] = 'Password'; $string['password'] = 'Password';
$string['enterpassword'] = 'Enter password'; $string['enterpassword'] = 'Enter password';

21
locallib.php

@ -177,12 +177,21 @@ function attendance_form_sessiondate_selector (MoodleQuickForm $mform) {
} }
$sesendtime = array(); $sesendtime = array();
if (!right_to_left()) {
$sesendtime[] =& $mform->createElement('static', 'from', '', get_string('from', 'attendance')); $sesendtime[] =& $mform->createElement('static', 'from', '', get_string('from', 'attendance'));
$sesendtime[] =& $mform->createElement('select', 'starthour', get_string('hour', 'form'), $hours, false, true); $sesendtime[] =& $mform->createElement('select', 'starthour', get_string('hour', 'form'), $hours, false, true);
$sesendtime[] =& $mform->createElement('select', 'startminute', get_string('minute', 'form'), $minutes, false, true); $sesendtime[] =& $mform->createElement('select', 'startminute', get_string('minute', 'form'), $minutes, false, true);
$sesendtime[] =& $mform->createElement('static', 'to', '', get_string('to', 'attendance')); $sesendtime[] =& $mform->createElement('static', 'to', '', get_string('to', 'attendance'));
$sesendtime[] =& $mform->createElement('select', 'endhour', get_string('hour', 'form'), $hours, false, true); $sesendtime[] =& $mform->createElement('select', 'endhour', get_string('hour', 'form'), $hours, false, true);
$sesendtime[] =& $mform->createElement('select', 'endminute', get_string('minute', 'form'), $minutes, false, true); $sesendtime[] =& $mform->createElement('select', 'endminute', get_string('minute', 'form'), $minutes, false, true);
} else {
$sesendtime[] =& $mform->createElement('static', 'from', '', get_string('from', 'attendance'));
$sesendtime[] =& $mform->createElement('select', 'startminute', get_string('minute', 'form'), $minutes, false, true);
$sesendtime[] =& $mform->createElement('select', 'starthour', get_string('hour', 'form'), $hours, false, true);
$sesendtime[] =& $mform->createElement('static', 'to', '', get_string('to', 'attendance'));
$sesendtime[] =& $mform->createElement('select', 'endminute', get_string('minute', 'form'), $minutes, false, true);
$sesendtime[] =& $mform->createElement('select', 'endhour', get_string('hour', 'form'), $hours, false, true);
}
$mform->addGroup($sesendtime, 'sestime', get_string('time', 'attendance'), array(' '), true); $mform->addGroup($sesendtime, 'sestime', get_string('time', 'attendance'), array(' '), true);
} }
@ -458,7 +467,7 @@ function attendance_can_student_mark($sess, $log = true) {
$record = $DB->get_record_select('attendance_log', $sql, $params); $record = $DB->get_record_select('attendance_log', $sql, $params);
} else { } else {
// Assume ATTENDANCE_SHAREDIP_FORCED. // Assume ATTENDANCE_SHAREDIP_FORCED.
$sql = 'sessionid = ? AND studentid <> ? ipaddress = ?'; $sql = 'sessionid = ? AND studentid <> ? AND ipaddress = ?';
$params = array($sess->id, $USER->id, getremoteaddr()); $params = array($sess->id, $USER->id, getremoteaddr());
$record = $DB->get_record_select('attendance_log', $sql, $params); $record = $DB->get_record_select('attendance_log', $sql, $params);
} }
@ -509,7 +518,7 @@ function attendance_exporttotableed($data, $filename, $format) {
// Sending HTTP headers. // Sending HTTP headers.
$workbook->send($filename); $workbook->send($filename);
// Creating the first worksheet. // Creating the first worksheet.
$myxls = $workbook->add_worksheet('Attendances'); $myxls = $workbook->add_worksheet(get_string('modulenameplural', 'attendance'));
// Format types. // Format types.
$formatbc = $workbook->add_format(); $formatbc = $workbook->add_format();
$formatbc->set_bold(1); $formatbc->set_bold(1);
@ -695,7 +704,13 @@ function attendance_construct_sessions_data_for_add($formdata, mod_attendance_st
} }
} else { } else {
$sess = new stdClass(); $sess = new stdClass();
$sess->sessdate = $sessiondate; $sess->sessdate = make_timestamp(
date("Y", $formdata->sessiondate),
date("m", $formdata->sessiondate),
date("d", $formdata->sessiondate),
$formdata->sestime['starthour'],
$formdata->sestime['startminute']
);
$sess->duration = $duration; $sess->duration = $duration;
$sess->descriptionitemid = $formdata->sdescription['itemid']; $sess->descriptionitemid = $formdata->sdescription['itemid'];
$sess->description = $formdata->sdescription['text']; $sess->description = $formdata->sdescription['text'];

16
renderer.php

@ -129,7 +129,11 @@ class mod_attendance_renderer extends plugin_renderer_base {
'page' => $fcontrols->pageparams->page - 1)), 'page' => $fcontrols->pageparams->page - 1)),
$this->output->larrow()); $this->output->larrow());
} }
$pagingcontrols .= html_writer::tag('span', "Page {$fcontrols->pageparams->page} of $numberofpages", $a = new stdClass();
$a->page = $fcontrols->pageparams->page;
$a->numpages = $numberofpages;
$text = get_string('pageof', 'attendance', $a);
$pagingcontrols .= html_writer::tag('span', $text,
array('class' => 'attbtn')); array('class' => 'attbtn'));
if ($fcontrols->pageparams->page < $numberofpages) { if ($fcontrols->pageparams->page < $numberofpages) {
$pagingcontrols .= html_writer::link($fcontrols->url(array('curdate' => $fcontrols->curdate, $pagingcontrols .= html_writer::link($fcontrols->url(array('curdate' => $fcontrols->curdate,
@ -253,8 +257,8 @@ class mod_attendance_renderer extends plugin_renderer_base {
$table->width = '100%'; $table->width = '100%';
$table->head = array( $table->head = array(
'#', '#',
get_string('date'), get_string('date', 'attendance'),
get_string('time'), get_string('time', 'attendance'),
get_string('sessiontypeshort', 'attendance'), get_string('sessiontypeshort', 'attendance'),
get_string('description', 'attendance'), get_string('description', 'attendance'),
get_string('actions'), get_string('actions'),
@ -532,7 +536,11 @@ class mod_attendance_renderer extends plugin_renderer_base {
$controls .= html_writer::link($takedata->url(array('page' => $takedata->pageparams->page - 1)), $controls .= html_writer::link($takedata->url(array('page' => $takedata->pageparams->page - 1)),
$this->output->larrow()); $this->output->larrow());
} }
$controls .= html_writer::tag('span', "Page {$takedata->pageparams->page} of $numberofpages", $a = new stdClass();
$a->page = $takedata->pageparams->page;
$a->numpages = $numberofpages;
$text = get_string('pageof', 'attendance', $a);
$controls .= html_writer::tag('span', $text,
array('class' => 'attbtn')); array('class' => 'attbtn'));
if ($takedata->pageparams->page < $numberofpages) { if ($takedata->pageparams->page < $numberofpages) {
$controls .= html_writer::link($takedata->url(array('page' => $takedata->pageparams->page + 1, $controls .= html_writer::link($takedata->url(array('page' => $takedata->pageparams->page + 1,

Loading…
Cancel
Save