Пример #1
0
 private function checkSubCondition($condition)
 {
     $q['condition'] = $condition;
     if ($q['condition'] == "") {
         return true;
     }
     $negate = false;
     if ($condition[0] == "!") {
         $q['condition'] = substr($q['condition'], 1);
         $negate = true;
     }
     $dat = explode(".", $q['condition']);
     $result = Result::findOne(['e_fr_id' => $dat[0], 'e_z_id' => Yii::$app->session['anketData']['code']['z_id']]);
     //$quer = "select a_id, antwort from ".RES." where e_fr_id='".$dat[0]."' and e_z_id='".$user['uid']."'";
     $question = Question::findOne($dat[0])->toArray();
     $ok = false;
     //If there were no answers
     if (is_null($result)) {
         return $ok;
     }
     $aid = $result->a_id;
     $answers = $result->antwort;
     $alist = array();
     if (trim($answers) == "") {
         $alist[] = $aid;
     } else {
         $questionAnswers = explode(";", $question['antworten']);
         $userAnswers = explode(";", $answers);
         for ($i = 0; $i < count($questionAnswers); $i++) {
             foreach ($userAnswers as $userAnswer) {
                 if ($userAnswer == $questionAnswers[$i]) {
                     $alist[] = $i;
                 }
             }
         }
     }
     foreach ($alist as $a) {
         if ($a == $dat[1] - 1) {
             if (isset($a)) {
                 $ok = true;
             }
         }
     }
     if ($negate) {
         return !$ok;
     } else {
         return $ok;
     }
 }