Neill Magill
11 years ago
2 changed files with 221 additions and 0 deletions
@ -0,0 +1,105 @@ |
|||||
|
@mod @uon @mod_attendance |
||||
|
Feature: Teachers and Students can record session attendance |
||||
|
In order to record session attendance |
||||
|
As a student |
||||
|
I need to be able to mark my own attendance to a session |
||||
|
And as a teacher |
||||
|
I need to be able to mark any students attendance to a session |
||||
|
In order to report on session attendance |
||||
|
As a teacher |
||||
|
I need to be able to export session attendance and run reports |
||||
|
In order to contact students with poor attendance |
||||
|
As a teacher |
||||
|
I need the ability to message a group of students with low attendance |
||||
|
|
||||
|
Background: |
||||
|
Given the following "courses" exist: |
||||
|
| fullname | shortname | summary | category | |
||||
|
| Course 1 | C101 | Prove the attendance activity works | 0 | |
||||
|
And the following "users" exist: |
||||
|
| username | firstname | lastname | email | idnumber | department | institution | |
||||
|
| student1 | Sam | Student | student1@asd.com | 1234 | computer science | University of Nottingham | |
||||
|
| teacher1 | Teacher | One | teacher1@asd.com | 5678 | computer science | University of Nottingham | |
||||
|
And the following "course enrolments" exist: |
||||
|
| user | course | role | |
||||
|
| student1 | C101 | student | |
||||
|
| teacher1 | C101 | editingteacher | |
||||
|
And I log in as "teacher1" |
||||
|
And I follow "Course 1" |
||||
|
And I turn editing mode on |
||||
|
And I add a "Attendance" to section "1" |
||||
|
And I press "Save and display" |
||||
|
And I log out |
||||
|
|
||||
|
Scenario: Students can mark their own attendance |
||||
|
When I log in as "teacher1" |
||||
|
And I follow "Course 1" |
||||
|
And I follow "Attendance" |
||||
|
And I follow "Add" |
||||
|
And I check "Allow students to record own attendance" |
||||
|
And I set the following fields to these values: |
||||
|
| id_sessiondate_hour | 23 | |
||||
|
And I click on "id_submitbutton" "button" |
||||
|
And I follow "Continue" |
||||
|
And I log out |
||||
|
When I log in as "student1" |
||||
|
And I follow "Course 1" |
||||
|
And I follow "Attendance" |
||||
|
And I follow "Submit attendance" |
||||
|
And I check "Present" |
||||
|
And I press "Save changes" |
||||
|
Then I should see "Self-recorded" |
||||
|
And I log out |
||||
|
When I log in as "teacher1" |
||||
|
And I follow "Course 1" |
||||
|
And I expand "Reports" node |
||||
|
And I follow "Logs" |
||||
|
And I click on "Get these logs" "button" |
||||
|
Then "attendance taken by student" "link" should exist |
||||
|
|
||||
|
Scenario: Teachers can view low grade report and send a message |
||||
|
When I log in as "teacher1" |
||||
|
And I follow "Course 1" |
||||
|
And I follow "Attendance" |
||||
|
And I follow "Add" |
||||
|
And I set the following fields to these values: |
||||
|
| id_sessiondate_hour | 01 | |
||||
|
And I click on "id_submitbutton" "button" |
||||
|
And I follow "Continue" |
||||
|
And I follow "Report" |
||||
|
And I follow "Low grade" |
||||
|
And I check "user3" |
||||
|
And I click on "Send a message" "button" |
||||
|
Then I should see "Message body" |
||||
|
And I should see "student1@asd.com" |
||||
|
And I expand "Reports" node |
||||
|
And I follow "Logs" |
||||
|
And I click on "Get these logs" "button" |
||||
|
Then "attendance report viewed" "link" should exist |
||||
|
|
||||
|
# Dependency - selenium running with firefox profile with auto saving of txt files to $CFG->behat_download. |
||||
|
@javascript @_file_download |
||||
|
Scenario: Export report includes id number, department and institution |
||||
|
When I log in as "teacher1" |
||||
|
And I follow "Course 1" |
||||
|
And I follow "Attendance" |
||||
|
And I follow "Add" |
||||
|
And I set the following fields to these values: |
||||
|
| id_sessiondate_hour | 01 | |
||||
|
And I click on "id_submitbutton" "button" |
||||
|
And I follow "Continue" |
||||
|
And I follow "Export" |
||||
|
Then the "id_ident_idnumber" checkbox should not be checked |
||||
|
And the "id_ident_institution" checkbox should not be checked |
||||
|
And the "id_ident_department" checkbox should not be checked |
||||
|
And I check "id_ident_idnumber" |
||||
|
And I check "id_ident_institution" |
||||
|
And I check "id_ident_department" |
||||
|
And I set the following fields to these values: |
||||
|
| format | Download in text format | |
||||
|
And I click on "OK" "button" |
||||
|
Then attendance export file is ok |
||||
|
And I should see "ID number" as "1234" in the file |
||||
|
And I should see "Department" as "computer science" in the file |
||||
|
And I should see "Institution" as "University of Nottingham" in the file |
||||
|
|
@ -0,0 +1,116 @@ |
|||||
|
<?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/>. |
||||
|
|
||||
|
|
||||
|
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. |
||||
|
|
||||
|
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); |
||||
|
|
||||
|
use Behat\Mink\Exception\ExpectationException as ExpectationException, |
||||
|
Behat\Behat\Exception\PendingException as PendingException; |
||||
|
|
||||
|
/** |
||||
|
* Attendance steps definitions. |
||||
|
* |
||||
|
* @package mod |
||||
|
* @subpackage attendance |
||||
|
* @category test |
||||
|
* @copyright 2014 University of Nottingham |
||||
|
* @author Joseph Baxter (joseph.baxter@nottingham.ac.uk) |
||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||||
|
*/ |
||||
|
class behat_mod_attendance extends behat_base { |
||||
|
|
||||
|
protected $file_contents; |
||||
|
|
||||
|
/** |
||||
|
* @Then /^attendance export file is ok$/ |
||||
|
*/ |
||||
|
public function attendance_export_file_is_ok() { |
||||
|
|
||||
|
global $CFG; |
||||
|
|
||||
|
$check = true; |
||||
|
|
||||
|
// Location selenium will download to. |
||||
|
$dir = $CFG->behat_download; |
||||
|
$files = scandir($dir, 1); |
||||
|
$filename = $files[0]; |
||||
|
$file = fopen($dir . $filename, "r"); |
||||
|
|
||||
|
$count = 0; |
||||
|
$header = null; |
||||
|
|
||||
|
// The file is tab seperated but not exactly a tsv. |
||||
|
while (($row = fgetcsv($file, 0, "\t")) !== FALSE) { |
||||
|
|
||||
|
// Ignore unwanted information at the start of the file. |
||||
|
if ($count < 3) { |
||||
|
$count++; |
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
if (!$header) { |
||||
|
$header = $row; |
||||
|
} else { |
||||
|
$this->file_contents = array_combine($header, $row); |
||||
|
} |
||||
|
|
||||
|
$count++; |
||||
|
} |
||||
|
|
||||
|
fclose($file); |
||||
|
unlink($dir . $filename); |
||||
|
|
||||
|
// Check if data rows exist. |
||||
|
if ($count < 2) { |
||||
|
$check = false; |
||||
|
} |
||||
|
|
||||
|
if ($check) { |
||||
|
|
||||
|
return true; |
||||
|
|
||||
|
} else { |
||||
|
|
||||
|
throw new ExpectationException('Attendance export file not ok', $this->getSession()); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @Given /^I should see "([^"]*)" as "([^"]*)" in the file$/ |
||||
|
*/ |
||||
|
public function i_should_see_as_in_the_file($field, $value) { |
||||
|
|
||||
|
foreach ($this->file_contents as $array_field => $array_value) { |
||||
|
|
||||
|
if ($field == $array_field) { |
||||
|
|
||||
|
if ($value == $array_value) { |
||||
|
|
||||
|
return true; |
||||
|
|
||||
|
} else { |
||||
|
|
||||
|
throw new PendingException(); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue