Configuring a Logo (Turtle) Problem
Turtle problems allow students to use the Python Turtle API to make programs that draw vector graphics.
Basic Configuration Details
These problems are configured with Language: Logo.
Marking a Logo problem requires using the Python 3 Logo
driver, with the Logo Diff
checker.
Beta: It is now possible to use the Python 3 Function
driver with the Logo Diff
checker. Care must be taken to configure the failure message template for this combination of driver / checker. Please ask us for assistance if you'd like to mark questions with this configuration.
Initialisation file
You can include turtle commands in a special initial workspace file -- ___turtle.py
-- in order to set up the turtle world (if needed). These commands will be executed before any commands in program.py
(or program.blockly
) and will be saved (on a Terminal run) in the logo-final
and logo-animation
data used in an inline snippet.
The ___turtle.py
workspace file needs to have the following File Settings to function correctly:
undeletable
,unrenamable
,readonly
,hidden
,exportable
If using an inline snippet, it must have the following parameters:
path:___turtle.py;readonly;hidden;exportable;eg:your-eg-id;
Supported API Features
The following commands from the Turtle API are supported:
- Movement commands:
forward
,backward
,right
,left
,goto
- Set position and heading:
setx
,sety
,setheading
- Shorthand drawing commands:
circle
,dot
- World configuration:
bgcolor
,degrees
,radians
,reset
,clear
,setworldcoordinates
- State information:
position
,towards
,xcor
,ycor
,heading
,distance
- Pen configuration:
pensize
,penup
,pendown
,pen
,isdown
- Colours:
color
,pencolor
,fillcolor
,colormode
- Fills:
filling
,begin_fill
,end_fill
- Turtle Appearance:
showturtle
,hideturtle
,isvisible
,speed
,shape
,settiltangle
,tilt
,tiltangle
,get_shapepoly
,getshapes
Creating Turtle Animations
___logo_animation
and
___logo_final
respectively. You can copy the contents by cmd+click'ing the Copy button in the editor. This allows you to specify the workspace filename to copy. Enter one of these two hidden filenames, and the contents of those hidden workspace files will be copied to their copy buffer.
NOTE there is currently a bug that means you need to perform this copy operation twice before the clipboard is populated.
Author-only API Features (custom API)
Grok has added new API hooks to allow an author to use features that are not in the Python Turtle AP.
bgurl(image_url)
-- Set the background to an image loaded via an asset URL. The background image should be 400 x 300 in size, to match the shape of the Turtle display window. Images that are smaller than this size will tile across the background. Use this api hook inside a ___turtle.py
workspace file.