- Posts: 57
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
How can I test if a survey is submitted or completed?
- sodiumchl
-
Topic Author
- Offline
- Senior Member
-
Less
More
3 years 4 months ago #210279
by sodiumchl
How can I test if a survey is submitted or completed? was created by sodiumchl
How can I test if a survey is submitted or completed? I tried the following
But it seems to return a date even if the survey is not submitted yet.
Code:
$tComp = strip_tags(LimeExpressionManager::ProcessString('{TOKEN:COMPLETED}', $qid)); //should return "TOKEN:COMPLETED", "N" or "2020-12-22 18:50"
The topic has been locked.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13716
- Thank you received: 2502
3 years 4 months ago #210287
by DenisChenu
Did you check during Survey {TOKEN:COMPLETED} inside question text ?
And maybe better PorcessStepString ?
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.
Replied by DenisChenu on topic How can I test if a survey is submitted or completed?
Strange,sodiumchl wrote: How can I test if a survey is submitted or completed? I tried the following
But it seems to return a date even if the survey is not submitted yet.Code:$tComp = strip_tags(LimeExpressionManager::ProcessString('{TOKEN:COMPLETED}', $qid)); //should return "TOKEN:COMPLETED", "N" or "2020-12-22 18:50"
Did you check during Survey {TOKEN:COMPLETED} inside question text ?
And maybe better PorcessStepString ?
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 topic has been locked.
- sodiumchl
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 57
- Thank you received: 1
3 years 4 months ago #210322
by sodiumchl
Replied by sodiumchl on topic How can I test if a survey is submitted or completed?
I am using this in beforeQuestionRender() of a plugin. I would like to view a survey as it was filled out, but readonly after submitted. Currently I cannot detect "submitted" reliably while other aspects work.
I tried ProcessStepString. Same result.
Code:
public function beforeQuestionRender() { $oEvent=$this->getEvent(); $qid = $oEvent->get('qid'); $tComp = strip_tags(LimeExpressionManager:ProcessStepString('{TOKEN:COMPLETED}', $qid)); var_dump($tComp); ...
I tried ProcessStepString. Same result.
The topic has been locked.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13716
- Thank you received: 2502
3 years 4 months ago #210334
by DenisChenu
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.
Replied by DenisChenu on topic How can I test if a survey is submitted or completed?
And put {TOKEN:COMPLETED} inside question text ?
PS : don't need strip_tags : it's a constant.
PS : don't need strip_tags : it's a constant.
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 topic has been locked.
- sodiumchl
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 57
- Thank you received: 1
3 years 4 months ago #210337
by sodiumchl
Replied by sodiumchl on topic How can I test if a survey is submitted or completed?
Yes, putting {TOKEN:COMPLETED} inside question text works: it returns Yes or No.
But then there is another issue: Anyway to refer to this question by its code, such as eComplete? Otherwise I have to put its qid in config which is inconvenient.
But then there is another issue: Anyway to refer to this question by its code, such as eComplete? Otherwise I have to put its qid in config which is inconvenient.
The topic has been locked.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13716
- Thank you received: 2502
3 years 4 months ago #210338
by DenisChenu
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.
Replied by DenisChenu on topic How can I test if a survey is submitted or completed?
Can you upload your mini plugin ?
3.X or 4.X ?
3.X or 4.X ?
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 topic has been locked.
- sodiumchl
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 57
- Thank you received: 1
3 years 4 months ago #210403
by sodiumchl
Replied by sodiumchl on topic How can I test if a survey is submitted or completed?
Thank you, Denis!
I am using version LimeSurvey 3.23.7+201006
I just made a small modification to SondagesPro/answersAsReadonly
github.com/SondagesPro/answersAsReadonly...nswersAsReadonly.php
so that only completed surveys are to be turned readonly.
I am using version LimeSurvey 3.23.7+201006
I just made a small modification to SondagesPro/answersAsReadonly
github.com/SondagesPro/answersAsReadonly...nswersAsReadonly.php
so that only completed surveys are to be turned readonly.
Code:
public function beforeQuestionRender() { //originally setReadonly() $oEvent=$this->getEvent(); $qid = $oEvent->get('qid'); $tComp = strip_tags(LimeExpressionManager:ProcessStepString('{TOKEN:COMPLETED}', $qid)); //var_dump($tComp); //debuging only $isRO = (isset($tComp) && $tComp != 'TOKEN:COMPLETED' && $tComp != 'N' && (strtotime("now")-strtotime($tComp)) > 3600); if (!$isRO) return; //original code $aAttributes=QuestionAttribute::model()->getQuestionAttributes($qid); if(empty($aAttributes['readonly'])) { return; } //... }
The topic has been locked.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13716
- Thank you received: 2502
3 years 4 months ago #210423
by DenisChenu
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.
Replied by DenisChenu on topic How can I test if a survey is submitted or completed?
Did you test {TOKEN:COMPLETED == 'N' OR TOKEN:COMPLETED == "} in answer as readonly test sting ?
Else i test
It work without issue.
can update at 1st launch, can not at 2nd one (with same token)
Else i test
Code:
$currentReadonly = trim(LimeExpressionManager::ProcessStepString('{TOKEN:COMPLETED}',$aReplacement,3,1)); tracevar($currentReadonly); if(empty($currentReadonly) || $currentReadonly == "N") { return; }
can update at 1st launch, can not at 2nd one (with same token)
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 topic has been locked.
- sodiumchl
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 57
- Thank you received: 1
3 years 4 months ago #210429
by sodiumchl
Replied by sodiumchl on topic How can I test if a survey is submitted or completed?
I tried the above. Still getting a date. My case is reloading/editing response multiple times with the same token. Anyway to make it working for 2nd or later load?
The topic has been locked.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13716
- Thank you received: 2502
3 years 4 months ago #210435
by DenisChenu
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.
Replied by DenisChenu on topic How can I test if a survey is submitted or completed?
I have N when token launch for 1st time, a date after.
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 topic has been locked.
- sodiumchl
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 57
- Thank you received: 1
3 years 4 months ago #210439
by sodiumchl
Replied by sodiumchl on topic How can I test if a survey is submitted or completed?
> I have N when token launch for 1st time, a date after.
Yes, I get this too. My question is, for later launches, how can I tell if the survey is submitted or not since it always returns a date?
Yes, I get this too. My question is, for later launches, how can I tell if the survey is submitted or not since it always returns a date?
The topic has been locked.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13716
- Thank you received: 2502
3 years 4 months ago - 3 years 4 months ago #210442
by DenisChenu
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.
Replied by DenisChenu on topic How can I test if a survey is submitted or completed?
PLEASE EXPLAIN WHAT YOU WANT TO DO !
You talk for token completed … then no problem : the token is completed.
For current response : Reponse::model($sid)->getByPk($srid)->submitdate
You talk for token completed … then no problem : the token is completed.
For current response : Reponse::model($sid)->getByPk($srid)->submitdate
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.
Last edit: 3 years 4 months ago by DenisChenu.
The topic has been locked.