Browse Source

Fix behat/coding guideline issues.

MOODLE_29_STABLE
Dan Marsden 9 years ago
parent
commit
1e54d10bd0
  1. 10
      calendar.js
  2. 2
      db/upgrade.php
  3. 5
      export_form.php
  4. 14
      renderer.php
  5. 6
      tests/behat/attendance_mod.feature
  6. 104
      tests/behat/attendance_taken_by_student.php
  7. 18
      tests/behat/extra_features.feature

10
calendar.js

@ -26,7 +26,7 @@ YUI().use('yui2-container', 'yui2-calendar', function(Y) {
// until the first time the button is clicked. // until the first time the button is clicked.
if (!dialog) { if (!dialog) {
// Hide Calendar if we click anywhere in the document other than the calendar // Hide Calendar if we click anywhere in the document other than the calendar.
Event.on(document, "click", function(e) { Event.on(document, "click", function(e) {
var el = Event.getTarget(e); var el = Event.getTarget(e);
var dialogEl = dialog.element; var dialogEl = dialog.element;
@ -51,7 +51,7 @@ YUI().use('yui2-container', 'yui2-calendar', function(Y) {
if (YAHOO.env.ua.ie) { if (YAHOO.env.ua.ie) {
// Since we're hiding the table using yui-overlay-hidden, we // Since we're hiding the table using yui-overlay-hidden, we
// want to let the dialog know that the content size has changed, when // want to let the dialog know that the content size has changed, when
// shown // shown.
dialog.fireEvent("changeContent"); dialog.fireEvent("changeContent");
} }
}); });
@ -62,7 +62,7 @@ YUI().use('yui2-container', 'yui2-calendar', function(Y) {
calendar = new YAHOO.widget.Calendar("cal", { calendar = new YAHOO.widget.Calendar("cal", {
iframe:false, // Turn iframe off, since container has iframe support. iframe:false, // Turn iframe off, since container has iframe support.
hide_blank_weeks:true // Enable, to demonstrate how we handle changing height, using changeContent hide_blank_weeks:true // Enable, to demonstrate how we handle changing height, using changeContent.
}); });
calendar.cfg.setProperty("start_weekday", M.attendance.cal_start_weekday); calendar.cfg.setProperty("start_weekday", M.attendance.cal_start_weekday);
@ -83,7 +83,7 @@ YUI().use('yui2-container', 'yui2-calendar', function(Y) {
calendar.renderEvent.subscribe(function() { calendar.renderEvent.subscribe(function() {
// Tell Dialog it's contents have changed, which allows // Tell Dialog it's contents have changed, which allows
// container to redraw the underlay (for IE6/Safari2) // container to redraw the underlay (for IE6/Safari2).
dialog.fireEvent("changeContent"); dialog.fireEvent("changeContent");
}); });
} }
@ -91,7 +91,7 @@ YUI().use('yui2-container', 'yui2-calendar', function(Y) {
var seldate = calendar.getSelectedDates(); var seldate = calendar.getSelectedDates();
if (seldate.length > 0) { if (seldate.length > 0) {
// Set the pagedate to show the selected date if it exists // Set the pagedate to show the selected date if it exists.
calendar.cfg.setProperty("pagedate", seldate[0]); calendar.cfg.setProperty("pagedate", seldate[0]);
calendar.render(); calendar.render();
} }

2
db/upgrade.php

@ -29,7 +29,7 @@
*/ */
function xmldb_attendance_upgrade($oldversion=0) { function xmldb_attendance_upgrade($oldversion=0) {
global $CFG, $THEME, $DB; global $DB;
$dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
$result = true; $result = true;

5
export_form.php

@ -38,10 +38,8 @@ class mod_attendance_export_form extends moodleform {
* @return void * @return void
*/ */
public function definition() { public function definition() {
global $USER, $DB, $PAGE; global $USER, $DB, $PAGE;
$mform =& $this->_form; $mform =& $this->_form;
$course = $this->_customdata['course']; $course = $this->_customdata['course'];
$cm = $this->_customdata['cm']; $cm = $this->_customdata['cm'];
$modcontext = $this->_customdata['modcontext']; $modcontext = $this->_customdata['modcontext'];
@ -130,8 +128,7 @@ class mod_attendance_export_form extends moodleform {
$mform->addElement('select', 'format', get_string('format'), $mform->addElement('select', 'format', get_string('format'),
array('excel' => get_string('downloadexcel', 'attendance'), array('excel' => get_string('downloadexcel', 'attendance'),
'ooo' => get_string('downloadooo', 'attendance'), 'ooo' => get_string('downloadooo', 'attendance'),
'text' => get_string('downloadtext', 'attendance') 'text' => get_string('downloadtext', 'attendance')));
));
$submitstring = get_string('ok'); $submitstring = get_string('ok');
$this->add_action_buttons(false, $submitstring); $this->add_action_buttons(false, $submitstring);

14
renderer.php

@ -234,8 +234,8 @@ class mod_attendance_renderer extends plugin_renderer_base {
$dta = $this->construct_date_time_actions($sessdata, $sess); $dta = $this->construct_date_time_actions($sessdata, $sess);
$table->data[$sess->id][] = $i; $table->data[$sess->id][] = $i;
$table->data[$sess->id][] = $sess->groupid ? get_string('group') . ': ' . $sessdata->groups[$sess->groupid]->name : $table->data[$sess->id][] = $sess->groupid ? get_string('group') . ': ' . $sessdata->groups[$sess->groupid]->name
get_string('commonsession', 'attendance'); : get_string('commonsession', 'attendance');
$table->data[$sess->id][] = $dta['date']; $table->data[$sess->id][] = $dta['date'];
$table->data[$sess->id][] = $dta['time']; $table->data[$sess->id][] = $dta['time'];
$table->data[$sess->id][] = $sess->description; $table->data[$sess->id][] = $sess->description;
@ -770,8 +770,8 @@ class mod_attendance_renderer extends plugin_renderer_base {
$row = new html_table_row(); $row = new html_table_row();
$row->cells[] = $i; $row->cells[] = $i;
$sessiontypeshort = $sess->groupid ? get_string('group') . ': ' . $userdata->groups[$sess->groupid]->name : $sessiontypeshort = $sess->groupid ? get_string('group') . ': ' . $userdata->groups[$sess->groupid]->name
get_string('commonsession', 'attendance'); : get_string('commonsession', 'attendance');
$row->cells[] = html_writer::tag('nobr', $sessiontypeshort); $row->cells[] = html_writer::tag('nobr', $sessiontypeshort);
$row->cells[] = userdate($sess->sessdate, get_string('strftimedmyw', 'attendance')); $row->cells[] = userdate($sess->sessdate, get_string('strftimedmyw', 'attendance'));
$row->cells[] = $this->construct_time($sess->sessdate, $sess->duration); $row->cells[] = $this->construct_time($sess->sessdate, $sess->duration);
@ -850,7 +850,8 @@ class mod_attendance_renderer extends plugin_renderer_base {
$sesstext = html_writer::link($reportdata->url_take($sess->id, $sess->groupid), $sesstext); $sesstext = html_writer::link($reportdata->url_take($sess->id, $sess->groupid), $sesstext);
} }
$sesstext .= html_writer::empty_tag('br'); $sesstext .= html_writer::empty_tag('br');
$sesstext .= $sess->groupid ? get_string('group') . ': ' . $reportdata->groups[$sess->groupid]->name : get_string('commonsession', 'attendance'); $sesstext .= $sess->groupid ? get_string('group') . ': ' . $reportdata->groups[$sess->groupid]->name
: get_string('commonsession', 'attendance');
$table->head[] = $sesstext; $table->head[] = $sesstext;
$table->align[] = 'center'; $table->align[] = 'center';
@ -899,7 +900,8 @@ class mod_attendance_renderer extends plugin_renderer_base {
} }
if ($bulkmessagecapability) { // Create the checkbox for bulk messaging. if ($bulkmessagecapability) { // Create the checkbox for bulk messaging.
$row->cells[] = html_writer::checkbox('user'.$user->id, 'on', false, '', array('class' => 'attendancesesscheckbox')); $row->cells[] = html_writer::checkbox('user'.$user->id, 'on', false, '',
array('class' => 'attendancesesscheckbox'));
} }
$table->data[] = $row; $table->data[] = $row;

6
tests/behat/attendance_mod.feature

@ -38,7 +38,7 @@ Feature: Teachers and Students can record session attendance
And I follow "Add" And I follow "Add"
And I set the field "Allow students to record own attendance" to "1" And I set the field "Allow students to record own attendance" to "1"
And I set the following fields to these values: And I set the following fields to these values:
| id_sessiondate_hour | 23 | | id_sestime_starthour | 23 |
And I click on "id_submitbutton" "button" And I click on "id_submitbutton" "button"
And I log out And I log out
When I log in as "student1" When I log in as "student1"
@ -62,7 +62,7 @@ Feature: Teachers and Students can record session attendance
And I follow "Attendance" And I follow "Attendance"
And I follow "Add" And I follow "Add"
And I set the following fields to these values: And I set the following fields to these values:
| id_sessiondate_hour | 01 | | id_sestime_starthour | 01 |
And I click on "id_submitbutton" "button" And I click on "id_submitbutton" "button"
And I follow "Report" And I follow "Report"
And I follow "Low grade" And I follow "Low grade"
@ -81,7 +81,7 @@ Feature: Teachers and Students can record session attendance
And I follow "Attendance" And I follow "Attendance"
And I follow "Add" And I follow "Add"
And I set the following fields to these values: And I set the following fields to these values:
| id_sessiondate_hour | 01 | | id_sestime_starthour | 01 |
And I click on "id_submitbutton" "button" And I click on "id_submitbutton" "button"
And I follow "Export" And I follow "Export"
Then the field "id_ident_idnumber" matches value "" Then the field "id_ident_idnumber" matches value ""

104
tests/behat/attendance_taken_by_student.php

@ -1,104 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains an event for when an attendance is taken.
*
* @package mod_attendance
* @copyright 2014 onwards Dan Marsden
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_attendance\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event for when an attendance is taken.
*
* @property-read array $other {
* Extra information about event properties.
*
* string mode Mode of the report viewed.
* }
* @package mod_attendance
* @since Moodle 2.7
* @copyright 2013 onwards Dan Marsden
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class attendance_taken_by_student extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'attendance';
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return 'Student with id ' . $this->userid . ' took attendance with instanceid ' .
$this->objectid;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventtakenbystudent', 'mod_attendance');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/attendance/take.php', array('id' => $this->contextinstanceid,
'sessionid' => $this->other['sessionid'],
'grouptype' => $this->other['grouptype']));
}
/**
* Replace add_to_log() statement.
*
* @return array of parameters to be passed to legacy add_to_log() function.
*/
protected function get_legacy_logdata() {
return array($this->courseid, 'attendance', 'taken', $this->get_url(),
'', $this->contextinstanceid);
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
if (empty($this->other['sessionid'])) {
throw new \coding_exception('The event mod_attendance\\event\\attendance_taken must specify sessionid.');
}
parent::validate_data();
}
}

18
tests/behat/extra_features.feature

@ -74,7 +74,7 @@ Feature: Test the various new features in the attendance module
And I follow "Add" And I follow "Add"
And I set the following fields to these values: And I set the following fields to these values:
| Create multiple sessions | 0 | | id_addmultiply | 0 |
And I click on "submitbutton" "button" And I click on "submitbutton" "button"
When I follow "Take attendance" When I follow "Take attendance"
@ -127,7 +127,7 @@ Feature: Test the various new features in the attendance module
And I follow "Test attendance" And I follow "Test attendance"
And I follow "Add" And I follow "Add"
And I set the following fields to these values: And I set the following fields to these values:
| Create multiple sessions | 0 | | id_addmultiply | 0 |
And I click on "submitbutton" "button" And I click on "submitbutton" "button"
And I follow "Export" And I follow "Export"
@ -166,17 +166,17 @@ Feature: Test the various new features in the attendance module
And I follow "Add" And I follow "Add"
And I set the following fields to these values: And I set the following fields to these values:
| Create multiple sessions | 0 | | id_addmultiply | 0 |
| Use status set | Status set 1 (P L E A) | | Use status set | Status set 1 (P L E A) |
| id_sessiondate_hour | 10 | | id_sestime_starthour | 10 |
| id_sessiondate_minute | 0 | | id_sestime_startminute | 0 |
And I click on "submitbutton" "button" And I click on "submitbutton" "button"
And I follow "Add" And I follow "Add"
And I set the following fields to these values: And I set the following fields to these values:
| Create multiple sessions | 0 | | id_addmultiply | 0 |
| Use status set | Status set 2 (G O B) | | Use status set | Status set 2 (G O B) |
| id_sessiondate_hour | 11 | | id_sestime_starthour | 11 |
| id_sessiondate_minute | 0 | | id_sestime_startminute | 0 |
And I click on "submitbutton" "button" And I click on "submitbutton" "button"
When I click on "Take attendance" "link" in the "10:00" "table_row" When I click on "Take attendance" "link" in the "10:00" "table_row"
@ -197,7 +197,7 @@ Feature: Test the various new features in the attendance module
And I follow "Test attendance" And I follow "Test attendance"
And I follow "Add" And I follow "Add"
And I set the following fields to these values: And I set the following fields to these values:
| Create multiple sessions | 0 | | id_addmultiply | 0 |
And I click on "submitbutton" "button" And I click on "submitbutton" "button"
And I click on "Take attendance" "link" And I click on "Take attendance" "link"

Loading…
Cancel
Save