Decision trees will be a plugin which allows a user to create one or more branched (dendritic) decision trees from the WordPress admin area. A decision tree will consist of two or more nodes which each explain a question or item which requires a decision. Each node will have a number of one way paths from it to other nodes, I am referring to these as "answers".
This diagram from Wikipedia illustrates the kind of decision trees this plugin will handle. Note the simple branching structure, and that all nodes only link to their own child nodes, and there is no "doubling back" or "linking across". I hope this will keep a good level of simplicity, and help users to maintain a coherent mental model of each tree.
The plugin will register a CPT called "Decision Trees".
Editing
Required elements of a node:
- A title
- At least one answer
Initially we will just require multiple choice answers, which could be implemented as an array of links (most probably), or an array of radio buttons (I'm not sure why Smart Answers implements the selection mechanism as a form, it seems less crawlable… but perhaps they're not bothered). I'd like to have it so that the selection mechanism for the answers can be extended using another plugin.
Here's a mockup showing how I think of the selection meta box with just the basic multiple choice answers available:
In the model above, when you add an answer you are simultaneously adding a new child node and defining the answer text. If no title is provided, the answer text should be used for the title; however it should be possible for the text of the answer leading to a node to be separate from the title of that node.
I think re-parenting nodes will not be necessary.
Here's mockup showing how the selection meta box might work with some additional selection mechanisms enabled:
As an admin user, it would be useful to be able to navigate an entire decision tree while it is in draft, before it's published. This would require filtering permalinks to make them preview compatible.
It would be useful to be able to publish an entire decision tree in one action, rather than having to set the post_status
on each node in turn.
Display
The answer links (or other selection mechanism) should be appended using the_content
filter, and should have lots of lovely classes and IDs for CSS.
If no answer text has been provided, then the title of the child nodes should be used.
There should be no archive view for the Decision Trees CPT.