Blocks - adaptive-learning/flocs GitHub Wiki

Blocks are used for building code in Blockly. Every task has its own set of blocks available from which the user must construct a solution to a given problem. This set is defined in a task fixture under the section "workspace settings" using the attribute "toolbox" (see Tasks). The toolbox is list of strings where each string is the name of a block or category. It is not possible to mix block names and categories names due to some Blockly limitation.

Some categories and more complex blocks (those with input values) are accessible through simple names defined in a file blocks.cst.js (see section Available blocks). If you are not satisfied with predefined categories and wish to use for example just some subset of it, feel free to define your own by editing the file with name definitions (blocks.cst.js). Adding a name definition is basically adding an attribute to JS object.

"unique_name":"corresponding part of toolbox in XML",

It is also possible to define a category directly in the toolbox, where you can use object instead of string. The object must conform to the following structure.

{
  "category":"Name of your category",
  "items": [ "list of block/category names as strings" ]
}

You can even create nested categories if necessary.

Blocks Order

  • maze_move_forward
  • maze_turn
  • controls_repeat [task can specify controls_repeat:10]
  • controls_while, maze_check_goal
  • maze_check_path
  • maze_check_color
  • controls_if
  • controls_if_else
  • logic_operation
  • functions [task can then specify which functions will be available]
  • variables [includes both variables_set and variables_get, ideally enable to specify predefined list of variables for each task] + number + plus [???] / read and compare color? [maybe this is better for text programming..?]

Available blocks

  • maze_category

    • maze_move_forward
    • maze_turn
    • maze_check_path
    • maze_check_goal
    • maze_check_color
  • not present in the maze category, but available as standalone

    • maze_check_path_left
    • maze_check_path_right
    • maze_check_path_front
    • maze_turn_left
    • maze_turn_right
  • if_category

    • controls_if
    • controls_if_else
    • controls_if_elseif_else
  • loops_category

    • controls_repeat – repeat given number of times
    • controls_repeat:10 – repeat given number of times, with prefilled 10
    • controls_while – repeat while
    • controls_for – for loop variable from, to and step
    • controls_forEach
    • controls_flow_statements – break, continue
  • boolean_category

    • logic_compare – (non) equality, less/greater (equal) than
    • logic_operation – conjunction and disjunction
    • logic_negate – negation
    • logic_boolean – boolean constants
    • logic_null – null value
    • logic_ternary – same as ?: in Java
  • math_category

    • math_number – number constant
    • math_arithmetic – basic arithmetic operations
    • math_single – some predefined functions like square root
    • math_trig – trigonometric functions
    • math_constant – some predefined constant (pi, e, ...)
    • math_number_property – check parity and other properties
    • math_round
    • math_on_list – compute some functions across all list items
    • math_modulo
      • some other block, that are not defined as standalone
  • lists_category

    • lists_create_empty
    • lists_create_with
    • list_repeat
    • lists_length
    • lists_isEmpty
    • lists_indexOf
    • lists_getIndex
    • lists_setIndex
  • variables_category

    • variables_set
    • variables_get
  • functions_category

Inspiration for new blocks: blockly maze-game (from Google), code.org