ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAssQuestionTypeOrderer Class Reference
+ Collaboration diagram for ilAssQuestionTypeOrderer:

Public Member Functions

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

Data Fields

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

Static Public Attributes

static $fixQuestionTypeOrder
static $flippedQuestionTypeOrder = null

Detailed Description

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

Constructor & Destructor Documentation

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

Constructor.

Parameters
array$unOrderedTypes
string$orderMode
Exceptions
ilTestQuestionPoolException

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

{
self::$flippedQuestionTypeOrder = array_flip(self::$fixQuestionTypeOrder);
$this->types = $unOrderedTypes;
switch($orderMode)
{
case self::ORDER_MODE_FIX:
uasort($this->types, array($this, 'fixQuestionTypeOrderSortCallback'));
break;
case self::ORDER_MODE_ALPHA:
ksort($this->types);
break;
default:
throw new ilTestQuestionPoolException('invalid order mode given: '.$orderMode);
}
}

Member Function Documentation

ilAssQuestionTypeOrderer::fixQuestionTypeOrderSortCallback (   $a,
  $b 
)

custom sort callback for ordering the question types

public

Parameters
array$a
array$b
Returns
integer

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

{
$r = 0;
if( self::$flippedQuestionTypeOrder[ $a['type_tag'] ] > self::$flippedQuestionTypeOrder[ $b['type_tag'] ] )
{
$r = 1;
}
elseif( self::$flippedQuestionTypeOrder[ $a['type_tag'] ] < self::$flippedQuestionTypeOrder[ $b['type_tag'] ] )
{
$r = -1;
}
return $r;
}
ilAssQuestionTypeOrderer::getOrderedTypes ( )

getter for ordered question types

Returns
array $orderedQuestionTypes

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

{
return $this->types;
}

Field Documentation

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

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

ilAssQuestionTypeOrderer::$flippedQuestionTypeOrder = null
static

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

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().

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: