1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4/**
5 * @author        Björn Heyser <bheyser@databay.de>
6 * @version        $Id$
7 *
8 * @package     Modules/Test(QuestionPool)
9 */
10class ilTestSkillLevelThresholdImportList implements Iterator
11{
12    protected $originalSkillTitles = array();
13    protected $originalSkillPaths = array();
14    protected $importedSkillLevelThresholds = array();
15
16    public function addOriginalSkillTitle($skillBaseId, $skillTrefId, $originalSkillTitle)
17    {
18        $this->originalSkillTitles["{$skillBaseId}:{$skillTrefId}"] = $originalSkillTitle;
19    }
20
21    public function addOriginalSkillPath($skillBaseId, $skillTrefId, $originalSkillPath)
22    {
23        $this->originalSkillPaths["{$skillBaseId}:{$skillTrefId}"] = $originalSkillPath;
24    }
25
26    public function addSkillLevelThreshold(ilTestSkillLevelThresholdImport $importedSkillLevelThreshold)
27    {
28        $this->importedSkillLevelThresholds[] = $importedSkillLevelThreshold;
29    }
30
31    public function getThresholdsByImportSkill($importSkillBaseId, $importSkillTrefId)
32    {
33        $thresholds = array();
34
35        foreach ($this as $skillLevelThreshold) {
36            if ($skillLevelThreshold->getImportSkillBaseId() != $importSkillBaseId) {
37                continue;
38            }
39
40            if ($skillLevelThreshold->getImportSkillTrefId() != $importSkillTrefId) {
41                continue;
42            }
43
44            $thresholds[] = $skillLevelThreshold;
45        }
46
47        return $thresholds;
48    }
49
50    /**
51     * @return ilTestSkillLevelThresholdImport
52     */
53    public function current()
54    {
55        return current($this->importedSkillLevelThresholds);
56    }
57
58    /**
59     * @return ilTestSkillLevelThresholdImport
60     */
61    public function next()
62    {
63        return next($this->importedSkillLevelThresholds);
64    }
65
66    /**
67     * @return integer|bool
68     */
69    public function key()
70    {
71        return key($this->importedSkillLevelThresholds);
72    }
73
74    /**
75     * @return bool
76     */
77    public function valid()
78    {
79        return key($this->importedSkillLevelThresholds) !== null;
80    }
81
82    /**
83     * @return ilTestSkillLevelThresholdImport|bool
84     */
85    public function rewind()
86    {
87        return reset($this->importedSkillLevelThresholds);
88    }
89}
90