DeleteUnlinkedPage.custom_move()#

DeleteUnlinkedPage.custom_move()[source]#

Hook for defining a page’s own movement behavior, executed every time a movement from the page takes place, before on_first_hide() and on_each_hide().

User input to the elements on the current page is available in this method through the page’s Page.data attribute.

Use the ExperimentSession s movement methods to define your own behavior. The available methods are

forward

Moves the experiment forward one page.

backward

Moves the experiment backward one page.

jump

Jumps to a specific page in the experiment.

Notes

You can fall back to alfred3’s movement system by returning True from your custom move function.

Examples

Create a page that always jumps to a specific page upon submission:

exp = al.Experiment()

@exp.member
class CustomMove(al.Page):
    name = "custom_move"

    def custom_move(self):
        self.exp.jump(to="third")

exp += al.Page(name="second")
exp += al.Page(name="third")

Create a page that jumps to a specific page, if it received a user input of ‘yes’, and use alfred3’s usual movement system otherwise:

exp = al.Experiment()

@exp.member
class CustomMove(al.Page):

    def on_exp_access(self):
        self += elm.TextEntry(name="text")

    def custom_move(self):
        if self.data.get("text) == "yes":
            self.exp.jump(to="third")
        else:
            return True

exp += al.Page(name="second")
exp += al.Page(name="third")