1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetBuilder.php';
5
6/**
7 * @author		Björn Heyser <bheyser@databay.de>
8 * @version		$Id$
9 *
10 * @package     Modules/Test
11 */
12class ilTestRandomQuestionSetBuilderWithAmountPerTest extends ilTestRandomQuestionSetBuilder
13{
14    /**
15     * @return bool
16     */
17    public function checkBuildable()
18    {
19        $questionStage = $this->getSrcPoolDefListRelatedQuestUniqueCollection($this->sourcePoolDefinitionList);
20
21        if ($questionStage->isSmallerThan($this->questionSetConfig->getQuestionAmountPerTest())) {
22            return false;
23        }
24
25        return true;
26    }
27
28    /**
29     * @param ilTestSession $testSession
30     */
31    public function performBuild(ilTestSession $testSession)
32    {
33        $questionStage = $this->getSrcPoolDefListRelatedQuestUniqueCollection($this->sourcePoolDefinitionList);
34
35        $questionSet = $this->fetchQuestionsFromStageRandomly(
36            $questionStage,
37            $this->questionSetConfig->getQuestionAmountPerTest()
38        );
39
40        $this->handleQuestionOrdering($questionSet);
41
42        $this->storeQuestionSet($testSession, $questionSet);
43    }
44}
45