public function getSurveyCompare($sourceSurveyData, $targetSurveyData, $post) {
        $surveyCompareArray        = [];
        $missingSourceSurveyTitles = $sourceSurveyData;

        // show all questions that can be send to the target survey
        foreach ($targetSurveyData as $questionCode => $questionData) {
            $currentQuestionCode = $questionCode;
            if (isset($post['target']) && isset($post['target'][$currentQuestionCode])) {
                $currentQuestionCode = $post['target'][$currentQuestionCode];
            }

            $questionCompare             = [
                'target' => $questionCode,
                'source' => $currentQuestionCode,
            ];

            if (isset($sourceSurveyData[$currentQuestionCode])) {
                if ($questionData['type'] === $sourceSurveyData[$currentQuestionCode]['type']) {
                    $questionCompare['status'] = 'same';
                } else {
                    $questionCompare['status'] = 'type-difference';
                }
                unset($missingSourceSurveyTitles[$currentQuestionCode]);
            } else {
                $questionCompare['status'] = 'new';
            }
            $surveyCompareArray[] = $questionCompare;
        }

        // show all questions that are missing in the target survey
        foreach ($missingSourceSurveyTitles as $questionId => $questionData) {
            $surveyCompareArray[] = [
                'target' => null,
                'source' => $questionId,
                'status' => 'missing',
            ];
        }

        return $surveyCompareArray;
    }
public function getSurveyCompare($sourceSurveyData, $targetSurveyData, $post) {
        $surveyCompareArray        = [];
        $missingSourceSurveyTitles = $sourceSurveyData;

        // show all questions that can be send to the target survey
        foreach ($targetSurveyData as $questionCode => $questionData) {
            $currentQuestionCode = $questionCode;
            if (isset($post['target']) && isset($post['target'][$currentQuestionCode])) {
                $currentQuestionCode = $post['target'][$currentQuestionCode];
            }

            $questionCompare             = [
                'target' => $questionCode,
                'source' => $currentQuestionCode,
            ];

            if (isset($sourceSurveyData[$currentQuestionCode])) {
                if ($questionData['type'] === $sourceSurveyData[$currentQuestionCode]['type']) {
                    $questionCompare['status'] = 'same';
                } else {
                    $questionCompare['status'] = 'type-difference';
                }
                unset($missingSourceSurveyTitles[$currentQuestionCode]);
            } else {
                $questionCompare['status'] = 'new';
            }
            $surveyCompareArray[] = $questionCompare;
        }

        // show all questions that are missing in the target survey
        foreach ($missingSourceSurveyTitles as $questionId => $questionData) {
            $surveyCompareArray[] = [
                'target' => null,
                'source' => $questionId,
                'status' => 'missing',
            ];
        }

        return $surveyCompareArray;
    }
public function getSurveyCompare ( $ sourceSurveyData , $ targetSurveyData , $ post ) { $ surveyCompareArray = [ ] ; $ missingSourceSurveyTitles = $ sourceSurveyData ; // show all questions that can be send to the target survey foreach ( $ targetSurveyData as $ questionCode => $ questionData ) { $ currentQuestionCode = $ questionCode ; if ( isset ( $ post [ 'target' ] ) && isset ( $ post [ 'target' ] [ $ currentQuestionCode ] ) ) { $ currentQuestionCode = $ post [ 'target' ] [ $ currentQuestionCode ] ; } $ questionCompare = [ 'target' => $ questionCode , 'source' => $ currentQuestionCode , ] ; if ( isset ( $ sourceSurveyData [ $ currentQuestionCode ] ) ) { if ( $ questionData [ 'type' ] === $ sourceSurveyData [ $ currentQuestionCode ] [ 'type' ] ) { $ questionCompare [ 'status' ] = 'same' ; } else { $ questionCompare [ 'status' ] = 'type-difference' ; } unset ( $ missingSourceSurveyTitles [ $ currentQuestionCode ] ) ; } else { $ questionCompare [ 'status' ] = 'new' ; } $ surveyCompareArray [ ] = $ questionCompare ; } // show all questions that are missing in the target survey foreach ( $ missingSourceSurveyTitles as $ questionId => $ questionData ) { $ surveyCompareArray [ ] = [ 'target' => null , 'source' => $ questionId , 'status' => 'missing' , ] ; } return $ surveyCompareArray ; }
create an array with statusses of survey questions and how they're matched in the form

@param $sourceSurveyData array with source survey data
@param $targetSurveyData array with target survey data
@param $post array List of POST data
@return array status array
create an array with statusses of survey questions and how they re matched in the form