Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]

mod_h5pactivity attempt tests

Copyright: 2020 Ferran Recio <ferran@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 483 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: attempt_test  - X-Ref

Attempt tests class for mod_h5pactivity.

generate_testing_scenario()   X-Ref
Generate a scenario to run all tests.

return: array course_modules, user record, course record

test_create_attempt()   X-Ref
Test for create_attempt method.


test_last_attempt()   X-Ref
Test for last_attempt method


test_save_statement(string $subcontent, bool $hasdefinition, bool $hasresult, array $results)   X-Ref
Test saving statements.

param: string $subcontent subcontent identifier
param: bool $hasdefinition generate definition
param: bool $hasresult generate result
param: array $results 0 => insert ok, 1 => maxscore, 2 => rawscore, 3 => count

save_statement_data()   X-Ref
Data provider for data request creation tests.

return: array

test_delete_results()   X-Ref
Test delete results from attempt.


test_delete_attempt()   X-Ref
Test delete attempt.


test_delete_all_attempts(bool $hasstudent, array $results)   X-Ref
Test delete all attempts.

param: bool $hasstudent if user is specificed
param: int[] 0-3 => statements count results, 4-5 => totals

delete_all_attempts_data()   X-Ref
Data provider for data request creation tests.

return: array

test_set_score()   X-Ref
Test set_score method.


test_basic_setters(string $attribute, int $oldvalue, int $newvalue)   X-Ref
Test set_duration method.

param: string $attribute the stribute to test
param: int $oldvalue attribute old value
param: int $newvalue attribute new expected value

basic_setters_data()   X-Ref
Data provider for testing basic setters.

return: array

generate_full_attempt($student, $cm)   X-Ref
Generate a fake attempt with two results.

param: stdClass $student a user record
param: stdClass $cm a course_module record
return: attempt

generate_statement(bool $hasdefinition, bool $hasresult)   X-Ref
Return a xAPI partial statement with object defined.

param: bool $hasdefinition if has to include definition
param: bool $hasresult if has to include results
return: statement