当前位置: 首页>>代码示例>>PHP>>正文


PHP LimeExpressionManager::getConditionsForEM方法代码示例

本文整理汇总了PHP中LimeExpressionManager::getConditionsForEM方法的典型用法代码示例。如果您正苦于以下问题:PHP LimeExpressionManager::getConditionsForEM方法的具体用法?PHP LimeExpressionManager::getConditionsForEM怎么用?PHP LimeExpressionManager::getConditionsForEM使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LimeExpressionManager的用法示例。


在下文中一共展示了LimeExpressionManager::getConditionsForEM方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ConvertConditionsToRelevance

 /**
  * If $qid is set, returns the relevance equation generated from conditions (or NULL if there are no conditions for that $qid)
  * If $qid is NULL, returns an array of relevance equations generated from Condition, keyed on the question ID
  * @param <integer> $surveyId
  * @param <integer> $qid - if passed, only generates relevance equation for that question - otherwise genereates for all questions with conditions
  * @return array of generated relevance strings, indexed by $qid
  */
 public static function ConvertConditionsToRelevance($surveyId = NULL, $qid = NULL)
 {
     $query = LimeExpressionManager::getConditionsForEM($surveyId, $qid);
     $_qid = -1;
     $relevanceEqns = array();
     $scenarios = array();
     $relAndList = array();
     $relOrList = array();
     foreach ($query->readAll() as $row) {
         $row['method'] = trim($row['method']);
         //For Postgres
         if ($row['qid'] != $_qid) {
             // output the values for prior question is there was one
             if ($_qid != -1) {
                 if (count($relOrList) > 0) {
                     $relAndList[] = '(' . implode(' or ', $relOrList) . ')';
                 }
                 if (count($relAndList) > 0) {
                     $scenarios[] = '(' . implode(' and ', $relAndList) . ')';
                 }
                 $relevanceEqn = implode(' or ', $scenarios);
                 $relevanceEqns[$_qid] = $relevanceEqn;
             }
             // clear for next question
             $_qid = $row['qid'];
             $_scenario = $row['scenario'];
             $_cqid = $row['cqid'];
             $_subqid = -1;
             $relAndList = array();
             $relOrList = array();
             $scenarios = array();
             $releqn = '';
         }
         if ($row['scenario'] != $_scenario) {
             if (count($relOrList) > 0) {
                 $relAndList[] = '(' . implode(' or ', $relOrList) . ')';
             }
             $scenarios[] = '(' . implode(' and ', $relAndList) . ')';
             $relAndList = array();
             $relOrList = array();
             $_scenario = $row['scenario'];
             $_cqid = $row['cqid'];
             $_subqid = -1;
         }
         if ($row['cqid'] != $_cqid) {
             $relAndList[] = '(' . implode(' or ', $relOrList) . ')';
             $relOrList = array();
             $_cqid = $row['cqid'];
             $_subqid = -1;
         }
         // fix fieldnames
         if ($row['type'] == '' && preg_match('/^{.+}$/', $row['cfieldname'])) {
             $fieldname = substr($row['cfieldname'], 1, -1);
             // {TOKEN:xxxx}
             $subqid = $fieldname;
             $value = $row['value'];
         } else {
             if ($row['type'] == 'M' || $row['type'] == 'P') {
                 if (substr($row['cfieldname'], 0, 1) == '+') {
                     // if prefixed with +, then a fully resolved name
                     $fieldname = substr($row['cfieldname'], 1) . '.NAOK';
                     $subqid = $fieldname;
                     $value = $row['value'];
                 } else {
                     // else create name by concatenating two parts together
                     $fieldname = $row['cfieldname'] . $row['value'] . '.NAOK';
                     $subqid = $row['cfieldname'];
                     $value = 'Y';
                 }
             } else {
                 $fieldname = $row['cfieldname'] . '.NAOK';
                 $subqid = $fieldname;
                 $value = $row['value'];
             }
         }
         if ($_subqid != -1 && $_subqid != $subqid) {
             $relAndList[] = '(' . implode(' or ', $relOrList) . ')';
             $relOrList = array();
         }
         $_subqid = $subqid;
         // fix values
         if (preg_match('/^@\\d+X\\d+X\\d+.*@$/', $value)) {
             $value = substr($value, 1, -1);
         } else {
             if (preg_match('/^{.+}$/', $value)) {
                 $value = substr($value, 1, -1);
             } else {
                 if ($row['method'] == 'RX') {
                     if (!preg_match('#^/.*/$#', $value)) {
                         $value = '"/' . $value . '/"';
                         // if not surrounded by slashes, add them.
                     }
                 } else {
//.........这里部分代码省略.........
开发者ID:GuillaumeSmaha,项目名称:LimeSurvey,代码行数:101,代码来源:em_manager_helper.php


注:本文中的LimeExpressionManager::getConditionsForEM方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。