public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     $html = $this->getHtmlSequence();
     $html->div($this->token->getSurveyName(), array('class' => 'surveyTitle'));
     $html->div($this->token->getRoundDescription(), array('class' => 'roundDescription', 'renderClosingTag' => true));
     return $html;
 }
 /**
  * Process the data and return the answers that should be changed.
  *
  * Storing the changed values is handled by the calling function.
  *
  * @param \Gems_Tracker_Token $token Gems token object
  * @return array Containing the changed values
  */
 public function processTokenData(\Gems_Tracker_Token $token)
 {
     if (!$token->getReceptionCode()->isSuccess()) {
         return;
     }
     $answers = $token->getRawAnswers();
     if (isset($answers['informedconsent'])) {
         $consent = $this->util->getConsent($answers['informedconsent']);
         if ($consent->exists) {
             // Is existing consent description as answer
             $consentCode = $consent->getDescription();
         } else {
             if ($answers['informedconsent']) {
                 // Uses start of consent description as answer (LS has only 5 chars for an answer option)
                 $consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_description LIKE ? ORDER BY gco_order", $answers['informedconsent'] . '%');
             } else {
                 $consentCode = false;
             }
             if (!$consentCode) {
                 if ($answers['informedconsent']) {
                     // Code not found, use first positive consent
                     $consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_code != ? ORDER BY gco_order", $this->util->getConsentRejected());
                 } else {
                     // Code not found, use first negative consent
                     $consentCode = $this->db->fetchOne("SELECT gco_description FROM gems__consents WHERE gco_code = ? ORDER BY gco_order", $this->util->getConsentRejected());
                 }
             }
         }
         $respondent = $token->getRespondent();
         $values = array('gr2o_patient_nr' => $respondent->getPatientNumber(), 'gr2o_id_organization' => $respondent->getOrganizationId(), 'gr2o_consent' => $consentCode);
         $respondent->getRespondentModel()->save($values);
     }
     return false;
 }
 /**
  * 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;
 }
 /**
  * Function that returns the snippets to use for this display.
  *
  * @param \Gems_Tracker_Token $token The token to get the snippets for
  * @return array of Snippet names or nothing
  */
 public function getAnswerDisplaySnippets(\Gems_Tracker_Token $token)
 {
     $this->token = $token;
     $snippets = (array) $token->getTrackEngine()->getAnswerSnippetNames();
     $snippets['answerFilter'] = $this;
     return $snippets;
 }
 /**
  * Process the data and return the answers that should be changed.
  *
  * Storing the changed values is handled by the calling function.
  *
  * @param \Gems_Tracker_Token $token Gems token object
  * @return array Containing the changed values
  */
 public function processTokenData(\Gems_Tracker_Token $token)
 {
     $tokenAnswers = $token->getRawAnswers();
     if (isset($tokenAnswers['LENGTH'], $tokenAnswers['WEIGHT']) && $tokenAnswers['LENGTH'] && $tokenAnswers['WEIGHT']) {
         $length = $tokenAnswers['LENGTH'] / 100;
         $newValue = round($tokenAnswers['WEIGHT'] / ($length * $length), 2);
         if ($newValue !== $tokenAnswers['BMI']) {
             return array('BMI' => $newValue);
         }
     }
     return false;
 }
 /**
  * Create the snippets content
  *
  * This is a stub function either override getHtmlOutput() or override render()
  *
  * @param \Zend_View_Abstract $view Just in case it is needed here
  * @return \MUtil_Html_HtmlInterface Something that can be rendered
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     $delay = $this->project->getAskDelay($this->request, $this->wasAnswered);
     $href = $this->getTokenHref($this->showToken);
     $html = $this->getHtmlSequence();
     $org = $this->showToken->getOrganization();
     $url = $href->render($this->view);
     switch ($delay) {
         case 0:
             // Redirect at once
             header('Location: ' . $url);
             exit;
         case -1:
             break;
         default:
             // Let the page load after stated interval
             $this->view->headMeta()->appendHttpEquiv('Refresh', $delay . '; url=' . $url);
     }
     $html->h3($this->_('Token'));
     if ($this->token->hasRelation()) {
         $p = $html->pInfo(sprintf($this->_('Welcome %s,'), $this->showToken->getRelation()->getName()));
         $html->pInfo(sprintf($this->_('We kindly ask you to answer a survey about %s.'), $this->showToken->getRespondent()->getName()));
     } else {
         $p = $html->pInfo(sprintf($this->_('Welcome %s,'), $this->showToken->getRespondentName()));
     }
     if ($this->wasAnswered) {
         $html->pInfo(sprintf($this->_('Thank you for answering the "%s" survey.'), $this->token->getSurveyName()));
         $html->pInfo($this->_('Please click the button below to answer the next survey.'));
     } else {
         if ($welcome = $org->getWelcome()) {
             $html->pInfo()->raw(\MUtil_Markup::render($this->_($welcome), 'Bbcode', 'Html'));
         }
         $html->pInfo(sprintf($this->_('Please click the button below to answer the survey for token %s.'), strtoupper($this->showToken->getTokenId())));
     }
     if ($delay > 0) {
         $html->pInfo(sprintf($this->plural('Wait one second to open the survey automatically or click on Cancel to stop.', 'Wait %d seconds to open the survey automatically or click on Cancel to stop.', $delay), $delay));
     }
     $buttonDiv = $html->buttonDiv(array('class' => 'centerAlign'));
     $buttonDiv->actionLink($href, $this->showToken->getSurveyName());
     if ($delay > 0) {
         $buttonDiv->actionLink(array('delay_cancelled' => 1), $this->_('Cancel'));
     }
     if ($next = $this->showToken->getTokenCountUnanswered()) {
         $html->pInfo(sprintf($this->plural('After this survey there is one other survey we would like you to answer.', 'After this survey there are another %d surveys we would like you to answer.', $next), $next));
     }
     if ($sig = $org->getSignature()) {
         $html->pInfo()->raw(\MUtil_Markup::render($this->_($sig), 'Bbcode', 'Html'));
     }
     return $html;
 }
 /**
  * Process the data and return the answers that should be filled in beforehand.
  *
  * Storing the changed values is handled by the calling function.
  *
  * @param \Gems_Tracker_Token $token Gems token object
  * @return array Containing the changed values
  */
 public function processTokenInsertion(\Gems_Tracker_Token $token)
 {
     if ($token->hasSuccesCode() && !$token->isCompleted()) {
         // Preparation for a more general object class
         $surveyId = $token->getSurveyId();
         $prev = $token;
         while ($prev = $prev->getPreviousToken()) {
             if ($prev->hasSuccesCode() && $prev->isCompleted()) {
                 // Check first on survey id and when that does not work by name.
                 if ($prev->getSurveyId() == $surveyId) {
                     return $prev->getRawAnswers();
                 }
             }
         }
     }
 }
 /**
  * Go directly to url
  */
 public function toSurveyAction()
 {
     if (!$this->_initToken()) {
         // Default option
         $this->_forward('index');
         return;
     }
     $language = $this->locale->getLanguage();
     try {
         $url = $this->token->getUrl($language, $this->currentUser->getUserId() ? $this->currentUser->getUserId() : $this->token->getRespondentId());
         /************************
          * Optional user logout *
          ************************/
         if ($this->currentUser->isLogoutOnSurvey()) {
             $this->currentUser->unsetAsCurrentUser();
         }
         // Redirect at once
         header('Location: ' . $url);
         exit;
     } catch (\Gems_Tracker_Source_SurveyNotFoundException $e) {
         $this->addMessage(sprintf($this->_('The survey for token %s is no longer active.'), strtoupper($this->tokenId)));
         // Default option
         $this->_forward('index');
     }
 }
 /**
  * Set what to do when the form is 'finished'.
  *
  * @return self
  */
 protected function setAfterSaveRoute()
 {
     // Default is just go to the index
     if ($this->routeAction && $this->request->getActionName() !== $this->routeAction) {
         $this->afterSaveRouteUrl = array($this->request->getControllerKey() => 'track', $this->request->getActionKey() => $this->routeAction, \MUtil_Model::REQUEST_ID => $this->token->getTokenId());
     }
     return $this;
 }
 /**
  * Update the token data when a Mail has been sent.
  * @param  integer $tokenId TokenId to update. If none is supplied, use the current token
  */
 public function updateToken($tokenId = false)
 {
     if (!$tokenId) {
         $tokenId = $this->token->getTokenId();
     }
     $tokenData['gto_mail_sent_num'] = new \Zend_Db_Expr('gto_mail_sent_num + 1');
     $tokenData['gto_mail_sent_date'] = \MUtil_Date::format(new \Zend_Date(), 'yyyy-MM-dd');
     $this->db->update('gems__tokens', $tokenData, $this->db->quoteInto('gto_id_token = ?', $tokenId));
 }
 /**
  * Set what to do when the form is 'finished'.
  *
  * @return DeleteTrackTokenSnippet (continuation pattern)
  */
 protected function setAfterSaveRoute()
 {
     // Default is just go to the index
     if ($this->routeAction && $this->request->getActionName() !== $this->routeAction) {
         $tokenId = $this->_replacementTokenId ? $this->_replacementTokenId : $this->token->getTokenId();
         $this->afterSaveRouteUrl = array($this->request->getActionKey() => $this->routeAction, \MUtil_Model::REQUEST_ID => $tokenId);
     }
     return $this;
 }
 protected function loadExport()
 {
     $this->export = $this->loader->getRespondentExport();
     if ($this->token instanceof \Gems_Tracker_Token) {
         $this->addRespondent($this->token->getPatientNumber(), $this->token->getOrganizationId());
         $this->export->addRespondentTrackFilter($this->token->getRespondentTrackId());
         $this->export->addTokenFilter($this->token->getTokenId());
     } elseif ($this->respondentTrack instanceof \Gems_Tracker_RespondentTrack) {
         $this->addRespondent($this->respondentTrack->getPatientNumber(), $this->respondentTrack->getOrganizationId());
         $this->export->addRespondentTrackFilter($this->respondentTrack->getRespondentTrackId());
     } elseif ($this->respondent instanceof \Gems_Tracker_Respondent) {
         $this->addRespondent($this->respondent->getPatientNumber(), $this->respondent->getOrganizationId());
     }
 }
 /**
  * The place to check if the data set in the snippet is valid
  * to generate the snippet.
  *
  * When invalid data should result in an error, you can throw it
  * here but you can also perform the check in the
  * checkRegistryRequestsAnswers() function from the
  * {@see \MUtil_Registry_TargetInterface}.
  *
  * @return boolean
  */
 public function hasHtmlOutput()
 {
     if (!$this->tokenId) {
         if ($this->token) {
             $this->tokenId = $this->token->getTokenId();
         } elseif ($this->request) {
             $this->tokenId = $this->request->getParam(\MUtil_Model::REQUEST_ID);
         }
     }
     if ($this->tokenId && !$this->token) {
         $this->token = $this->loader->getTracker()->getToken($this->tokenId);
     }
     // Output always true, returns an error message as html when anything is wrong
     return parent::hasHtmlOutput();
 }
 /**
  *
  * @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 the date to use to calculate the ValidUntil if any
  *
  * @param string $fieldSource Source for field from round
  * @param string $fieldName Name from round
  * @param int $prevRoundId Id from round
  * @param \Gems_Tracker_Token $token
  * @param \Gems_Tracker_RespondentTrack $respTrack
  * @param \MUtil_Date $validFrom The calculated new valid from value or null
  * @return \MUtil_Date date time or null
  */
 protected function getValidUntilDate($fieldSource, $fieldName, $prevRoundId, \Gems_Tracker_Token $token, \Gems_Tracker_RespondentTrack $respTrack, $validFrom)
 {
     $date = null;
     switch ($fieldSource) {
         case parent::NO_TABLE:
             break;
         case parent::TOKEN_TABLE:
             // Always uses the current token
             if ($fieldName == 'gto_valid_from') {
                 // May be changed but is not yet stored
                 $date = $validFrom;
             } else {
                 // No previous here, date is always from this tokens date
                 $date = $token->getDateTime($fieldName);
             }
             break;
         case parent::ANSWER_TABLE:
             if ($prev = $token->getPreviousSuccessToken()) {
                 $date = $prev->getAnswerDateTime($fieldName);
             }
             break;
         case parent::APPOINTMENT_TABLE:
         case parent::RESPONDENT_TRACK_TABLE:
             $date = $respTrack->getDate($fieldName);
             break;
     }
     return $date;
 }
 /**
  * Get the href for a token
  *
  * @param \Gems_Tracker_Token $token
  * @return \MUtil_Html_HrefArrayAttribute
  */
 protected function getTokenHref(\Gems_Tracker_Token $token)
 {
     /***************
      * Get the url *
      ***************/
     $params = array($this->request->getActionKey() => 'to-survey', \MUtil_Model::REQUEST_ID => $token->getTokenId(), 'RouteReset' => false);
     return new \MUtil_Html_HrefArrayAttribute($params);
 }
 /**
  * Determines if this particular token should be included
  * in the report
  *
  * @param  \Gems_Tracker_Token $token
  * @return boolean This dummy implementation always returns true
  */
 protected function _isTokenInFilter(\Gems_Tracker_Token $token)
 {
     $result = false;
     // Only if token has a success code
     if ($token->getReceptionCode()->isSuccess()) {
         $result = true;
     }
     if ($result) {
         $tokenInfo = array('code' => $token->getSurvey()->getCode(), 'surveyid' => $token->getSurveyId(), 'tokenid' => $token->getTokenId());
         // Now check if the tokenfilter is true
         if (empty($this->tokenFilter)) {
             $result = true;
         } else {
             $result = false;
             // Now read the filter and split by track code or track id
             foreach ($this->tokenFilter as $filter) {
                 $remaining = array_diff_assoc($filter, $tokenInfo);
                 if (empty($remaining)) {
                     $result = true;
                     break;
                 }
             }
         }
     }
     return $result;
 }
 /**
  * The place to check if the data set in the snippet is valid
  * to generate the snippet.
  *
  * When invalid data should result in an error, you can throw it
  * here but you can also perform the check in the
  * checkRegistryRequestsAnswers() function from the
  * {@see \MUtil_Registry_TargetInterface}.
  *
  * @return boolean
  */
 public function hasHtmlOutput()
 {
     if (!$this->tokenId) {
         if (isset($this->token)) {
             $this->tokenId = $this->token->getTokenId();
         }
     } elseif (!$this->token) {
         $this->token = $this->loader->getTracker()->getToken($this->tokenId);
     }
     // Output always true, returns an error message as html when anything is wrong
     return true;
 }
 /**
  * Copied from parent, but insert chart instead of table after commented out part
  *
  * @param \Zend_View_Abstract $view
  * @return type
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     //$view->headLink()->prependStylesheet($view->serverUrl() . \GemsEscort::getInstance()->basepath->getBasePath() . '/gems/css/barchart.less', 'screen,print');
     $htmlDiv = \MUtil_Html::create()->div(' ', array('class' => 'barchartcontainer'));
     if ($this->showHeaders) {
         if (isset($this->token)) {
             $htmlDiv->h3(sprintf($this->_('Overview for patient number %s'), $this->token->getPatientNumber()));
             $htmlDiv->pInfo(sprintf($this->_('Overview for patient number %s: %s.'), $this->token->getPatientNumber(), $this->token->getRespondentName()))->appendAttrib('class', 'noprint');
         } else {
             $htmlDiv->pInfo($this->_('No data present'));
         }
     }
     if (!empty($this->data)) {
         $htmlDiv->append($this->getChart());
         // Insert the chart here
     }
     if ($this->showButtons) {
         $buttonDiv = $htmlDiv->buttonDiv();
         $buttonDiv->actionLink(array(), $this->_('Back'), array('onclick' => 'window.history.go(-1); return false;'));
         $buttonDiv->actionLink(array(), $this->_('Print'), array('onclick' => 'window.print();'));
     }
     // Make vertically resizable
     $view = \Zend_Layout::getMvcInstance()->getView();
     /*$jquery = $view->jQuery();
       $jquery->enable();*/
     \MUtil_JQuery::enableView($view);
     // We need width 100% otherwise it will look strange in print output
     $view->jQuery()->addOnLoad("\$('.barchart').resizable({\r\n            handles: 's',\r\n            resize: function( event, ui ) { ui.element.css({ width: '100%'}); },\r\n            minHeight: 150\r\n            });");
     return $htmlDiv;
 }
 /**
  * An array of snippet names for displaying a token
  *
  * @param \Gems_Tracker_Token $token Allows token status dependent show snippets
  * @return array of string snippet names
  */
 public function getTokenShowSnippetNames(\Gems_Tracker_Token $token)
 {
     $output[] = 'Token\\ShowTrackTokenSnippet';
     if ($token->isCompleted()) {
         $output[] = 'Tracker_Answers_SingleTokenAnswerModelSnippet';
     } else {
         $output[] = 'Survey\\SurveyQuestionsSnippet';
     }
     return $output;
 }
Example #21
0
 /**
  * The maximum length of the result field
  *
  * @return int
  */
 protected function _getResultFieldLength()
 {
     if (null !== $this->resultFieldLength) {
         return $this->resultFieldLength;
     }
     if (null !== self::$staticResultFieldLength) {
         $this->resultFieldLength = self::$staticResultFieldLength;
         return $this->resultFieldLength;
     }
     $model = new \MUtil_Model_TableModel('gems__tokens');
     self::$staticResultFieldLength = $model->get('gto_result', 'maxlength');
     $this->resultFieldLength = self::$staticResultFieldLength;
     return $this->resultFieldLength;
 }
 /**
  * Remove token from cache for saving memory
  *
  * @param string|\Gems_Tracker_Token $token
  * @return \Gems_Tracker (continuation pattern)
  */
 public function removeToken($token)
 {
     if ($token instanceof \Gems_Tracker_Token) {
         $tokenId = $token->getTokenId();
     } else {
         $tokenId = $token;
     }
     unset($this->_tokens[$tokenId]);
     return $this;
 }
 /**
  * Process the data and return the answers that should be changed.
  *
  * Storing the changed values is handled by the calling function.
  *
  * @param \Gems_Tracker_Token $token Gems token object
  * @return array Containing the changed values
  */
 public function processTokenData(\Gems_Tracker_Token $token)
 {
     $result = var_export($token->getRawAnswers(), true);
     \MUtil_Echo::r($result, $token->getTokenId());
     return false;
 }
 /**
  * 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);
     }
 }
 /**
  * Returns the url that (should) start the survey for this token
  *
  * @param \Gems_Tracker_Token $token Gems token object
  * @param string $language
  * @param int $surveyId Gems Survey Id
  * @param string $sourceSurveyId Optional Survey Id used by source
  * @return string The url to start the survey
  */
 public function getTokenUrl(\Gems_Tracker_Token $token, $language, $surveyId, $sourceSurveyId)
 {
     if (null === $sourceSurveyId) {
         $sourceSurveyId = $this->_getSid($surveyId);
     }
     $tokenId = $this->_getToken($token->getTokenId());
     if ($this->_isLanguage($sourceSurveyId, $language)) {
         $langUrl = '/lang/' . $language;
     } else {
         $langUrl = '';
     }
     // <base>/index.php/survey/index/sid/834486/token/234/lang/en
     $baseurl = $this->getBaseUrl();
     $start = $baseurl . ('/' == substr($baseurl, -1) ? '' : '/');
     if (stripos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false || ini_get('security.limit_extensions') && ini_get('security.limit_extensions') != '') {
         // Apache : index.php/
         $start .= 'index.php/';
     } else {
         $start .= 'index.php?r=';
     }
     return $start . 'survey/index/sid/' . $sourceSurveyId . '/token/' . $tokenId . $langUrl;
 }
 /**
  * The place to check if the data set in the snippet is valid
  * to generate the snippet.
  *
  * When invalid data should result in an error, you can throw it
  * here but you can also perform the check in the
  * checkRegistryRequestsAnswers() function from the
  * {@see \MUtil_Registry_TargetInterface}.
  *
  * @return boolean
  */
 public function hasHtmlOutput()
 {
     // Apply translations
     if (!$this->showAnswersTranslated) {
         // Here, not in e.g. __construct as these vars may be set during initiation
         $this->showAnswersNone = $this->_($this->showAnswersNone);
         $this->showAnswersRemoved = $this->_($this->showAnswersRemoved);
         $this->showAnswersSeparator = $this->_($this->showAnswersSeparator);
         $this->showAnswersTranslated = true;
     }
     // Overrule any setting of these values from source
     $this->data = null;
     $this->repeater = null;
     if (!$this->surveyId) {
         if ($this->token instanceof \Gems_Tracker_Token && $this->token->exists) {
             $this->surveyId = $this->token->getSurveyId();
         } elseif ($this->trackData && !$this->trackId) {
             // Look up key values from trackData
             if (isset($this->trackData['gsu_id_survey'])) {
                 $this->surveyId = $this->trackData['gsu_id_survey'];
             } elseif (isset($this->trackData['gro_id_survey'])) {
                 $this->surveyId = $this->trackData['gro_id_survey'];
             } elseif (!$this->trackId) {
                 if (isset($this->trackData['gtr_id_track'])) {
                     $this->trackId = $this->trackData['gtr_id_track'];
                 } elseif (isset($this->trackData['gro_id_track'])) {
                     $this->trackId = $this->trackData['gro_id_track'];
                 }
             }
         }
         if (!$this->trackId && $this->trackEngine) {
             $this->trackId = $this->trackEngine->getTrackId();
         }
         if ($this->trackId && !$this->surveyId) {
             // Use the track ID to get the id of the first active survey
             $this->surveyId = $this->db->fetchOne('SELECT gro_id_survey FROM gems__rounds WHERE gro_active = 1 AND gro_id_track = ? ORDER BY gro_id_order', $this->trackId);
         }
     }
     // \MUtil_Echo::track($this->surveyId, $this->trackId);
     // Get the survey
     if ($this->surveyId && !$this->survey instanceof \Gems_Tracker_Survey) {
         $this->survey = $this->loader->getTracker()->getSurvey($this->surveyId);
     }
     // Load the data
     if ($this->survey instanceof \Gems_Tracker_Survey && $this->survey->exists) {
         $this->data = \MUtil_Ra::addKey($this->survey->getQuestionInformation($this->locale->getLanguage()), 'key');
         //\MUtil_Echo::track($this->data);
     }
     return parent::hasHtmlOutput();
 }
 /**
  * @covers Gems_Tracker_Token::cacheReset
  */
 public function testCacheReset()
 {
     $this->token->cacheSet('foo3', 'baz');
     $this->token->cacheReset();
     $this->assertEquals(null, $this->token->cacheGet('foo3'));
 }
 /**
  * Returns true if the survey was completed according to the source
  *
  * @param \Gems_Tracker_Token $token Gems token object
  * @param int $surveyId Gems Survey Id
  * @param string $sourceSurveyId Optional Survey Id used by source
  * @return boolean True if the token has completed
  */
 public function isCompleted(\Gems_Tracker_Token $token, $surveyId, $sourceSurveyId = null)
 {
     $result = $this->getRawTokenAnswerRow($token->getTokenId(), $surveyId);
     $completed = !empty($result);
     return $completed;
 }