HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/apklausos/application/core/plugins/statFunctions/questionCodeHelper.php
<?php

/**
 * This file is part of statFunctions plugin
 */

namespace statFunctions;

use Yii;
use Survey;
use SurveyDynamic;
use CDbCriteria;

class questionCodeHelper
{
    /** @var integer $surveyId **/
    public $surveyId = 0;

    /**
     * @param integer $surveyId
     */
    public function __construct($surveyId)
    {
        $this->surveyId = $surveyId;
        /* Throw error if surveyid is invalid ? */
    }

    /**
     * Check the survey
     * @param string $qCode question SGQA
     * @return string|null : the final column name, null if not found
     */
    public function getColumnByQCode($qCode)
    {
        $availableColumns = SurveyDynamic::model($this->surveyId)->getAttributes();
        /* Sample : Q01.sgqa Q01_SQ01.sgqa */
        if (array_key_exists($qCode, $availableColumns)) {
            return $qCode;
        }

        /* @todo : allow "Q0" and "Q0_SQ0" …
         * But without using LimeExpressionManager::ProcessString or LimeExpressionManager::getLEMqcode2sgqa
         * Because break logic file
         * Wait for OK to merge to start it …
         */
        return null;
    }
}