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
Create 3 default lessons on the Course Outline Block #5196
Create 3 default lessons on the Course Outline Block #5196
Conversation
{ type: 'lesson', title: __( 'Lesson 1', 'sensei-lms' ) }, | ||
{ type: 'lesson', title: __( 'Lesson 2', 'sensei-lms' ) }, | ||
{ type: 'lesson', title: __( 'Lesson 3', 'sensei-lms' ) }, |
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.
By the way, I added translated strings here but I'm not 100% sure if we really need to give these "lessons" a title.
With this code, when I create a new lesson I see this:
Meanwhile, without the title, I see this:
Which IMHO doesn't look bad either.
WDYT?
Also, would you implement this translation in any different way?
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 like the "Lesson 1", "Lesson 2", "Lesson 3" text, personally. I think it makes it a bit more clear.
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.
Have you tried an approach to just update the base template to start with 3 lessons?
You can find it in Sensei_Course_Blocks::initialize_blocks
.
Hey @renatho. Thanks for your review! I just tested the approach that you suggested and, while it works, for now, I have a question: Do you think that this will work after the implementation of the patterns for the courses? Like, based on my understanding, the patterns work by replacing the blocks used on the template (or, effectively, the template), so if the user chooses a pattern containing the course outline, the course outline block will appear as defined on the pattern. In other words, by updating the Meanwhile, with the current approach, even if the user chooses another pattern because this behavior is implemented inside the course outline block itself, the default lessons will always be there, without having to redefine the default lessons again and again... WDYT? |
@fjorgemota, good point! But I think we could also define the expected templates in the patterns. Maybe it also makes it more flexible in case we wanna give specific names to lessons in the patterns? My main concern with the current approach is that we usually should try to avoid changes in the blocks while mounting them. It can cause issues with the changes history (undo/redo), which could be fixed with |
…g in the block As suggested by Renatho during review.
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.
Looks good and works well! 🎉
@@ -1,21 +1,24 @@ | |||
/** | |||
* WordPress dependencies | |||
*/ | |||
import { InnerBlocks } from '@wordpress/block-editor'; | |||
import { |
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 for the improvements in this file! =)
Fixes #5142
Changes proposed in this Pull Request
Testing instructions
npm start
(or install the plugin build on this PR on some WordPress installation);Screenshots
Note
I'm not 100% sure if this PR covers all the behaviors that we are expecting from issue #5142, but I 100% feel like this is a good starting point to start experimenting and working on that issue.