From 067f5556ebb90dd962661702656a3ff1d2eb3bb7 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 17 Apr 2019 15:04:26 +0200 Subject: [PATCH] Update from 1.11.x --- .../default/social/group_block.html.twig | 1 + .../Editor/CkEditor/Toolbar/Basic.php | 1 + .../Editor/CkEditor/Toolbar/Forum.php | 2 +- .../CkEditor/Toolbar/IntroductionSection.php | 135 ++++++++++++++++++ src/CoreBundle/Component/Utils/ChamiloApi.php | 40 ++++++ .../Component/CourseCopy/CourseRestorer.php | 4 +- .../CourseCopy/Resources/QuizQuestion.php | 2 +- 7 files changed, 181 insertions(+), 4 deletions(-) create mode 100644 main/template/default/social/group_block.html.twig create mode 100644 src/CoreBundle/Component/Editor/CkEditor/Toolbar/IntroductionSection.php diff --git a/main/template/default/social/group_block.html.twig b/main/template/default/social/group_block.html.twig new file mode 100644 index 0000000000..d3123dbe64 --- /dev/null +++ b/main/template/default/social/group_block.html.twig @@ -0,0 +1 @@ +{{ social_avatar_block }} diff --git a/src/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php b/src/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php index 2297480afa..7800d098e8 100644 --- a/src/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php +++ b/src/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php @@ -63,6 +63,7 @@ class Basic extends Toolbar 'wordcount', 'inserthtml', 'xml', + 'qmarkersrolls', ]; /** diff --git a/src/CoreBundle/Component/Editor/CkEditor/Toolbar/Forum.php b/src/CoreBundle/Component/Editor/CkEditor/Toolbar/Forum.php index 265ba47a7e..f0b9b075b3 100644 --- a/src/CoreBundle/Component/Editor/CkEditor/Toolbar/Forum.php +++ b/src/CoreBundle/Component/Editor/CkEditor/Toolbar/Forum.php @@ -73,7 +73,7 @@ class Forum extends Basic ['Undo', 'Redo'], ['Link', 'Image', 'Video', 'Oembed', 'Flash', 'Youtube', 'Audio', 'Table', 'Asciimath', 'Asciisvg'], ['BulletedList', 'NumberedList', 'HorizontalRule'], - ['JustifyLeft', 'JustifyCenter', 'JustifyBlock'], + ['JustifyLeft', 'JustifyCenter', 'JustifyRight'], ['Format', 'Font', 'FontSize', 'Bold', 'Italic', 'Underline', 'TextColor', 'BGColor', 'Source'], ['Toolbarswitch'], ]; diff --git a/src/CoreBundle/Component/Editor/CkEditor/Toolbar/IntroductionSection.php b/src/CoreBundle/Component/Editor/CkEditor/Toolbar/IntroductionSection.php new file mode 100644 index 0000000000..93d6c3647b --- /dev/null +++ b/src/CoreBundle/Component/Editor/CkEditor/Toolbar/IntroductionSection.php @@ -0,0 +1,135 @@ +getNormalToolbar(); + } else { + $config['toolbar_minToolbar'] = $this->getMinimizedToolbar(); + } + + $config['extraPlugins'] = $this->getPluginsToString(); + $config['fullPage'] = true; + + return $config; + } + + /** + * @return array + */ + public function getConditionalPlugins() + { + $plugins = []; + + if (api_get_setting('show_glossary_in_documents') === 'ismanual') { + $plugins[] = 'glossary'; + } + + return $plugins; + } + + /** + * Get the default toolbar configuration when the setting more_buttons_maximized_mode is false. + * + * @return array + */ + protected function getNormalToolbar() + { + return [ + ['Maximize', 'PasteFromWord', '-', 'Undo', 'Redo'], + ['Link', 'Unlink', 'Anchor', 'inserthtml', 'Glossary'], + [ + 'Image', + 'Video', + 'Flash', + 'Oembed', + 'Youtube', + 'Audio', + 'Asciimath', + 'Asciisvg', + ], + ['Table', 'SpecialChar'], + [ + 'Outdent', + 'Indent', + '-', + 'TextColor', + 'BGColor', + '-', + 'NumberedList', + 'BulletedList', + '-', + api_get_configuration_value('translate_html') ? 'Language' : '', + api_get_setting('allow_spellcheck') === 'true' ? 'Scayt' : '', + ], + '/', + ['Styles', 'Format', 'Font', 'FontSize'], + ['Bold', 'Italic', 'Underline'], + ['JustifyLeft', 'JustifyCenter', 'JustifyRight'], + api_get_setting('enabled_wiris') === 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''], + ['Source'], + ]; + } + + /** + * Get the toolbar configuration when CKEditor is minimized. + * + * @return array + */ + protected function getMinimizedToolbar() + { + return [ + $this->getNewPageBlock(), + ['Undo', 'Redo'], + [ + 'Link', + 'Image', + 'Video', + 'Flash', + 'Youtube', + 'Audio', + 'Table', + 'Asciimath', + 'Asciisvg', + ], + ['BulletedList', 'NumberedList', 'HorizontalRule'], + ['JustifyLeft', 'JustifyCenter', 'JustifyBlock'], + ['Styles', + 'Format', + 'Font', + 'FontSize', + 'Bold', + 'Italic', + 'Underline', + 'TextColor', + 'BGColor', + ], + [ + 'Language', + 'ShowBlocks', + 'Source', + ], + api_get_setting('enabled_wiris') === 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''], + ['Toolbarswitch'], + ]; + } +} diff --git a/src/CoreBundle/Component/Utils/ChamiloApi.php b/src/CoreBundle/Component/Utils/ChamiloApi.php index 95a8f3d1d1..42d3f33b3f 100644 --- a/src/CoreBundle/Component/Utils/ChamiloApi.php +++ b/src/CoreBundle/Component/Utils/ChamiloApi.php @@ -355,4 +355,44 @@ class ChamiloApi return $localMidnight; } + + /** + * Get JavaScript code necessary to load quiz markers-rolls in medialement's Markers Rolls plugin. + * + * @return string + */ + public static function getQuizMarkersRollsJS() + { + $webCodePath = api_get_path(WEB_CODE_PATH); + $colorPalette = self::getColorPalette(false, true); + + return " + var \$originalNode = $(originalNode), + qMarkersRolls = \$originalNode.data('q-markersrolls') || [], + qMarkersColor = \$originalNode.data('q-markersrolls-color') || '{$colorPalette[0]}'; + + if (0 == qMarkersRolls.length) { + return; + } + + instance.options.markersRollsColor = qMarkersColor; + instance.options.markersRollsWidth = 2; + instance.options.markersRolls = {}; + + qMarkersRolls.forEach(function (qMarkerRoll) { + var url = '{$webCodePath}exercise/exercise_submit.php?{{ _p.web_cid_query }}&' + + $.param({ + exerciseId: qMarkerRoll[1], + learnpath_id: 0, + learnpath_item_id: 0, + learnpath_item_view_id: 0, + origin: 'embeddable' + }); + + instance.options.markersRolls[qMarkerRoll[0]] = url; + }); + + instance.buildmarkersrolls(instance, instance.controls, instance.layers, instance.media); + "; + } } diff --git a/src/CourseBundle/Component/CourseCopy/CourseRestorer.php b/src/CourseBundle/Component/CourseCopy/CourseRestorer.php index 22f99fee65..908303d627 100644 --- a/src/CourseBundle/Component/CourseCopy/CourseRestorer.php +++ b/src/CourseBundle/Component/CourseCopy/CourseRestorer.php @@ -3347,7 +3347,7 @@ class CourseRestorer $this->destination_course_info['real_id'] ); if (!empty($workData)) { - continue; + break; } break; case FILE_OVERWRITE: @@ -3543,7 +3543,7 @@ class CourseRestorer ) { switch ($this->file_option) { case FILE_SKIP: - continue; + break; case FILE_OVERWRITE: copy( $this->course->backup_path.'/'.$asset->path, diff --git a/src/CourseBundle/Component/CourseCopy/Resources/QuizQuestion.php b/src/CourseBundle/Component/CourseCopy/Resources/QuizQuestion.php index 415da830db..559c9d5ac5 100644 --- a/src/CourseBundle/Component/CourseCopy/Resources/QuizQuestion.php +++ b/src/CourseBundle/Component/CourseCopy/Resources/QuizQuestion.php @@ -110,7 +110,7 @@ class QuizQuestion extends Resource $courseId = $courseInfo['real_id']; $courseCode = $courseInfo['code']; $questionId = $this->source_id; - $question = \Question::read($questionId, $courseId); + $question = \Question::read($questionId, $courseInfo); $pictureId = $question->getPictureId(); // Add the picture document in the builder if (!empty($pictureId)) {