Skip to content

Fix required quiz score texts#7793

Merged
renatho merged 6 commits intotrunkfrom
fix/required-quiz-score-text
Mar 29, 2025
Merged

Fix required quiz score texts#7793
renatho merged 6 commits intotrunkfrom
fix/required-quiz-score-text

Conversation

@renatho
Copy link
Copy Markdown
Contributor

@renatho renatho commented Mar 27, 2025

Resolves #7788

Proposed Changes

  • Fix required quiz score texts.
  • The used approach will keep the old text for translations until it's translated. I created an issue to remove the conditionals in the future here: Remove translation conditionals #7794
    • Notice that I used the new has_translation function (introduced in WP 6.7). The strings won't be translated in older versions until we remove the conditionals.

Testing Instructions

  1. Create a course with a lesson and a quiz with pass required.
  2. Answer the quiz and grade it.
  3. Visit the lesson and quiz pages with and without Learning Mode.
  4. Check that the new text is applied to your English site.
  5. Change the site language (I tested it with "Português do Brasil", but you can use any language that contains the translations), and make sure it continues getting the existing translations.
  6. Test that it's not broken on WordPress 6.5.

Screenshots

Screenshot 2025-03-27 at 17 37 55
Screenshot 2025-03-27 at 17 38 32
Screenshot 2025-03-27 at 18 03 39
Screenshot 2025-03-27 at 18 05 04
Screenshot 2025-03-27 at 18 05 11

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • Follows our naming conventions (P6rkRX-4oA-p2)
  • Hooks (p6rkRX-1uS-p2) and functions are documented
  • New UIs are responsive and use a mobile-first approach
  • Code is tested on the minimum supported PHP and WordPress versions

@renatho renatho changed the title Fix/required quiz score text Fix required quiz score texts Mar 27, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Test the previous changes of this PR with WordPress Playground.

@renatho renatho self-assigned this Mar 27, 2025
@renatho renatho added this to the 4.24.6 milestone Mar 27, 2025
@renatho renatho requested a review from a team March 27, 2025 21:22
@renatho renatho marked this pull request as ready for review March 27, 2025 21:23
@github-actions
Copy link
Copy Markdown
Contributor

Test the previous changes of this PR with WordPress Playground.

@renatho
Copy link
Copy Markdown
Contributor Author

renatho commented Mar 27, 2025

Ah, I need to take a look at the Psalm issues here.

@renatho renatho marked this pull request as draft March 27, 2025 22:34
@renatho renatho marked this pull request as ready for review March 27, 2025 22:53
@github-actions
Copy link
Copy Markdown
Contributor

Test the previous changes of this PR with WordPress Playground.

$grade_rounded
);

if ( get_locale() === 'en_US' || ( function_exists( 'has_translation' ) && has_translation( 'You must score at least %1$s%% to pass this quiz. Your grade is %2$s%%.', 'sensei-lms' ) ) ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extract these three checks to a helper function? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure! Updated in these 2 commits:

@renatho renatho force-pushed the fix/required-quiz-score-text branch from 073146c to 961c171 Compare March 28, 2025 22:12
@github-actions
Copy link
Copy Markdown
Contributor

Test the previous changes of this PR with WordPress Playground.

@github-actions
Copy link
Copy Markdown
Contributor

Test the previous changes of this PR with WordPress Playground.

@renatho renatho force-pushed the fix/required-quiz-score-text branch from 961c171 to 38522d5 Compare March 28, 2025 22:22
@renatho renatho force-pushed the fix/required-quiz-score-text branch from 38522d5 to 83314ea Compare March 28, 2025 22:23
// Quiz grade.
$submission = Sensei()->quiz_submission_repository->get( $quiz_id, $user_id );
$quiz_grade = $submission ? $submission->get_final_grade() : 0;
$quiz_grade = ( $submission ? $submission->get_final_grade() : 0 ) ?? 0;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just fixing a psalm issue.

@github-actions
Copy link
Copy Markdown
Contributor

Test the previous changes of this PR with WordPress Playground.

@github-actions
Copy link
Copy Markdown
Contributor

Test the previous changes of this PR with WordPress Playground.

Copy link
Copy Markdown
Contributor

@Imran92 Imran92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@renatho renatho merged commit bf84d54 into trunk Mar 29, 2025
22 checks passed
@renatho renatho deleted the fix/required-quiz-score-text branch March 29, 2025 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the wording clearer: "You require %1$d%% to pass this lesson's quiz."

2 participants