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: Translate quizzes with questions #7480
Conversation
WordPress Dependencies ReportThe 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 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #7480 +/- ##
==========================================
Coverage 51.93% 51.94%
- Complexity 11267 11310 +43
==========================================
Files 630 639 +9
Lines 47665 47821 +156
Branches 420 421 +1
==========================================
+ Hits 24756 24840 +84
- Misses 22572 22644 +72
Partials 337 337
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
4f1bda0
to
9b5da48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 things I realized while testing it:
- I noticed it doesn't consider question categories. And I don't know exactly how we should handle it. Maybe when a category is added to a lesson, we should duplicate the category (categories have translation?) and all the questions in that category? Anyway, I think it's something for a separate issue since it could be complicated.
- I realized that when duplicating the course, it created the lessons in the reverse order. In my test in the other PR I tried to order the lessons so maybe it only happens when we don't order them?
And I couldn't test it on the frontend because it's not opening the courses in translated languages for me, as I commented in the other PR. 😉
includes/class-sensei-lesson.php
Outdated
* @param {int} $quiz_id Quiz post ID. | ||
* @param {int} $lesson_id Course post ID. | ||
*/ | ||
do_action( 'sensei_lesson_quiz_created', $quiz_id, $post_id ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the only meaningful change in the file, the rest is the code style fix.
Here we fire an action on the creation of a new quiz within a non-block editor.
* @param {int} $quiz_id Quiz post ID. | ||
* @param {int} $lesson_id Course post ID. | ||
*/ | ||
do_action( 'sensei_rest_api_lesson_quiz_created', (int) $quiz_id, (int) $lesson->ID ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the only meaningful change, the rest is the code style fix.
Here we fire an action on the creation of a new quiz within a block editor.
// Load WPML compatibility class. | ||
$this->sensei_wpml = new WPML(); | ||
$this->sensei_wpml->init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the only meaningful change, the rest is the code style fix.
We instantiate and init a new compatibility class (the old one is deprecated).
* @hook sensei_course_structure_quiz_created | ||
* | ||
* @param {int} $quiz_id Quiz post ID. | ||
* @param {int} $lesson_id Course post ID. | ||
*/ | ||
do_action( 'sensei_course_structure_quiz_created', $quiz_id, $lesson_id ); | ||
do_action_deprecated( 'sensei_course_structure_quiz_created', $quiz_id, $lesson_id, '$$next-version$$', 'sensei_quiz_create' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to deprecate it as it was already released.
Can't reproduce it for "unordered" lessons (when order hasn't been changed). Looking into it... |
Test the previous changes of this PR with WordPress Playground. |
@renatho I've fixed the lesson order for "translated" lessons here: 1446661 Update Eventually, while testing re-usable progress, I encountered the behaviour you described. I didn't order lesson, but in the translated course they appeared reversed. Not cool at all, looking for a solution... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @merkushin!
I re-tested the lessons order after the course translation, and it worked properly for me.
Update Eventually, while testing re-usable progress, I encountered the behaviour you described. I didn't order lesson, but in the translated course they appeared reversed. Not cool at all, looking for a solution...
About this, I didn't know how to test it, so I'll wait for your fix to give the approval. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@merkushin, I'm approving it since we talked and you couldn't reproduce the other issue anymore.
Hopefully, it was just a mistake while testing it. But if not, we can always iterate in the future and it probably wouldn't be a critical issue.
Resolves #5841
In this PR we don't address an issue of not working properly question translation: when you translated a question in a lesson, but the question remain containing the original content.
Proposed Changes
Testing Instructions
New/Updated Hooks
sensei_rest_api_lesson_quiz_created
- Fires after a quiz is created via the REST API.sensei_lesson_quiz_created
- Fires after a quiz is created while saving a lesson in a non-block editor.Deprecated Code
Sensei_WPML
- replaced withSensei\WPML\WPML
.Pre-Merge Checklist