project: Moodle
summary: Add Web Services to the lesson module including the required API refactoring
description: Add Web Services to the lesson module including the required API refactoring Spec:

1.summary: New Web Service mod_lesson_get_lessons_by_courses
description: Return a list of lessons available for the current user in the given course. This Ws should return only the lesson configuration fields available according the user permissions in the course.
2.summary: New Web Service mod_lesson_get_lesson_access_information
description: Return access information for the current user in a given course. This WS check if the user can attempt the lesson and return capabilities and other information summarizing the current status of the user in the lesson.
3.summary: New Web Service mod_lesson_view_lesson
description: Set the module viewed and trigger module viewed event. This issue should fix also how completion works currently, the module is marked as view completed regardless the access restrictions.
4.summary: New Web Service mod_lesson_get_questions_attempts
description: Return the list of page question attempts in a given lesson. Parameters: - retries: the lesson attempt number - pageid: to retrieve attempts only for the given page - correct: to retrieve only correct attempts - userid: to retrive only attempts for the given user
5.summary: Web Services for returning final and lesson attempt grades
description: We will be needing two web services here: mod_lesson_get_user_grade: For returning user final grades mod_lesson_get_user_attempt_grade: For returning grade information for an attempt
6.summary: New Web Service mod_lesson_get_content_pages_viewed
description: Return the list of content pages (formerly known as "branch tables")| that a user visited during an attempt in a lesson.
7.summary: New Web Service mod_lesson_get_user_timers
description: Return the timers in the lesson for the given user.
8.summary: New Web Service mod_lesson_get_pages
description: Return a complete list of the pages in a lesson (just the basic information, excluding contents) so external clients (like the mobile app) can print the lesson menu and calculate the amount of information to download.
9.summary: New Web Service mod_lesson_launch_attempt
description: Starts or continues an existing lesson attempt (it basically set the user timers to correct values)
10.summary: New Web Service mod_lesson_get_page_data
description: Return information of a given page, including its contents, the ongoing status, lesson progress and related area files. This function is similar to mod_quiz_get_attempt_data, it is returning the questions (if any) already rendered.
11.summary: New Web Service mod_lesson_process_page
description: Processes page responses (when a user answer a question or choose where to go)
12.summary: New Web Service mod_lesson_finish_attempt
description: Finish an existing attempt, this usually happens when the user reach the lesson EOL page or when the timer is off
13.summary: New Web Service mod_lesson_get_attempts_overview
description: Get a list of all the attempts made by users in a lesson (so a teacher can review the attempts), including all attempts statistics.
14.summary: New Web Service mod_lesson_get_user_attempt
description: Get information for a finished attempt of a given user including users answers (so a teacher can review a specific attempt)
15.summary: Allow offline attempts via the Mobile app in the lesson module
description: This is very similar to what we did for the quiz module () we should add new fields in the lesson module to: - Allow teachers a lesson to be attempted offline - Notify students when they are continuing an attempt that was previously done in the app
16.summary: New Web Service mod_lesson_get_pages_possible_jumps
description: Return all the possible jumps for the pages in a given lesson, this is to pre-calculate a path for users that will use the offline functionality.
17.summary: Implement the check_updates callback in the lesson module
description: We need this callback to be able to check for updates in the lesson module
18.summary: Use exporters for returned structures in lesson Web Services
description: Now that exporters are integrated into core we should use them for Web Services. Note that I wont be using persistent because it may require a big refactor of the current lesson class.
19.summary: New Web Service mod_lesson_get_lesson
description: Retrieve the information from a given lesson

Below is an instruction that describes a task, paired with an input that provides an epic with this format: 
"project": "Name of the project" 
"summary": "Summary of the epic user story" 
"description": "Description of the epic user story". Write a response that appropriately completes the request.### Instruction:
Break this epic user story into smaller tasks to help the developers understand the epic better, you can divide this epic into as much as you want depending on the complexity of the epic.
### Input:
project: Moodle
summary: Add Web Services to the lesson module including the required API refactoring
description: Add Web Services to the lesson module including the required API refactoring Spec:

### Response:
1.summary: New Web Service mod_lesson_get_lessons_by_courses
description: Return a list of lessons available for the current user in the given course. This Ws should return only the lesson configuration fields available according the user permissions in the course.
2.summary: New Web Service mod_lesson_get_lesson_access_information
description: Return access information for the current user in a given course. This WS check if the user can attempt the lesson and return capabilities and other information summarizing the current status of the user in the lesson.
3.summary: New Web Service mod_lesson_view_lesson
description: Set the module viewed and trigger module viewed event. This issue should fix also how completion works currently, the module is marked as view completed regardless the access restrictions.
4.summary: New Web Service mod_lesson_get_questions_attempts
description: Return the list of page question attempts in a given lesson. Parameters: - retries: the lesson attempt number - pageid: to retrieve attempts only for the given page - correct: to retrieve only correct attempts - userid: to retrive only attempts for the given user
5.summary: Web Services for returning final and lesson attempt grades
description: We will be needing two web services here: mod_lesson_get_user_grade: For returning user final grades mod_lesson_get_user_attempt_grade: For returning grade information for an attempt
6.summary: New Web Service mod_lesson_get_content_pages_viewed
description: Return the list of content pages (formerly known as "branch tables")| that a user visited during an attempt in a lesson.
7.summary: New Web Service mod_lesson_get_user_timers
description: Return the timers in the lesson for the given user.
8.summary: New Web Service mod_lesson_get_pages
description: Return a complete list of the pages in a lesson (just the basic information, excluding contents) so external clients (like the mobile app) can print the lesson menu and calculate the amount of information to download.
9.summary: New Web Service mod_lesson_launch_attempt
description: Starts or continues an existing lesson attempt (it basically set the user timers to correct values)
10.summary: New Web Service mod_lesson_get_page_data
description: Return information of a given page, including its contents, the ongoing status, lesson progress and related area files. This function is similar to mod_quiz_get_attempt_data, it is returning the questions (if any) already rendered.
11.summary: New Web Service mod_lesson_process_page
description: Processes page responses (when a user answer a question or choose where to go)
12.summary: New Web Service mod_lesson_finish_attempt
description: Finish an existing attempt, this usually happens when the user reach the lesson EOL page or when the timer is off
13.summary: New Web Service mod_lesson_get_attempts_overview
description: Get a list of all the attempts made by users in a lesson (so a teacher can review the attempts), including all attempts statistics.
14.summary: New Web Service mod_lesson_get_user_attempt
description: Get information for a finished attempt of a given user including users answers (so a teacher can review a specific attempt)
15.summary: Allow offline attempts via the Mobile app in the lesson module
description: This is very similar to what we did for the quiz module () we should add new fields in the lesson module to: - Allow teachers a lesson to be attempted offline - Notify students when they are continuing an attempt that was previously done in the app
16.summary: New Web Service mod_lesson_get_pages_possible_jumps
description: Return all the possible jumps for the pages in a given lesson, this is to pre-calculate a path for users that will use the offline functionality.
17.summary: Implement the check_updates callback in the lesson module
description: We need this callback to be able to check for updates in the lesson module
18.summary: Use exporters for returned structures in lesson Web Services
description: Now that exporters are integrated into core we should use them for Web Services. Note that I wont be using persistent because it may require a big refactor of the current lesson class.
19.summary: New Web Service mod_lesson_get_lesson
description: Retrieve the information from a given lesson
