Add ckeditor to matching and matching drag n drop see BT#12303

remotes/angel/1.11.x
jmontoyaa 8 years ago
parent f2ff57db64
commit b2910dcc84
  1. 34
      main/exercise/MatchingDraggable.php
  2. 24
      main/exercise/matching.class.php
  3. 106
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestMatching.php

@ -118,9 +118,14 @@ class MatchingDraggable extends Question
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
}
$editorConfig = array(
'ToolbarSet' => 'TestMatching',
'Width' => '100%',
'Height' => '125'
);
for ($i = 1; $i <= $nb_matches; ++$i) {
$renderer = &$form->defaultRenderer();
$renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>',
"answer[$i]"
@ -138,16 +143,22 @@ class MatchingDraggable extends Question
$form->addHtml('<tr>');
$form->addHtml("<td>$i</td>");
$form->addText("answer[$i]", null);
//$form->addText("answer[$i]", null);
$form->addHtmlEditor(
"answer[$i]",
null,
null,
false,
$editorConfig
);
$form->addSelect("matches[$i]", null, $matches);
$form->addText("weighting[$i]", null, true, ['style' => 'width: 60px;', 'value' => 10]);
$form->addHtml('</tr>');
}
$form->addHtml('</tbody></table>');
$group = array();
$form->addGroup($group);
// DISPLAY OPTIONS
$html = '<table class="table table-striped table-hover">
@ -176,19 +187,24 @@ class MatchingDraggable extends Question
$form->addHtml('<tr>');
$form->addHtml('<td>' . chr(64 + $i) . '</td>');
$form->addText("option[$i]", null);
//$form->addText("option[$i]", null);
$form->addHtmlEditor(
"option[$i]",
null,
null,
false,
$editorConfig
);
$form->addHtml('</tr>');
}
$form->addHtml('</table>');
$group = array();
global $text;
$group = array();
// setting the save button here and not in the question class.php
$group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessOptions', true);
$group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreOptions', true);
$group[] = $form->addButtonSave($text, 'submitQuestion', true);
$form->addGroup($group);
if (!empty($this->id)) {

@ -123,6 +123,12 @@ class Matching extends Question
);
}
$editorConfig = array(
'ToolbarSet' => 'TestMatching',
'Width' => '100%',
'Height' => '125'
);
for ($i = 1; $i <= $nb_matches; ++$i) {
$renderer = &$form->defaultRenderer();
$renderer->setElementTemplate(
@ -142,7 +148,14 @@ class Matching extends Question
$form->addHtml('<tr>');
$form->addHtml("<td>$i</td>");
$form->addText("answer[$i]", null);
//$form->addText("answer[$i]", null);
$form->addHtmlEditor(
"answer[$i]",
null,
null,
false,
$editorConfig
);
$form->addSelect(
"matches[$i]",
null,
@ -188,7 +201,14 @@ class Matching extends Question
$form->addHtml('<tr>');
$form->addHtml('<td>' . chr(64 + $i) . '</td>');
$form->addText("option[$i]", null);
$form->addHtmlEditor(
"option[$i]",
null,
null,
false,
$editorConfig
);
$form->addHtml('</tr>');
}

@ -0,0 +1,106 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar;
/**
* TestFreeAnswer toolbar configuration
*
* @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar
*/
class TestMatching extends Basic
{
/**
* Get the toolbar config
* @return array
*/
public function getConfig()
{
if (api_get_setting('more_buttons_maximized_mode') != 'true') {
$config['toolbar'] = $this->getNormalToolbar();
} else {
$config['toolbar_minToolbar'] = $this->getMinimizedToolbar();
$config['toolbar_maxToolbar'] = $this->getMaximizedToolbar();
}
$config['fullPage'] = false;
$config['extraPlugins'] = 'wordcount';
$config['wordcount'] = array(
// Whether or not you want to show the Word Count
'showWordCount' => true,
// Whether or not you want to show the Char Count
'showCharCount' => true,
// Option to limit the characters in the Editor
'charLimit' => 'unlimited',
// Option to limit the words in the Editor
'wordLimit' => 'unlimited'
);
//$config['height'] = '200';
return $config;
}
/**
* Get the toolbar configuration when CKEditor is maximized
* @return array
*/
protected function getMaximizedToolbar()
{
return [
['NewPage', 'Templates', '-', 'Preview', 'Print'],
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
['Undo', 'Redo', '-', 'SelectAll', 'Find', '-', 'RemoveFormat'],
['Link', 'Unlink', 'Anchor', 'Glossary'],
['Image', 'Mapping', 'Video', 'Oembed', 'Youtube', 'Flash', 'Audio', 'leaflet', 'Smiley', 'SpecialChar', 'Asciimath',],
'/',
['Table', '-', 'CreateDiv'],
['BulletedList', 'NumberedList', 'HorizontalRule', '-', 'Outdent', 'Indent', 'Blockquote'],
['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript', '-', 'TextColor', 'BGColor'],
[api_get_setting('allow_spellcheck') == 'true' ? 'Scayt' : ''],
['Styles', 'Format', 'Font', 'FontSize'],
['PageBreak', 'ShowBlocks'],
['Toolbarswitch']
];
}
/**
* Get the default toolbar configuration when the setting more_buttons_maximized_mode is false
* @return array
*/
protected function getNormalToolbar()
{
return [
[
'Maximize',
'Bold',
'Image',
'Link',
'PasteFromWord',
'Audio',
'Table',
'Subscript',
'Superscript',
'ShowBlocks'
]
];
}
/**
* Get the toolbar configuration when CKEditor is minimized
* @return array
*/
protected function getMinimizedToolbar()
{
return [
$this->getNewPageBlock(),
['Undo', 'Redo'],
['Link', 'Image', 'Video', 'Flash', 'Audio', 'Table', 'Asciimath'],
['BulletedList', 'NumberedList', 'HorizontalRule'],
['JustifyLeft', 'JustifyCenter', 'JustifyBlock'],
['Format', 'Font', 'FontSize', 'Bold', 'Italic', 'Underline', 'TextColor', 'BGColor'],
['Toolbarswitch']
];
}
}
Loading…
Cancel
Save