Skip to content
rrees edited this page Jun 4, 2011 · 4 revisions

Dojo exercises

There are three things I see as being potentially interesting for hacking on.

Creating new flows

The script create-flowchart-data.py creates an example question set. However it is a bit awkward as it traverses flows to check whether things exist in order to create them.

Try and create a new flow and put your data into an index to allow you to see directly whether something exists.

You can access indexes via db.nodes.indexes which is dictionary-like. You can use the methods create and get to create and access indexes.

Really making the question set a flow

Currently the questions are not linked in the question-set. Ideally when we click on an answer in the web application we would be taken to the next question.

Create a relationship between each answer and the question you feel should follow it and then create the appropriate link in the web demo code.

Once you have linked all the questions then only the question with the First relationship should appear on the questionnaire.

You can create some interesting loops doing this where some answers take you on to other questions before returning to the main flow.

For example if a character was surrounded by the sea you might ask them whether they had a boat or not.

Creating characters

This is a bit challenging for a half-hour slot. To avoid having to implement the flow above you might want to apply the hack that after each answer the next question id will be qn to qn+1. So if you answered a Question with id q2, just jump to the Question with id q3. If that question does not exist then you've finished creating a character.

There are two stub urls in the application:

  • /start/flow/:flow_id
  • /character/:character_id

The first creates a character node and puts it in an index. The second just displays the character's id.

What should happen is that the second link should show you either the current question and answer set from the question flow or instead display the character's details if no questions are left.

When a character is created they have a relationship of Current set to node that the First relationship points to in the question flow.

As the player answers the questions the Current question should be set to look at the next question and the character node should create a relationship of Reward with the answer's related reward. Once all the questions are complete the url should instead display all the Rewards the character has.

You can find all the relationships a node has with other nodes by using node.relationships.outgoing([the relationship type, so Reward, Question, Answer and so on]).