Welcome, Guest
Username: Password: Remember me

TOPIC: Create and use global variable in questions

Create and use global variable in questions 1 year 8 months ago #87920

  • bhessen
  • bhessen's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Hi,

I have a survey which is copied each year. I have a lot of questions with the current year in it. It is a lot of hassle and effort and very error prone to change all the questions to the correct year each time.

Is it possible to create a global variable and use this in the questions? Then, I would only have to change the correct year once.

Or maybe there is another way of doing this?

Thanks a lot in advance.
Last Edit: 1 year 8 months ago by bhessen.
The administrator has disabled public write access.

Re: Create and use global variable in questions 1 year 8 months ago #87936

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6236
  • Thank you received: 794
  • Karma: 238
Hello,
Use an equation question type.

Give the code ACTUALYEAR for question, and put "what you want" in question text.
After, you can use {ACTUALYEAR} in your questio text to be replaced with the actual year.

For the actual year, you have alternative automatic solution:
try {date("YY")}

Denis
The administrator has disabled public write access.

Aw: Create and use global variable in questions 1 year 8 months ago #87941

  • bhessen
  • bhessen's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Thanks a lot. The actual code was:

{date("Y")} (otherwise, the year will be printed 2 times)
The administrator has disabled public write access.

Aw: Create and use global variable in questions 1 year 8 months ago #87983

  • bhessen
  • bhessen's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Hi,

this works fine for each question which comes after the ACTUALYEAR question. But I also want to use this in the description of the survey.

Is this possible?
The administrator has disabled public write access.

Re: Aw: Create and use global variable in questions 1 year 8 months ago #87999

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6236
  • Thank you received: 794
  • Karma: 238
Not sure,

But think you can use {date("Y")} in description of the survey (maybe title too).

Denis
The administrator has disabled public write access.

Aw: Create and use global variable in questions 1 year 8 months ago #88009

  • bhessen
  • bhessen's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Ok, that is not very nice, but doable.

But I just noticed that it is all rather futile, because it does not work at all if you use the printable version :S, which I need...

Any ideas other than editing the resulting html file? I would like to have a robust process.

Ben
The administrator has disabled public write access.

Re: Aw: Create and use global variable in questions 1 year 8 months ago #88026

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6236
  • Thank you received: 794
  • Karma: 238
There are a bug reporting for printable version, but i think it's only for Token information.

And i think it's difficult to know if EM need recalculation or not.

Feel free to report a bug for this.

Denis
PS: why is not very nice ? To have the actual year, you have to do some calculation.
Last Edit: 1 year 8 months ago by DenisChenu.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.118 seconds
Donation Image