ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestRandomQuestionSetBuilderWithAmountPerTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetBuilder.php';
5 
13 {
14  public function checkBuildable()
15  {
16  $questionStage = $this->getQuestionStageForSourcePoolDefinitionList($this->sourcePoolDefinitionList);
17 
18  return $this->isQuestionSetFetchable($questionStage);
19  }
20 
21  public function performBuild(ilTestSession $testSession)
22  {
23  $questionStage = $this->getQuestionStageForSourcePoolDefinitionList($this->sourcePoolDefinitionList);
24 
25  $questionSet = $this->fetchQuestionsFromStageRandomly(
26  $questionStage, $this->questionSetConfig->getQuestionAmountPerTest()
27  );
28 
29  $questionSet = $this->handleQuestionOrdering($questionSet);
30 
31  $this->storeQuestionSet($testSession, $questionSet);
32  }
33 
34  private function isQuestionSetFetchable($questionStage)
35  {
36  $requiredAmount = $this->questionSetConfig->getQuestionAmountPerTest();
37  $possibleAmount = count($questionStage);
38 
39  return ( $possibleAmount >= $requiredAmount );
40  }
41 }