ILIAS  release_8 Revision v8.24
ilECSCourseAttributes Class Reference

Storage of course attributes for assignment rules. More...

+ Collaboration diagram for ilECSCourseAttributes:

Public Member Functions

 __construct (int $a_server_id, int $a_mid)
 Constructor. More...
 
 getAttributes ()
 Get current attributes. More...
 
 getFirstAttribute ()
 Get first defined attribute. More...
 
 getFirstAttributeName ()
 Get first attribute name. More...
 
 getAttributeSequence ($a_last_attribute)
 Get attribute sequence. More...
 
 getUpperAttributes ($a_name)
 Get upper attributes in hierarchy. More...
 
 getNextAttributeName (string $a_name)
 Get next attribute name in sequence. More...
 
 getPreviousAttributeName (string $a_name)
 Get next attribute name in sequence. More...
 
 getAttributeValues ()
 Get active attribute values. More...
 
 delete ()
 Delete all mappings. More...
 

Static Public Member Functions

static getInstance (int $a_server_id, int $a_mid)
 Get instance. More...
 

Protected Member Functions

 read ()
 Read attributes. More...
 

Private Attributes

int $server_id
 
int $mid
 
array $attributes = array()
 
ilDBInterface $db
 

Static Private Attributes

static array $instances = null
 

Detailed Description

Storage of course attributes for assignment rules.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

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

Constructor & Destructor Documentation

◆ __construct()

ilECSCourseAttributes::__construct ( int  $a_server_id,
int  $a_mid 
)

Constructor.

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

40 {
41 global $DIC;
42
43 $this->db = $DIC->database();
44
45 $this->server_id = $a_server_id;
46 $this->mid = $a_mid;
47
48 $this->read();
49 }
global $DIC
Definition: feed.php:28

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilECSCourseAttributes::delete ( )

Delete all mappings.

Definition at line 184 of file class.ilECSCourseAttributes.php.

184 : void
185 {
186 foreach ($this->getAttributes() as $att) {
187 $att->delete();
188 }
189 $this->attributes = [];
190 }
getAttributes()
Get current attributes.

References getAttributes().

+ Here is the call graph for this function:

◆ getAttributes()

ilECSCourseAttributes::getAttributes ( )

Get current attributes.

Definition at line 63 of file class.ilECSCourseAttributes.php.

63 : array
64 {
65 return $this->attributes;
66 }

References $attributes.

Referenced by delete(), getAttributeSequence(), getAttributeValues(), getFirstAttribute(), getNextAttributeName(), getPreviousAttributeName(), and getUpperAttributes().

+ Here is the caller graph for this function:

◆ getAttributeSequence()

ilECSCourseAttributes::getAttributeSequence (   $a_last_attribute)

Get attribute sequence.

Definition at line 90 of file class.ilECSCourseAttributes.php.

90 : array
91 {
92 if (!$a_last_attribute) {
93 return [];
94 }
95 $sequence = [];
96 foreach ($this->getAttributes() as $att) {
97 $sequence[] = $att->getName();
98 if ($a_last_attribute === $att->getName()) {
99 break;
100 }
101 }
102 return $sequence;
103 }

References getAttributes().

+ Here is the call graph for this function:

◆ getAttributeValues()

ilECSCourseAttributes::getAttributeValues ( )

Get active attribute values.

Definition at line 172 of file class.ilECSCourseAttributes.php.

172 : array
173 {
174 $values = array();
175 foreach ($this->getAttributes() as $att) {
176 $values[] = $att->getName();
177 }
178 return $values;
179 }

References getAttributes().

+ Here is the call graph for this function:

◆ getFirstAttribute()

ilECSCourseAttributes::getFirstAttribute ( )

Get first defined attribute.

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

72 {
73 return $this->getAttributes()[0] ?? null;
74 }
Storage of course attributes for assignment rules.

References getAttributes().

Referenced by getFirstAttributeName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFirstAttributeName()

ilECSCourseAttributes::getFirstAttributeName ( )

Get first attribute name.

Definition at line 79 of file class.ilECSCourseAttributes.php.

79 : string
80 {
81 if ($this->getFirstAttribute() instanceof ilECSCourseAttribute) {
82 return $this->getFirstAttribute()->getName();
83 }
84 return '';
85 }
getFirstAttribute()
Get first defined attribute.

References getFirstAttribute().

Referenced by getNextAttributeName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstance()

static ilECSCourseAttributes::getInstance ( int  $a_server_id,
int  $a_mid 
)
static

Get instance.

Definition at line 54 of file class.ilECSCourseAttributes.php.

55 {
56 $id = $a_server_id . '_' . $a_mid;
57 return self::$instances[$id] ?? (self::$instances[$id] = new ilECSCourseAttributes($a_server_id, $a_mid));
58 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Storage of course attributes for assignment rules.

References $id.

Referenced by ilECSMappingSettingsGUI\cAddAttribute(), ilECSMappingSettingsGUI\cDeleteAttribute(), ilECSMappingSettingsGUI\cInitMappingForm(), and ilECSMappingSettingsGUI\initFormCSettings().

+ Here is the caller graph for this function:

◆ getNextAttributeName()

ilECSCourseAttributes::getNextAttributeName ( string  $a_name)

Get next attribute name in sequence.

Definition at line 129 of file class.ilECSCourseAttributes.php.

129 : string
130 {
131 if (!$a_name) {
132 return $this->getFirstAttributeName();
133 }
134 $found = false;
135 foreach ($this->getAttributes() as $att) {
136 if ($a_name === $att->getName()) {
137 $found = true;
138 continue;
139 }
140 if ($found) {
141 return $att->getName();
142 }
143 }
144 return '';
145 }
getFirstAttributeName()
Get first attribute name.

References getAttributes(), and getFirstAttributeName().

+ Here is the call graph for this function:

◆ getPreviousAttributeName()

ilECSCourseAttributes::getPreviousAttributeName ( string  $a_name)

Get next attribute name in sequence.

Definition at line 150 of file class.ilECSCourseAttributes.php.

150 : string
151 {
152 if (!$a_name) {
153 return '';
154 }
155 $found = false;
156 $reverse_attributes = array_reverse($this->getAttributes());
157 foreach ($reverse_attributes as $att) {
158 if ($a_name === $att->getName()) {
159 $found = true;
160 continue;
161 }
162 if ($found) {
163 return $att->getName();
164 }
165 }
166 return '';
167 }

References getAttributes().

+ Here is the call graph for this function:

◆ getUpperAttributes()

ilECSCourseAttributes::getUpperAttributes (   $a_name)

Get upper attributes in hierarchy.

Definition at line 108 of file class.ilECSCourseAttributes.php.

108 : array
109 {
110 $reverse_attributes = array_reverse($this->getAttributes());
111
112 $found = false;
113 $upper = array();
114 foreach ($reverse_attributes as $att) {
115 if ($att->getName() === $a_name) {
116 $found = true;
117 continue;
118 }
119 if ($found) {
120 $upper[] = $att->getName();
121 }
122 }
123 return array_reverse($upper);
124 }

References getAttributes().

+ Here is the call graph for this function:

◆ read()

ilECSCourseAttributes::read ( )
protected

Read attributes.

Definition at line 196 of file class.ilECSCourseAttributes.php.

196 : void
197 {
198 $this->attributes = [];
199
200 $query = 'SELECT * FROM ecs_crs_mapping_atts ' .
201 'WHERE sid = ' . $this->db->quote($this->server_id, 'integer') . ' ' .
202 'AND mid = ' . $this->db->quote($this->mid, 'integer') . ' ' .
203 'ORDER BY id';
204 $res = $this->db->query($query);
205 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
206 $this->attributes[] = new ilECSCourseAttribute((int) $row->id);
207 }
208 }
$res
Definition: ltiservices.php:69
$query

References $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $attributes

array ilECSCourseAttributes::$attributes = array()
private

Definition at line 32 of file class.ilECSCourseAttributes.php.

Referenced by getAttributes().

◆ $db

ilDBInterface ilECSCourseAttributes::$db
private

Definition at line 34 of file class.ilECSCourseAttributes.php.

◆ $instances

array ilECSCourseAttributes::$instances = null
staticprivate

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

◆ $mid

int ilECSCourseAttributes::$mid
private

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

◆ $server_id

int ilECSCourseAttributes::$server_id
private

Definition at line 29 of file class.ilECSCourseAttributes.php.


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