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

Allow searching for substring in content #215

Open
3 tasks
BTWS2 opened this issue Apr 4, 2022 · 0 comments
Open
3 tasks

Allow searching for substring in content #215

BTWS2 opened this issue Apr 4, 2022 · 0 comments
Labels
enhancement New feature or request high priority Things we want to see implemented soon
Milestone

Comments

@BTWS2
Copy link
Collaborator

BTWS2 commented Apr 4, 2022

has_content doesn't allow to check if a substring is present. Either add contains_content or add substring search functionality to has_content.

Use case: Make exercises more personal and detecting plagiarism easier. Structure has to be there, but content can be different for each student e.g.

"Make mini website with an image, a paragraph of at least 50 characters and a table of 3 rows. If the image can't be displayed the text should contain the text "not found".

  • Add option to compare only plain text, removing all tags (also child tags). See example below.
  • If possible option with direct to only search in top level. See example below.
  • Add option to specify minimum or maximum characters the plain text tag should contain.
<ol>
    <li>Fruitmand
        <ul>
            <li>Appel</li>
            <li>Peer</li>
        </ul>
    </li>
    <li><a href="groenten.html">Groentenschaal</a></li>
</ol>
html = HtmlSuite(content)
body = html.element('body')
ol = body.get_child('ol', 0)
li0 = ol.get_child('li', 0)

html.make_item("Het eerste lijstelement bevat de tekst 'Fruit' in het topniveau.",
        li0.contains_content("fruit", case_insensitive=True, remove_tags=True, direct=True))  # True
html.make_item("Het eerste lijstelement bevat de tekst 'Peer' in het topniveau.",
        li0.contains_content("peer", case_insensitive=True, remove_tags=True, direct=True))  # False
html.make_item("Het eerste lijstelement bevat ergens de tekst 'Peer'.",
        li0.contains_content("peer", case_insensitive=True, remove_tags=True, direct=False))  # True
@BTWS2 BTWS2 added the enhancement New feature or request label Apr 4, 2022
@BTWS2 BTWS2 added this to the 1.0.1 milestone Apr 4, 2022
@BTWS2 BTWS2 added the high priority Things we want to see implemented soon label Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request high priority Things we want to see implemented soon
Projects
None yet
Development

No branches or pull requests

1 participant