ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilTestShuffler Class Reference
+ Collaboration diagram for ilTestShuffler:

Public Member Functions

 __construct (protected Refinery $refinery)
 
 getAnswerShuffleFor (int $question_id, int $active_id, int $pass_id)
 

Data Fields

const FIXED_SHUFFLER_SEED_MIN_LENGTH = 8
 

Protected Member Functions

 buildFixedShufflerSeed (int $question_id, int $pass_id, int $active_id)
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilTestShuffler::__construct ( protected Refinery  $refinery)

Definition at line 33 of file class.ilTestShuffler.php.

35  {
36  }

Member Function Documentation

◆ buildFixedShufflerSeed()

ilTestShuffler::buildFixedShufflerSeed ( int  $question_id,
int  $pass_id,
int  $active_id 
)
protected

Definition at line 47 of file class.ilTestShuffler.php.

Referenced by getAnswerShuffleFor().

47  : int
48  {
49  $seed = ($question_id + $pass_id) * $active_id;
50  if (is_float($seed) && is_float($seed = $active_id + $pass_id)) {
51  $seed = $active_id;
52  }
53 
54  $div = ceil((10 ** (self::FIXED_SHUFFLER_SEED_MIN_LENGTH - 1)) / $seed);
55  if ($div > 1) {
56  $seed = $seed * ($div + $seed % 10);
57  }
58  return (int) $seed;
59  }
+ Here is the caller graph for this function:

◆ getAnswerShuffleFor()

ilTestShuffler::getAnswerShuffleFor ( int  $question_id,
int  $active_id,
int  $pass_id 
)

Definition at line 38 of file class.ilTestShuffler.php.

References buildFixedShufflerSeed(), and ILIAS\Repository\refinery().

43  $fixedSeed = $this->buildFixedShufflerSeed($question_id, $pass_id, $active_id);
44  return $this->refinery->random()->shuffleArray(new GivenSeed($fixedSeed));
45  }
buildFixedShufflerSeed(int $question_id, int $pass_id, int $active_id)
+ Here is the call graph for this function:

Field Documentation

◆ FIXED_SHUFFLER_SEED_MIN_LENGTH

const ilTestShuffler::FIXED_SHUFFLER_SEED_MIN_LENGTH = 8

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


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