Experiment.finish()#
- Experiment.finish(func)[source]#
Decorator for code to be run upon
ExperimentSession.finish()
.The decorated function can have an arbitrary name. It must take an
ExperimentSession
object as its only argument (usually spelled as exp). You can use this decorator on as many functions as you like.The purpose of this decorator is to allow manipulation of the
ExperimentSession
object generated byExperiment
a last time before the final page is shown. The decorated functions are the first things to be called in theExperimentSession.finish()
method.A common usecase would be to conditionally assign the experiment’s final page based on subject input during the experiment.
Examples
Using the
@exp.finish
decorator for conditionally changing the final page:import alfred3 as al exp = al.Experiment() @exp.member class Demo(al.Page): name = "demo1" @exp.finish def set_final_page(exp): # the decorated function can have any name if exp.values["text1"] == "value": exp.final_page = al.Page("Option A", name="final_page_a") else: exp.final_page = al.Page("Option B", name="final_page_b")