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

WPML: Fix usage of question categories in translated quizzes #7559

Merged
merged 59 commits into from Apr 9, 2024

Conversation

merkushin
Copy link
Member

@merkushin merkushin commented Mar 23, 2024

Resolves #7537

Here I process the multiple question post type:

  • Set proper language details for a post of this type.
  • Update relation with the actual category during translation.

In this PR I also addressed an issue with redirect on lesson translation: I added a filter and try to return the translated page there.

Unfortunately, questions are not translated automatically. (You can see these strings in the WPML translation editor, but they don't appear in the translated lesson.)
For now, the user has to translate them manually in lessons: open the translated lesson in the WordPress editor and change texts for questions.

Proposed Changes

  • Fix usage of question categories in translated quizzes.

Testing Instructions

  1. Install and activate WPML.
  2. Create a few questions and add them to a question category.
  3. Translate the questions first. We have a separate PR that translates questions from a category automatically: Create translations for questions in category #7568
  4. Create a course with lessons and at least with one quiz.
  5. In the quiz add a question category.
  6. Publish the course.
  7. Create translation for the course.
  8. Take the translated course on the frontend.
  9. Make sure you saw question(s) from the question category.
  10. No errors expected.

New/Updated Hooks

  • sensei_course_completed_page_id — Filter course completed page ID.

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
  • Legacy courses (course without blocks) are tested
  • 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

* @param {int} $page_id Course completed page ID.
* @return {int} Course completed page ID.
*/
$page_id = apply_filters( 'sensei_course_completed_page_id', $page_id );
Copy link
Member Author

Choose a reason for hiding this comment

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

The only manual change in this file.
The rest is the result of vendor/bin/phpcbf

Copy link

Test the previous changes of this PR with WordPress Playground.

Copy link

Test the previous changes of this PR with WordPress Playground.

@merkushin merkushin marked this pull request as ready for review March 23, 2024 23:37
@merkushin merkushin force-pushed the fix/wpml-question-categories branch from 3e4cdf4 to 42aca07 Compare April 4, 2024 13:02
@renatho renatho modified the milestones: 4.23.0, 4.23.1 Apr 4, 2024
Copy link

github-actions bot commented Apr 4, 2024

Test the previous changes of this PR with WordPress Playground.

Copy link

github-actions bot commented Apr 4, 2024

WordPress Dependencies Report

The github-action-wordpress-dependencies-report action has detected some script changes between the commit a2473fd and trunk. Please review and confirm the following are correct before merging.

No changes detected in the current commit. But the comment was left so it is possible to check for the edit history.

This comment was automatically generated by the github-action-wordpress-dependencies-report action.

Copy link

github-actions bot commented Apr 4, 2024

Test the previous changes of this PR with WordPress Playground.

m1r0
m1r0 previously approved these changes Apr 5, 2024
Copy link
Member

@m1r0 m1r0 left a comment

Choose a reason for hiding this comment

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

I was able to get the translated questions from the category, so works for me. 👍

Copy link

github-actions bot commented Apr 8, 2024

Test the previous changes of this PR with WordPress Playground.

Base automatically changed from fix/wpml-progress to trunk April 9, 2024 21:59
@merkushin merkushin dismissed m1r0’s stale review April 9, 2024 21:59

The base branch was changed.

Copy link

github-actions bot commented Apr 9, 2024

Test the previous changes of this PR with WordPress Playground.

@merkushin merkushin merged commit b13be20 into trunk Apr 9, 2024
23 checks passed
@merkushin merkushin deleted the fix/wpml-question-categories branch April 9, 2024 22:26
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.

Translate question categories
3 participants