- Posts: 22
- Thank you received: 1
How can I test if a survey is submitted or completed?
1 week 3 days 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 followingBut it seems to return a date even if the survey is not submitted yet.
$tComp = strip_tags(LimeExpressionManager::ProcessString('{TOKEN:COMPLETED}', $qid)); //should return "TOKEN:COMPLETED", "N" or "2020-12-22 18:50"
Please Log in to join the conversation.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13987
- Thank you received: 2475
1 week 3 days 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.$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.
Please Log in to join the conversation.
1 week 2 days 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.
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.
Please Log in to join the conversation.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13987
- Thank you received: 2475
1 week 2 days 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.
Please Log in to join the conversation.
1 week 2 days 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.
Please Log in to join the conversation.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13987
- Thank you received: 2475
1 week 2 days 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.
Please Log in to join the conversation.
1 week 1 day 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.
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;
}
//...
}
Please Log in to join the conversation.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13987
- Thank you received: 2475
1 week 1 day 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 testIt work without issue.
can update at 1st launch, can not at 2nd one (with same token)
Else i test
$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.
Please Log in to join the conversation.
1 week 1 day 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?
Please Log in to join the conversation.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13987
- Thank you received: 2475
1 week 1 day 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.
Please Log in to join the conversation.
1 week 18 hours 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?
Please Log in to join the conversation.
- DenisChenu
-
- Offline
- LimeSurvey Community Team
-
Less
More
- Posts: 13987
- Thank you received: 2475
1 week 18 hours ago - 1 week 18 hours 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: 1 week 18 hours ago by DenisChenu.
Please Log in to join the conversation.