Parsons Exercise: Shuffling Extracted Blocks and Auto-grading

I am trying to develop Parsons Problem exercise for defining algebraic data types, as shown by the screenshot below.

I used the feature “generate puzzle” to extract the constructor names, field names, and types (displayed as Keyword Fragment -- the purple blocks) from a complete data definition. This exercise is intended for students to create correct data definition using extracted pieces and other provided blocks. This is the result I got after implementing the "generate puzzle" feature.

I have two questions regarding this outcome:

  1. When using “generate puzzle” feature, I was hoping that the extracted pieces (in "Keyword Fragment") are randomly shuffled. However, when I run “generate puzzle”, the order is still the same as the original data definition. Is there any way to shuffle the order of these pieces?

  2. I would like to implement auto-grading for students’ data definition. How can I implement this auto-grading feature that can grade whether students arrange the block correctly or not?

I really appreciate any insight and advice. Thanks in advance!

HI Jessica! Welcome to Snap!.

  1. I don't think there's currently a way to shuffle the palette. Bear in mind that mostly what people want is to be able to find the same block in the same place next time. On our list for When Things Slow Down™ is a way to let Snap! programs rearrange the palettes, but that's not even designed yet let alone implemented.

  2. Yes, it's possible; we have teachers doing that. But it's not trivial. You can arrange your reporter blocks so that they report a list structure showing the tree of types, then have your top-level C-shaped block compare their tree with yours. Alternatively, you can turn a script into a syntax tree and then write code to analyze it. A third way would be to create instances of the defined type and ask it questions such as "what fields do you have?" All of these are a lot of work to set up, especially the first time. I would suggest delegating this project to a 12-year-old. But I'll see if some of my colleagues can point you to examples.

I'm intrigued that you chose Snap! as the basis for a type-heavy curriculum; we mostly let data carry their type information, like Lisp, rather than putting the type information in variable declarations, like Java. So, for example, I'd be inclined just to say LENGTH rather than LENGTH OF TYPE INT, so it'd just be SQUARE HAS LENGTH. Just to satisfy my curiosity, could you say more about where the curriculum comes from and how you chose Snap! to implement it? (I'm delighted that you did, don't misunderstand.)

Hi Brian!

Thank you so much for your kind response. I am looking forward to the implementation of the shuffle palette in the near future :slight_smile:

I am really glad that you are interested in our project!
This project inspired by one of the lectures in my college (yes, I am a college student) about functional programming in Scala, which is taught by my academic advisor. One of the topics given is learning about constructing algebraic data types. This might answer your question why it is type-heavy: because we are using Scala, a statically typed language.

We are trying to consider many block-based programming language for the implementation. We found Snap!, and it feels like it suits my project with less hassle to make block, i.e. you can easily use and make your own block + define how those block work freely. Also, we found that there is a feature in Snap! that enable us to use Parsons Problem.

I am delighted to have discovered Snap! and excited to delve deeper into this programming language :slight_smile:

Interesting. We have had people use Snap! to represent exactly some other language, with one block per syntactic element. That sounds like what you're after. And probably you won't find a better tool for the purpose -- unless there's a block-based user interface specifically for Scala, the way Greenfoot is an exact representation of Java.

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