Example #1
0
 /**
  * <p>Метод возвращает количество вопросов по заданному фильтру.</p>
  *
  *
  * @param array $arrayarFilter = Array() Массив вида <i> array("фильтруемое поле"=&gt;"значение фильтра" [, ...])</i>.
  * Описание фильтра см. в <a
  * href="http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/getlist.php">CLQuestion::GetList</a>.<br> По
  * умолчанию вопросы не фильтруются.
  *
  * @return int <p>Число - количество вопросов.</p>
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * if (CModule::IncludeModule("learning"))
  * {
  *     $COURSE_ID = 97;
  *     
  *     $cnt = CLQuestion::GetCount(Array("ACTIVE" =&gt; "Y", "COURSE_ID" =&gt; $COURSE_ID));
  * 
  *     echo "Number of questions: ".$cnt;
  * }
  * 
  * ?&gt;
  * 
  * &lt;?
  * if (CModule::IncludeModule("learning"))
  * {
  *     $LESSON_ID = 426;
  *     
  *     $cnt = CLQuestion::GetCount(Array("LESSON_ID" =&gt; $LESSON_ID));
  * 
  *     echo "Number of questions: ".$cnt;
  * }
  * 
  * ?&gt;
  * </pre>
  *
  *
  * <h4>See Also</h4> 
  * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/index.php">CLQuestion</a>::<a
  * href="http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/getlist.php">GetList</a> </li> </ul><a
  * name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/getcount.php
  * @author Bitrix
  */
 public static function GetCount($arFilter = array())
 {
     global $DB;
     $arSqlSearch = CLQuestion::GetFilter($arFilter);
     $strSqlSearch = "";
     $cnt = count($arSqlSearch);
     for ($i = 0; $i < $cnt; $i++) {
         if (strlen($arSqlSearch[$i]) > 0) {
             $strSqlSearch .= " AND " . $arSqlSearch[$i] . " ";
         }
     }
     $strSql = "SELECT COUNT(DISTINCT CQ.ID) as C " . "FROM b_learn_question CQ " . "INNER JOIN b_learn_lesson CL ON CQ.LESSON_ID = CL.ID " . "WHERE 1=1 " . $strSqlSearch;
     $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $res_cnt = $res->Fetch();
     return intval($res_cnt["C"]);
 }