From 82f2de2fbc941b22ce1334ea17e4ebab96462702 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Wed, 27 Feb 2013 22:46:37 +0000 Subject: [PATCH] Support and tags in the conversion of checklists to tutorials. --- Nasal/checklist.nas | 57 +++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/Nasal/checklist.nas b/Nasal/checklist.nas index 52ae324b5..27f852a15 100644 --- a/Nasal/checklist.nas +++ b/Nasal/checklist.nas @@ -26,26 +26,43 @@ var convert_checklists = func { # Now go through each of the checklist items and generate a tutorial step # for each. - foreach (var item; ch.getChildren("item")) { - step = tutorial.getNode("step["~ size(tutorial.getChildren("step")) ~ "]", 1); - - var msg = item.getNode("name", 1).getValue(); - - if (size(item.getChildren("value")) > 0) { - msg = msg ~ " :"; - foreach (var v; item.getChildren("value")) { - msg = msg ~ " " ~ v.getValue(); - } - } - - step.getNode("message", 1).setValue(msg); - description = description ~ msg ~ "\n"; - - if (item.getNode("condition") != nil) { - var cond = step.getNode("exit", 1).getNode("condition", 1); - props.copy(item.getNode("condition", 1), cond); - } - } + + # Checklist may consist of one or more pages. + var pages = ch.getChildren("page"); + + if (size(pages) == 0) { + # Or no pages at all, in which case we need to create a checklist of one page + append(pages, ch); + } + + foreach (var page; pages) { + foreach (var item; page.getChildren("item")) { + step = tutorial.getNode("step["~ size(tutorial.getChildren("step")) ~ "]", 1); + + var msg = item.getNode("name", 1).getValue(); + + if (size(item.getChildren("value")) > 0) { + msg = msg ~ " :"; + foreach (var v; item.getChildren("value")) { + msg = msg ~ " " ~ v.getValue(); + } + } + + step.getNode("message", 1).setValue(msg); + description = description ~ msg ~ "\n"; + + if (item.getNode("condition") != nil) { + var cond = step.getNode("exit", 1).getNode("condition", 1); + props.copy(item.getNode("condition"), cond); + } + + if (item.getNode("marker") != nil) { + var marker= step.getNode("marker", 1); + props.copy(item.getNode("marker"), marker); + } + + } + } tutorial.getNode("description", 1).setValue(description); }