"Contains" option for checking strings

I’ve added some feedback to an activity where students have to write the standard form and the vertex form of a quadratic. I have my feedback use a hidden graph to check for equivalent functions as opposed to the exact contents of the string, and this is working great to avoid issues where students write a correct answer that is slightly different from mine. The students will still be marked correct as long as they have an equivalent function in the answer boxes.

However, a lot of my students are mixing up which is which between standard and vertex form, and my feedback is still marking their answers correct. Is there a way for me to add in a conditional to check that a string contains a particular set of characters? For example, I know that the standard form version of the equation must contain an x^2 whereas the vertex form must NOT contain an x^2. Combined with my current equivalent function check, I think these conditionals should avoid some of the problems I’m having.

Slide:

This a place to flex the power of patterns. They can definitely take some practice and experimentation to get right and identify edge cases, but here’s my go at this one.

I didn’t know about patterns. This is rad. Gonna dig deeper into this. Just started watching the pattern matching playlist from Desmos on youtube.

Quick question after looking at some of what you did. It appears that patterns.product and patterns.sum are commutative-- so (x+6) will be identified the same as (6+x). Is that right?

Gonna watch the rest of the videos and try to understand your code. Will follow up with more questions if I have them. Thanks!

Those patterns are commutative. You can, however, add .strictOrder to a pattern to limit to the order of the pattern if it’s desirable.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.