ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAssQuestionTypeOrderer Class Reference
+ Collaboration diagram for ilAssQuestionTypeOrderer:

Public Member Functions

 __construct ($unOrderedTypes, $orderMode=self::ORDER_MODE_ALPHA)
 Constructor. More...
 
 getOrderedTypes ()
 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
 

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 70 of file class.ilAssQuestionTypeOrderer.php.

References array.

71  {
72  self::$flippedQuestionTypeOrder = array_flip(self::$fixQuestionTypeOrder);
73  #vd($unOrderedTypes);
74  $this->types = $unOrderedTypes;
75 
76  switch ($orderMode) {
77  case self::ORDER_MODE_FIX:
78 
79  uasort($this->types, array($this, 'fixQuestionTypeOrderSortCallback'));
80  break;
81 
82  case self::ORDER_MODE_ALPHA:
83 
84  ksort($this->types);
85  break;
86 
87  default:
88 
89  throw new ilTestQuestionPoolException('invalid order mode given: ' . $orderMode);
90  }
91 
92  #vd($this->types);
93  }
Create styles array
The data for the language used.

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 113 of file class.ilAssQuestionTypeOrderer.php.

114  {
115  if (self::$flippedQuestionTypeOrder[ $a['type_tag'] ] > self::$flippedQuestionTypeOrder[ $b['type_tag'] ]) {
116  return 1;
117  } elseif (!isset(self::$flippedQuestionTypeOrder[ $a['type_tag'] ])) {
118  return 1;
119  } elseif (self::$flippedQuestionTypeOrder[ $a['type_tag'] ] < self::$flippedQuestionTypeOrder[ $b['type_tag'] ]) {
120  return -1;
121  } elseif (!isset(self::$flippedQuestionTypeOrder[ $b['type_tag'] ])) {
122  return -1;
123  }
124 
125  return 0;
126  }

◆ getOrderedTypes()

ilAssQuestionTypeOrderer::getOrderedTypes ( )

getter for ordered question types

Returns
array $orderedQuestionTypes

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

101  {
102  return $this->types;
103  }

Field Documentation

◆ $fixQuestionTypeOrder

ilAssQuestionTypeOrderer::$fixQuestionTypeOrder
static
Initial value:
'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 61 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: