-
Notifications
You must be signed in to change notification settings - Fork 7
Routing MK2 Author to Runner Conversion
SamGodwin2 edited this page Nov 22, 2018
·
6 revisions
Author API output
{ < -- RoutingRuleSet
condition: And,
rules: [
{ <- RoutingRule
lhs: {
id: "1",
__typename: "Answer"
},
operator: Equal,
rhs: RHS
},
{ <- RoutingRule
lhs: {
id: "2",
__typename: "Answer"
},
operator: Equal,
rhs: "2"
}
],
destination: Block
}
{
goto: {
block: "blockId",
when: [{
id: "1",
condition: "equals",
value: RHS
},
{
id: "2",
condition: "equals",
value: "2"
}]
}
}
Author API output
{ < -- RoutingRuleSet
condition: Or,
rules: [
{ <- RoutingRule
lhs: {
id: "1",
__typename: "Answer"
},
operator: Equal,
rhs: RHS
},
{ <- RoutingRule
lhs: {
id: "2",
__typename: "Answer"
},
operator: Equal,
rhs: "2"
}
],
destination: Block
}
[{
goto: {
block: "blockId",
when: [{
id: "1",
condition: "equals",
value: RHS
}]
}
},
{
goto: {
block: "blockId",
when: [
{
id: "2",
condition: "equals",
value: "2"
}]
}
}]
Author API output
{
condition: AND
rules: [
{
condition: OR,
rules: [
{
lhs: answer1
comparator:Equal
rhs:2
},
{
lhs: answer1
comparator:Not Set
rhs:null
},
{
lhs: answer1
comparator:Not Set
rhs:null
}
]
},
{
condition: OR,
rules: [
{
lhs: answer1
comparator:Equal
rhs:2
},
{
lhs: answer1
comparator:Not Set
rhs:null
},
{
lhs: answer1
comparator:Not Set
rhs:null
}
]
}
{
lhs: answer2
comparator:NotEqual
rhs:8
},
{
lhs: answer3
comparator:Equal
rhs:1
}
]
}
[
{
goto: destination,
when: [
{
condition: "not set",
id: answer1
},
{
condition: "not equals",
id: answer2,
value: 8
},
{
condition: "not equals",
id: answer3,
value: option1
}
]
},
{
goto: destination,
when: [
{
condition: "equals",
id: answer1,
value: option2
},
{
condition: "not equals",
id: answer2,
value: 8
},
{
condition: "not equals",
id: answer3,
value: option1
}
]
}
];
Author API output
{
condition: OR
rules: [
{
condition: AND,
rules: [
{
lhs: answer1
comparator:Equal
rhs:2
},
{
lhs: answer1
comparator:Not Set
rhs:null
},
{
lhs: answer1
comparator:Not Set
rhs:null
}
]
},
{
condition: AND,
rules: [
{
lhs: answer1
comparator:Equal
rhs:2
},
{
lhs: answer1
comparator:Not Set
rhs:null
},
{
lhs: answer1
comparator:Not Set
rhs:null
}
]
}
{
lhs: answer2
comparator:NotEqual
rhs:8
},
{
lhs: answer3
comparator:Equal
rhs:1
}
]
}
[
{
goto: destination,
when: [
{
condition: "not set",
id: answer1
},
{
condition: "not equals",
id: answer2,
value: 8
},
{
condition: "not equals",
id: answer3,
value: option1
}
]
},
{
goto: destination,
when: [
{
condition: "equals",
id: answer1,
value: option2
},
{
condition: "not equals",
id: answer2,
value: 8
},
{
condition: "not equals",
id: answer3,
value: option1
}
]
}
];
enum LeftHandSideEntity {
answer
metadata
}
enum RightHandSideEntity {
answer
custom
optionArray
}
type LHS {
entityType: LeftHandSideEntity!
answer: Answer
metadata: Metadata
}
type RHS {
entityType: RightHandSideEntity!
answer: Answer
custom: JSON
optionArray: [Option]
}
Hacky and very basic gist that seems to work to translate the logic into the correct format (needs cleaning): https://gist.github.com/SamGodwin2/e761857c7c14ad23937d07964e90b511