Skip to content

Blockly that's more Python than JavaScript, powered with Skulpt

License

Notifications You must be signed in to change notification settings

scareface972/blockpy

 
 

Repository files navigation

corgis-blockly

CORGIS BlockPy

BlockPy is a web-based Python environment that lets you work with blocks, text, or both. Designed for Data Science and equipped with powerful tools like the State Explorer and Guided Feedback, the goal of BlockPy is to let you solve authentic, real-world problems.

The goal of BlockPy is to give you a gentle introduction to Python but eventually mature you into a more serious programming environment (such as Spyder or PyCharm). Long-term, we may support some game/animation design stuff that Scratch/Snap does, but that's not the real goal.

The BlockPy project is aimed at solving some hard technical problems: having a block-based environment for a dynamic language can be tricky - are a given pair of square brackets representing list indexing or dictionary indexing? Our goal is to use advanced program analysis techniques to provide excellent support to learners.

Overview

The core architecture of BlockPy is a synthesis of:

  • Blockly: a visual library for manipulating a block canvas that can generate equivalent textual code in a variety of languages
  • Skulpt: an in-browser Python-to-JavaScript compiler/intepreter, that aims to emulate the full language with precision if not speed.

By combining these two technologies, we end up with a powerful system for writing Python code quickly. Everything is meant to run locally in the client, so there's no complexity of sandboxing students' code on the server.

The major innovations are:

  • PythonToBlocks: by parsing the AST generated by Skulpt, we can build equivalent Blockly code, effectively allowing round-trips between text and blocks.
  • CORGIS Datsets: new blocks access real-world datasets (although currently these are only cached versions, for performance reasons).
  • Interactive Guided Problems: Problem text is given to students, along with teacher provided code that can do analysis on the students' code and make suggestions (e.g., observing that they haven't printed anything yet).
  • Data Explorer: The data explorer allows users to walk through their code.

Installation

First, clone it locally. This could take a little while.

> git clone https://github.com/RealTimeWeb/blockpy.git

You'll need to build Skulpt and Blockly. Both of these depend on the Closure Compiler, so you'll need to put that in the empty closure-library folder. You can follow the [Blockly instructions here] (https://developers.google.com/blockly/hacking/closure) , but the gist will be:

> wget https://github.com/google/closure-library/zipball/master -O closure.zip
> unzip closure.zip

That's from memory - if anyone can submit a PR or correction for this, that'd be amazing. The crucial thing is that you want to make sure that you have a folder named closure and a folder named third-party one layer below the top folder, and that you don't have multiple closure-library folders. This may be much easier to do by hand.

Next, you'll need to build Blockly:

> cd blockly
> python build.py
> cd ..

And then you'll build Skulpt:

> cd skulpt
> python skulpt.py dist
> cd ..

And now you should be able to try out the example file!

> start blockpy.html

The server has its own requirements.txt and uses a python manage.py runserver

Commands

Both Blockly and Skulpt are subtrees.

Push changes to the subtrees' repos:

> git subtree push --prefix=skulpt/ --squash skulpt master
> git subtree push --prefix=blockly/ --squash blockly master
> git subtree push --prefix=server/ --squash server master
> git subtree push --prefix=server/static/blockly-games --squash blockly_games master

Pull changes from upstream repos (e.g., official Blockly and Skulpt, our production server):

> git subtree pull --prefix=skulpt --squash skulpt_upstream master
> git subtree pull --prefix=blockly --squash blockly_upstream master
> git subtree pull --prefix=server --squash server master
> git subtree pull --prefix=server/static/blockly-games --squash blockly_games master

Note: if you get an error about a "fatal entry", make sure you don't have a trailing slash on the prefix!

About

Blockly that's more Python than JavaScript, powered with Skulpt

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 81.5%
  • HTML 16.5%
  • Python 1.3%
  • CSS 0.6%
  • C 0.1%
  • Shell 0.0%