Tag passages with same word and add count each time learner selects it to have sum at end of scenario

Twine Version: Latest version of Twine in Browser - latest version of Harlowe

Greyelf and Hal9000 have been so helpful. I don’t want to keep bothering them on one one stream, so thought this should be a new topic.

I have created a scenario where clinicians each time have 3 options they can select. 2 are incorrect and 1 will move them through their day. I was wondering if it was possible to add something like a tag on all the incorrect passages and they can get a +1 count each time. Then on my last page of the scenario it would say you took “x” number of wrong turns but you made it through your twelve hour shift. And that “x” would be all the times added up that they chose one of the incorrect links.

I tried googling what I was looking for and I honestly am too new to know if this is even possible. But thought tagging the passages might be an easy way to add it up at the end if there is a count formula that would work.

I hope this makes sense. And if the number on the last page is in a certain range say “0-6” or “7-11” can I make different messages appear.

I realize I may be asking for way too much. So no worries.

Cheers
T

Not only is it possible, it’s quite straight forward. We’ve got you covered. I’m not at my computer, but I’ll look into it much later today if someone else doesn’t reply first. I don’t want to give you code that looks like it works without actually testing it. I think I corrected myself twice last time. :wink:

The simplest way to do this is probably to put something like this on the final screen:

You took (print: (history: where its tags contains "wronganswer")'s length) wrong turns.

(Replacing “wronganswer” with whatever passage tag you’re using to indicate this.)

Here’s the explanation of the history macro in the manual.

2 Likes

While you can use the (metadata:) macro to add additional information to a Passage’s definition during play-through, the Passage’s Tags are read-only and can only be assigned while editing your project.

So if your want to use a Passage Tag to mark the ‘wrong’ passages you would need to do so before generating a Story HTML file. And E. Joyce has supplied you with an example of how to search through History to find any entries that have the tag you are looking for.

note: History tracks the order that Passages were visited. So if a specific Passage is visited three times then its Name will appear in History three times, thus potentially inflating the count of how many Passages in History have a specific tag.

There are many other ways to track which ‘wrong’ Passages the end-user visited, and one of the simplest is to use an Array variable in which you store the Name of the ‘wrong’ Passages that were visited. And this technique allows to control the uniqueness of the Name being tracked.

1: Initialise the Array variable in your project’s startup tagged Passage.

(set: $wrongs to (a:))

2: Add the Name of the ‘wrong’ Passage to the Array when it is visited.

There are two points you can do this:

a: Within the content of the ‘wrong’ Passage itself:

<!-- using generic code, where the Name is dynamically determined -->
(unless: $wrongs contains (passage:)'s name)[
	(set: $wrongs to it + (a: (passage:)'s name))
]

<!-- using specific code, where the Name is set while editing the project -->
(unless: $wrongs contains 'Two plus two is twenty-two')[
	(set: $wrongs to it + (a: 'Two plus two is twenty-two'))
]

note: one of the above examples uses the (passage:) macro to determine the Name of the current Passage.

b: Within the link that caused the transition to the ‘wrong’ Passage:

(link-reveal-goto: "Select Me", 'Two plus two is twenty-two')[
	(unless: $wrongs contains 'Two plus two is twenty-two')[
		(set: $wrongs to it + (a: 'Two plus two is twenty-two'))
	]
]

note: the above uses the (link-reveal-goto:) macro to execute a (set:) macro before transitioning to the target Passage.

3: Use the Array’s length property to determine how many ‘wrong’ Passages were visited.

You made (print: $wrongs's length) wrong answers.
1 Like

Ah, yeah, I was assuming the scenario was linear and the passages couldn’t be revisited, but that might have been a bad assumption.

Oh good point E.Joyce, I am really new to trying out a full scenario, so if they make a wrong choice right now I have them go back to the previous level, I did with the help of @HAL9000 and @Greyelf learn to change my link colours if they are visited, so I have done that for now, so that learner can see they were already there.

okay, gonna start to read the others and see if I can get the count working. Thanks so much

Thanks everyone. I am going to try to figure out GreyElf’s code ,but I am not too confident in myself lol!

I am wondering if there is away to insert my example in GreyElfs information so I can figure it out.

My start up passage is Safe Med Admin Scenario.
I have a passage: “Morgan’ 1st patient” - it will have three links on it:
Option 1 - this one is incorrect and I make them go back to “Morgan 1’st patient)”
Option 1a - this one is incorrect and I make them go back to “Morgan 1’st patient)”
Option 1b - this one is correct and they move forward

In my start up passage “Safe Med Admin Scenario” I think this is where I put (set: $wrongs to (a:)), do I put it in exactly like that?

For step two in the example below in the Option 1 passage would I write:

(unless: $wrongs contains (Option 1:)'s name) [
(set: $wrongs to it + (a: (Option 1:)'s name))
]

And I do this for every incorrect passage I have?

Then in my " Congratulations" passage I write

You made (print: $wrong's length) wrong answers.

Do I write it like that?

You two are being very patient with me. Thank ou. I wasn’t sure if b (the link info) was another example or something else I have to do, if yes, where would it go? For this example my link from Morgan’s 1st patient to Option 1 passage has a link name of “Do not give Morgan the medication”

Hope I haven’t completed confused myself :slight_smile:

Thank you both.

Just a quick update. I got the set instructions in the startup passage and the print in the last passage and the last passage does say 0 returns so I think that is good.

But when I did the Option 1 write up it says “I can’t run macro 'Option 1” because it doesn’t exist. and it says this twice. It asked me if I meant to run a macro as I had (this:)

This bit of code

(unless: $wrongs contains (passage:)'s name)[
	(set: $wrongs to it + (a: (passage:)'s name))
]

is meant to be used verbatim; “passage” isn’t a placeholder to be replaced with the name of the passage in question, it’s a specific macro that’s being called here.

Oh Okay, I have a lot to learn. So I write this code on every passage that I consider to be incorrect?

Update: it worked, thank you…

And on the last passage where now I see my number going up. Can I put a macro in here like an If macro
meaning if the number is 0-5 show this text if it is 6-11 shows this text? Then they can really understand how well they did.

Hi there, just an update, I found a link reveal/replace macro and I got it to work for my ranges :0
I just can’t get the text to hide if I select another one, but I am thinking maybe that is okay. Would that be easy.

I have this:

Throughout the scenario you took (print: $wrongs's length) incorrect turns.

Select your range to get some feedback.

(text-colour:yellow)[You took] (link-reveal: "0-5") [(replace: ?great) 

[Great work! You have a good understanding of safe medication administration best practices, policies and procedures. Remember, policies are reviewed and updated regularly, so be sure to check back to review what you know. You can find all the CAMH policies and procedures on Insite.]] (text-colour:yellow)[incorrect turns.]
|great>[]

(text-colour:yellow)[You took] (link-reveal: "6-10") [(replace: ?good) 

[You have a fair understanding of safe medication administration best practices, policies and procedures, but could benefit from a deeper review. These policies are reviewed and updated regularly, so be sure to check back to review the latest versions. You can find all the CAMH policies and procedures on Insite.]] (text-colour:yellow)[incorrect turns.]
|good>[]

and it works, but wondering if the text that reveals can disappear when I select a different one.

Cheers
T

You can automate this using an if macro instead of making the test-taker select their score manually. Something like:

\(if: $wrongs's length <= 5)
    [Great work! You have a good understanding of safe medication administration best practices, policies and procedures. Remember, policies are reviewed and updated regularly, so be sure to check back to review what you know. You can find all the CAMH policies and procedures on Insite.]
\(else: )
    [You have a fair understanding of safe medication administration best practices, policies and procedures, but could benefit from a deeper review. These policies are reviewed and updated regularly, so be sure to check back to review the latest versions. You can find all the CAMH policies and procedures on Insite.]
1 Like

Oh that is cool, I didn’t copy all the code I have 11-15 and 16-20 so I assume I would have to tweak the above a little…as I have two other statements that come up for those ranges.

Yeah, you’d want to take a look at the (else-if: ) macro for that, but the concept is the same.

Thank you, I got it to work!!
You all have been so helpful, thank you!

1 Like

Personally I find that Hidden Hooks combined with the (show:) macro is a better way to dynamically reveal additional content, as the technique allows better control over where that ‘revealed’ content is positioned…

Throughout the scenario you took (print: $wrongs's length) incorrect turns.

Select your range to get some feedback.

(text-colour: yellow)[You took] (link-reveal: "0-5") [(show: ?great)] (text-colour: yellow)[incorrect turns.]
|great)[Great work! You have a good understanding of safe medication administration best practices, policies and procedures. Remember, policies are reviewed and updated regularly, so be sure to check back to review what you know. You can find all the CAMH policies and procedures on Insite.]

(text-colour: yellow)[You took] (link-reveal: "6-10") [(show: ?good)] (text-colour: yellow)[incorrect turns.]
|good)[You have a fair understanding of safe medication administration best practices, policies and procedures, but could benefit from a deeper review. These policies are reviewed and updated regularly, so be sure to check back to review the latest versions. You can find all the CAMH policies and procedures on Insite.]

…and styling Changer macros can be directly applied to the (show:) macro call…

(link: 'Reveal content')[(transition: "slide-right")(show: ?more)]
|more)[
More content]

Thanks @Greyelf you all have been great, thank you so much!