ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 67 of file class.ilAssQuestionTypeOrderer.php.

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

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

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

◆ getOrderedTypes()

ilAssQuestionTypeOrderer::getOrderedTypes ( )

getter for ordered question types

Returns
array $orderedQuestionTypes

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

99  {
100  return $this->types;
101  }

Field Documentation

◆ $fixQuestionTypeOrder

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

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

◆ $flippedQuestionTypeOrder

ilAssQuestionTypeOrderer::$flippedQuestionTypeOrder = null
static

Definition at line 58 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: