Ejemplo n.º 1
0
 private function loadQPList($qpItem)
 {
     $retval = array();
     $curT = intval(time());
     // $this->log(json_encode($qpItem));
     // check predefined timings
     if (intval($qpItem["timing_type"]) == 0) {
         // ensure that the correct timings are used
         if (array_key_exists("start", $qpItem) && ($curT < intval($qpItem["start"]) || $curT > intval($qpItem["end"])) || array_key_exists("timing_start", $qpItem) && ($curT < intval($qpItem["timing_start"]) || $curT > intval($qpItem["timing_end"]))) {
             $this->log('bad timig, skip question pool');
             return $retval;
         }
     }
     $questionPool = new ilObjQuestionPool($qpItem["ref_id"]);
     $questionPool->read();
     // check online state
     if ($questionPool->getOnline() == 0) {
         $this->log('offline, skip question pool');
         return $retval;
     }
     $questions = $questionPool->getQuestionList();
     if (empty($questions)) {
         // ignore empty question pools
         return $retval;
     }
     // load the actual questions.
     if ($this->iliasVersion != "4.2") {
         $retval["questions"] = $this->getQuestionListNew($questions);
     } else {
         $retval["questions"] = $this->getQuestionListOld($questions);
     }
     $retval["id"] = $qpItem["ref_id"];
     // pass only the reference id
     $retval["title"] = $questionPool->getTitle();
     $retval["description"] = $questionPool->getDescription();
     if (intval($qpItem["timing_type"]) == 0) {
         // pass the end-date on, so the remote broker can switch
         // the pool off if necessary.
         if (array_key_exists("end", $qpItem)) {
             $retval["end-date"] = intval($qpItem["end"]);
         } else {
             if (array_key_exists("timing_end", $qpItem)) {
                 $retval["end-date"] = intval($qpItem["timing_end"]);
             }
         }
     }
     return $retval;
 }