Exemplo n.º 1
0
 /**
  * @param KalturaFilterPager $pager
  * @param KalturaDetachedResponseProfile $responseProfile
  * @return KalturaListResponse
  */
 public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $response = new KalturaUserEntryListResponse();
     if (in_array(kCurrentContext::getCurrentSessionType(), array(kSessionBase::SESSION_TYPE_NONE, kSessionBase::SESSION_TYPE_WIDGET))) {
         $response->totalCount = 0;
         return $response;
     }
     $c = new Criteria();
     if (!is_null($this->userIdEqualCurrent) && $this->userIdEqualCurrent) {
         $this->userIdEqual = kCurrentContext::getCurrentKsKuserId();
     } else {
         $this->fixFilterUserId();
     }
     $userEntryFilter = $this->toObject();
     $userEntryFilter->attachToCriteria($c);
     $pager->attachToCriteria($c);
     $list = UserEntryPeer::doSelect($c);
     $resultCount = count($list);
     if ($resultCount && $resultCount < $pager->pageSize) {
         $totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount;
     } else {
         KalturaFilterPager::detachFromCriteria($c);
         $totalCount = UserEntryPeer::doCount($c);
     }
     $response->totalCount = $totalCount;
     $response->objects = KalturaUserEntryArray::fromDbArray($list, $responseProfile);
     return $response;
 }
Exemplo n.º 2
0
 /**
  * Returns the number of related UserEntry objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related UserEntry objects.
  * @throws     PropelException
  */
 public function countUserEntrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(kuserPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collUserEntrys === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(UserEntryPeer::KUSER_ID, $this->id);
             $count = UserEntryPeer::doCount($criteria, false, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(UserEntryPeer::KUSER_ID, $this->id);
             if (!isset($this->lastUserEntryCriteria) || !$this->lastUserEntryCriteria->equals($criteria)) {
                 $count = UserEntryPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collUserEntrys);
             }
         } else {
             $count = count($this->collUserEntrys);
         }
     }
     return $count;
 }
Exemplo n.º 3
0
 protected function getUserPercentageCount($objectIds)
 {
     $c = new Criteria();
     $c->setDistinct();
     $c->addSelectColumn(UserEntryPeer::KUSER_ID);
     $c->add(UserEntryPeer::ENTRY_ID, $objectIds);
     $c->add(UserEntryPeer::STATUS, QuizPlugin::getCoreValue('UserEntryStatus', QuizUserEntryStatus::QUIZ_SUBMITTED));
     // if a user has answered the test twice (consider anonymous users) it will be calculated twice.
     $count = UserEntryPeer::doCount($c);
     $res = array();
     $res['count_all'] = $count;
     return array($res);
 }