Example #1
0
 protected function getUserPrecentageByUserAndEntryTable($entryIds, $inputFilter, $orderBy)
 {
     $userIds = $this->getUserIdsFromFilter($inputFilter);
     $noEntryIds = QuizPlugin::isWithoutValue($entryIds);
     $noUserIds = QuizPlugin::isWithoutValue($userIds);
     if ($noEntryIds && $noUserIds) {
         return array();
     }
     $c = new Criteria();
     if (!$noUserIds) {
         $c->add(UserEntryPeer::KUSER_ID, $this->getKuserIds($userIds), Criteria::IN);
     }
     if (!$noEntryIds) {
         $entryIdsArray = explode(",", $entryIds);
         $dbEntries = entryPeer::retrieveByPKs($entryIdsArray);
         if (empty($dbEntries)) {
             throw new kCoreException("", kCoreException::INVALID_ENTRY_ID, $entryIds);
         }
         $c->add(UserEntryPeer::ENTRY_ID, $entryIdsArray, Criteria::IN);
         $hasAnonymous = false;
         foreach ($dbEntries as $dbEntry) {
             $anonKuserIds = $this->getAnonymousKuserIds($dbEntry->getPartnerId());
             if (!empty($anonKuserIds)) {
                 $hasAnonymous = true;
                 break;
             }
         }
         if ($hasAnonymous) {
             $c->addAnd(UserEntryPeer::KUSER_ID, $anonKuserIds, Criteria::NOT_IN);
         }
     }
     $userEntries = UserEntryPeer::doSelect($c);
     return $this->getAggregateDataForUsers($userEntries, $orderBy);
 }
Example #2
0
 protected function getUserPrecentageByUserAndEntryTable($entryIds, $inputFilter, $orderBy)
 {
     $userIds = $this->getUserIdsFromFilter($inputFilter);
     $noEntryIds = QuizPlugin::isWithoutValue($entryIds);
     $noUserIds = QuizPlugin::isWithoutValue($userIds);
     if ($noEntryIds && $noUserIds) {
         return array();
     }
     $userIds = $this->getUserIdsFromFilter($inputFilter);
     $c = new Criteria();
     $c->add(CuePointPeer::TYPE, QuizPlugin::getCoreValue('CuePointType', QuizCuePointType::QUIZ_ANSWER));
     if (!$noUserIds) {
         $c = $this->createGetCuePointByUserIdsCriteria($userIds, $c);
     }
     if (!$noEntryIds) {
         $c->add(CuePointPeer::ENTRY_ID, explode(",", $entryIds), Criteria::IN);
     }
     $answers = CuePointPeer::doSelect($c);
     return $this->getAggregateDataForUsers($answers, $orderBy);
 }