ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
SurveySearch Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for SurveySearch:

Public Member Functions

 __construct (string $search_text="", int $concatenation=self::CONCAT_AND, string $search_field="all", string $search_type="all")
 
 search ()
 

Data Fields

const CONCAT_AND = 0
 
const CONCAT_OR = 1
 
array $search_terms
 
int $concatenation
 
string $search_field
 
string $search_type
 
array $search_results
 
ilDBInterface $ilDB
 

Protected Attributes

ilRbacSystem $rbacsystem
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class for search actions in ILIAS survey tool The SurveySearch class defines and encapsulates basic methods and attributes to search the ILIAS survey tool for questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m

Definition at line 25 of file class.SurveySearch.php.

Constructor & Destructor Documentation

◆ __construct()

SurveySearch::__construct ( string  $search_text = "",
int  $concatenation = self::CONCAT_AND,
string  $search_field = "all",
string  $search_type = "all" 
)

Definition at line 50 of file class.SurveySearch.php.

References $concatenation, $DIC, $ilDB, $search_field, and $search_type.

55  {
56  global $DIC;
57 
58  $this->rbacsystem = $DIC->rbac()->system();
59  $ilDB = $DIC->database();
60 
61  $this->ilDB = $ilDB;
62 
63  $this->search_terms = explode(" +", $search_text);
64  $this->concatenation = $concatenation;
65  $this->search_field = $search_field;
66  $this->search_type = $search_type;
67  $this->search_results = array();
68  }
global $DIC
Definition: shib_login.php:22
ilDBInterface $ilDB

Member Function Documentation

◆ search()

SurveySearch::search ( )

Definition at line 71 of file class.SurveySearch.php.

References $ilDB, $params, $rbacsystem, ilRbacSystem\checkAccess(), ilDBInterface\fetchAssoc(), ilDBInterface\like(), ilDBInterface\query(), and ilDBInterface\quote().

71  : void
72  {
74 
75  $where = "";
76  $fields = array();
77  if (strcmp($this->search_type, "all") !== 0) {
78  $where = "svy_qtype.type_tag = " . $ilDB->quote($this->search_type, 'text');
79  }
80  foreach ($this->search_terms as $term) {
81  $fields[(string) $term] = array();
82  switch ($this->search_field) {
83  case "all":
84  $fields[(string) $term][] = $ilDB->like("svy_question.title", 'text', "%" . $term . "%");
85  $fields[(string) $term][] = $ilDB->like("svy_question.description", 'text', "%" . $term . "%");
86  $fields[(string) $term][] = $ilDB->like("svy_question.author", 'text', "%" . $term . "%");
87  $fields[(string) $term][] = $ilDB->like("svy_question.questiontext", 'text', "%" . $term . "%");
88  break;
89  default:
90  $fields[(string) $term][] = $ilDB->like("svy_question." . $this->search_field, 'text', "%" . $term . "%");
91  break;
92  }
93  }
94  $cumulated_fields = array();
95  foreach ($fields as $params) {
96  $cumulated_fields[] = "(" . implode(" OR ", $params) . ")";
97  }
98  $str_where = "";
99  if ($this->concatenation === self::CONCAT_AND) {
100  $str_where = "(" . implode(" AND ", $cumulated_fields) . ")";
101  } else {
102  $str_where = "(" . implode(" OR ", $cumulated_fields) . ")";
103  }
104  if ($str_where) {
105  $str_where = " AND $str_where";
106  }
107  if ($where) {
108  $str_where .= " AND (" . $where . ")";
109  }
110  $result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag, object_reference.ref_id FROM " .
111  "svy_question, svy_qtype, object_reference WHERE svy_question.questiontype_fi = svy_qtype.questiontype_id " .
112  "AND svy_question.original_id IS NULL AND svy_question.obj_fi = object_reference.obj_id AND " .
113  "svy_question.obj_fi > 0$str_where");
114  $result_array = array();
116  if ($result->numRows() > 0) {
117  while ($row = $ilDB->fetchAssoc($result)) {
118  if (((int) $row["complete"]) === 1 && $rbacsystem->checkAccess('write', $row["ref_id"])) {
119  $result_array[] = $row;
120  }
121  }
122  }
123  $this->search_results = $result_array;
124  }
fetchAssoc(ilDBStatement $statement)
like(string $column, string $type, string $value="?", bool $case_insensitive=true)
Generate a like subquery.
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
quote($value, string $type)
ilRbacSystem $rbacsystem
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
query(string $query)
Run a (read-only) Query on the database.
ilDBInterface $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $concatenation

int SurveySearch::$concatenation

Definition at line 36 of file class.SurveySearch.php.

Referenced by __construct().

◆ $ilDB

ilDBInterface SurveySearch::$ilDB

Definition at line 47 of file class.SurveySearch.php.

Referenced by __construct(), and search().

◆ $rbacsystem

ilRbacSystem SurveySearch::$rbacsystem
protected

Definition at line 30 of file class.SurveySearch.php.

Referenced by search().

◆ $search_field

string SurveySearch::$search_field

Definition at line 39 of file class.SurveySearch.php.

Referenced by __construct().

◆ $search_results

array SurveySearch::$search_results

Definition at line 45 of file class.SurveySearch.php.

◆ $search_terms

array SurveySearch::$search_terms

Definition at line 33 of file class.SurveySearch.php.

◆ $search_type

string SurveySearch::$search_type

Definition at line 42 of file class.SurveySearch.php.

Referenced by __construct().

◆ CONCAT_AND

const SurveySearch::CONCAT_AND = 0

Definition at line 27 of file class.SurveySearch.php.

◆ CONCAT_OR

const SurveySearch::CONCAT_OR = 1

Definition at line 28 of file class.SurveySearch.php.


The documentation for this class was generated from the following file: