forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-68721 mod_h5pactivity: report acceptance tests
- Loading branch information
1 parent
a93828a
commit fe3ee4a
Showing
5 changed files
with
1,007 additions
and
0 deletions.
There are no files selected for viewing
262 changes: 262 additions & 0 deletions
262
mod/h5pactivity/tests/behat/display_result_types.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,262 @@ | ||
@mod @mod_h5pactivity @core_h5p @core_xapi | ||
Feature: Report different types of interactions. | ||
In order to let users to review attempts | ||
As a user | ||
I need to view all valid interactions in the report | ||
|
||
Background: | ||
Given the following "users" exist: | ||
| username | firstname | lastname | email | | ||
| student1 | Student | 1 | student1@example.com | | ||
And the following "courses" exist: | ||
| fullname | shortname | category | | ||
| Course 1 | C1 | 0 | | ||
And the following "course enrolments" exist: | ||
| user | course | role | | ||
| student1 | C1 | student | | ||
# This test is only about reporting, we don't need to specify any valid H5P file for it. | ||
And the following "activities" exist: | ||
| activity | name | intro | course | idnumber | | ||
| h5pactivity | H5P package | Test H5P description | C1 | h5ppackage | | ||
|
||
Scenario: General success attempt information | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | compound | 2 | 2 | 4 | 1 | 1 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "2 out of 2" | ||
And I should see "Pass" | ||
And I should see "4 seconds" | ||
And I should see "This attempt is completed" | ||
|
||
Scenario: General failed attempt statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | compound | 0 | 2 | 4 | 1 | 0 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "0 out of 2" | ||
And I should see "Fail" | ||
And I should see "4 seconds" | ||
And I should see "This attempt is completed" | ||
|
||
Scenario: View a success choice statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | choice | 2 | 2 | 1 | 1 | 1 | | ||
| student1 | H5P package | 1 | compound | 2 | 2 | 4 | 1 | 1 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "Select the correct answers" | ||
And "Correct answer" "icon" should exist in the "This is also a correct answer" "table_row" | ||
And I should see "Score: 2 out of 2" | ||
|
||
Scenario: View a failed choice statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | choice | 0 | 2 | 1 | 1 | 0 | | ||
| student1 | H5P package | 1 | compound | 0 | 2 | 4 | 1 | 0 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "Select the correct answers" | ||
And "Incorrect answer" "icon" should exist in the "Another wrong answer" "table_row" | ||
And I should see "Score: 0 out of 2" | ||
|
||
Scenario: View a success matching statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | matching | 2 | 2 | 1 | 1 | 1 | | ||
| student1 | H5P package | 1 | compound | 2 | 2 | 4 | 1 | 1 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "Drag and Drop example 1" | ||
And "Your answer is correct" "icon" should exist in the "Drop item A" "table_row" | ||
And I should see "Score: 2 out of 2" | ||
|
||
Scenario: View a failed matching statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | matching | 0 | 2 | 1 | 1 | 1 | | ||
| student1 | H5P package | 1 | compound | 0 | 2 | 4 | 1 | 1 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "Drag and Drop example 1" | ||
And "Your answer is incorrect" "icon" should exist in the "Drop item A" "table_row" | ||
And I should see "Score: 0 out of 2" | ||
|
||
Scenario: View a success true-false statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | true-false | 2 | 2 | 1 | 1 | 1 | | ||
| student1 | H5P package | 1 | compound | 2 | 2 | 4 | 1 | 1 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "The correct answer is true" | ||
And "Correct answer" "icon" should exist in the "True" "table_row" | ||
And I should see "Score: 2 out of 2" | ||
|
||
Scenario: View a failed true-false statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | true-false | 0 | 2 | 1 | 1 | 0 | | ||
| student1 | H5P package | 1 | compound | 0 | 2 | 4 | 1 | 0 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "The correct answer is true" | ||
And "Incorrect answer" "icon" should exist in the "False" "table_row" | ||
And I should see "Score: 0 out of 2" | ||
|
||
Scenario: View a success fill-in statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | fill-in | 2 | 2 | 1 | 1 | 1 | | ||
| student1 | H5P package | 1 | compound | 2 | 2 | 4 | 1 | 1 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "This an example of missing word text" | ||
And "Your answer is correct" "icon" should exist in the "Gap #1" "table_row" | ||
And I should see "first" in the "Gap #1" "table_row" | ||
And "Your answer is correct" "icon" should exist in the "Gap #2" "table_row" | ||
And I should see "second" in the "Gap #2" "table_row" | ||
And I should see "Score: 2 out of 2" | ||
|
||
Scenario: View a failed fill-in statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | fill-in | 0 | 2 | 1 | 1 | 0 | | ||
| student1 | H5P package | 1 | compound | 0 | 2 | 4 | 1 | 0 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "This an example of missing word text" | ||
And "Your answer is incorrect" "icon" should exist in the "Gap #1" "table_row" | ||
And I should see "first" in the "Gap #1" "table_row" | ||
And I should see "something" in the "Gap #1" "table_row" | ||
And "Your answer is incorrect" "icon" should exist in the "Gap #2" "table_row" | ||
And I should see "second" in the "Gap #2" "table_row" | ||
And I should see "else" in the "Gap #2" "table_row" | ||
And I should see "Score: 0 out of 2" | ||
|
||
Scenario: View a success long-fill-in statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | long-fill-in | 2 | 2 | 1 | 1 | 1 | | ||
| student1 | H5P package | 1 | compound | 2 | 2 | 4 | 1 | 1 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "Please describe the novel The Hobbit" | ||
And I should see "The Hobbit is book" | ||
# Fill-in does not have a partial scope indicador, we only check the general one. | ||
And I should see "2 out of 2" | ||
|
||
Scenario: View a failed long-fill-in statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | long-fill-in | 0 | 2 | 1 | 1 | 0 | | ||
| student1 | H5P package | 1 | compound | 0 | 2 | 4 | 1 | 0 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "Please describe the novel The Hobbit" | ||
And I should see "Who cares?" | ||
# Fill-in does not have a partial scope indicador, we only check the general one. | ||
And I should see "0 out of 2" | ||
|
||
# The current H5P implementation does not send a complete sequencing interaction statement | ||
# we check only the warning and the final result. | ||
Scenario: View a success sequencing statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | sequencing | 2 | 2 | 1 | 1 | 1 | | ||
| student1 | H5P package | 1 | compound | 2 | 2 | 4 | 1 | 1 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "This interaction (sequencing) does not provide tracking information" | ||
# Sequencing does not have a partial scope indicador, we only check the general one. | ||
And I should see "2 out of 2" | ||
|
||
# The current H5P implementation does not send a complete sequencing interaction statement | ||
# we check only the warning and the final result. | ||
Scenario: View a failed sequencing statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | sequencing | 2 | 2 | 1 | 1 | 0 | | ||
| student1 | H5P package | 1 | compound | 0 | 2 | 4 | 1 | 0 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "This interaction (sequencing) does not provide tracking information" | ||
# Sequencing does not have a partial scope indicador, we only check the general one. | ||
And I should see "0 out of 2" | ||
|
||
# The current H5P implementation does not send a complete sequencing interaction statement | ||
# we check only the warning and the final result. | ||
Scenario: View a success other statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | other | 2 | 2 | 1 | 1 | 1 | | ||
| student1 | H5P package | 1 | compound | 2 | 2 | 4 | 1 | 1 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "This interaction (other) does not provide tracking information" | ||
# Other does not have a partial scope indicador, we only check the general one. | ||
And I should see "2 out of 2" | ||
|
||
# The current H5P implementation does not send a complete sequencing interaction statement | ||
# we check only the warning and the final result. | ||
Scenario: View a failed other statement | ||
Given the following "mod_h5pactivity > attempts" exist: | ||
| user | h5pactivity | attempt | interactiontype | rawscore | maxscore | duration | completion | success | | ||
| student1 | H5P package | 1 | other | 2 | 2 | 1 | 1 | 0 | | ||
| student1 | H5P package | 1 | compound | 0 | 2 | 4 | 1 | 0 | | ||
When I log in as "student1" | ||
And I am on "Course 1" course homepage | ||
And I follow "H5P package" | ||
And I follow "View my attempts" | ||
And I follow "View report" | ||
Then I should see "This interaction (other) does not provide tracking information" | ||
# Other does not have a partial scope indicador, we only check the general one. | ||
And I should see "0 out of 2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Coverage information for the mod_h5pactivity. | ||
* | ||
* @package mod_h5pactivity | ||
* @category test | ||
* @copyright 2021 Ferran Recio <ferran@moode.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
return new class extends phpunit_coverage_info { | ||
/** @var array The list of folders relative to the plugin root to whitelist in coverage generation. */ | ||
protected $whitelistfolders = [ | ||
'classes', | ||
'tests/generator', | ||
]; | ||
|
||
/** @var array The list of files relative to the plugin root to whitelist in coverage generation. */ | ||
protected $whitelistfiles = []; | ||
|
||
/** @var array The list of folders relative to the plugin root to excludelist in coverage generation. */ | ||
protected $excludelistfolders = []; | ||
|
||
/** @var array The list of files relative to the plugin root to excludelist in coverage generation. */ | ||
protected $excludelistfiles = []; | ||
}; |
52 changes: 52 additions & 0 deletions
52
mod/h5pactivity/tests/generator/behat_mod_h5pactivity_generator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?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/>. | ||
|
||
/** | ||
* H5P-related steps definitions. | ||
* | ||
* @package mod_h5pactivity | ||
* @category test | ||
* @copyright 2020 Ferran Recio | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class behat_mod_h5pactivity_generator extends behat_generator_base { | ||
|
||
protected function get_creatable_entities(): array { | ||
return [ | ||
'attempts' => [ | ||
'singular' => 'attempt', | ||
'datagenerator' => 'attempt', | ||
'required' => ['h5pactivity', 'user'], | ||
'switchids' => ['h5pactivity' => 'h5pactivityid', 'user' => 'userid'], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Look up the id of a h5p from its name. | ||
* | ||
* @param string $h5pname the activity name, for example 'Test h5p'. | ||
* @return int corresponding id | ||
*/ | ||
protected function get_h5pactivity_id(string $h5pname): int { | ||
global $DB; | ||
|
||
if (!$id = $DB->get_field('h5pactivity', 'id', ['name' => $h5pname])) { | ||
throw new Exception('There is no h5p activity with name "' . $h5pname); | ||
} | ||
return $id; | ||
} | ||
} |
Oops, something went wrong.