ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
 

Detailed Description

Definition at line 14 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 77 of file class.ilAssQuestionTypeOrderer.php.

78  {
79  self::$flippedQuestionTypeOrder = array_flip(self::$fixQuestionTypeOrder);
80  #vd($unOrderedTypes);
81  $this->types = $unOrderedTypes;
82 
83  switch ($orderMode) {
84  case self::ORDER_MODE_FIX:
85 
86  uasort($this->types, array($this, 'fixQuestionTypeOrderSortCallback'));
87  break;
88 
89  case self::ORDER_MODE_ALPHA:
90 
91  ksort($this->types);
92  break;
93 
94  default:
95 
96  throw new ilTestQuestionPoolException('invalid order mode given: ' . $orderMode);
97  }
98 
99  #vd($this->types);
100  }

Member Function Documentation

◆ fixQuestionTypeOrderSortCallback()

ilAssQuestionTypeOrderer::fixQuestionTypeOrderSortCallback (   $a,
  $b 
)

custom sort callback for ordering the question types

public

Parameters
array$a
array$b
Returns
integer

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

135  {
136  if (self::$flippedQuestionTypeOrder[ $a['type_tag'] ] > self::$flippedQuestionTypeOrder[ $b['type_tag'] ]) {
137  return 1;
138  } elseif (!isset(self::$flippedQuestionTypeOrder[ $a['type_tag'] ])) {
139  return 1;
140  } elseif (self::$flippedQuestionTypeOrder[ $a['type_tag'] ] < self::$flippedQuestionTypeOrder[ $b['type_tag'] ]) {
141  return -1;
142  } elseif (!isset(self::$flippedQuestionTypeOrder[ $b['type_tag'] ])) {
143  return -1;
144  }
145 
146  return 0;
147  }

◆ getOrderedTypes()

ilAssQuestionTypeOrderer::getOrderedTypes (   $withDeprecatedTypes = true)

getter for ordered question types

Returns
array $orderedQuestionTypes

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

108  {
109  if ($withDeprecatedTypes) {
110  return $this->types;
111  }
112 
113  $types = array();
114 
115  foreach ($this->types as $translation => $typeData) {
116  if (in_array($typeData['type_tag'], $this->deprecatedTypes)) {
117  continue;
118  }
119 
120  $types[$translation] = $typeData;
121  }
122 
123  return $types;
124  }

Field Documentation

◆ $deprecatedTypes

ilAssQuestionTypeOrderer::$deprecatedTypes
protected
Initial value:
= array(
'assFlashQuestion', 'assJavaApplet'
)

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

◆ $fixQuestionTypeOrder

ilAssQuestionTypeOrderer::$fixQuestionTypeOrder
static
Initial value:
= array(
'assSingleChoice',
'assMultipleChoice',
'assKprimChoice',
'assErrorText',
'assImagemapQuestion',
'assClozeTest',
'assNumeric',
'assFormulaQuestion',
'assTextSubset',
'assOrderingQuestion',
'assOrderingHorizontal',
'assMatchingQuestion',
'assTextQuestion',
'assFileUpload',
'assLongMenu',
'assFlashQuestion',
'assJavaApplet',
)

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

◆ $flippedQuestionTypeOrder

ilAssQuestionTypeOrderer::$flippedQuestionTypeOrder = null
static

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

◆ ORDER_MODE_ALPHA

const ilAssQuestionTypeOrderer::ORDER_MODE_ALPHA = 'alpha'

order mode that orders by alphanumerical priority

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

Referenced by ilObjQuestionPool\_getQuestionTypes().

◆ ORDER_MODE_FIX

const ilAssQuestionTypeOrderer::ORDER_MODE_FIX = 'fix'

order mode with fixed priority for ordering

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

Referenced by ilObjQuestionPool\_getQuestionTypes().


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