- Posts: 16
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
foreach ($questions as $question) {
I read about pdfreport and also tried with it. I read the manual, but there is no step by step instruction just analyze data and demo files and i tried to replicate it.// Retrieve the raw answer from values
$raw_answer = isset($values[$question]) ? $values[$question] : null;
error_log("Processing Question ID: " . $question . " | Raw Answer: '" . $raw_answer . "'");
// Trim answer to remove leading/trailing spaces
$answer = trim($raw_answer);
// Skip if answer is considered empty (including '0', 'NULL', null, or spaces)
if ($answer === '' || strtolower($answer) === 'null' || $answer === '0' || $answer === ' ') {
error_log("Skipping Question ID: " . $question . " | Reason: Empty, null, '0' or 'NULL'");
continue; // Skip this question and move to the next
}
// If not skipped, add the answer to the PDF
$this->pdf->addAnswer($headers[$question], $answer, false);
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.
And he point me of adding a condition in this line for skipping unanswered questions like this:foreach ($questions as $question) { if (isset($values[$question]) && isset($headers[$question])) { $this->pdf->addAnswer($headers[$question], $values[$question], false);
I tried different codes like:foreach ($questions as $question) { // Check if the value is non-empty before adding it to the PDF if(!empty(trim($values[$question])) && isset($headers[$question])) { $this->pdf->addAnswer($headers[$question], $values[$question], false); } }
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.