ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAssQuestionTypeOrderer Class Reference
+ Collaboration diagram for ilAssQuestionTypeOrderer:

Public Member Functions

 __construct ($unOrderedTypes, $orderMode=self::ORDER_MODE_ALPHA)
 Constructor. More...
 
 getOrderedTypes ($withDeprecatedTypes=true)
 getter for ordered question types More...
 
 fixQuestionTypeOrderSortCallback ($a, $b)
 custom sort callback for ordering the question types More...
 

Data Fields

const ORDER_MODE_FIX = 'fix'
 order mode with fixed priority for ordering More...
 
const ORDER_MODE_ALPHA = 'alpha'
 order mode that orders by alphanumerical priority More...
 

Static Public Attributes

static $fixQuestionTypeOrder
 
static $flippedQuestionTypeOrder = null
 

Protected Attributes

 $deprecatedTypes
 

Private Attributes

array $types
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionTypeOrderer::__construct (   $unOrderedTypes,
  $orderMode = self::ORDER_MODE_ALPHA 
)

Constructor.

Parameters
array$unOrderedTypes
string$orderMode
Exceptions
ilTestQuestionPoolException

Definition at line 89 of file class.ilAssQuestionTypeOrderer.php.

90 {
91 self::$flippedQuestionTypeOrder = array_flip(self::$fixQuestionTypeOrder);
92 #vd($unOrderedTypes);
93 $this->types = $unOrderedTypes;
94
95 switch ($orderMode) {
97
98 uasort($this->types, [$this, 'fixQuestionTypeOrderSortCallback']);
99 break;
100
102
103 ksort($this->types);
104 break;
105
106 default:
107
108 throw new ilTestQuestionPoolException('invalid order mode given: ' . $orderMode);
109 }
110
111 #vd($this->types);
112 }
const ORDER_MODE_FIX
order mode with fixed priority for ordering
const ORDER_MODE_ALPHA
order mode that orders by alphanumerical priority

References ORDER_MODE_ALPHA, and ORDER_MODE_FIX.

Member Function Documentation

◆ fixQuestionTypeOrderSortCallback()

ilAssQuestionTypeOrderer::fixQuestionTypeOrderSortCallback (   $a,
  $b 
)

custom sort callback for ordering the question types

@access public

Parameters
array$a
array$b
Returns
integer

Definition at line 146 of file class.ilAssQuestionTypeOrderer.php.

146 : int
147 {
148 if (!isset(self::$flippedQuestionTypeOrder[ $a['type_tag'] ])) {
149 return 1;
150 } elseif (!isset(self::$flippedQuestionTypeOrder[ $b['type_tag'] ])) {
151 return -1;
152 } elseif (self::$flippedQuestionTypeOrder[ $a['type_tag'] ] > self::$flippedQuestionTypeOrder[ $b['type_tag'] ]) {
153 return 1;
154 } elseif (self::$flippedQuestionTypeOrder[ $a['type_tag'] ] < self::$flippedQuestionTypeOrder[ $b['type_tag'] ]) {
155 return -1;
156 }
157
158 return 0;
159 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, and Vendor\Package\$b.

◆ getOrderedTypes()

ilAssQuestionTypeOrderer::getOrderedTypes (   $withDeprecatedTypes = true)

getter for ordered question types

Returns
array $orderedQuestionTypes

Definition at line 119 of file class.ilAssQuestionTypeOrderer.php.

119 : array
120 {
121 if ($withDeprecatedTypes) {
122 return $this->types;
123 }
124
125 $types = [];
126
127 foreach ($this->types as $translation => $typeData) {
128 if (in_array($typeData['type_tag'], $this->deprecatedTypes)) {
129 continue;
130 }
131
132 $types[$translation] = $typeData;
133 }
134
135 return $types;
136 }

References $types.

Field Documentation

◆ $deprecatedTypes

ilAssQuestionTypeOrderer::$deprecatedTypes
protected
Initial value:
= [
]

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

◆ $fixQuestionTypeOrder

ilAssQuestionTypeOrderer::$fixQuestionTypeOrder
static
Initial value:
= [
'assSingleChoice',
'assMultipleChoice',
'assKprimChoice',
'assErrorText',
'assImagemapQuestion',
'assClozeTest',
'assNumeric',
'assFormulaQuestion',
'assTextSubset',
'assOrderingQuestion',
'assOrderingHorizontal',
'assMatchingQuestion',
'assTextQuestion',
'assFileUpload',
'assLongMenu'
]

Definition at line 46 of file class.ilAssQuestionTypeOrderer.php.

◆ $flippedQuestionTypeOrder

ilAssQuestionTypeOrderer::$flippedQuestionTypeOrder = null
static

Definition at line 80 of file class.ilAssQuestionTypeOrderer.php.

◆ $types

array ilAssQuestionTypeOrderer::$types
private

Definition at line 67 of file class.ilAssQuestionTypeOrderer.php.

Referenced by getOrderedTypes().

◆ ORDER_MODE_ALPHA

const ilAssQuestionTypeOrderer::ORDER_MODE_ALPHA = 'alpha'

order mode that orders by alphanumerical priority

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

Referenced by __construct(), ilObjQuestionPool\_getQuestionTypes(), and ilAssQuestionTypeOrdererTest\setUp().

◆ ORDER_MODE_FIX

const ilAssQuestionTypeOrderer::ORDER_MODE_FIX = 'fix'

order mode with fixed priority for ordering

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

Referenced by __construct(), and ilObjQuestionPool\_getQuestionTypes().


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