/** * Get config options for this token * * Order of reading is track/round, survey, survey code * * @param \Gems_Tracker_Token $token */ public function getConfig($token) { try { $trackId = $token->getTrackId(); $roundId = $token->getRoundId(); $db = \Zend_Db_Table::getDefaultAdapter(); $select = $db->select()->from('gems__chart_config')->where('gcc_tid = ?', $trackId)->where('gcc_rid = ?', $roundId); if ($result = $select->query()->fetch()) { $config = \Zend_Json::decode($result['gcc_config']); return $config; } $surveyId = $token->getSurveyId(); $select = $db->select()->from('gems__chart_config')->where('gcc_sid = ?', $surveyId); if ($result = $select->query()->fetch()) { $config = \Zend_Json::decode($result['gcc_config']); return $config; } $surveyCode = $token->getSurvey()->getCode(); $select = $db->select()->from('gems__chart_config')->where('gcc_code = ?', $surveyCode); $config = $select->query()->fetch(); if ($config !== false) { $config = \Zend_Json::decode($config['gcc_config']); } return $config; } catch (\Exception $exc) { // Just ignore... } // If all fails, we might be missing the config table return false; }
/** * * @param mixed $token * @param int $userId The current user * @return int The number of tokens changed by this event */ public function handleRoundCompletion($token, $userId) { if (!$token instanceof \Gems_Tracker_Token) { $token = $this->tracker->getToken($token); } // \MUtil_Echo::track($token->getRawAnswers()); // Store the current token as startpoint if it is the first changed token if ($this->_checkStart) { if ($this->_checkStart->getRoundId() > $token->getRoundId()) { // Replace current token $this->_checkStart = $token; } } else { $this->_checkStart = $token; } // Process any events if ($event = $this->getTrackEngine()->getRoundChangedEvent($token->getRoundId())) { return $event->processChangedRound($token, $this, $userId); } return 0; }
/** * Returns a snippet name that can be used to display the answers to the token or nothing. * * @param \Gems_Tracker_Token $token * @return array Of snippet names */ public function getRoundAnswerSnippets(\Gems_Tracker_Token $token) { $this->_ensureRounds(); $roundId = $token->getRoundId(); if (isset($this->_rounds[$roundId]['gro_display_event']) && $this->_rounds[$roundId]['gro_display_event']) { $event = $this->events->loadSurveyDisplayEvent($this->_rounds[$roundId]['gro_display_event']); return $event->getAnswerDisplaySnippets($token); } }