Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Access to last page information DURING the survey

  • cshaw
  • cshaw's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
9 years 14 hours ago #118422 by cshaw
LS 2.05+

I am utilizing incremental indexing, but suppress the display elements because I find them fairly ugly by default.

I ask about ten female relatives cancer history and then I provide a summary page. On that page I provide one button to jump back to the cancer history page relevant for each relative. When a user returns to a relative's cancer page I want to make visible a button to use to jump back to the summary, BUT that should only show up if they have returned to the page not on a first visit. Had I access to to the 'lastpage' variable that is stored with each response this would be easy, but I do not know how to reference that lastpage variable.

Not knowing how to reference it, even just to use {} to insert it into the text of a question like you can a the answer from a previous question, I have tried {lastpage}, and {token.lastpage}. I would have been shocked if {token.lastpage} had worked since I don't even think that is the right table!!

What is the name of the table where responses are stored? Can I just refer to it? {<sometable>.lastpage}

Is there some built in function that will return data from the response table for the current record?

Thanks!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 1 hour ago #118443 by tpartner
There is no Expression manager variable "lastpage" - manual.limesurvey.org/Expression_Manager#Access_to_Variables

I think the simplest solution may be to use jQuery to detect whether the question(s) on the page have been answered and show the button accordingly.


.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • cshaw
  • cshaw's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 11 months ago - 8 years 11 months ago #118474 by cshaw
I have a workaround for this issue now. I am inserting an html tag in the startpage.pstpl, that contains attributes I want available throughout the survey. In particular the information I need about how many relatives groups I am including, how many questions I am asking about each relative, and an offset from the end of the last relative's last question, to my summary question.

<myvars>
relativequestioncount="5"
relativequestiongroups="10"
relativeoffset="3"
</myvars>

Then I inserted a question of type text that will store the page number of the first relative question, as a starting offset. Since it is before all the relative questions I can access that value via {} on all other relative questions. This question prompt contains a tag <trackpage></trackpage>, invisible to the person taking the questionnaire.

In the javascript $(document).ready(function(){}, I am watching for any pages that contain the trackpage tag, if($('trackpage').length>0){ <do some stuff> }, if that is found it triggers some javascript/jquery that populates the current element's text box with the value of the hidden page element named 'thisstep'. Then the function runs the click event of the "Next" button and the page comes and goes before the user really sees it. Still haven't made that seamless, there is a bit of a flash, especially if there is a longish survey involved.

Also I added a script to the startpage, $(document).ready(function(){}, that suppresses the display of the indexes, I really didn't like the way they were implemented.

So now when survey takers complete entry of the family history section they are presented with a set of custom buttons labeled with the description and initials of the relative that they entered history for. Clicking one of those buttons jumps control to the page where the history was entered. I pass all the variables to javascript by embedding each relevant answer from previous questions into an invisible tag on the summary page within the question text. Something like this:

Here is a list of the relatives you indicated had a cancer history:<insertlinks reltiveinfo="{rel1},{rel2},{rel3},{rel3},{rel4},{rel5},{rel6},{rel7},{rel8},{rel9},{rel10}"></insertlinks>

My javascript determines whether or not a button needs to be provided for each relative and puts them on the page as needed with an index to the page where the info was entered.

It is all rather complicated, but works beautifully. It all makes me think that life would be so much easier if I had a way to persist values from one page to the next on a survey. We have that kind of mechanism working with the token table. I just wish we had something like that related to the response table, if that makes any sense.

My thoughts are complex and hard to put into words, ya know? :)

Sample Survey
Last edit: 8 years 11 months ago by cshaw. Reason: Added a sample survey link
The topic has been locked.
More
8 years 11 months ago #118475 by Ben_V

ohvelma wrote: ...life would be so much easier if I had a way to persist values from one page to the next on a survey


I know that creating too many hidden questions never can be a good solution, but assuming that you survey is not using the assessment module, a workaround (more or less like this) can be the start of something helpful...
For each page:
1) a hidden weighted question (e.g. a radio question with only a default answer option scoring 1point)
2) a hidden equation recording the {ASSESSMENT_CURRENT_TOTAL}

Like this, the value {ASSESSMENT_CURRENT_TOTAL} will be increased (1 point) only if a page is displayed.
Maybe, this value can be reused somewhere to set your links to previous pages (questions or groups)...
I don't know, It's just an idea :unsure:

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The following user(s) said Thank You: cshaw
The topic has been locked.
  • cshaw
  • cshaw's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 11 months ago #118476 by cshaw
I will try that out, thank you!
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 11 months ago #118500 by DenisChenu
Replied by DenisChenu on topic Access to last page information DURING the survey
Sorry for this answer ....

But in 2.06, you can reference a question in the last group. ANd you can use (if i don't make error) QuestionCode.relevant to know if user have seen this question (but if not : a mandatory question on the group before the last group ans !is_empty(QuestionCode) can be a good way to do).

And to have the {LASTPAGE} can be a good idea too. Think we must have a Plugin system for this :

Have a plugin event to add Expression Manager variable.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: Ben_V
The topic has been locked.
More
8 years 11 months ago #118501 by Ben_V
I've made a quick test...
Yes it's possible to get some result playing with the assessments...

It's the end of the good news because it's impossible to use {ASSESSMENT _CURRENT_TOTAL} :
It's a dynamic value so you can edit a page only 1 time; After the value of the equation retrieving the score will change and there comes the troubles... It will be very easy if a placeholder giving the score for all previous questions were available {ASSESSMENT_VALUE_FOR_THE_MOMENT} :cheer: ; The only solution is to configure each equation with something like {sum(Q1.value, Q2.value, etc...)} but it's probably more work compared with what you already did...

The only good point: few javascript code is required.

I attach a working sample, because this can be a start for other users ;)

File Attachment:

File Name: test_79973.lss
File Size:55 KB

Benoît

EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Attachments:
The topic has been locked.
  • cshaw
  • cshaw's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
8 years 11 months ago - 8 years 11 months ago #118582 by cshaw
Okay here is the situation, I have 10 groups on my survey one for each of ten female relatives (fr1,fr2, up to fr10). Each group contains 5 questions, the key one being fr<x>cancer. Following the 10 female relative groups I have a group for the female relative summary, frsum. There is a question in the frsum group, frsumquest. In that question I have 10 buttons, that I turn on using java script whenever there is an answer to the associated fr<x>cancer. That button contains a "jump" via the index back to that specific page, for example group fr1 question fr1cancer.

When the survey returns to that question I know that it is not being visited for the first time via a hidden question right after fr1cancer that gets incremented each time it is accessed. In that situation, where the index button link has been clicked to return control to the earlier question fr1cancer, I display a button link to the summary page. For now I calculate how many pages there are from the fr1cancer question to the frsumquest question, but I would like that calculation to be dynamic rather than calculated so that if I decided to add another question to the frsum group before the frsumquest question it wouldn't throw the calculation off.

Hence I wanted to put something like {frsum} or {responsetable.lastpage} to know where to target the button that returns control back to the summary. However, it appears that you cannot access the information about the last page visited during the taking of a survey (even though it is stored when you save the survey response for later use) and you cannot reference a question that is in later groups of the survey from an earlier group, though the other way around works fine.

When you calculate the location to move to and jump from fr1cancer forward to the frsumquest, the values for all the questions for the groups between are retained so you don't lose anything by having used the index capability to move around.

I experimented with hidden questions and questions that store their page number and then hid themselves right after they were visited, but they weren't meeting the needs. The questions that hid themselves after storing their page sort of worked, but with a longer survey there was a troubling delay where for a moment you could see the "hidden" page before it moved on. Very disturbing for my test survey takers, and we decided not suitable for real survey takers.
Last edit: 8 years 11 months ago by cshaw. Reason: Just trying to make it clearer.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose