Search moodle.org's
Developer Documentation

See Release Notes

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

Class: manager_test  - X-Ref

Manager tests class for mod_h5pactivity.

test_create()   X-Ref
Test for static create methods.


test_is_tracking_enabled(bool $login, string $role, int $enabletracking, bool $expected)   X-Ref
Test for is_tracking_enabled.

param: bool $login if the user is logged in
param: string $role user role in course
param: int $enabletracking if tracking is enabled
param: bool $expected expected result

is_tracking_enabled_data()   X-Ref
Data provider for is_tracking_enabled.

return: array

test_get_users_scaled_score(int $enabletracking, int $gradingmethod, array $result1, array $result2)   X-Ref
Test for get_users_scaled_score.

param: int $enabletracking if tracking is enabled
param: int $gradingmethod new grading method
param: array $result1 student 1 results (scaled, timemodified, attempt number)
param: array $result2 student 2 results (scaled, timemodified, attempt number)

get_users_scaled_score_data()   X-Ref
Data provider for get_users_scaled_score.

return: array

test_get_grading_methods()   X-Ref
Test static get_grading_methods.


test_get_selected_attempt(int $enabletracking, int $gradingmethod, int $result)   X-Ref
Test static get_selected_attempt.

param: int $enabletracking if tracking is enabled
param: int $gradingmethod new grading method
param: int $result the expected result

get_selected_attempt_data()   X-Ref
Data provider for get_users_scaled_score.

return: array

test_get_review_modes()   X-Ref
Test static get_review_modes.


test_get_grader()   X-Ref
Test get_grader method.


test_can_view_all_attempts(int $enabletracking, bool $usestudent, bool $useloggedin, bool $result)   X-Ref
Test static can_view_all_attempts.

param: int $enabletracking if tracking is enabled
param: bool $usestudent if test must be done with a user role
param: bool $useloggedin if test must be done with the loggedin user
param: bool $result the expected result

can_view_all_attempts_data()   X-Ref
Data provider for test_can_view_all_attempts.

return: array

test_can_view_own_attempts(int $enabletracking, int $reviewmode,bool $useloggedin, bool $hasattempts, bool $result)   X-Ref
Test static can_view_own_attempts.

param: int $enabletracking if tracking is enabled
param: int $reviewmode the attempt review mode
param: bool $useloggedin if test must be done with the loggedin user
param: bool $hasattempts if the student have attempts
param: bool $result the expected result

can_view_own_attempts_data()   X-Ref
Data provider for test_can_view_own_attempts.

return: array

test_count_attempts()   X-Ref
Test static count_attempts of one user.


test_count_attempts_all(bool $canview, bool $cansubmit, bool $extrarole, int $result)   X-Ref
Test static count_attempts of all active participants.

param: bool $canview if the student role has mod_h5pactivity/view capability
param: bool $cansubmit if the student role has mod_h5pactivity/submit capability
param: bool $extrarole if an extra role without submit capability is required
param: int $result the expected result

count_attempts_all_data()   X-Ref
Data provider for test_count_attempts_all.

return: array

test_get_active_users_join(bool $allpotentialusers, int $result)   X-Ref
Test static test_get_active_users_join of all active participants.

Most method scenarios are tested in test_count_attempts_all so we only
need to test the with $allpotentialusers true and false.

param: bool $allpotentialusers if the join should return all potential users or only the submitted ones.
param: int $result the expected result

get_active_users_join_data()   X-Ref
Data provider for test_get_active_users_join.

return: array

test_get_active_users_join_groupmode()   X-Ref
Test active users joins returns appropriate results for groups


test_get_active_users_join_no_reviewers()   X-Ref
Test getting active users join where there are no roles with 'mod/h5pactivity:reviewattempts' capability


test_count_users_attempts()   X-Ref
Test static count_attempts.


test_get_report(int $enabletracking, int $reviewmode, bool $createattempts,string $role, array $results)   X-Ref
Test static get_report.

param: int $enabletracking if tracking is enabled
param: int $reviewmode the attempt review mode
param: bool $createattempts if the student have attempts
param: string $role the user role (student or editingteacher)
param: array $results the expected classname (or null)

get_report_data()   X-Ref
Data provider for test_get_report.

return: array

test_get_attempt(string $attemptname, ?string $result)   X-Ref
Test get_attempt method.

param: string $attemptname the attempt to use
param: string|null $result the expected attempt ID or null for none

get_attempt_data()   X-Ref
Data provider for test_get_attempt.

return: array

generate_fake_attempts(stdClass $activity, stdClass $user, int $basescore)   X-Ref
Insert fake attempt data into h5pactiviyt_attempts.

This function insert 4 attempts. 3 of them finished with different gradings
and timestamps and 1 unfinished.

param: stdClass $activity the activity record
param: stdClass $user user record
param: int $basescore a score to be used to generate all attempts