Пример #1
0
 /**
  * Дисциплина, к которой вопрос привязан
  *
  * @return CTerm
  */
 public function getDiscipline()
 {
     if (is_null($this->_discipline)) {
         $this->_discipline = CTaxonomyManager::getCacheDisciplines()->getItem($this->getRecord()->getItemValue("discipline_id"));
     }
     return $this->_discipline;
 }
 public function actionGetQuestionsJSON()
 {
     $arr = array();
     $disc = CTaxonomyManager::getCacheDisciplines()->getItem(CRequest::getInt("id"));
     foreach (CSEBQuestionsManager::getQuestionsByDiscipline($disc)->getItems() as $i) {
         $arr[] = $i->toArrayForJSON();
     }
     echo json_encode($arr);
 }
 /**
  * Список дисциплин для указанной специальности, по
  * которым есть вопросы
  *
  * @static
  * @param CTerm $speciality
  * @return CArrayList
  */
 public static function getDisciplinesBySpeciality(CTerm $speciality)
 {
     if (!self::getCacheDisciplinesBySpeciality()->hasElement($speciality->getId())) {
         $res = new CArrayList();
         $q = new CQuery();
         $q->select("distinct(discipline_id)")->from(TABLE_SEB_QUESTIONS)->condition("speciality_id=" . $speciality->getId());
         foreach ($q->execute()->getItems() as $ar) {
             $disc = CTaxonomyManager::getCacheDisciplines()->getItem($ar["discipline_id"]);
             if (!is_null($disc)) {
                 $res->add($disc->getId(), $disc);
             }
         }
         self::getCacheDisciplinesBySpeciality()->add($speciality->getId(), $res);
     }
     return self::getCacheDisciplinesBySpeciality()->getItem($speciality->getId());
 }