Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 61 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| SimplePageModule | |
0.00% |
0 / 61 |
|
0.00% |
0 / 4 |
210 | |
0.00% |
0 / 1 |
| defaultData | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getLayout | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| getRequestOptions | |
0.00% |
0 / 40 |
|
0.00% |
0 / 1 |
132 | |||
| getDefaultOptions | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| 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) 2015 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | namespace oat\taoProctoring\controller; |
| 24 | |
| 25 | use common_session_SessionManager as SessionManager; |
| 26 | use oat\tao\model\mvc\DefaultUrlService; |
| 27 | use oat\taoProctoring\helpers\DataTableHelper; |
| 28 | use DateTime; |
| 29 | |
| 30 | /** |
| 31 | * Base proctoring interface controller |
| 32 | * |
| 33 | * @author Open Assessment Technologies SA |
| 34 | * @package taoProctoring |
| 35 | * @license GPL-2.0 |
| 36 | * |
| 37 | */ |
| 38 | abstract class SimplePageModule extends \tao_actions_SinglePageModule |
| 39 | { |
| 40 | /** |
| 41 | * Retrieve the data from the url and make the base initialization |
| 42 | * |
| 43 | * @return void |
| 44 | */ |
| 45 | protected function defaultData() |
| 46 | { |
| 47 | parent::defaultData(); |
| 48 | $this->setData('userLabel', SessionManager::getSession()->getUserLabel()); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Gets the path to the layout |
| 53 | * @return array |
| 54 | */ |
| 55 | protected function getLayout() |
| 56 | { |
| 57 | $this->setData( |
| 58 | 'homeUrl', |
| 59 | $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID)->getUrl('ProctoringHome') |
| 60 | ); |
| 61 | $this->setData( |
| 62 | 'logout', |
| 63 | $this->getServiceManager()->get(DefaultUrlService::SERVICE_ID)->getUrl('ProctoringLogout') |
| 64 | ); |
| 65 | return ['layout.tpl', 'taoProctoring']; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Gets the data table request options |
| 70 | * |
| 71 | * @param array $defaults |
| 72 | * @return array |
| 73 | */ |
| 74 | protected function getRequestOptions(array $defaults = []) |
| 75 | { |
| 76 | |
| 77 | $defaults = array_merge($this->getDefaultOptions(), $defaults); |
| 78 | |
| 79 | $page = $this->hasRequestParameter('page') |
| 80 | ? $this->getRequestParameter('page') |
| 81 | : $defaults['page']; |
| 82 | $rows = $this->hasRequestParameter('rows') |
| 83 | ? $this->getRequestParameter('rows') |
| 84 | : $defaults['rows']; |
| 85 | $sortBy = $this->hasRequestParameter('sortby') |
| 86 | ? $this->getRequestParameter('sortby') |
| 87 | : $defaults['sortby']; |
| 88 | $sortOrder = $this->hasRequestParameter('sortorder') |
| 89 | ? $this->getRequestParameter('sortorder') |
| 90 | : $defaults['sortorder']; |
| 91 | $filter = $this->hasRequestParameter('filter') |
| 92 | ? $this->getRequestParameter('filter') |
| 93 | : $defaults['filter']; |
| 94 | $filterquery = $this->hasRequestParameter('filterquery') |
| 95 | ? $this->getRequestParameter('filterquery') |
| 96 | : $defaults['filter']; |
| 97 | $periodStart = $this->hasRequestParameter('periodStart') |
| 98 | ? $this->getRequestParameter('periodStart') |
| 99 | : $defaults['periodStart']; |
| 100 | $periodEnd = $this->hasRequestParameter('periodEnd') |
| 101 | ? $this->getRequestParameter('periodEnd') |
| 102 | : $defaults['periodEnd']; |
| 103 | $detailed = $this->hasRequestParameter('detailed') |
| 104 | ? $this->getRequestParameter('detailed') |
| 105 | : 'false'; |
| 106 | $detailed = filter_var($detailed, FILTER_VALIDATE_BOOLEAN); |
| 107 | |
| 108 | return array( |
| 109 | 'page' => $page, |
| 110 | 'rows' => $rows, |
| 111 | 'sortBy' => $sortBy, |
| 112 | 'sortOrder' => $sortOrder, |
| 113 | 'filter' => $filter ? $filter : $filterquery, |
| 114 | 'periodStart' => $periodStart, |
| 115 | 'detailed' => $detailed, |
| 116 | 'periodEnd' => $periodEnd |
| 117 | ); |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * @return array |
| 122 | */ |
| 123 | private function getDefaultOptions() |
| 124 | { |
| 125 | $today = new DateTime(); |
| 126 | return [ |
| 127 | 'page' => DataTableHelper::DEFAULT_PAGE, |
| 128 | 'rows' => DataTableHelper::DEFAULT_ROWS, |
| 129 | 'sortby' => 'id', |
| 130 | 'sortorder' => DataTableHelper::DEFAULT_SORT_ORDER, |
| 131 | 'filter' => null, |
| 132 | 'periodStart' => $today->format('Y-m-d'), |
| 133 | 'periodEnd' => $today->format('Y-m-d') |
| 134 | ]; |
| 135 | } |
| 136 | } |