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
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
5c37ea6
Add config for course-outline-lesson block
merkushin Dec 18, 2023
6cf15ee
Try to configure blocks
merkushin Jan 21, 2024
79ae9a4
Fix course outline for a course translation
merkushin Jan 26, 2024
7fcd4f4
Create translations for lessons and update relations for new lessons
merkushin Jan 31, 2024
99ed118
Restore upadate lesson properties on lesson translation created
merkushin Feb 1, 2024
08aa6c6
Add changelog entry
merkushin Feb 1, 2024
4e0d017
Fix linter issues
merkushin Feb 1, 2024
7e9e80b
Fix psalm issues
merkushin Feb 1, 2024
9f89730
Fix docblock return type
merkushin Feb 1, 2024
05875ec
Ignore issues in legacy code
merkushin Feb 1, 2024
094a53e
Add tests for wpml hooks
merkushin Feb 1, 2024
125ac82
Test lesson course was updated for translated lessons
merkushin Feb 1, 2024
390d1c8
Merge branch 'trunk' into fix/wpml-save-dependent-posts
merkushin Feb 16, 2024
1930766
Fix linter issues in tests
merkushin Feb 16, 2024
cf82b25
Merge branch 'trunk' into fix/wpml-save-dependent-posts
merkushin Feb 16, 2024
abf49e9
Handle translations for quizzes and questions, refactor code structure
merkushin Feb 19, 2024
54a8cd7
Add hooks, fix some legacy linter issues
merkushin Feb 19, 2024
0c1fd79
Update WPML instance, fix legacy linter issues
merkushin Feb 19, 2024
fc79ae1
Update Psal baseline
merkushin Feb 19, 2024
94030f8
Add config for question block
merkushin Feb 19, 2024
4dc22ce
Add/fix some tests for WPML
merkushin Feb 19, 2024
9b5da48
Add changelog entry
merkushin Feb 19, 2024
232edb2
Update tests
merkushin Feb 20, 2024
567fb31
Update Psal baseline
merkushin Feb 20, 2024
3521a24
Update Psal baseline
merkushin Feb 20, 2024
7f84dda
Update quiz id for questions
merkushin Feb 20, 2024
d7f69da
WPML: Add support for reusable student progress
merkushin Feb 22, 2024
abaa44b
Merge branch 'trunk' into fix/wpml-quiz
merkushin Feb 22, 2024
ee4c7d0
Update lesson relations for existing lessons as well
merkushin Feb 22, 2024
1f9ce56
Add filters for identifiers in quiz submission repositories
merkushin Feb 24, 2024
e5ebe8a
Merge branch 'trunk' into fix/wpml-quiz
merkushin Mar 13, 2024
1320cbe
Rename the hook on quiz create
merkushin Mar 13, 2024
1446661
Save lesson order for translated lessons
merkushin Mar 14, 2024
eaa9733
Fix usage of do_action_deprecated
merkushin Mar 14, 2024
34dd065
Merge branch 'fix/wpml-quiz' into fix/wpml-progress
merkushin Mar 14, 2024
f2a9c1f
Merge branch 'trunk' into fix/wpml-progress
merkushin Mar 15, 2024
cdb8537
Fix linter issue
merkushin Mar 15, 2024
c56aa4d
Filter course id when enroll course
merkushin Mar 15, 2024
6cf7c78
Make it possible to start translated course and share course and less…
merkushin Mar 18, 2024
84a74fe
Fix comment fetching issues
merkushin Mar 20, 2024
b2ac8c8
Update tests
merkushin Mar 21, 2024
748a484
Add changelog entry
merkushin Mar 21, 2024
11e1f96
Fix linter issues
merkushin Mar 21, 2024
4c899ec
Fix hook docs
merkushin Mar 21, 2024
025d80e
Fix psalm issues
merkushin Mar 21, 2024
8d455a4
Merge branch 'trunk' into fix/wpml-progress
merkushin Mar 21, 2024
96814c9
Omit defaults in hooks registration
merkushin Apr 3, 2024
3d78f2f
Fix hook name
merkushin Apr 3, 2024
b9c61df
Explicitly cast lesson id and quiz id to int for consistency
merkushin Apr 3, 2024
438efc6
Support question categories
merkushin Mar 23, 2024
3f7909f
Add changelog entry and fix linter issues
merkushin Mar 23, 2024
0c569c4
Update baseline
merkushin Mar 23, 2024
06cb76a
Add tests
merkushin Mar 23, 2024
42aca07
Fix linter issues
merkushin Mar 23, 2024
5cc0fdc
Merge branch 'trunk' into fix/wpml-progress
merkushin Apr 4, 2024
bd0eda9
Merge branch 'fix/wpml-progress' into fix/wpml-question-categories
merkushin Apr 4, 2024
c09d330
Merge branch 'trunk' into fix/wpml-progress
merkushin Apr 8, 2024
1d9d67b
Merge branch 'fix/wpml-progress' into fix/wpml-question-categories
merkushin Apr 8, 2024
a2473fd
Merge branch 'trunk' into fix/wpml-question-categories
merkushin Apr 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/fix-wpml-progress
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Share student progress and quiz submission across translations
4 changes: 4 additions & 0 deletions changelog/fix-wpml-question-categories
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fix usage of question categories in translated quizzes
46 changes: 17 additions & 29 deletions config/psalm/psalm-baseline.xml
Expand Up @@ -1422,22 +1422,19 @@
<MissingDocblockType occurrences="1">
<code>public $token;</code>
</MissingDocblockType>
<MissingParamType occurrences="16">
<MissingParamType occurrences="13">
<code>$class</code>
<code>$classes</code>
<code>$course</code>
<code>$course_id</code>
<code>$course_id</code>
<code>$course_id</code>
<code>$course_id</code>
<code>$course_id</code>
<code>$excludes</code>
<code>$excludes</code>
<code>$message</code>
<code>$query</code>
<code>$query</code>
<code>$should_send</code>
<code>$user_id</code>
<code>$user_id</code>
</MissingParamType>
<MissingPropertyType occurrences="1">
Expand Down Expand Up @@ -1885,11 +1882,9 @@
<code>'WP_Post'</code>
<code>'WP_User'</code>
</ArgumentTypeCoercion>
<DocblockTypeContradiction occurrences="4">
<DocblockTypeContradiction occurrences="2">
<code>! isset( $lesson_id )</code>
<code>- 1 !== $new_course</code>
<code>-1</code>
<code>-1 !== $new_complexity</code>
</DocblockTypeContradiction>
<FalsableReturnStatement occurrences="2">
<code>empty( $block['innerBlocks'][0]['attrs']['id'] ) ? null : wp_get_attachment_url( get_post_thumbnail_id( $block['innerBlocks'][0]['attrs']['id'] ) )</code>
Expand Down Expand Up @@ -2080,12 +2075,10 @@
<code>is_array( $question_data )</code>
<code>is_countable( $questions_array )</code>
</RedundantCondition>
<RedundantConditionGivenDocblockType occurrences="9">
<RedundantConditionGivenDocblockType occurrences="7">
<code>! is_wp_error( $multiple_id )</code>
<code>$module_term</code>
<code>$module_term</code>
<code>- 1 !== $new_course</code>
<code>-1 !== $new_complexity</code>
<code>is_array( $data ) &amp;&amp; count( $data ) &gt; 0</code>
<code>is_array( $this-&gt;meta_fields )</code>
<code>isset( $this-&gt;meta_fields ) &amp;&amp; is_array( $this-&gt;meta_fields )</code>
Expand Down Expand Up @@ -2483,7 +2476,7 @@
<code>public static function gap_fill_load_question_data( $question_data, $question_id, $quiz_id ) {</code>
<code>public static function multiple_choice_load_question_data( $question_data, $question_id, $quiz_id ) {</code>
</InvalidDocblock>
<InvalidScalarArgument occurrences="29">
<InvalidScalarArgument occurrences="27">
<code>$id</code>
<code>$lesson_id</code>
<code>$lesson_id</code>
Expand All @@ -2501,8 +2494,6 @@
<code>$lesson_id</code>
<code>$lesson_id</code>
<code>$lesson_id</code>
<code>$lesson_id</code>
<code>$lesson_id</code>
<code>$question_id</code>
<code>$question_id</code>
<code>$question_id</code>
Expand Down Expand Up @@ -2726,9 +2717,6 @@
<code>! is_array( $new_value )</code>
<code>! is_array( $old_value )</code>
</DocblockTypeContradiction>
<DuplicateArrayKey occurrences="1">
<code>'type' =&gt; 'email'</code>
</DuplicateArrayKey>
<InvalidArgument occurrences="1"/>
<MissingParamType occurrences="3">
<code>$include_milliseconds</code>
Expand Down Expand Up @@ -4736,9 +4724,8 @@
</PossiblyInvalidPropertyFetch>
</file>
<file src="includes/internal/student-progress/quiz-progress/repositories/class-comments-based-quiz-progress-repository.php">
<InvalidScalarArgument occurrences="2">
<InvalidScalarArgument occurrences="1">
<code>$comment-&gt;comment_post_ID</code>
<code>$lesson_id</code>
</InvalidScalarArgument>
<PossiblyInvalidIterator occurrences="2">
<code>$comments</code>
Expand Down Expand Up @@ -5187,6 +5174,11 @@
<code>Sensei_REST_API_Import_Controller</code>
</PropertyNotSetInConstructor>
</file>
<file src="includes/rest-api/class-sensei-rest-api-internal.php">
<PossiblyNullArgument occurrences="1">
<code>Sensei()-&gt;tour</code>
</PossiblyNullArgument>
</file>
<file src="includes/rest-api/class-sensei-rest-api-lesson-quiz-controller.php">
<ArgumentTypeCoercion occurrences="1"/>
<DocblockTypeContradiction occurrences="1">
Expand Down Expand Up @@ -5422,6 +5414,11 @@
<code>Sensei_REST_API_Theme_Controller</code>
</PropertyNotSetInConstructor>
</file>
<file src="includes/rest-api/class-sensei-rest-api-tour-controller.php">
<PropertyNotSetInConstructor occurrences="1">
<code>Sensei_REST_API_Tour_Controller</code>
</PropertyNotSetInConstructor>
</file>
<file src="includes/sensei-functions.php">
<InvalidIterator occurrences="2">
<code>$base</code>
Expand Down Expand Up @@ -5798,7 +5795,8 @@
</RedundantCast>
</file>
<file src="includes/wpml/class-language-details.php">
<DocblockTypeContradiction occurrences="1">
<DocblockTypeContradiction occurrences="2">
<code>is_wp_error( $question_id )</code>
<code>is_wp_error( $question_id )</code>
</DocblockTypeContradiction>
</file>
Expand All @@ -5818,14 +5816,4 @@
<code>function wp_remote_request($url, $args = array())</code>
</InvalidDocblock>
</file>
<file src="includes/rest-api/class-sensei-rest-api-tour-controller.php">
<PropertyNotSetInConstructor occurrences="1">
<code>Sensei_REST_API_Tour_Controller</code>
</PropertyNotSetInConstructor>
</file>
<file src="includes/rest-api/class-sensei-rest-api-internal.php">
<PossiblyNullArgument occurrences="1">
<code>Sensei()->tour</code>
</PossiblyNullArgument>
</file>
</files>
17 changes: 15 additions & 2 deletions includes/blocks/class-sensei-block-take-course.php
Expand Up @@ -48,7 +48,20 @@ public function render_take_course_block( $attributes, $content ): string {
}

$course_id = $post->ID;
$html = '';

/**
* Filters the course ID for the take course block.
*
* @hook sensei_block_take_course_course_id
*
* @since $$next-version$$
*
* @param {int} $course_id The course ID.
* @return {int} The course ID.
*/
$course_id = apply_filters( 'sensei_block_take_course_course_id', $course_id );

$html = '';

if ( 'course' !== get_post_type( $course_id ) ) {
return '';
Expand Down Expand Up @@ -117,7 +130,7 @@ private function render_with_start_course_form( $course_id, $button ) {
*
* @return string The html with the added classes.
*/
private function add_button_classes( $button ) : string {
private function add_button_classes( $button ): string {
wp_enqueue_script( 'sensei-stop-double-submission' );

if ( preg_match( '/<button(.*)class="(.*)"/', $button ) ) {
Expand Down
1 change: 0 additions & 1 deletion includes/blocks/class-sensei-course-progress-block.php
Expand Up @@ -46,7 +46,6 @@ public function register_block() {
public function render_course_progress( $attributes ): string {

$course_id = $attributes['postId'] ?? get_the_ID();

if ( 'course' !== get_post_type( $course_id ) ) {
return '';
}
Expand Down