- Posts: 57
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
$tComp = strip_tags(LimeExpressionManager::ProcessString('{TOKEN:COMPLETED}', $qid)); //should return "TOKEN:COMPLETED", "N" or "2020-12-22 18:50"
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"
public function beforeQuestionRender() { $oEvent=$this->getEvent(); $qid = $oEvent->get('qid'); $tComp = strip_tags(LimeExpressionManager:ProcessStepString('{TOKEN:COMPLETED}', $qid)); var_dump($tComp); ...
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; } //... }
$currentReadonly = trim(LimeExpressionManager::ProcessStepString('{TOKEN:COMPLETED}',$aReplacement,3,1)); tracevar($currentReadonly); if(empty($currentReadonly) || $currentReadonly == "N") { return; }