Adding an activity
Revision as of 05:12, 20 August 2006 by 82.228.70.121 (talk)
Adding an activity is very simple. There are 2 ways do develop activities, in C code or in Python. The easiest and recommended language is python.
Menu creation
First, create a menu for your activity. The menus are XML formatted. They are located under the boards directory. They contain many informations about your activity. They must be in a file named myactivity.xml.in:
<?xml version="1.0" encoding="UTF-8"?> <GCompris> <Board name="pythontest" type="python:myactivity" section="/experimental" icon="boardicons/python.png" difficulty="1" author="Bruno (bruno@gxxx.net)" boarddir=""> <_title>Python Test</_title> <_description>Test board for the python plugin</_description> <_prerequisite>Advanced Python Programmer :)</_prerequisite> <_goal>Add a language-binding to gcompris.</_goal> <_credit>Thanks to Guido van Rossum and the python team for this powerful language!</_credit> </Board> <Data directory=""/> </GCompris>
Here are the meaning of each field:
Field | Description |
---|---|
name | Must be the name of this file |
type | This let GCompris knows where is the code for your activity. Note that several menu enties can use the same activity code. If the code is in python, the prefix python: must be added. |
section | Where in the directory structure of the menu this activity will be placed. It must be one of those:
|
icon | Points to a png image representing your activity. The directory is relative to the boards directory. By convention, all icons are always placed in the same boardicons directory. |
difficulty | The level of difficulty, must be a number from 1 to 6.
|
author | Who wrote the code, who made the graphism |
boarddir | Usualy empty. In some case, you want to create an antivity that parse specific data and behave accordingly. In this case, you can specify in this field, where is the data directory for this activity. |
_title | Note the underscore, it's very important. It means this field will be translated. Put here a title name for your activity. GCompris is dedicated to children. You must use words they can understand. |
_description | Provide here a little bit more information about the activity |
_prerequisite | What competencies are needed to play this activity. This information is part of the inline (and online on gcompris.net) help. |
_goal | What are you going to teach, what must be achieved in the activity. |
_credit | Did you get help, rewards goes here |
Last step, add your new menu to the file boards/Makefile.am and the file po/POTFILES.in. You can run make to be sure it is valid. The file boards/myactivity.xml will be created.
Activity code
Now your menu is ready, you need the code:
- In python, create src/boards/python/myactivity.py and add it in the Makefile.am there.
- In C, create src/boards/myactivity.c and add it in the Makefile.am there.