How to organise multipart answers to difficult questions?

So this comes in a couple of separate but interrelated (interwingled?) problems.

  1. I have a question broken down into the steps shown above. Semantically…what’s the best way to label them which clearly shows where the answer in in relation to the overall solution? Answer Part 1, 1 of 2 or something else?

2.TWiki code NEEDED: No matter what naming convention I use I need all the answers and sub answers to point back to the same question. (And possibly back up to the previous level of answer?).

Answers currently start with A: and have the same name as the question which starts with 'Q: ’

It I understand the question, I’d create two list fields for an answer tiddler:

list fields: question and answer.

The question list field lists tiddlers for any question it answers.

The answer list field optionally lists tiddlers for any parent answer tiddler.

It would be up to you if the question field should be empty if a parent answer field is populated. I think I would do this.

Technically, if you define that answer can only have 1 question and optionally only 1 parent answer, then these fields are not list fields, but rather title fields.

You’d have to recurse the hierarchy. In fact there are tree plugins that could draw your diagram if needed.

Does this make sense?

1 Like

I actually think that the labels you have there are just fine for labeling them. An alternate version might be A: Winding Demo 1.1.2, but I think just as you have them is fine. Use captions if you want a more pleasant display of their titles. One big advantage of the style you have now is that you can derive the hierarchy directly from the titles. No need to fiddle with parent fields or children list fields.

If you do go this route, then we can have straightforward answers to this question:

We can use code like this:

<$let 
  question={{{ [<currentTiddler>removeprefix[A: ]search-replace::regexp[(\/\d+)+$],[]addprefix[Q: ]] }}}
  parent={{{ [<currentTiddler>search-replace::regexp[\/\d+$],[]] :filter[is[tiddler]] }}}
>

to derive the Question and (when applicable) the parent from any part of a template for Answer tiddlers.

And we can get the children of any question or answer with a function like this:

\function get.children(ans) 
  [prefix<ans>] -[<ans>]
  :filter[trim:prefix<ans>regexp[\/\d+$]!regexp[\/\d+\/\d+$]]
  +[format:titlelist[]join[ ]]
\end

If we wanted, we could write some recursive tool to show the entire hierarchy of a Question and its Answer(s), perhaps highlighting the current node, and put the result in the footer of each tiddler. I didn’t go that far, but I did create a little demo you can try: QandA.json (2.4 KB) QandA.json (2.6 KB)

Here’s how a few of the tiddlers look:

Only a few of the tiddlers have captions, but that’s easy to remedy. If you’re interested in the kind of hierarchical view I mentioned, let me know if you need help. I’ve done things like it a few times.

1 Like

Thanks for that Scott. I’ll give you a full reply when I’ve had a chance to look at it properly. (work is a bit mad at the moment!)

And lo, a few minutes at lunch time opened up. That looks absolutely spot on. Thank you!

What is that?

A CurlyWurly?

Ok, finishing a boring meeting, and I did try this (although not with the footers) and created a hierarchy sidebar tab, showing all Questions with their Answers and (sub )sub-Answers:

QandA2.json (3.9 KB)

To be production-ready, it would probably need to mimic the selective-expandable TOC, which would take a bit of work, but this shows the idea.

1 Like

Tiny tiny thing…
Works wonderfully for multiparts, but doesn’t pick up a straight Q: This Question, A: This answer where there is no \1, because there is just the answer. Not the end of the world, I can always \1 up :slight_smile:

While we could certainly fix that, I’d be afraid of an ambiguity in naming. Is A: My Question/1 the first answer to Q: My Question, or is it the first child of the one and only answer A: My Question?

But to fix it, we could simply update Question Footer Template this way:

<% if [<currentTiddler>tag[Question]] %>

----------
!!! All Answers
<$let 
  base={{{ [<currentTiddler>removeprefix[Q: ]addprefix[A: ]] }}}
>
<ul>
  <$list filter="[<base>is[tiddler]] [get.children<base>enlist-input[]]">
<!--    add:     ^^^^^^^^^^^^^^^^^^^^  -->
    <li><$link><$view field="caption"><$view field="title"/></$view></$link></li>
  </$list>
</ul>
</$let>
<% endif %>

I’d have to think a bit more about how to update the sidebar tab from my recent response. Let me know if you would like me to try.

Much appreciated. I’m happy with the current solution, but, if you did have any more boring meetings :smiley:

Sorry to peck your head again…

image

The answer sans ‘/’ now picks up it’s self as a parent. I guessed (probably wrongly) that this was a regex thing in the answer footer, but I’ve been unable to AI my way to a solution!

I think this would fix that, in the answer footer:

<$let 
  question={{{ [<currentTiddler>removeprefix[A: ]search-replace::regexp[(\/\d+)+$],[]addprefix[Q: ]] }}}
  parent={{{ [<currentTiddler>search-replace::regexp[\/\d+$],[]] :filter[is[tiddler]!match<currentTiddler>] }}}
<!--                                                                    add this:   ^^^^^^^^^^^^^^^^^^^^^^  -->
>

This version fixes that, and updates the (still naive) Q+A sidebar to handle extension-less single answer titles.

QandA3.json (4.6 KB)

But don’t forget, allowing for both numbered and unnumbered answers can lead to naming ambiguities.