Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ToolsStateStorage
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 getPersistence
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
 storeStates
n/a
0 / 0
n/a
0 / 0
0
 getStates
n/a
0 / 0
n/a
0 / 0
0
 deleteStates
n/a
0 / 0
n/a
0 / 0
0
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; under version 2
7 * of the License (non-upgradable).
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 *
18 * Copyright (c) 2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
19 *
20 */
21
22namespace oat\taoQtiTest\models\runner\toolsStates;
23
24use oat\oatbox\service\ConfigurableService;
25
26/**
27 * Service for persisting states of runners plugins
28 *
29 * Class ToolsStateStorage
30 * @package oat\taoQtiTest\models\runner\toolsStates
31 */
32abstract class ToolsStateStorage extends ConfigurableService
33{
34    public const SERVICE_ID = 'taoQtiTest/ToolsStateStorage';
35
36    public const OPTION_PERSISTENCE = 'persistence';
37
38    /**
39     * @return \common_persistence_Persistence
40     */
41    protected function getPersistence()
42    {
43        $persistenceId = $this->getOption(self::OPTION_PERSISTENCE) ?: 'default';
44        return $this
45            ->getServiceLocator()
46            ->get(\common_persistence_Manager::SERVICE_ID)
47            ->getPersistenceById($persistenceId);
48    }
49
50    /**
51     * Put the states associated with delivery into the storage
52     *
53     * @param string $deliveryExecutionId
54     * @param array $states
55     */
56    abstract public function storeStates($deliveryExecutionId, $states);
57
58    /**
59     * @param string $deliveryExecutionId
60     * @return array
61     */
62    abstract public function getStates($deliveryExecutionId);
63
64    /**
65     * @param string $deliveryExecutionId
66     * @return bool whether deleted successfully
67     */
68    abstract public function deleteStates($deliveryExecutionId);
69}