forked from ILIAS-eLearning/ILIAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.ilCertificateGUIFactory.php
181 lines (159 loc) · 5.92 KB
/
class.ilCertificateGUIFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
/**
* @author Niels Theen <[email protected]>
*/
class ilCertificateGUIFactory
{
/**
* @var
*/
private $dic;
/**
* @param \ILIAS\DI\Container|null $dic
*/
public function __construct(\ILIAS\DI\Container $dic = null)
{
if (null === $dic) {
global $DIC;
$dic = $DIC;
}
$this->dic = $dic;
}
/**
* @param ilObject $object
* @return ilCertificateGUI
* @throws ilException
*/
public function create(\ilObject $object) : ilCertificateGUI
{
global $DIC;
$type = $object->getType();
$objectId = $object->getId();
$logger = $DIC->logger()->cert();
$templateRepository = new ilCertificateTemplateRepository($this->dic->database(), $logger);
$deleteAction = new ilCertificateTemplateDeleteAction($templateRepository);
$pathFactory = new ilCertificatePathFactory();
$certificatePath = $pathFactory->create($object);
switch ($type) {
case 'tst':
$placeholderDescriptionObject = new ilTestPlaceholderDescription();
$placeholderValuesObject = new ilTestPlaceholderValues();
$formFactory = new ilCertificateSettingsTestFormRepository(
$objectId,
$certificatePath,
false,
$object,
$DIC->language(),
$DIC->ctrl(),
$DIC->access(),
$DIC->toolbar(),
$placeholderDescriptionObject
);
$deleteAction = new ilCertificateTestTemplateDeleteAction(
$deleteAction,
new ilCertificateObjectHelper()
);
break;
case 'crs':
$hasAdditionalElements = true;
$placeholderDescriptionObject = new ilCoursePlaceholderDescription($objectId);
$placeholderValuesObject = new ilCoursePlaceholderValues();
$formFactory = new ilCertificateSettingsCourseFormRepository(
$object,
$certificatePath,
false,
$DIC->language(),
$DIC->ctrl(),
$DIC->access(),
$DIC->toolbar(),
$placeholderDescriptionObject
);
break;
case 'exc':
$placeholderDescriptionObject = new ilExercisePlaceholderDescription();
$placeholderValuesObject = new ilExercisePlaceholderValues();
$formFactory = new ilCertificateSettingsExerciseRepository(
$object,
$certificatePath,
false,
$DIC->language(),
$DIC->ctrl(),
$DIC->access(),
$DIC->toolbar(),
$placeholderDescriptionObject
);
break;
case 'sahs':
$placeholderDescriptionObject = new ilScormPlaceholderDescription($object);
$placeholderValuesObject = new ilScormPlaceholderValues();
$formFactory = new ilCertificateSettingsScormFormRepository(
$object,
$certificatePath,
true,
$DIC->language(),
$DIC->ctrl(),
$DIC->access(),
$DIC->toolbar(),
$placeholderDescriptionObject
);
break;
case 'lti':
$placeholderDescriptionObject = new ilLTIConsumerPlaceholderDescription();
$placeholderValuesObject = new ilLTIConsumerPlaceholderValues();
$formFactory = new ilCertificateSettingsLTIConsumerFormRepository(
$object,
$certificatePath,
true,
$DIC->language(),
$DIC->ctrl(),
$DIC->access(),
$DIC->toolbar(),
$placeholderDescriptionObject
);
break;
case 'cmix':
$placeholderDescriptionObject = new ilCmiXapiPlaceholderDescription();
$placeholderValuesObject = new ilCmiXapiPlaceholderValues();
$formFactory = new ilCertificateSettingsCmiXapiFormRepository(
$object,
$certificatePath,
true,
$DIC->language(),
$DIC->ctrl(),
$DIC->access(),
$DIC->toolbar(),
$placeholderDescriptionObject
);
break;
case 'prg':
$placeholderDescriptionObject =
new ilStudyProgrammePlaceholderDescription();
$placeholderValuesObject =
new ilStudyProgrammePlaceholderValues();
$formFactory = new ilCertificateSettingsStudyProgrammeFormRepository(
$object,
$certificatePath,
true,
$DIC->language(),
$DIC->ctrl(),
$DIC->access(),
$DIC->toolbar(),
$placeholderDescriptionObject
);
break;
default:
throw new ilException(sprintf('The type "%s" is currently not defined for certificates', $type));
break;
}
$gui = new ilCertificateGUI(
$placeholderDescriptionObject,
$placeholderValuesObject,
$objectId,
$certificatePath,
$formFactory,
$deleteAction
);
return $gui;
}
}