ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 26 of file class.ilECSCourseAttributes.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

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

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

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilECSCourseAttributes::delete ( )

Delete all mappings.

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

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

References getAttributes().

+ Here is the call graph for this function:

◆ getAttributes()

ilECSCourseAttributes::getAttributes ( )

Get current attributes.

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

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

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 91 of file class.ilECSCourseAttributes.php.

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

References getAttributes().

+ Here is the call graph for this function:

◆ getAttributeValues()

ilECSCourseAttributes::getAttributeValues ( )

Get active attribute values.

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

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

References getAttributes().

+ Here is the call graph for this function:

◆ getFirstAttribute()

ilECSCourseAttributes::getFirstAttribute ( )

Get first defined attribute.

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

73 {
74 return $this->getAttributes()[0] ?? null;
75 }
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 80 of file class.ilECSCourseAttributes.php.

80 : string
81 {
82 if ($this->getFirstAttribute() instanceof ilECSCourseAttribute) {
83 return $this->getFirstAttribute()->getName();
84 }
85 return '';
86 }
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 55 of file class.ilECSCourseAttributes.php.

56 {
57 $id = $a_server_id . '_' . $a_mid;
58 return self::$instances[$id] ?? (self::$instances[$id] = new ilECSCourseAttributes($a_server_id, $a_mid));
59 }
$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 130 of file class.ilECSCourseAttributes.php.

130 : string
131 {
132 if (!$a_name) {
133 return $this->getFirstAttributeName();
134 }
135 $found = false;
136 foreach ($this->getAttributes() as $att) {
137 if ($a_name === $att->getName()) {
138 $found = true;
139 continue;
140 }
141 if ($found) {
142 return $att->getName();
143 }
144 }
145 return '';
146 }
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 151 of file class.ilECSCourseAttributes.php.

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

References getAttributes().

+ Here is the call graph for this function:

◆ getUpperAttributes()

ilECSCourseAttributes::getUpperAttributes (   $a_name)

Get upper attributes in hierarchy.

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

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

References getAttributes().

+ Here is the call graph for this function:

◆ read()

ilECSCourseAttributes::read ( )
protected

Read attributes.

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

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

References $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 33 of file class.ilECSCourseAttributes.php.

Referenced by getAttributes().

◆ $db

ilDBInterface ilECSCourseAttributes::$db
private

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

◆ $instances

array ilECSCourseAttributes::$instances = null
staticprivate

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

◆ $mid

int ilECSCourseAttributes::$mid
private

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

◆ $server_id

int ilECSCourseAttributes::$server_id
private

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


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