|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
|
6
|
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\Settings; |
|
8
|
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
|
10
|
|
|
use Chamilo\CoreBundle\Form\DataTransformer\ResourceToIdentifierTransformer; |
|
11
|
|
|
use Chamilo\CoreBundle\Form\Type\YesNoType; |
|
12
|
|
|
use Chamilo\CoreBundle\Repository\Node\CourseRepository; |
|
13
|
|
|
use Chamilo\CoreBundle\Tool\AbstractTool; |
|
14
|
|
|
use Chamilo\CoreBundle\Tool\ToolChain; |
|
15
|
|
|
use Chamilo\CoreBundle\Transformer\ArrayToIdentifierTransformer; |
|
16
|
|
|
use Sylius\Bundle\SettingsBundle\Schema\AbstractSettingsBuilder; |
|
17
|
|
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType; |
|
18
|
|
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; |
|
19
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType; |
|
20
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
|
21
|
|
|
use Symfony\Component\Form\Extension\Core\Type\UrlType; |
|
22
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
|
23
|
|
|
|
|
24
|
|
|
class CourseSettingsSchema extends AbstractSettingsSchema |
|
25
|
|
|
{ |
|
26
|
|
|
protected ToolChain $toolChain; |
|
27
|
|
|
|
|
28
|
|
|
public function __construct( |
|
29
|
|
|
private readonly CourseRepository $courseRepository, |
|
30
|
|
|
) {} |
|
31
|
|
|
|
|
32
|
|
|
public function getProcessedToolChain(): array |
|
33
|
|
|
{ |
|
34
|
|
|
$tools = []; |
|
35
|
|
|
|
|
36
|
|
|
/** @var AbstractTool $tool */ |
|
37
|
|
|
foreach ($this->toolChain->getTools() as $tool) { |
|
38
|
|
|
$name = $tool->getTitle(); |
|
39
|
|
|
$tools[$name] = $name; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
return $tools; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function setToolChain(ToolChain $tools): void |
|
46
|
|
|
{ |
|
47
|
|
|
$this->toolChain = $tools; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function buildSettings(AbstractSettingsBuilder $builder): void |
|
51
|
|
|
{ |
|
52
|
|
|
$tools = $this->getProcessedToolChain(); |
|
53
|
|
|
|
|
54
|
|
|
$builder |
|
55
|
|
|
->setDefaults( |
|
56
|
|
|
[ |
|
57
|
|
|
'active_tools_on_create' => $tools, |
|
58
|
|
|
'display_coursecode_in_courselist' => 'false', |
|
59
|
|
|
'display_teacher_in_courselist' => 'true', |
|
60
|
|
|
'student_view_enabled' => 'true', |
|
61
|
|
|
'go_to_course_after_login' => 'false', |
|
62
|
|
|
'show_navigation_menu' => 'false', |
|
63
|
|
|
'enable_tool_introduction' => 'false', |
|
64
|
|
|
'breadcrumbs_course_homepage' => 'course_title', |
|
65
|
|
|
'example_material_course_creation' => 'true', |
|
66
|
|
|
'allow_course_theme' => 'true', |
|
67
|
|
|
'allow_users_to_create_courses' => 'true', |
|
68
|
|
|
'show_courses_descriptions_in_catalog' => 'true', |
|
69
|
|
|
'send_email_to_admin_when_create_course' => 'false', |
|
70
|
|
|
'allow_user_course_subscription_by_course_admin' => 'true', |
|
71
|
|
|
'course_validation' => 'false', |
|
72
|
|
|
'course_validation_terms_and_conditions_url' => '', |
|
73
|
|
|
'course_hide_tools' => [], |
|
74
|
|
|
'scorm_cumulative_session_time' => 'true', |
|
75
|
|
|
'courses_default_creation_visibility' => '2', |
|
76
|
|
|
// COURSE_VISIBILITY_OPEN_PLATFORM |
|
77
|
|
|
'allow_public_certificates' => 'false', |
|
78
|
|
|
'allow_lp_return_link' => 'true', |
|
79
|
|
|
'course_creation_use_template' => null, |
|
80
|
|
|
'hide_scorm_export_link' => 'false', |
|
81
|
|
|
'hide_scorm_copy_link' => 'false', |
|
82
|
|
|
'hide_scorm_pdf_link' => 'true', |
|
83
|
|
|
'course_catalog_published' => 'false', |
|
84
|
|
|
'course_images_in_courses_list' => 'true', |
|
85
|
|
|
'teacher_can_select_course_template' => 'true', |
|
86
|
|
|
'show_toolshortcuts' => '', |
|
87
|
|
|
'lp_show_reduced_report' => 'false', |
|
88
|
|
|
'course_creation_splash_screen' => 'true', |
|
89
|
|
|
'block_registered_users_access_to_open_course_contents' => 'false', |
|
90
|
|
|
'enable_bootstrap_in_documents_html' => 'false', |
|
91
|
|
|
'view_grid_courses' => 'true', |
|
92
|
|
|
'show_simple_session_info' => 'true', |
|
93
|
|
|
'my_courses_show_courses_in_user_language_only' => 'false', |
|
94
|
|
|
'allow_public_course_with_no_terms_conditions' => 'false', |
|
95
|
|
|
'show_all_sessions_on_my_course_page' => 'true', |
|
96
|
|
|
'disabled_edit_session_coaches_course_editing_course' => 'false', |
|
97
|
|
|
'allow_base_course_category' => 'false', |
|
98
|
|
|
'hide_course_sidebar' => 'true', |
|
99
|
|
|
'allow_course_extra_field_in_catalog' => 'false', |
|
100
|
|
|
'multiple_access_url_show_shared_course_marker' => 'false', |
|
101
|
|
|
'course_category_code_to_use_as_model' => 'MY_CATEGORY', |
|
102
|
|
|
'enable_unsubscribe_button_on_my_course_page' => 'false', |
|
103
|
|
|
'course_creation_donate_message_show' => 'false', |
|
104
|
|
|
'course_creation_donate_link' => '<some donate button html>', |
|
105
|
|
|
'courses_list_session_title_link' => '1', |
|
106
|
|
|
'hide_course_rating' => 'false', |
|
107
|
|
|
'course_log_hide_columns' => '', |
|
108
|
|
|
'course_student_info' => '', |
|
109
|
|
|
'course_catalog_settings' => '', |
|
110
|
|
|
'resource_sequence_show_dependency_in_course_intro' => 'false', |
|
111
|
|
|
'course_catalog_display_in_home' => 'false', |
|
112
|
|
|
'course_creation_form_set_course_category_mandatory' => 'false', |
|
113
|
|
|
'course_creation_form_hide_course_code' => 'false', |
|
114
|
|
|
'course_about_teacher_name_hide' => 'false', |
|
115
|
|
|
'course_visibility_change_only_admin' => 'false', |
|
116
|
|
|
'catalog_hide_public_link' => 'false', |
|
117
|
|
|
'course_log_default_extra_fields' => '', |
|
118
|
|
|
'show_courses_in_catalogue' => 'false', |
|
119
|
|
|
'courses_catalogue_show_only_category' => '', |
|
120
|
|
|
'course_creation_by_teacher_extra_fields_to_show' => '', |
|
121
|
|
|
'course_creation_form_set_extra_fields_mandatory' => '', |
|
122
|
|
|
'course_configuration_tool_extra_fields_to_show_and_edit' => '', |
|
123
|
|
|
'course_creation_user_course_extra_field_relation_to_prefill' => '', |
|
124
|
|
|
'allow_edit_tool_visibility_in_session' => 'true', |
|
125
|
|
|
'show_course_duration' => 'false', |
|
126
|
|
|
'access_url_specific_files' => 'false', |
|
127
|
|
|
] |
|
128
|
|
|
) |
|
129
|
|
|
->setTransformer( |
|
130
|
|
|
'active_tools_on_create', |
|
131
|
|
|
new ArrayToIdentifierTransformer() |
|
132
|
|
|
) |
|
133
|
|
|
->setTransformer( |
|
134
|
|
|
'course_hide_tools', |
|
135
|
|
|
new ArrayToIdentifierTransformer() |
|
136
|
|
|
) |
|
137
|
|
|
->setTransformer( |
|
138
|
|
|
'course_creation_use_template', |
|
139
|
|
|
new ResourceToIdentifierTransformer($this->courseRepository, 'id') |
|
140
|
|
|
); |
|
141
|
|
|
|
|
142
|
|
|
$allowedTypes = [ |
|
143
|
|
|
'active_tools_on_create' => ['array'], |
|
144
|
|
|
'course_hide_tools' => ['array'], |
|
145
|
|
|
'display_coursecode_in_courselist' => ['string'], |
|
146
|
|
|
'display_teacher_in_courselist' => ['string'], |
|
147
|
|
|
'student_view_enabled' => ['string'], |
|
148
|
|
|
]; |
|
149
|
|
|
|
|
150
|
|
|
$this->setMultipleAllowedTypes($allowedTypes, $builder); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
public function buildForm(FormBuilderInterface $builder): void |
|
154
|
|
|
{ |
|
155
|
|
|
$tools = $this->getProcessedToolChain(); |
|
156
|
|
|
|
|
157
|
|
|
$builder |
|
158
|
|
|
->add('active_tools_on_create', ChoiceType::class, [ |
|
159
|
|
|
'choices' => $tools, |
|
160
|
|
|
'multiple' => true, |
|
161
|
|
|
'expanded' => true, |
|
162
|
|
|
]) |
|
163
|
|
|
->add('display_coursecode_in_courselist', YesNoType::class) |
|
164
|
|
|
->add('display_teacher_in_courselist', YesNoType::class) |
|
165
|
|
|
->add('student_view_enabled', YesNoType::class) |
|
166
|
|
|
->add('go_to_course_after_login', YesNoType::class) |
|
167
|
|
|
->add('show_navigation_menu', ChoiceType::class, [ |
|
168
|
|
|
'choices' => [ |
|
169
|
|
|
'No' => 'false', |
|
170
|
|
|
'Icons only' => 'icons', |
|
171
|
|
|
'Text only' => 'text', |
|
172
|
|
|
'Icons text' => 'iconstext', |
|
173
|
|
|
], |
|
174
|
|
|
]) |
|
175
|
|
|
->add('enable_tool_introduction', YesNoType::class) |
|
176
|
|
|
->add('breadcrumbs_course_homepage', ChoiceType::class, [ |
|
177
|
|
|
'choices' => [ |
|
178
|
|
|
'Course homepage' => 'course_home', |
|
179
|
|
|
'Course code' => 'course_code', |
|
180
|
|
|
'Course title' => 'course_title', |
|
181
|
|
|
'Session name and course title' => 'session_name_and_course_title', |
|
182
|
|
|
], |
|
183
|
|
|
]) |
|
184
|
|
|
->add('example_material_course_creation', YesNoType::class) |
|
185
|
|
|
->add('allow_course_theme', YesNoType::class) |
|
186
|
|
|
->add('allow_users_to_create_courses', YesNoType::class) |
|
187
|
|
|
->add('show_courses_descriptions_in_catalog', YesNoType::class) |
|
188
|
|
|
->add('send_email_to_admin_when_create_course', YesNoType::class) |
|
189
|
|
|
->add('allow_user_course_subscription_by_course_admin', YesNoType::class) |
|
190
|
|
|
->add('course_validation', YesNoType::class) |
|
191
|
|
|
->add('course_validation_terms_and_conditions_url', UrlType::class) |
|
192
|
|
|
->add('course_hide_tools', ChoiceType::class, [ |
|
193
|
|
|
'choices' => $tools, |
|
194
|
|
|
'multiple' => true, |
|
195
|
|
|
'expanded' => true, |
|
196
|
|
|
]) |
|
197
|
|
|
->add('scorm_cumulative_session_time', YesNoType::class) |
|
198
|
|
|
->add('courses_default_creation_visibility', ChoiceType::class, [ |
|
199
|
|
|
'choices' => [ |
|
200
|
|
|
'Public' => '3', |
|
201
|
|
|
'Open' => '2', |
|
202
|
|
|
'Private' => '1', |
|
203
|
|
|
'Closed' => '0', |
|
204
|
|
|
], |
|
205
|
|
|
]) |
|
206
|
|
|
->add('allow_public_certificates', YesNoType::class) |
|
207
|
|
|
->add('allow_lp_return_link', YesNoType::class) |
|
208
|
|
|
->add('course_creation_use_template', EntityType::class, [ |
|
209
|
|
|
'class' => Course::class, |
|
210
|
|
|
'placeholder' => 'Choose ...', |
|
211
|
|
|
'empty_data' => null, |
|
212
|
|
|
'choice_label' => 'title', |
|
213
|
|
|
'choice_value' => 'id', |
|
214
|
|
|
'required' => false, |
|
215
|
|
|
]) |
|
216
|
|
|
->add('hide_scorm_export_link', YesNoType::class) |
|
217
|
|
|
->add('hide_scorm_copy_link', YesNoType::class) |
|
218
|
|
|
->add('hide_scorm_pdf_link', YesNoType::class) |
|
219
|
|
|
->add('course_catalog_published', YesNoType::class) |
|
220
|
|
|
->add('course_images_in_courses_list', YesNoType::class) |
|
221
|
|
|
->add('teacher_can_select_course_template', YesNoType::class) |
|
222
|
|
|
->add('show_toolshortcuts', YesNoType::class) |
|
223
|
|
|
->add('lp_show_reduced_report', YesNoType::class) |
|
224
|
|
|
->add('course_creation_splash_screen', YesNoType::class) |
|
225
|
|
|
->add('block_registered_users_access_to_open_course_contents', YesNoType::class) |
|
226
|
|
|
->add('enable_bootstrap_in_documents_html', YesNoType::class) |
|
227
|
|
|
->add('view_grid_courses', YesNoType::class) |
|
228
|
|
|
->add('show_simple_session_info', YesNoType::class) |
|
229
|
|
|
->add('my_courses_show_courses_in_user_language_only', YesNoType::class) |
|
230
|
|
|
->add('allow_public_course_with_no_terms_conditions', YesNoType::class) |
|
231
|
|
|
->add('show_all_sessions_on_my_course_page', YesNoType::class) |
|
232
|
|
|
->add('disabled_edit_session_coaches_course_editing_course', YesNoType::class) |
|
233
|
|
|
->add('allow_base_course_category', YesNoType::class) |
|
234
|
|
|
->add('hide_course_sidebar', YesNoType::class) |
|
235
|
|
|
->add('allow_course_extra_field_in_catalog', YesNoType::class) |
|
236
|
|
|
->add('multiple_access_url_show_shared_course_marker', YesNoType::class) |
|
237
|
|
|
->add('course_category_code_to_use_as_model', TextType::class) |
|
238
|
|
|
->add('enable_unsubscribe_button_on_my_course_page', YesNoType::class) |
|
239
|
|
|
->add('course_creation_donate_message_show', YesNoType::class) |
|
240
|
|
|
->add('course_creation_donate_link', TextType::class) |
|
241
|
|
|
->add('courses_list_session_title_link', ChoiceType::class, [ |
|
242
|
|
|
'choices' => [ |
|
243
|
|
|
'No link' => '0', |
|
244
|
|
|
'Default' => '1', |
|
245
|
|
|
'Link' => '2', |
|
246
|
|
|
'Session link' => '3', |
|
247
|
|
|
], |
|
248
|
|
|
]) |
|
249
|
|
|
->add('hide_course_rating', YesNoType::class) |
|
250
|
|
|
->add('course_log_hide_columns', TextareaType::class, [ |
|
251
|
|
|
'attr' => ['rows' => 5, 'style' => 'font-family: monospace;'], |
|
252
|
|
|
]) |
|
253
|
|
|
->add('course_student_info', TextareaType::class, [ |
|
254
|
|
|
'attr' => ['rows' => 5, 'style' => 'font-family: monospace;'], |
|
255
|
|
|
]) |
|
256
|
|
|
->add('course_catalog_settings', TextareaType::class, [ |
|
257
|
|
|
'attr' => ['rows' => 10, 'style' => 'font-family: monospace;'], |
|
258
|
|
|
]) |
|
259
|
|
|
->add('resource_sequence_show_dependency_in_course_intro', YesNoType::class) |
|
260
|
|
|
->add('course_catalog_display_in_home', YesNoType::class) |
|
261
|
|
|
->add('course_creation_form_set_course_category_mandatory', YesNoType::class) |
|
262
|
|
|
->add('course_creation_form_hide_course_code', YesNoType::class) |
|
263
|
|
|
->add('course_about_teacher_name_hide', YesNoType::class) |
|
264
|
|
|
->add('course_visibility_change_only_admin', YesNoType::class) |
|
265
|
|
|
->add('catalog_hide_public_link', YesNoType::class) |
|
266
|
|
|
->add('course_log_default_extra_fields', TextareaType::class, [ |
|
267
|
|
|
'attr' => ['rows' => 5, 'style' => 'font-family: monospace;'], |
|
268
|
|
|
]) |
|
269
|
|
|
->add('show_courses_in_catalogue', YesNoType::class) |
|
270
|
|
|
->add('courses_catalogue_show_only_category', TextareaType::class, [ |
|
271
|
|
|
'attr' => ['rows' => 3, 'style' => 'font-family: monospace;'], |
|
272
|
|
|
]) |
|
273
|
|
|
->add('course_creation_by_teacher_extra_fields_to_show', TextareaType::class, [ |
|
274
|
|
|
'attr' => ['rows' => 3, 'style' => 'font-family: monospace;'], |
|
275
|
|
|
]) |
|
276
|
|
|
->add('course_creation_form_set_extra_fields_mandatory', TextareaType::class, [ |
|
277
|
|
|
'attr' => ['rows' => 3, 'style' => 'font-family: monospace;'], |
|
278
|
|
|
]) |
|
279
|
|
|
->add('course_configuration_tool_extra_fields_to_show_and_edit', TextareaType::class, [ |
|
280
|
|
|
'attr' => ['rows' => 3, 'style' => 'font-family: monospace;'], |
|
281
|
|
|
]) |
|
282
|
|
|
->add('course_creation_user_course_extra_field_relation_to_prefill', TextareaType::class, [ |
|
283
|
|
|
'attr' => ['rows' => 5, 'style' => 'font-family: monospace;'], |
|
284
|
|
|
]) |
|
285
|
|
|
->add('allow_edit_tool_visibility_in_session', YesNoType::class) |
|
286
|
|
|
->add('show_course_duration', YesNoType::class) |
|
287
|
|
|
->add('access_url_specific_files', YesNoType::class); |
|
288
|
|
|
|
|
289
|
|
|
$this->updateFormFieldsFromSettingsInfo($builder); |
|
290
|
|
|
} |
|
291
|
|
|
} |
|
292
|
|
|
|