コード例 #1
0
 /**
  * Creates the model
  *
  * @return \MUtil_Model_ModelAbstract
  */
 protected function createModel()
 {
     $model = $this->token->getModel();
     if ($this->useFakeForm && $this->token->hasSuccesCode() && !$this->token->isCompleted()) {
         $model->set('gto_id_token', 'formatFunction', array(__CLASS__, 'makeFakeForm'));
     } else {
         $model->set('gto_id_token', 'formatFunction', 'strtoupper');
     }
     $model->setBridgeFor('itemTable', 'ThreeColumnTableBridge');
     return $model;
 }
コード例 #2
0
 /**
  * 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();
                 }
             }
         }
     }
 }
コード例 #3
0
 /**
  * Returns a token with a success reception code for this round or null
  *
  * @param type $roundId Gems round id
  * @param \Gems_Tracker_Token $token Optional token to add as a round (for speed optimization)
  * @return \Gems_Tracker_Token
  */
 public function getActiveRoundToken($roundId, \Gems_Tracker_Token $token = null)
 {
     if (null !== $token && $token->hasSuccesCode()) {
         // Cache the token
         //
         // WARNING: This may cause bugs for tracks where two tokens exists
         // with this roundId and a success reception code, but this does speed
         // this function with track engines where that should not occur.
         $this->_activeTokens[$token->getRoundId()] = $token;
     }
     // Nothing to find
     if (!$roundId) {
         return null;
     }
     // Use array_key_exists since there may not be a valid round
     if (!array_key_exists($roundId, $this->_activeTokens)) {
         $tokenSelect = $this->tracker->getTokenSelect();
         $tokenSelect->andReceptionCodes()->forRespondentTrack($this->_respTrackId)->forRound($roundId)->onlySucces();
         // \MUtil_Echo::track($tokenSelect->__toString());
         if ($tokenData = $tokenSelect->fetchRow()) {
             $this->_activeTokens[$roundId] = $this->tracker->getToken($tokenData);
         } else {
             $this->_activeTokens[$roundId] = null;
         }
     }
     return $this->_activeTokens[$roundId];
 }