1<?php 2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetQuestionCollection.php'; 5 6/** 7 * @author Björn Heyser <bheyser@databay.de> 8 * @version $Id$ 9 * 10 * @package Modules/Test 11 */ 12class ilTestRandomQuestionCollectionSubsetApplication extends ilTestRandomQuestionSetQuestionCollection 13{ 14 /** 15 * @var integer 16 */ 17 protected $applicantId; 18 19 /** 20 * @var integer 21 */ 22 protected $requiredAmount; 23 24 /** 25 * @return int 26 */ 27 public function getApplicantId() 28 { 29 return $this->applicantId; 30 } 31 32 /** 33 * @param int $applicantId 34 */ 35 public function setApplicantId($applicantId) 36 { 37 $this->applicantId = $applicantId; 38 } 39 40 /** 41 * @return int 42 */ 43 public function getRequiredAmount() 44 { 45 return $this->requiredAmount; 46 } 47 48 /** 49 * @param int $requiredAmount 50 */ 51 public function setRequiredAmount($requiredAmount) 52 { 53 $this->requiredAmount = $requiredAmount; 54 } 55 56 /* 57 * returns the fact if required amount is still positive 58 */ 59 public function hasRequiredAmountLeft() 60 { 61 return $this->getRequiredAmount() > 0; 62 } 63 64 /** 65 * decrements the amount required by applicant 66 */ 67 public function decrementRequiredAmount() 68 { 69 $this->setRequiredAmount($this->getRequiredAmount() - 1); 70 } 71 72 /** 73 * @return bool 74 */ 75 public function hasQuestion($questionId) 76 { 77 return $this->getQuestion($questionId) !== null; 78 } 79 80 /** 81 * @return ilTestRandomQuestionSetQuestion 82 */ 83 public function getQuestion($questionId) 84 { 85 foreach ($this as $question) { 86 if ($question->getQuestionId() != $questionId) { 87 continue; 88 } 89 90 return $question; 91 } 92 93 return null; 94 } 95} 96