I can’t order the lessons when using Polylang
-
I’m using:
– WordPress 6.0
– Sensei LMS version 4.4.2
– Polylang 3.2.3
– Classsinc Editor 1.6.2I’m using the Polylang to create a new course translation in the Korean language. So when I try to order the lessons the order doesn’t change. For the English version, the order is working.
Steps to replicate this issue:
– Install a fresh WordPress.
– Install Sensei.
– Install Polylang.
– Install Classsic Editor.
– Setup two languages (English and Korean).
– Create a new test course in Korean. Add to this course two (or more) modules.
– Create two or more lessons and assign them to one module (so we can order).
– Try to reorder the Korean course.I tried to figure out why this problem is happening and I think that the problem is with the module slug. So when you create a new module in Korean it creates two modules. One with the slug depending on the module name and the other with the same slug but adding the ko at the end (module1 and module1-ko). And I think that when you are ordering Sensei use the incorrect slug for the modules.
-
Hi @fedenuche,
Thanks for reaching out. I tried replicating the issue on a new test website following the steps you have outlined above.
But I was not able to replicate the issue. On the test website, I was able to rearrange modules and lessons inside the module for both languages without any issue.
Could you share a screenshot or a screen recording so we can see what you’re describing?
You can create screenshots using something like [Snipboard](https://snipboard.io) or [Imgur](https://imgur.com), or [Loom](https://www.loom.com/) for a screencast video and post the link here.
Best,
Thanks for your reply. I’m sending the screen recording.
Hi again,
Thanks for the update and for sharing the screen recording. I retried replicating the issue with a local install of WordPress using Flywheel, but I could not replicate the issue.
I was able to re-order lessons in both languages. You can see a video of my test here https://d.pr/v/XSYwS1
Can you tell me how you are adding the lessons to a course on your website? Are you adding them one by one for each language or adding all the lessons for one language at a time followed by the second language?
For testing, try creating a new course with a few new lessons, make sure you add both lesson versions of the course and lessons simultaneously (ie, create the Korean version immediately after creating the English version), and let us know what you find out.
Best,
I think that the problem is with the modules. When I’m creating a new course in the Korean language I’ve created modules. As you can see in my video (0:31) there are 4 modules but I only created two. I think that when you add a new module in a foreign language Sensei adds the lang iso at the end. In my example, I created the “module1” from the Korean course, and this action automatically creates two modules. One with the slug “module1” and the other with “module1-ko”. So I think that the lesson is added in the module “module1-ko” but when you save the order Sensei is trying to use the “module1”.
In addition to that, I followed the source code and applied a quick fix. I’m sending my solution to see if this is helpful for you.
File: plugins\sensei-lms\includes\class-sensei-course-structure.php
Function: get_module_slug
Line: 421private function get_module_slug( $title ) { $teacher_user_id = get_post( $this->course_id )->post_author; $lang = ''; if(is_polylang_active()) { $aux_lang = pll_get_post_language($this->course_id, 'slug'); if($aux_lang != pll_default_language()) { $lang = $aux_lang; } } return sanitize_title( $title ).'-'.$lang; /*return user_can( $teacher_user_id, 'manage_options' ) ? sanitize_title( $title ) : intval( $teacher_user_id ) . '-' . sanitize_title( $title );*/ }
-
This reply was modified 2 years, 9 months ago by
fedenuche.
Hi @fedenuche ,
Thank you for the code!
Two things I’m speculating upon:
– Classic Editor hasn’t been supported by Sensei since 2019. Wondering if that’s affecting anything here.
> I think that the problem is with the module slug. So when you create a new module in Korean it creates two modules. One with the slug depending on the module name and the other with the same slug but adding the ko at the end (module1 and module1-ko)
– if Polylang is auto-creating translated modules/slugs (appending -ko or other language marker), then this is probably(?) related to this issue:
https://github.com/Automattic/sensei/issues/5176
I’ve added this forum thread to the issue so the developers can take a look (and you can comment there, if you’d like!)
Best,
CenaHi there,
It has been more than one week since we have heard from you, so I’m marking this topic as resolved.
But if you have any further questions or need some more help, you’re welcome to reply here or open another thread.
Sorry, I didn’t respond because I read “I’ve added this forum thread to the issue so the developers can take a look”.
In addition, I tried to remove the Classic Editor plugin but the issue is still there. About the Polylang adding the extra slug, that was my guess too. I’ve sent this issue to you because on your site you are recommending using Polylang or WPML (https://senseilms.com/documentation/translating-sensei-lms/) and if this is normal Polylang behavior, maybe you are interested in fixing it.
Thanks for your support, and let me know if I can help in any other way.
-
This reply was modified 2 years, 9 months ago by
fedenuche.
Hi @fedenuche,
Thanks for the update. I tried to test and replicate the problem on a new install of WordPress with only Sensei LMS and Polylang plugin active. Unfortunately, I was not able to replicate the issue you are describing.
Unless we can replicate the issue on our test websites I cannot report it to our developers for fixing. Can you share some steps with us to help replicate the issue on a test website?
While reading through the earlier messages in the thread, I noticed that you mention “when you create a new module in Korean it creates two modules”. On my test website when I add a new module the plugin does not create a new module for the second language.
Lastly, do you have the [Synchronize metadata between translations
](https://polylang.pro/doc/synchronize-metadatas-between-translations/) option enabled in Polylang? If yes please try disabling this option and check if the issue with the Module persists.Let us know what you find out.
Hi @gaurav, I don’t have any “Synchronize metadata between translations” marked in my configuration. Did you create modules for your courses and assign those lessons to the modules? I think that the problem is with the modules.
I tried to figure out why this problem is happening and I think that the problem is with the module slug. So when you create a new module in Korean it creates two modules. One with the slug depending on the module name and the other with the same slug but adding the ko at the end (module1 and module1-ko). And I think that when you are ordering Sensei use the incorrect slug for the modules
In my screen recorded at 00:32, you can see four modules but I’ve just created two. So every module is used in the corresponding language (in English Sensei use “module1” and in Korean use “module1-ko”), but I think that the problem is when you are ordering in Korean (remember that in English works as expected) Sensei try to use the English version of the modules instead of corean. So when trying to get the new order for “module1” the result is empty and doesn’t change the order because is set for the “module1-ko”.
Hi @fedenuche,
I created modules for a course in Korean language using Polylang, and I couldn’t replicate either. Here is what I did:
– Using a staging site environment, only installed Polylang and SenseiLMS on Twenty Twenty theme.
– I didn’t install Classic Editor since it’s not been supported by Sensei since 2019.
– Created two courses: English Course, and ?? ?? (Korean Course).
– Created two modules for each course manually and assigned relevant course and language, like this: https://d.pr/i/FuxgCL
– Manually created lessons in respective language and assigned each to respective modules within the course.
– Tried re-ordering modules without any issues. Screencast here: https://d.pr/v/tbMN4N—
Since I could not reproduce the issue on my end, I suspect the issue may be specific to how you’ve set up your courses using Polylang.Would you be able to walk through exact steps you’ve taken to create Korean and English courses?
– Did you create an English course first, and then created Korean courses?
– Did you duplicate an existing course to create the same course in a different language?
– Did you add a module within a lesson, or did you add a module manually from Sensei LMS > Modules?
– Did you add a lesson within a course, or did you add a lesson manually from Sensei LMS > Lessons?
– Did you allow Polylang to translate slugs for courses, or did you customize slugs on your own?
– Did you specify string translations using Polylang?Also, would you share a screenshot of the modules page on SenseiLMS > Modules page?
Please note, we cannot investigate further unless we can reproduce the result consistently. Please share as many details as possible on how you created the courses in two different languages, and how you translated them (if any), and share all relevant settings in both polylang, permalinks settings, and SenseiLMS settings.
Thanks!
I think that the module duplication occurs when you create a new module from the edit/create Korean course (in the “Course Modules” right box).
If I create the modules in the modules screen and after that, I go to the lesson screen and add those modules to the lesson it works as expected. And there isn’t module duplication.
@bluejay77 How did you create those Korean modules?
In addition to that, in the module order, I’m having the same problem.
I follow the code and I found this:
private function save_module( array $item ) { if ( $item['id'] ) { $term = get_term( $item['id'], 'module' ); $slug = $this->get_module_slug( $item['title'] );// <-- This line ...
File: wp-content\plugins\sensei-lms\includes\class-sensei-course-structure.php
Function: private function save_module( array $item )When I have the module duplication the title for both modules is the same (see the attached image https://www.loom.com/i/9881744331e742c3a509959a868b8091). So the slug gets in the code above will be always the module for the eng version.
One possible solution is change this line:
$slug = $this->get_module_slug( $item['title'] );
For this one:
$slug = $term->slug;
I hope this is useful.
Hi guys, could you reproduce the error? Remember to create the modules inside the course edition page.
Hi @fedenuche ,
Could you let us know the answers to Jay’s questions, so we can attempt to further test?
`Would you be able to walk through exact steps you’ve taken to create Korean and English courses?
– Did you create an English course first, and then created Korean courses?
– Did you duplicate an existing course to create the same course in a different language?
– Did you add a module within a lesson, or did you add a module manually from Sensei LMS > Modules?
– Did you add a lesson within a course, or did you add a lesson manually from Sensei LMS > Lessons?
– Did you allow Polylang to translate slugs for courses, or did you customize slugs on your own?
– Did you specify string translations using Polylang?Also, would you share a screenshot of the modules page on SenseiLMS > Modules page?
Best,
Cena -
This reply was modified 2 years, 9 months ago by
- The topic ‘I can’t order the lessons when using Polylang’ is closed to new replies.