Python Parsons Problems with Visual Results. Quebra-cabeças de Parsons em Python com resultado visual
  • JavaScript 60.4%
  • Python 28.8%
  • HTML 8.3%
  • CSS 2.5%
Find a file
2026-04-29 21:21:09 +02:00
.vscode Run prettier 2022-08-08 15:59:14 -07:00
dist updating pyp5js with more py5 compat hacks 2025-07-02 10:11:42 -03:00
js updating pyp5js with more py5 compat hacks 2025-07-02 10:11:42 -03:00
js-parsons Update LICENSE 2025-03-18 10:59:27 -03:00
parsons_probs update 130_olhos 2025-07-05 13:54:35 -03:00
.editorconfig Use tabsize of 2 2022-11-20 17:43:08 -03:00
.eslintignore Refactoring 2022-08-10 13:03:39 -07:00
.eslintrc.json remove unecessary console.log eslint rule 2023-07-07 15:54:56 -03:00
.git-blame-ignore-revs Adding git blame ignore refs 2022-08-08 16:01:31 -07:00
.gitignore Add idea files to gitignore 2022-11-20 17:43:19 -03:00
.prettierrc.json Refactoring 2022-08-10 13:03:39 -07:00
index.html Update index.html 2026-04-19 22:15:17 -03:00
LICENSE Create LICENSE 2022-08-11 13:15:07 -07:00
package-lock.json update... 2023-09-21 12:47:39 -03:00
package.json Update package.json 2025-03-18 11:06:19 -03:00
parsons_ideas_log.md Update parsons_ideas_log.md 2024-04-27 14:09:59 -03:00
problem.html Update problem.html 2024-04-30 13:00:39 -03:00
README.MD Update README.MD 2026-04-29 21:21:09 +02:00
rollup.config.js Using a web worker 2022-08-26 13:13:25 -07:00
update_index.py Updates doctstring of update_index.py 2025-07-02 15:50:04 +02:00

Python Faded Parsons Problems with Visual Output

This tool should allow you to run Faded Parsons Problems in static page in the browser, with visual results, using pyp5js (pyodide and the p5js canvas) to show the sketch results, as written with puzzle blocks in a dialect close to py5 in imported mode style.

Based on faded-parsons-static by Pamela Fox, with help from many people! With special thanks to Luciano Ratamero who adapted & inserted pyp5js and made this all work.

Work in progress, working prototype!

Check out the tool in action at https://abav.lugaralgum.com/python-parsons-visual/

A quick way to make and publish your own puzzles

You can fork this repository, edit the YAML files in the parsons_prob folder as explained bellow, and set the GitHub Pages settings to publish your own page, or upload on some other webhosting server. This tool is based on "static pages", so uploading the files (mostly html, js, yaml, images and etc.) is all there is to it.

If you want to know more and contribute with this tool/project

Setting up a local development environmet

Be sure to have nodejs installed. To install nodejs, go to their download page and download the installer for your operating system: https://nodejs.org/en/download/

We will assume you have at least some familiarity with the command line. After installing, open a terminal, go to the project's folder using cd (the one you're in right now) and run:

npm install

This will install all the dependencies for the website.

If you don't have npm installed, double check the installation instructions for nodejs for your operating system.

Running the website locally

From the download directory:

npm run dev

This will start a local server at http://localhost:8000/ where you can see the website. Also, whenever you change something in the code, reload the page to see the changes.

Building the website

To make the site ready for deployment, run:

npm run build

This will recreate the dist folder with the website ready to be deployed.

Deploying the website

The website can be deployed anywhere since it's entirely static. The working prototype example at https://abav.lugaralgum.com/python-parsons-visual/ is served using the files index.html (home page), problem.html (puzzle page) and the folder with the puzzles YAML data and assets. You can use the Codeberg Pages or GitHub Pages feature on your own fork of the repo to host it. Note the README.md should not become the starting page due to the index.html presence.

Adding a new problem

Add files to the parson_probs folder:

  • problem_file.yaml: This is a YAML file that includes the problem description (HTML) and code lines with blanks.

  • You should add an image to the description, like problem_file.png, in the same folder.

  • Example 000_variables.yaml that uses 000_variables.png in the same folder:


problem_name: Variables

problem_subtitle: assignement

problem_category: Getting Started

problem_description: |
  <img src="parsons_probs/000_variables.png"></br>
  <h5>Variables</h5>
  <code>assignement</code></br>
  Organize blocks of lines to make the drawing above.
  Notice indentation matters.

code_lines: |
  def setup(): #0given
  size(400, 400) #1given
  background(200) # fundo cinza
  nome = '!BLANK'
  text(nome, 20, 180)  # desenha o texto de `nome`
  # Se tentar usar a variável `a` antes de criar...
  # ... vai ter um erro do tipo NameError (não conheço `a`)
  a = 10  # cria a variável `a` que aponta para o valor 10
  square(a, 10, 140)  # desenha um quadrado de lado 140 em x:10, y:10
  a = a + 145  # calcula o valor de `a + 145` e muda a variável `a`
  square(a, 10, !BLANK)  # desenha um quadrado de lado 140

Then you can access the new problem at .../problem.html?name=problem_file

Updating the index/home page

The Python script update_index.py, that depends on Beautiful Soup 4, will look for YAML problems in the parsons_probs folder, check the category and update the index.html with links to all the problems found.

Automating YAML generation from puzzle source code

Also inside the parson_probs folder, you will find some .py files that contain py5 code, in imported mode style for a problem, with added annotations like #0given as explained above, and some extra special comments containing !REMOVE on some lines, as well as commented out lines with code containing !BLANK. Those scripts will generate the YAML problem file and the image file for the problem description.