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

Fix HTML generation for content descriptions (particularly for answers) #4848

Closed
BenHenning opened this issue Jan 20, 2023 · 2 comments · Fixed by #5614 or #5655
Closed

Fix HTML generation for content descriptions (particularly for answers) #4848

BenHenning opened this issue Jan 20, 2023 · 2 comments · Fixed by #5614 or #5655
Assignees
Labels
bug End user-perceivable behaviors which are not desirable. Impact: Low Low perceived user impact (e.g. edge cases). Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet.

Comments

@BenHenning
Copy link
Member

This was discovered as part of #4846. We currently generate content descriptions by parsing HTML and then converting that to a string (which strips the spans from the generated HTML). The problem with this approach is it leads to the custom tag text also being stripped out, which leads to incomplete strings like this:

Remember that two halves, when added together, make one whole. Click on this .

(Notice the lack of context before the '.').

The correct version would actually be:

Remember that two halves, when added together, make one whole. Click on this test_skill_id_1 concept card.

We probably need to introduce a custom generation pipeline for content descriptions in CustomHtmlContentHandler to ensure these cases can be properly covered. We also should be checking for other link cases, including anchors, or any case when text can appear between tags.

@adhiamboperes adhiamboperes added Impact: Low Low perceived user impact (e.g. edge cases). bug End user-perceivable behaviors which are not desirable. Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet. labels Aug 10, 2023
@adhiamboperes adhiamboperes self-assigned this May 17, 2024
@BenHenning BenHenning added this to the 1.0 Global availability milestone Aug 29, 2024
@adhiamboperes adhiamboperes removed their assignment Sep 17, 2024
@manas-yu manas-yu self-assigned this Dec 21, 2024
adhiamboperes added a commit that referenced this issue Jan 14, 2025
…in CustomHtmlContentHandler (#5614)

<!-- READ ME FIRST: Please fill in the explanation section below and
check off every point from the Essential Checklist! -->
## Explanation
<!--
- Explain what your PR does. If this PR fixes an existing bug, please
include
- "Fixes #bugnum:" in the explanation so that GitHub can auto-close the
issue
  - when this PR is merged.
  -->
Fix #4848: This PR resolves the issue with incomplete content
descriptions being generated for custom HTML tags. The existing
implementation stripped out spans and custom tag content, leading to
incomplete descriptions.

The updated implementation introduces a custom generation pipeline for
content descriptions in `CustomHtmlContentHandler`. It ensures that all
custom tag content is correctly processed and appended, resulting in
complete and accurate descriptions.

### Key Changes:
- Added a `StringBuilder` to accumulate content descriptions and a
`MutableMap` to handle custom tag descriptions.
- Implemented `getContentDescription()` to combine default text with
custom tag content descriptions, ensuring seamless integration.
- Introduced a `ContentDescriptionProvider` interface for handling
custom tags.
- Updated relevant tag handlers (`ImageTagHandler`,
`ConceptCardTagHandler`, `LiTagHandler`, `PolicyPageTagHandler` and
`MathTagHandler`) to implement the new interface.
- Verified the implementation with appropriate test cases.

## Essential Checklist
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [x] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).

---------

Co-authored-by: Adhiambo Peres <[email protected]>
@github-actions github-actions bot reopened this Jan 14, 2025
Copy link

The issue is reopened because of the following unresolved TODOs:

// TODO(#4848): Fix content description generation & update this test to verify using the

@adhiamboperes
Copy link
Collaborator

@manas-yu, PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug End user-perceivable behaviors which are not desirable. Impact: Low Low perceived user impact (e.g. edge cases). Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet.
3 participants