public function validateForInsert($propertiesToSkip = array())
 {
     parent::validateForInsert($propertiesToSkip);
     $dbEntry = entryPeer::retrieveByPK($this->entryId);
     QuizPlugin::validateAndGetQuiz($dbEntry);
     if (!QuizPlugin::validateUserEntitledForQuizEdit($dbEntry)) {
         throw new KalturaAPIException(KalturaErrors::INVALID_USER_ID);
     }
 }
 public function validateForInsert($propertiesToSkip = array())
 {
     parent::validateForInsert($propertiesToSkip);
     $dbEntry = entryPeer::retrieveByPK($this->entryId);
     QuizPlugin::validateAndGetQuiz($dbEntry);
     if (!QuizPlugin::validateUserEntitledForQuizEdit($dbEntry)) {
         KalturaLog::debug('Update quiz questions is allowed only with admin KS or entry owner or co-editor');
         throw new KalturaAPIException(KalturaErrors::INVALID_USER_ID);
     }
 }
 public function validateForUpdate($sourceObject, $propertiesToSkip = array())
 {
     parent::validateForUpdate($sourceObject, $propertiesToSkip);
     $dbEntry = entryPeer::retrieveByPK($this->entryId);
     $kQuiz = QuizPlugin::validateAndGetQuiz($dbEntry);
     $this->validateUserEntry();
     if (!$kQuiz->getAllowAnswerUpdate()) {
         throw new KalturaAPIException(KalturaQuizErrors::ANSWER_UPDATE_IS_NOT_ALLOWED, $sourceObject->getEntryId());
     }
 }
Example #4
0
 /**
  * Allows to update a quiz
  *
  * @action update
  * @param string $entryId
  * @param KalturaQuiz $quiz
  * @return KalturaQuiz
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::INVALID_USER_ID
  * @throws KalturaQuizErrors::PROVIDED_ENTRY_IS_NOT_A_QUIZ
  */
 public function updateAction($entryId, KalturaQuiz $quiz)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     $kQuiz = QuizPlugin::validateAndGetQuiz($dbEntry);
     return $this->validateAndUpdateQuizData($dbEntry, $quiz, $kQuiz->getVersion(), $kQuiz);
 }
Example #5
0
 /**
  * @param $objectIds
  * @return array
  * @throws kCoreException
  * @throws KalturaAPIException
  */
 protected function getUserPercentageTable($objectIds, $orderBy)
 {
     $dbEntry = entryPeer::retrieveByPK($objectIds);
     if (!$dbEntry) {
         throw new kCoreException("", kCoreException::INVALID_ENTRY_ID, $objectIds);
     }
     /**
      * @var kQuiz $kQuiz
      */
     $kQuiz = QuizPlugin::validateAndGetQuiz($dbEntry);
     $c = new Criteria();
     $c->add(UserEntryPeer::ENTRY_ID, $objectIds);
     $userEntries = UserEntryPeer::doSelect($c);
     return $this->getAggregateDataForUsers($userEntries, $orderBy);
 }
Example #6
0
 /**
  * @param $objectIds
  * @return array
  * @throws kCoreException
  * @throws KalturaAPIException
  */
 protected function getUserPercentageTable($objectIds, $orderBy)
 {
     $dbEntry = entryPeer::retrieveByPK($objectIds);
     if (!$dbEntry) {
         throw new kCoreException("", kCoreException::INVALID_ENTRY_ID, $objectIds);
     }
     /**
      * @var kQuiz $kQuiz
      */
     $kQuiz = QuizPlugin::validateAndGetQuiz($dbEntry);
     $c = new Criteria();
     $c->add(CuePointPeer::ENTRY_ID, $objectIds);
     $c->add(CuePointPeer::TYPE, QuizPlugin::getCoreValue('CuePointType', QuizCuePointType::QUIZ_ANSWER));
     $anonKuser = $this->getAnonymousKuser($dbEntry->getPartnerId());
     if (!is_null($anonKuser)) {
         $c->add(CuePointPeer::KUSER_ID, $anonKuser->getKuserId(), Criteria::NOT_IN);
     }
     $answers = CuePointPeer::doSelect($c);
     return $this->getAggregateDataForUsers($answers, $orderBy);
 }
Example #7
0
 /**
  * @param $objectIds
  * @return array
  * @throws Exception
  * @throws KalturaAPIException
  */
 protected function getUserPercentageTable($objectIds, $orderBy)
 {
     $dbEntry = entryPeer::retrieveByPK($objectIds);
     if (!$dbEntry) {
         throw new Exception(KalturaErrors::ENTRY_ID_NOT_FOUND, $objectIds);
     }
     /**
      * @var kQuiz $kQuiz
      */
     $kQuiz = QuizPlugin::validateAndGetQuiz($dbEntry);
     $c = new Criteria();
     $c->add(CuePointPeer::ENTRY_ID, $objectIds);
     $c->add(CuePointPeer::TYPE, QuizPlugin::getCoreValue('CuePointType', QuizCuePointType::QUIZ_ANSWER));
     $answers = CuePointPeer::doSelect($c);
     return $this->getAggregateDataForUsers($answers, $orderBy);
 }