Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

Lesson module external functions tests

Copyright: 2017 Juan Leyva <juan@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1384 lines (62 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes


Class: testable_mod_lesson_external  - X-Ref

Silly class to access mod_lesson_external internal methods.

validate_attempt(lesson $lesson, $params, $return = false)   X-Ref
Validates a new attempt.

param: lesson  $lesson lesson instance
param: array   $params request parameters
param: boolean $return whether to return the errors or throw exceptions
return: [array          the errors (if return set to true)

Class: external_test  - X-Ref

Lesson module external functions tests

setUp()   X-Ref
Set up for every test


test_mod_lesson_get_lessons_by_courses()   X-Ref
Test test_mod_lesson_get_lessons_by_courses


test_validate_attempt()   X-Ref
Test the validate_attempt function.


test_get_lesson_access_information()   X-Ref
Test the get_lesson_access_information function.


test_view_lesson_invalid_id()   X-Ref
Test test_view_lesson invalid id.


test_view_lesson_user_not_enrolled()   X-Ref
Test test_view_lesson user not enrolled.


test_view_lesson_user_student()   X-Ref
Test test_view_lesson user student.


test_view_lesson_user_missing_capabilities()   X-Ref
Test test_view_lesson user missing capabilities.


test_get_questions_attempts()   X-Ref
Test for get_questions_attempts


test_get_user_grade()   X-Ref
Test get user grade.


test_get_user_attempt_grade()   X-Ref
Test get_user_attempt_grade


test_get_content_pages_viewed()   X-Ref
Test get_content_pages_viewed


test_get_user_timers()   X-Ref
Test get_user_timers


test_get_pages()   X-Ref
Test for get_pages


test_launch_attempt()   X-Ref
Test launch_attempt. Time restrictions already tested in test_validate_attempt.


test_launch_attempt_not_finished_in_review_mode()   X-Ref
Test launch_attempt not finished forcing review mode.


test_launch_attempt_just_finished_in_review_mode()   X-Ref
Test launch_attempt just finished forcing review mode.


test_launch_attempt_not_just_finished_in_review_mode()   X-Ref
Test launch_attempt not just finished forcing review mode.


test_get_page_data()   X-Ref
No description

test_get_page_data_student()   X-Ref
Test get_page_data as student


test_get_page_data_without_launch()   X-Ref
Test get_page_data without launching attempt.


create_attempt($user, $correct = true, $finished = false)   X-Ref
Creates an attempt for the given userwith a correct or incorrect answer and optionally finishes it.

param: \stdClass $user    Create an attempt for this user
param: boolean $correct  If the answer should be correct
param: boolean $finished If we should finish the attempt
return: array the result of the attempt creation or finalisation

test_process_page()   X-Ref
Test process_page


test_finish_attempt_not_doing_anything()   X-Ref
Test finish attempt not doing anything.


test_finish_attempt_with_correct_answer()   X-Ref
Test finish attempt with correct answer.


test_get_attempts_overview()   X-Ref
Test get_attempts_overview


test_get_attempts_overview_no_attempts()   X-Ref
Test get_attempts_overview when there aren't attempts.


test_get_user_attempt()   X-Ref
Test get_user_attempt


test_get_pages_possible_jumps()   X-Ref
Test get_pages_possible_jumps


test_get_pages_possible_jumps_with_offlineattemps_disabled()   X-Ref
Test get_pages_possible_jumps when offline attemps are disabled for a normal user


test_get_pages_possible_jumps_with_offlineattemps_enabled()   X-Ref
Test get_pages_possible_jumps when offline attemps are enabled for a normal user


test_get_lesson_user_student()   X-Ref
No description

test_get_lesson_user_student_with_missing_password()   X-Ref
Test get_lesson user student with missing password.


test_get_lesson_user_student_with_correct_password()   X-Ref
Test get_lesson user student with correct password.


test_get_lesson_teacher()   X-Ref
Test get_lesson teacher.