New blocks-based intro course to js/DOM programming

229 views
Skip to first unread message

Gregory Dyke

unread,
Mar 20, 2022, 10:37:56 AM3/20/22
to Blockly

Hi all

I believe infrequent project announcements are ok on this group (particularly as there are subparts of the project I think would be useful for the wider community, so I would like feedback on what you would like to see made available as blockly plugins/importable projects).

I'm very excited that we now have a shareable MVP for CYF Blocks, Code Your Future's intro course to js/DOM programming.

We are a volunteer based full stack course with the aim of getting meaningful jobs in tech for refugees and other people who would not otherwise have access to learning to code.

This is part of our new Fundamentals module (that has not been trialled with actual students yet, so your feedback would be very welcome). It is the first 3 week module that will be followed by further modules: Html/css, JavaScript (3 modules), React, Node, Postgres, Project. Our goal with this Fundamentals module is to teach some basics of problem solving through code with the intent to transition quite rapidly to writing Javascript in subsequent modules. Blockly allows us to abstract away from javascript syntax and the conceputally challenging DOM API (and the frameworks that exist on top of it). The new DOM blocks we've created allow us to start solving exactly the same kinds of web development problems that students will see in the remainder of the course. (We previously used code.org and khan academy extensively, but saw some transfer problems when transitioning to Javascript/DOM).

What you can do for us:
- try it out and report back (in this thread or by email to me directly: greg...@gmail.com)
- share your experiences in teach adults introduction to programming, particularly to JS web development through blockly
- share your experiences in writing blocks for the DOM (I have only found one set of DOM blocks so far and that was more a 1-1 mapping)

What we can maybe do for you:
- Make our DOM blocks available more widely (I think they present a useful subset of the DOM in a way that both powerful and restricted enough to not be overwhelming, particularly in the design decision to use context rather than variables to manage which html element is currently being worked with)
- We have an mechanism for offering multiple exercises in sequence, and for authoring exercises (along with testing to know whether the exercise was completed succesfully), that might be useful for anyone wanting to teach web development

Hoping you're having a great transition into spring!
Greg

Beka Westberg

unread,
Apr 8, 2022, 6:43:01 PM4/8/22
to blo...@googlegroups.com
Hi Greg! Sorry we missed this post. This is so cool!

Some things I love about your project:
1) I think the way you've styled Blockly is wonderful. There are so many nice things about it, but to pick just one: the little pink highlight you gave to the categories really ties the workspace into the rest of your application  :D
2) Your dom manipulation blocks seem really thorough and well developed! For example, I was delighted to discover that this actually works how I would expect it to:
image.png

```
let element_list = document.getElementById('list');
let element_list2 = document.getElementById('list2');
element_list2.innerText = 'cats';
element_list.innerText = 'dogs';
```

(Side note: Are you using a custom JavaScript generator? I'm curious about how you're handling indentation)

Not to mention the use of shadow blocks, and using events to add warnings to blocks when they are incorrectly placed!

If you want to convert these blocks into a third-party plugin that would be awesome! And I'm sure other projects would find it helpful, even just as an example of some really great block design! Here are some resources to get you started with creating a plugin if you choose to.

And if you get stuck just post to this forum and the core team will happily help =)

Also, if you haven't signed up already, you should consider coming to our upcoming developers summit. We'd love to hear your thoughts on Blockly =)

Best wishes,
--Beka

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/4a93d52c-f92a-40d5-bc67-48dd1d32886en%40googlegroups.com.

Gregory Dyke

unread,
Apr 10, 2022, 7:10:22 AM4/10/22
to blo...@googlegroups.com
Hi Beka

Thanks for responding. You do wonderful work in this group and particularly in making sure that nobody goes unanswered!

The styling is my wonderful colleague and allround badass Sally McGrath (also our Director of Education at Code Your Future). I'm unreasonably excited about it.

I'm glad you noted the block design. I spent literally days (i.e multiple months of elapsed time) working it out and trying different combos. I also struggled with whether to use lists and how to differentiate js/blockly lists from html lists - and what operations to allow on lists.

The context variables (and lack of indentation inside those contexts) is "just" the following 3 lines of code, carrying a stack of context variables so that you can nest and unnest, plus a custom statementToCode that doesn't do indentation (each "context setting block" must call these lines, and each "context needing block" must be a descendant of a "context setting block")

Blockly.JavaScript.pushWithContextVariable(elementVar);
let branch = Blockly.JavaScript.statementToCodeNoIndent(block, "STACK");
Blockly.JavaScript.popWithContextVariable();

I'm already attending the developers summit (and presenting!!), so I look forward to "meeting" everyone there.

I'm also excited to figure out how to make a plugin and will definitely reach out

As a last point, allow me to introduce the ridiculousness that is our share button (everything is stored locally at the moment, so the url contains uriencoded compressed json serialized from blockly)


Cheers,
Greg

Beka Westberg

unread,
Apr 11, 2022, 10:27:31 AM4/11/22
to blo...@googlegroups.com
Hi again Greg!

> You do wonderful work in this group and particularly in making sure that nobody goes unanswered!

Hehe it's a team effort. There are a lot of questions to get to!

> The context variables (and lack of indentation inside those contexts) is "just" the following 3 lines of code, carrying a stack of context variables so that you can nest and unnest, plus a custom statementToCode that doesn't do indentation (each "context setting block" must call these lines, and each "context needing block" must be a descendant of a "context setting block")

That is very interesting! And seems like a very elegant solution to the problem. Both in terms of user experience, and in terms of implementation. For the user-experience side of things, were you inspired by any existing system? I don't think I've seen a solution like this before. The closest thing I can think of is AppInventor's lexical variable system, but you still have to directly refer to the variables (they aren't just scooped up from context).

> As a last point, allow me to introduce the ridiculousness that is our share button (everything is stored locally at the moment, so the url contains uriencoded compressed json serialized from blockly)

Haha that's wonderful! Whatever work works. Also love that you're using the JSON serialization <3

> I'm already attending the developers summit (and presenting!!), so I look forward to "meeting" everyone there.

Awesome! Can't wait to see you there :D

Best wishes,
--Beka

Gregory Dyke

unread,
Apr 12, 2022, 9:55:13 AM4/12/22
to blo...@googlegroups.com

> The context variables (and lack of indentation inside those contexts) is "just" the following 3 lines of code, carrying a stack of context variables so that you can nest and unnest, plus a custom statementToCode that doesn't do indentation (each "context setting block" must call these lines, and each "context needing block" must be a descendant of a "context setting block")

That is very interesting! And seems like a very elegant solution to the problem. Both in terms of user experience, and in terms of implementation. For the user-experience side of things, were you inspired by any existing system? I don't think I've seen a solution like this before. The closest thing I can think of is AppInventor's lexical variable system, but you still have to directly refer to the variables (they aren't just scooped up from context).

The inspiration was actually the xtend programming language, which is a slight variant on java that transpiles to java. Xtend has lambdas with an implicit "it" variable that is also optional (similar to how "this" is often optional), so the following are all equivalent.

people.forEach[person | person.greet]
people.forEach[it.greet]
people.forEach[greet]
people.forEach(Person::greet) // not sure about this one

xtend also has a with operator that allows a lambda block to be executed with an expression as the argument, which makes for nice builders

val greg = new Person
greg.setName("Greg")
greg.setEyeColor("blue")
greg.addInterest("CYF")
 
can be written as

val greg = new Person => [
  name = "Greg" // implicit it.setName
  eyeColor = "blue"
  addInterest("CYF")
]

I assume there are other languages with something similar

Cheers
Greg

Beka Westberg

unread,
Apr 12, 2022, 10:14:40 AM4/12/22
to blo...@googlegroups.com
Wow what a fun language construct! It's awesome that you were able to get something like it working in blocks. Thank you for sharing :D

--Beka

Reply all
Reply to author
Forward
0 new messages