Exemplo n.º 1
0
 /**
  * Submits the quiz so that it's status will be submitted and calculates the score for the quiz
  *
  * @action submitQuiz
  * @actionAlias userEntry.submitQuiz
  * @param int $id
  * @return KalturaQuizUserEntry
  * @throws KalturaAPIException
  */
 public function submitQuizAction($id)
 {
     $dbUserEntry = UserEntryPeer::retrieveByPK($id);
     if (!$dbUserEntry) {
         throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $id);
     }
     if ($dbUserEntry->getType() != QuizPlugin::getCoreValue('UserEntryType', QuizUserEntryType::QUIZ)) {
         throw new KalturaAPIException(KalturaQuizErrors::PROVIDED_ENTRY_IS_NOT_A_QUIZ, $id);
     }
     $dbUserEntry->setStatus(QuizPlugin::getCoreValue('UserEntryStatus', QuizUserEntryStatus::QUIZ_SUBMITTED));
     $userEntry = new KalturaQuizUserEntry();
     $userEntry->fromObject($dbUserEntry, $this->getResponseProfile());
     $entryId = $dbUserEntry->getEntryId();
     $entry = entryPeer::retrieveByPK($entryId);
     if (!$entry) {
         throw new KalturaAPIException(KalturaErrors::INVALID_OBJECT_ID, $entryId);
     }
     $kQuiz = QuizPlugin::getQuizData($entry);
     if (!$kQuiz) {
         throw new KalturaAPIException(KalturaQuizErrors::PROVIDED_ENTRY_IS_NOT_A_QUIZ, $entryId);
     }
     list($score, $numOfCorrectAnswers) = $dbUserEntry->calculateScoreAndCorrectAnswers();
     $dbUserEntry->setScore($score);
     $dbUserEntry->setNumOfCorrectAnswers($numOfCorrectAnswers);
     if ($kQuiz->getShowGradeAfterSubmission() == KalturaNullableBoolean::TRUE_VALUE || $this->getKs()->isAdmin() == true) {
         $userEntry->score = $score;
     } else {
         $userEntry->score = null;
     }
     $c = new Criteria();
     $c->add(CuePointPeer::ENTRY_ID, $dbUserEntry->getEntryId(), Criteria::EQUAL);
     $c->add(CuePointPeer::TYPE, QuizPlugin::getCoreValue('CuePointType', QuizCuePointType::QUIZ_QUESTION));
     $dbUserEntry->setNumOfQuestions(CuePointPeer::doCount($c));
     $dbUserEntry->setStatus(QuizPlugin::getCoreValue('UserEntryStatus', QuizUserEntryStatus::QUIZ_SUBMITTED));
     $dbUserEntry->save();
     return $userEntry;
 }
Exemplo n.º 2
0
 public function objectReplaced(BaseObject $object, BaseObject $replacingObject, BatchJob $raisedJob = null)
 {
     //replacement as a result of convertLiveSegmentFinished
     if (!$replacingObject->getIsTemporary()) {
         return true;
     }
     $c = new Criteria();
     $c->add(CuePointPeer::ENTRY_ID, $object->getId());
     if (CuePointPeer::doCount($c) > self::MAX_CUE_POINTS_TO_COPY_TO_CLIP) {
         KalturaLog::alert("Can't handle cuePoints after replacement for entry [{$object->getId()}] because cuePoints count exceeded max limit of [" . self::MAX_CUE_POINTS_TO_COPY_TO_CLIP . "]");
         return true;
     }
     $clipAttributes = self::getClipAttributesFromEntry($replacingObject);
     //replacement as a result of trimming
     if (!is_null($clipAttributes)) {
         kEventsManager::setForceDeferredEvents(true);
         $this->deleteCuePoints($c);
         //copy cuepoints from replacement entry
         $replacementCuePoints = CuePointPeer::retrieveByEntryId($replacingObject->getId());
         foreach ($replacementCuePoints as $cuePoint) {
             $newCuePoint = $cuePoint->copyToEntry($object);
             $newCuePoint->save();
         }
         kEventsManager::flushEvents();
     } else {
         if (PermissionPeer::isValidForPartner(CuePointPermissionName::REMOVE_CUE_POINTS_WHEN_REPLACING_MEDIA, $object->getPartnerId())) {
             $this->deleteCuePoints($c);
         }
     }
     return true;
 }
Exemplo n.º 3
0
 public static function doCountOnPeer(Criteria $c)
 {
     return CuePointPeer::doCount($c);
 }
Exemplo n.º 4
0
 protected function getQuestionCountByQusetionIds($objectIds)
 {
     $questionIds = baseObjectUtils::getObjectIdsAsArray($objectIds);
     $c = new Criteria();
     $c->add(CuePointPeer::ID, $questionIds, Criteria::IN);
     $numOfquestions = CuePointPeer::doCount($c);
     $res = array();
     $res['count_all'] = $numOfquestions;
     return array($res);
 }
 protected function doCountOnPeer(Criteria $c)
 {
     return CuePointPeer::doCount($c);
 }
Exemplo n.º 6
0
 protected function getAnswerCountByUserIds($objectIds)
 {
     $c = $this->createGetCuePointByUserIdsCriteria($objectIds);
     $numOfAnswers = CuePointPeer::doCount($c);
     $res['count_all'] = $numOfAnswers;
     return array($res);
 }