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 */ public static function initQuestions() { foreach (CActiveRecordProvider::getAllFromTable(TABLE_SEB_QUSTIONS_IN_TICKETS)->getItems() as $i) { if (self::getCacheTickets()->hasElement($i->getItemValue("ticket_id"))) { $question = CSEBQuestionsManager::getQuestion($i->getItemValue("question_id")); $ticket = self::getCacheTickets()->getItem($i->getItemValue("ticket_id")); $ticket->addQuestion($question); } } }
public function actionSave() { if (CRequest::getInt("id") == 0) { $ticket = CFactory::createSebTicket(); } else { $ticket = CSEBTicketsManager::getTicket(CRequest::getInt("id")); } foreach (CRequest::getArray("question") as $i) { $q = CSEBQuestionsManager::getQuestion($i); if (!is_null($q)) { $ticket->addQuestion($q); } } $ticket->setSpeciality(CTaxonomyManager::getCacheSpecialities()->getItem(CRequest::getInt("speciality_id"))); $ticket->setYear(CTaxonomyManager::getCacheYears()->getItem(CRequest::getInt("year_id"))); $ticket->setProtocol(CProtocolManager::getDepProtocol(CRequest::getInt("protocol_id"))); $ticket->setSigner(CStaffManager::getPersonById(CRequest::getInt("signer_id"))); $ticket->setNumber(CRequest::getInt("number")); $ticket->save(); $this->redirect("?action=index"); }
/** * Лист дисциплин, по которым есть вопросы * * @static * @return CArrayList */ public static function getDisciplines() { if (is_null(self::$_disciplines)) { self::$_disciplines = new CArrayList(); $q = new CQuery(); $q->select("distinct(discipline_id)")->from(TABLE_SEB_QUESTIONS); foreach ($q->execute()->getItems() as $ar) { $disc = CTaxonomyManager::getCacheDisciplines()->getItem($ar["discipline_id"]); if (!is_null($disc)) { self::$_disciplines->add($disc->getId(), $disc); } } } return self::$_disciplines; }
/** * Вопросы в билете * * @return CArrayList */ public function getQuestions() { if (is_null($this->_questions)) { $this->_questions = new CArrayList(); foreach (CActiveRecordProvider::getWithCondition(TABLE_SEB_QUSTIONS_IN_TICKETS, "ticket_id=" . $this->getId())->getItems() as $r) { $q = CSEBQuestionsManager::getQuestion($r->getItemValue("question_id")); if (!is_null($q)) { $this->_questions->add($q->getId(), $q); } } } return $this->_questions; }