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

Teacher tool: field value validator added #9867

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

srietkerk
Copy link
Contributor

@srietkerk srietkerk commented Feb 14, 2024

A validator that checks the field values of a block has been added to our validator library. Field values are a specific type of input for a block. The easiest type that I can demonstrate is the different operators that are associated with the math_arithmetic block. In this case, the field value type is "OP" or, I'm guessing, the shorthand for operation. Some others that I've seen in blocklycompiler.ts are: TEXT, EXPRESSION, VAR, BOOL, NAME, VALUE and more. The "OP" field value for the math_arithmetic block can be ADD, MINUS, MULTIPLY, DIVIDE and more.

You'll see that the validation I made for logic_compare is looking for something very specific. The logic_compare blocks in the following program don't pass because the one that has the EQ "OP" type doesn't have two math_number blocks, and the other that has two numbers has a different "OP" type.

nums-equal

Edit: And to show that it can pass lol
nums-equal-pass

One thing to note about this approach is that if we want to support any type of field value, we need to know that field value's name and possible values it can be before we can create the validator for it. @riknoll chatted with me and let me know that this will require quite a bit of work because all of our custom blocks have field value names that are going to be tricky to find. He recommended a way for me to find the different field values, which isn't hard, just tedious. I'm planning on making a table in OneNote that will have the relationship between a block, it's field value names, and the variations that a specific field value can have. For now, I'm planning to build this table as I go, but we might reach a time when we'll want to just fill the table as earnestly as possible.

@srietkerk srietkerk requested a review from a team February 14, 2024 03:22
Copy link
Contributor

@eanders-ms eanders-ms left a comment

Choose a reason for hiding this comment

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

Very nice! Made one small suggestion.

I agree building the table as we go is fine for now. We will want to put this info in a publicly visible doc at some point as part of documenting the process for writing validator plans.

common-docs/teachertool/catalog-shared.json Outdated Show resolved Hide resolved
@srietkerk srietkerk merged commit 461a8db into master Feb 15, 2024
6 checks passed
@srietkerk srietkerk deleted the srietkerk-field-val-validator branch February 15, 2024 00:34
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.

2 participants