diff --git a/assets/blocks/lesson-metadata/index.js b/assets/blocks/lesson-metadata/index.js index f5952a34dc..f22cf7b95a 100644 --- a/assets/blocks/lesson-metadata/index.js +++ b/assets/blocks/lesson-metadata/index.js @@ -11,10 +11,13 @@ import edit from './lesson-metadata-edit'; export default { title: __( 'Lesson Metadata', 'sensei-lms' ), - description: __( 'Add lesson details such as complexity and length.', 'sensei-lms' ), + description: __( + 'Add lesson details such as complexity and length.', + 'sensei-lms' + ), ...metadata, edit, save: () => { return null; - } + }, }; diff --git a/assets/blocks/lesson-metadata/lesson-metadata-edit.js b/assets/blocks/lesson-metadata/lesson-metadata-edit.js index 14eedfb4f3..33bbd9f9d3 100644 --- a/assets/blocks/lesson-metadata/lesson-metadata-edit.js +++ b/assets/blocks/lesson-metadata/lesson-metadata-edit.js @@ -2,10 +2,7 @@ * WordPress dependencies */ import { InspectorControls } from '@wordpress/block-editor'; -import { - PanelBody, - SelectControl, -} from '@wordpress/components'; +import { PanelBody, SelectControl } from '@wordpress/components'; import { __, _n } from '@wordpress/i18n'; /** @@ -23,10 +20,7 @@ import { COMPLEXITIES } from './constants'; const LessonMetadataEdit = ( props ) => { const { className, - attributes: { - complexity, - length, - }, + attributes: { complexity, length }, setAttributes, } = props; return ( @@ -39,17 +33,27 @@ const LessonMetadataEdit = ( props ) => { min={ 0 } step={ 1 } value={ length } - onChange={ length => setAttributes( { length } ) } - suffix={ _n( 'minute', 'minutes', length, 'sensei-lms' ) } + onChange={ ( newLength ) => + setAttributes( { newLength } ) + } + suffix={ _n( + 'minute', + 'minutes', + length, + 'sensei-lms' + ) } /> ( { label, value } ) - ) } + options={ COMPLEXITIES.map( ( { label, value } ) => ( { + label, + value, + } ) ) } value={ complexity } - onChange={ complexity => setAttributes( { complexity } ) } + onChange={ ( newComplexity ) => + setAttributes( { newComplexity } ) + } /> @@ -57,16 +61,22 @@ const LessonMetadataEdit = ( props ) => {
{ !! length && ( - { __( 'Length', 'sensei-lms' ) + ': ' + length + ' ' + _n( 'minute', 'minutes', length, 'sensei-lms' ) } + { __( 'Length', 'sensei-lms' ) + + ': ' + + length + + ' ' + + _n( 'minute', 'minutes', length, 'sensei-lms' ) } ) } { complexity && ( - { - __( 'Complexity', 'sensei-lms' ) + ': ' + - COMPLEXITIES.find( lessonComplexity => complexity === lessonComplexity.value )?.label - } + { __( 'Complexity', 'sensei-lms' ) + + ': ' + + COMPLEXITIES.find( + ( lessonComplexity ) => + complexity === lessonComplexity.value + )?.label } ) }
diff --git a/assets/blocks/quiz/quiz-block/use-update-quiz-has-questions-meta.js b/assets/blocks/quiz/quiz-block/use-update-quiz-has-questions-meta.js index fd67107eb4..ac1dec0837 100644 --- a/assets/blocks/quiz/quiz-block/use-update-quiz-has-questions-meta.js +++ b/assets/blocks/quiz/quiz-block/use-update-quiz-has-questions-meta.js @@ -22,16 +22,12 @@ export const useUpdateQuizHasQuestionsMeta = ( clientId ) => { .filter( ( block ) => ! isQuestionEmpty( block.attributes ) ) ); - const { editedValue: quizHasQuestionsMeta } = useSelect( - ( select ) => { - const editor = select( 'core/editor' ); - return { - editedValue: editor.getEditedPostAttribute( 'meta' )[ - META_KEY - ], - }; - } - ); + const { editedValue: quizHasQuestionsMeta } = useSelect( ( select ) => { + const editor = select( 'core/editor' ); + return { + editedValue: editor.getEditedPostAttribute( 'meta' )[ META_KEY ], + }; + } ); const { editPost } = useDispatch( 'core/editor' ); const setQuizHasQuestionsMeta = useCallback( diff --git a/includes/blocks/class-sensei-lesson-metadata-block.php b/includes/blocks/class-sensei-lesson-metadata-block.php index 4f8762a5e1..29c1f067fe 100644 --- a/includes/blocks/class-sensei-lesson-metadata-block.php +++ b/includes/blocks/class-sensei-lesson-metadata-block.php @@ -49,12 +49,13 @@ public function render( array $attributes, string $content ) : string { $content .= '' . __( 'Length', 'sensei-lms' ) . ': ' . + // translators: placeholder is lesson length in minutes. sprintf( _n( '%d minute', '%d minutes', $length, 'sensei-lms' ), $length ) . ''; } if ( $complexity ) { - $complexities = Sensei()->lesson->lesson_complexities(); + $complexities = Sensei()->lesson->lesson_complexities(); $lesson_complexity = $complexities[ $complexity ]; if ( $lesson_complexity ) { diff --git a/includes/rest-api/class-sensei-rest-api-lessons-controller.php b/includes/rest-api/class-sensei-rest-api-lessons-controller.php index cb0a86c5a9..c938c1606d 100644 --- a/includes/rest-api/class-sensei-rest-api-lessons-controller.php +++ b/includes/rest-api/class-sensei-rest-api-lessons-controller.php @@ -102,7 +102,7 @@ private function init_post_meta() { * * @param bool $allowed True if allowed to view the meta field by default, false otherwise. * @param string $meta_key Meta key. - * @param int $id Lesson ID. + * @param int $post_id Lesson ID. * @return bool Whether the user can edit the post meta. */ public function auth_callback( $allowed, $meta_key, $post_id ) {