예제 #1
0
 private function currentPoll($sessionId)
 {
     // Load the user-vote.php required for this
     include __DIR__ . "/user-vote.php";
     $session = $this->getSession($sessionId);
     // Create response array
     $votes = array();
     $currentPoll = $session->getCurrentPoll();
     foreach ($session->getMembers() as $index => $member) {
         $votes[$index] = UserVote::create($member, $currentPoll);
     }
     // Create reponse object
     $response = new stdClass();
     $response->name = $session->getName();
     $response->topic = $currentPoll != null ? $currentPoll->getTopic() : "";
     // Time taken for estimation
     if ($currentPoll != null) {
         $diff = $currentPoll->getEndTime()->diff($currentPoll->getStartTime());
         $response->duration = new stdClass();
         $response->duration->min = $diff->i;
         $response->duration->sec = $diff->s;
     }
     // Vote estimation
     $response->votes = $votes;
     $response->flipped = is_null($currentPoll) ? false : $currentPoll->getResult() > 0;
     $response->consensus = is_null($currentPoll) ? false : $currentPoll->getConsensus();
     return $response;
 }
예제 #2
0
 public function addUserVote(UserVote $l)
 {
     $this->collUserVotes[] = $l;
     $l->setsfGuardUser($this);
 }
 private function currentPoll($sessionId)
 {
     // Load the user-vote.php required for this
     include __DIR__ . "/user-vote.php";
     $session = $this->getSession($sessionId);
     // Create response array
     $votes = array();
     $currentPoll = $session->getCurrentPoll();
     foreach ($session->getMembers() as $index => $member) {
         $votes[$index] = UserVote::create($member, $currentPoll);
     }
     // Is poll complete?
     $flipped = is_null($currentPoll) ? false : $currentPoll->getResult() > 0;
     // Evaluate min and max if poll is complete
     if ($flipped) {
         $consensus = $this->evaluateEstimates($votes);
     } else {
         $consensus = false;
     }
     // Create reponse object
     $response = new stdClass();
     $response->votes = $votes;
     $response->flipped = $flipped;
     $response->consensus = $consensus;
     return $response;
 }