<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">The way we did conditional validations in the DfE project was to use validation contexts that mapped the current page/slug to specific validations, for example:<div class=""><br class=""></div><div class=""><table class="js-file-line-container highlight tab-size" data-tab-size="8" data-paste-markdown-skip="" style="box-sizing: border-box; border-spacing: 0px; border-collapse: collapse; tab-size: 8; caret-color: rgb(36, 41, 46); color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 14px;"><tbody style="box-sizing: border-box;" class=""><tr style="box-sizing: border-box;" class=""></tr><tr style="box-sizing: border-box;" class=""><td id="LC49" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; line-height: 20px; vertical-align: top; overflow: visible; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; word-wrap: normal; white-space: pre;">    <span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">validates</span> <span class="pl-pds" style="box-sizing: border-box; color: rgb(3, 47, 98);">:current_school</span><span class="pl-kos" style="box-sizing: border-box;">,
</span><span class="pl-pds" style="box-sizing: border-box;">      </span><span class="pl-pds" style="box-sizing: border-box; color: rgb(3, 47, 98);">on</span>: <span class="pl-kos" style="box-sizing: border-box;">[</span><span class="pl-pds" style="box-sizing: border-box; color: rgb(3, 47, 98);">:"current-school"</span><span class="pl-kos" style="box-sizing: border-box;">,</span> <span class="pl-pds" style="box-sizing: border-box; color: rgb(3, 47, 98);">:submit</span><span class="pl-kos" style="box-sizing: border-box;">]</span><span class="pl-kos" style="box-sizing: border-box;">,
</span><span class="pl-pds" style="box-sizing: border-box;">      </span><span class="pl-pds" style="box-sizing: border-box; color: rgb(3, 47, 98);">presence</span>: <span class="pl-kos" style="box-sizing: border-box;">{</span><span class="pl-pds" style="box-sizing: border-box; color: rgb(3, 47, 98);">message</span>: <span class="pl-s" style="box-sizing: border-box; color: rgb(3, 47, 98);">"Select a school from the list"</span><span class="pl-kos" style="box-sizing: border-box;">}</span></td></tr><tr style="box-sizing: border-box;" class=""><td id="L50" class="blob-num js-line-number" data-line-number="50" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; line-height: 20px; color: rgba(27, 31, 35, 0.3); text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none;"></td></tr></tbody></table><div class="">Works for the most part but does result in a large/messy set of validations on the models.</div><div class=""><br class=""><div class="">
<div>Tekin</div></div><div><a href="http://tekin.co.uk" class="">http://tekin.co.uk</a> / <a href="https://twitter.com/tekin" class="">@tekin</a></div><div><br class=""></div><div><blockquote type="cite" class=""><div class="">On 22 Jul 2020, at 11:45, Ed Jones <<a href="mailto:ed@error.agency" class="">ed@error.agency</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">We've used Wicked a few times, and wrote a gem to allow you to do conditional validation based on the step you're on: <a href="https://github.com/errorstudio/wicked-wizard-validations/" class="">https://github.com/errorstudio/wicked-wizard-validations/</a><div class=""><br class=""></div><div class="">I would echo Tekin - it's not the right solution for this. It's hard to reason with after a while, and that gem kinda demonstrates the complexity of relatively simple stuff.</div><div class=""><br class=""></div><div class="">Ed<br class=""><div class=""><div class="">
<div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">--</div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><b class="">Error</b><br class="">A human-centred interaction agency<br class=""><br class="">4th Floor, 86-90 Paul Street,<br class="">London, EC2A 4NE<br class=""><br class="">Tel: 020 3637 5060<br class="">Mobile: 0779 187 4282<br class="">Twitter: @erroragency<br class=""><a href="http://error.agency/" class="">http://error.agency</a></div>
</div>
<div class=""><br class=""><blockquote type="cite" class=""><div class="">On 22 Jul 2020, at 11:41, Tekin Süleyman <<a href="mailto:tekin@tekin.co.uk" class="">tekin@tekin.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Ed,<div class=""><br class=""></div><div class="">I recently completed a project for Department for Education that did a good chunk of those things from scratch:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">- Complex routing through the questionnaire</div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">- "Go back" to previous questions/change answers</div></blockquote><div class=""><br class=""></div><div class="">Adding “resume” and scoring wouldn’t be too difficult but wasn’t needed for this particular project.</div><div class=""><br class=""></div><div class="">It's open source and available to view on GitHub: <a href="https://github.com/DFE-Digital/claim-additional-payments-for-teaching" class="">https://github.com/DFE-Digital/claim-additional-payments-for-teaching</a>.</div><div class=""><br class=""></div><div class="">The best place to start to get an idea of how it works is to look at the <font face="Courier" class=""><span style="font-style: normal;" class="">ClaimsController</span></font>, the central <font face="Courier" class="">Claim</font> model and the two journey-specific <font face="Courier" class="">SlugSequence</font> classes that combine with the <font face="Courier" class="">PageSequence</font> class to provide the routing logic/flow.</div><div class=""> </div><div class="">It was written to support two separate question sets/flows that have a shared set of common questions (the <font face="Courier" class=""><span style="font-style: normal;" class="">Claim</span></font>) and flow-specific questions (see the polymorphic <font face="Courier" class=""><span style="font-style: normal;" class="">Eligibility</span></font> models and corresponding namespaces), with the idea that more could be added in the future without too much difficulty.</div><div class=""><br class=""></div><div class="">I know of the <a href="https://github.com/zombocom/wicked" class="">wicked</a> gem that I’ve seen used for step-by-step wizard-style flows. I’ve not used it personally but I would be very wary of building an engine of any sort of complexity on top of something like this. In my experience they work great until you need to do something slightly outside of what it supports, then you’re buggered.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">
<div class="">Tekin<br class=""><a href="http://tekin.co.uk/" class="">http://tekin.co.uk</a> / <a href="https://twitter.com/tekin" class="">@tekin</a><br class=""></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On 22 Jul 2020, at 10:37, Ed James <<a href="mailto:ed.james.spam@gmail.com" class="">ed.james.spam@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi all<div class=""><br class=""></div><div class="">Does anyone have any experience with building out a complex questionnaire engine?</div><div class="">I’m very interested in hearing what people have done and whether you wrote from scratch or used any 3rd-party tools/gems/etc.</div><div class=""><br class=""></div><div class="">Some of the things I need to be able to handle are:</div><div class=""><br class=""></div><div class=""><ul class="MailOutline"><li class="">Complex routing through the questionnaire based on answers to previous question(s)</li><li class="">Scoring/weighting of answers to calculate a final score</li><li class="">Grouping of weighted questions to allow for score calculations of “question groups”</li><li class="">Ability to “resume” questionnaire</li><li class="">Ability to “go back” through previous questions to change answers before completion</li></ul><div class=""><br class=""></div><div class="">Any advice/insights would be greatly appreciated.</div><div class=""><br class=""></div><div class="">Thanks!</div><div class="">
<br class="">
<hr style="display: block; height: 1px; border: 0; border-top: 1px dotted #ccc; margin: 5px 0; padding: 0;" class="">
<br class="">
<table border="0" cellpadding="0" width="100%" class="">
  <tbody class="">
    <tr class="">
      <td valign="top" width="70" class="">
        <img height="60" src="http://ej-public.s3.amazonaws.com/images/rubbish.png" style="margin: 8px 8px 0 0;" class="">
      </td>
      <td style="font-family:'Lucida Grande',sans-serif" class="">
          <span style="font-weight:bold; color: #333333; font-size: 18px; line-height:30px;" class="">Ed James</span>
          <br class="">
          <span style="font-weight:normal; color: #999; font-size: 12px; line-height:16px;" class="">
              <a href="mailto:ed.james.spam@gmail.com" style="color:#999; text-decoration:none" target="_blank" class="">I will respect your spam</a>
          </span>
      </td>
    </tr>
  </tbody>
</table>

</div>

<br class=""></div></div>_______________________________________________<br class="">Chat mailing list<br class=""><a href="mailto:Chat@lists.lrug.org" class="">Chat@lists.lrug.org</a><br class="">Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" class="">http://lists.lrug.org/pipermail/chat-lrug.org</a><br class="">Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" class="">http://lists.lrug.org/options.cgi/chat-lrug.org</a><br class="">List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" class="">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br class=""></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">Chat mailing list<br class=""><a href="mailto:Chat@lists.lrug.org" class="">Chat@lists.lrug.org</a><br class="">Archives: <a href="http://lists.lrug.org/pipermail/chat-lrug.org" class="">http://lists.lrug.org/pipermail/chat-lrug.org</a><br class="">Manage your subscription: <a href="http://lists.lrug.org/options.cgi/chat-lrug.org" class="">http://lists.lrug.org/options.cgi/chat-lrug.org</a><br class="">List info: <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" class="">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br class=""></div></blockquote></div><br class=""></div></div></div>_______________________________________________<br class="">Chat mailing list<br class=""><a href="mailto:Chat@lists.lrug.org" class="">Chat@lists.lrug.org</a><br class="">Archives: http://lists.lrug.org/pipermail/chat-lrug.org<br class="">Manage your subscription: http://lists.lrug.org/options.cgi/chat-lrug.org<br class="">List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org<br class=""></div></blockquote></div><br class=""></div></div></body></html>