HTML judge - use of any_of function #5419
-
What I want to achieveI want to check if the submitted HTML contains multiple How I am trying to do itI have an array with the contents I am looking for. While iterating the array I'm trying to check if an # Import all necessary modules (same for every exercise)
from validators.checks import HtmlSuite, TestSuite, ChecklistItem
def create_suites(content: str) -> list[TestSuite]:
# Create test suite for HTML with basic validator included
html = HtmlSuite(content)
#em contents to search
ems_contents ={
"the tendency to seek, interpret, and create information that verifies existing beliefs",
"self-fullfilling prophecy",
"meest waarschijnlijke reden voor de buitensporige invloed van bevestigende informatie is dat het makkelijker is om er cognitief mee om te gaan",
"Naar: Verplaetse, J. (2003). Inleiding in de argumentatieleer, Gent: onlinecursus."
}
#Get all ems on the page
foundems = html.all_elements('em')
# iterate trough the content and check that at least on em is found with the desired content
for em_content in ems_contents:
any_of(em.has_content(em_content) for em in foundems)
return [html] The problem I am experiencingWhile executing this validator I get an error indicating the any_of function does not exists. I am probably forgetting to load a library but din't find which one.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can find the example exercises here: https://github.com/dodona-edu/example-exercises/tree/master/html. Your exercise is similar to https://github.com/dodona-edu/example-exercises/blob/master/html/ugent_faculty_websites/evaluation/evaluator.py. You need to import the functions you are using from the module e.g. : from validators.checks import HtmlSuite, CssSuite, TestSuite, ChecklistItem, at_least, all_of, any_of Is your function Footnotes |
Beta Was this translation helpful? Give feedback.
You can find the example exercises here: https://github.com/dodona-edu/example-exercises/tree/master/html. Your exercise is similar to https://github.com/dodona-edu/example-exercises/blob/master/html/ugent_faculty_websites/evaluation/evaluator.py.
You need to import the functions you are using from the module e.g. :
Is your function
any_of
underlined or marked in orange (or similar)? For autocomplete you need to add the foldervalidators
with the checks.pyi file at the root of your project in which you write the evaluators. 1Footnotes
https://github.com/dodona-edu/judge-html?tab=readme…