コード例 #1
0
 /**
 * Calculates the data for the output of the question browser
 *
 * @access public
 */
 function getQuestionsTable($arrFilter)
 {
     global $ilUser;
     global $ilDB;
     $where = "";
     if (is_array($arrFilter)) {
         if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title'])) {
             $where .= " AND " . $ilDB->like('svy_question.title', 'text', "%%" . $arrFilter['title'] . "%%");
         }
         if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description'])) {
             $where .= " AND " . $ilDB->like('svy_question.description', 'text', "%%" . $arrFilter['description'] . "%%");
         }
         if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author'])) {
             $where .= " AND " . $ilDB->like('svy_question.author', 'text', "%%" . $arrFilter['author'] . "%%");
         }
         if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type'])) {
             $where .= " AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter['type'], 'text');
         }
         if (array_key_exists('spl', $arrFilter) && strlen($arrFilter['spl'])) {
             $where .= " AND svy_question.obj_fi = " . $ilDB->quote($arrFilter['spl'], 'integer');
         }
     }
     $spls =& $this->getAvailableQuestionpools($use_obj_id = TRUE, $could_be_offline = FALSE, $showPath = FALSE);
     $forbidden = "";
     $forbidden = " AND " . $ilDB->in('svy_question.obj_fi', array_keys($spls), false, 'integer');
     $forbidden .= " AND svy_question.complete = " . $ilDB->quote("1", 'text');
     $existing = "";
     $existing_questions =& $this->getExistingQuestions();
     if (count($existing_questions)) {
         $existing = " AND " . $ilDB->in('svy_question.question_id', $existing_questions, true, 'integer');
     }
     include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
     $trans = ilObjSurveyQuestionPool::_getQuestionTypeTranslations();
     $query_result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id" . " FROM svy_question, svy_qtype, object_reference" . " WHERE svy_question.original_id IS NULL" . $forbidden . $existing . " AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0" . " AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where);
     $rows = array();
     if ($query_result->numRows()) {
         while ($row = $ilDB->fetchAssoc($query_result)) {
             if (array_key_exists('spl_txt', $arrFilter) && strlen($arrFilter['spl_txt'])) {
                 if (!stristr($spls[$row["obj_fi"]], $arrFilter['spl_txt'])) {
                     continue;
                 }
             }
             $row['ttype'] = $trans[$row['type_tag']];
             if ($row["plugin"]) {
                 if ($this->isPluginActive($row["type_tag"])) {
                     array_push($rows, $row);
                 }
             } else {
                 array_push($rows, $row);
             }
         }
     }
     return $rows;
 }