如何在 Qualtrics 问题文本中创建全局变量?
How do I create a global variable in Qualtrics Question Text?
如何在多个问题中使用 Qualtrics 调查创建要在我的文本中使用的变量?我没有使用任何嵌入式数据或进行更改。该变量的唯一目的是更有效地编辑我的调查的未来草稿。例如我想要这样的东西:
myvar = 100
Q1。如果你有 %myvar% 我拿走 50 还剩多少?
Q2。如果你有 %myvar%,我给你 70,你得到多少?
...
解释的越详细越好!
这个 Qualtrics Community 答案可能对您有所帮助:
Add a function to the Look & Feel header that sets and returns the variable. Call the function from the JS in your questions.
这 support article 意味着您可以将 JavaScript 添加到任何可以设置全局变量的问题,但不建议这样做:
As with any implementation of JavaScript, we recommend abstaining from global variable creation as it can collide with existing functionality on the page.
这是他们描述的工作流程(下图来自文章):
在问题的设置下拉菜单中单击“添加 JavaScript”,然后在以下函数之一中输入您的(全局变量赋值)代码:
addOnload() – Executed when the page is loaded.
addOnReady() – Executed when the page is fully displayed.
addOnUnload() – Executed when a page is unloaded (when the page is left).
顺便说一句,这里 good answer from Brian Rasmussen 解释了全局变量的问题:
The problem with global variables is that since every function has access to these, it becomes increasingly hard to figure out which functions actually read and write these variables.
To understand how the application works, you pretty much have to take into account every function which modifies the global state. That can be done, but as the application grows it will get harder to the point of being virtually impossible (or at least a complete waste of time).
If you don't rely on global variables, you can pass state around between different functions as needed. That way you stand a much better chance of understanding what each function does, as you don't need to take the global state into account.
您不需要任何 JavaScript。在 Qualtrics 中,您想做的事情非常简单。
首先,在您的调查流程开始时,为嵌入的数据字段分配一个值:
myvar = 100
然后将值输入您的问题文本,例如:
Q1. If you have ${e://Field/myvar} and I take away 50 how much is left?
如何在多个问题中使用 Qualtrics 调查创建要在我的文本中使用的变量?我没有使用任何嵌入式数据或进行更改。该变量的唯一目的是更有效地编辑我的调查的未来草稿。例如我想要这样的东西:
myvar = 100
Q1。如果你有 %myvar% 我拿走 50 还剩多少?
Q2。如果你有 %myvar%,我给你 70,你得到多少?
...
解释的越详细越好!
这个 Qualtrics Community 答案可能对您有所帮助:
Add a function to the Look & Feel header that sets and returns the variable. Call the function from the JS in your questions.
这 support article 意味着您可以将 JavaScript 添加到任何可以设置全局变量的问题,但不建议这样做:
As with any implementation of JavaScript, we recommend abstaining from global variable creation as it can collide with existing functionality on the page.
这是他们描述的工作流程(下图来自文章):
在问题的设置下拉菜单中单击“添加 JavaScript”,然后在以下函数之一中输入您的(全局变量赋值)代码:
addOnload() – Executed when the page is loaded.
addOnReady() – Executed when the page is fully displayed.
addOnUnload() – Executed when a page is unloaded (when the page is left).
顺便说一句,这里 good answer from Brian Rasmussen 解释了全局变量的问题:
The problem with global variables is that since every function has access to these, it becomes increasingly hard to figure out which functions actually read and write these variables.
To understand how the application works, you pretty much have to take into account every function which modifies the global state. That can be done, but as the application grows it will get harder to the point of being virtually impossible (or at least a complete waste of time).
If you don't rely on global variables, you can pass state around between different functions as needed. That way you stand a much better chance of understanding what each function does, as you don't need to take the global state into account.
您不需要任何 JavaScript。在 Qualtrics 中,您想做的事情非常简单。
首先,在您的调查流程开始时,为嵌入的数据字段分配一个值:
myvar = 100
然后将值输入您的问题文本,例如:
Q1. If you have ${e://Field/myvar} and I take away 50 how much is left?