Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add translations for lessons and quizzes that were created while saving the course structure #7383

Merged
merged 10 commits into from Jan 16, 2024

Conversation

merkushin
Copy link
Member

@merkushin merkushin commented Dec 13, 2023

Resolves #6978

When we create a lesson or a quiz while saving the course structure, the translation is not created in WPML. Unfortunately, I didn't find why it works that way specifically for this case: if you create a course or a lesson in UI, everything work fine. I suppose it might happen with loading meta boxes or saving data from them.

Proposed Changes

  • Add translations for lessons and quizzes that were created while saving the course structure

Testing Instructions

  1. Install and activate WPML.
  2. Go to Sensei LMS > Courses, create a new course.
  3. Start with a blank (or default?) course structure (when 3 default lessons pre-filled). That's for simplicity, and you can play at this point.
  4. Save draft or publish the course.
  5. It is expected that the status of lessons changed from Unsaved to Draft.
  6. You can also check if a translation entry was created in database: SELECT * FROM wp_icl_translations WHERE element_id=7686; -- 7686 is Lesson ID

New/Updated Hooks

  • sensei_course_structure_lesson_created - Fires after a lesson is created while saving the course structure.
  • sensei_course_structure_quiz_created - Fires after a quiz is created while saving the course structure.

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Acceptance criteria is met
  • Decisions are publicly documented
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • Follows our naming conventions (P6rkRX-4oA-p2)
  • Hooks (p6rkRX-1uS-p2) and functions are documented
  • New UIs are responsive and use a mobile-first approach
  • New UIs match the designs
  • Different user privileges (admin, teacher, subscriber) are tested as appropriate
  • Code is tested on the minimum supported PHP and WordPress versions
  • User interface changes have been tested on the latest versions of Chrome, Firefox and Safari
  • "Needs Documentation" label is added if this change requires updates to documentation
  • Known issues are created as new GitHub issues

@merkushin merkushin added the WPML Compatibility issues with WPML label Dec 13, 2023
@merkushin merkushin added this to the 5.0.0 milestone Dec 13, 2023
@merkushin merkushin requested a review from a team December 13, 2023 22:10
@merkushin merkushin self-assigned this Dec 13, 2023
Copy link

codecov bot commented Dec 13, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (49038f8) 50.94% compared to head (179ff35) 51.21%.
Report is 105 commits behind head on trunk.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##              trunk    #7383      +/-   ##
============================================
+ Coverage     50.94%   51.21%   +0.26%     
- Complexity    11149    11184      +35     
============================================
  Files           613      614       +1     
  Lines         47062    47214     +152     
  Branches        404      405       +1     
============================================
+ Hits          23975    24179     +204     
+ Misses        22760    22708      -52     
  Partials        327      327              
Files Coverage Δ
includes/class-sensei-course-structure.php 91.70% <87.50%> (-0.16%) ⬇️
includes/wpml/class-sensei-wpml.php 91.11% <95.00%> (+91.11%) ⬆️

... and 26 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8eaf50...179ff35. Read the comment docs.

@merkushin merkushin added the Hooks This change adds or modifies one or more hooks. label Jan 9, 2024
@merkushin merkushin marked this pull request as ready for review January 9, 2024 06:39
donnapep
donnapep previously approved these changes Jan 15, 2024
Copy link
Collaborator

@donnapep donnapep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem is solved. 👍🏻 Left a few comments. Feel free to merge after addressing.

changelog/fix-wpml-save-course-structure Outdated Show resolved Hide resolved
includes/wpml/class-sensei-wpml.php Show resolved Hide resolved
includes/wpml/class-sensei-wpml.php Outdated Show resolved Hide resolved
includes/wpml/class-sensei-wpml.php Outdated Show resolved Hide resolved
tests/unit-tests/wpml/test-class-sensei-wpml.php Outdated Show resolved Hide resolved
tests/unit-tests/wpml/test-class-sensei-wpml.php Outdated Show resolved Hide resolved
includes/class-sensei-course-structure.php Outdated Show resolved Hide resolved
includes/class-sensei-course-structure.php Outdated Show resolved Hide resolved
@donnapep donnapep modified the milestones: 5.0.0, 4.20.1 Jan 15, 2024
@merkushin merkushin merged commit f9f7d4b into trunk Jan 16, 2024
24 checks passed
@merkushin merkushin deleted the fix/wpml-save-course-structure branch January 16, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hooks This change adds or modifies one or more hooks. WPML Compatibility issues with WPML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to save lessons when WPML is activated
2 participants