diff --git a/main/exercice/answer.class.php b/main/exercice/answer.class.php index b1a7ebc1be..c9e1b76380 100755 --- a/main/exercice/answer.class.php +++ b/main/exercice/answer.class.php @@ -184,9 +184,9 @@ class Answer $result_question = Database::query($sql); $question_type = Database::fetch_array($result_question); - $sql = "SELECT answer,correct,comment,ponderation,position, hotspot_coordinates, hotspot_type, destination, id_auto " . - "FROM $TBL_ANSWER WHERE c_id = {$this->course_id} AND question_id='".$questionId."' " . - "ORDER BY $field $order"; + $sql = "SELECT answer,correct,comment,ponderation,position, hotspot_coordinates, hotspot_type, destination, id_auto + FROM $TBL_ANSWER WHERE c_id = {$this->course_id} AND question_id='".$questionId."' + ORDER BY $field $order"; $result=Database::query($sql); $i = 1; @@ -326,8 +326,8 @@ class Answer public function getAnswersList($decode = false) { $list = array(); - for($i = 1; $i<=$this->nbrAnswers;$i++){ - if(!empty($this->answer[$i])){ + for ($i = 1; $i <= $this->nbrAnswers; $i++) { + if (!empty($this->answer[$i])) { //Avoid problems when parsing elements with accents if ($decode) { @@ -336,16 +336,16 @@ class Answer } $list[] = array( - 'id' => $i, - 'answer' => $this->answer[$i], - 'comment' => $this->comment[$i], - 'grade' => $this->weighting[$i], + 'id' => $i, + 'answer' => $this->answer[$i], + 'comment' => $this->comment[$i], + 'grade' => $this->weighting[$i], 'hotspot_coord' => $this->hotspot_coordinates[$i], - 'hotspot_type' => $this->hotspot_type[$i], - 'correct' => $this->correct[$i], - 'destination' => $this->destination[$i] + 'hotspot_type' => $this->hotspot_type[$i], + 'correct' => $this->correct[$i], + 'destination' => $this->destination[$i] ); - } + } } return $list; @@ -672,20 +672,20 @@ class Answer $TBL_REPONSES = Database :: get_course_table(TABLE_QUIZ_ANSWER); $fixed_list = array(); - if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE) { - - //Selecting origin options + if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || + self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE + ) { + // Selecting origin options $origin_options = Question::readQuestionOption($this->selectQuestionId(), $this->course['real_id']); - if (!empty($origin_options)) { - foreach($origin_options as $item) { - $new_option_list[]=$item['id']; + foreach ($origin_options as $item) { + $new_option_list[] = $item['id']; } } $destination_options = Question::readQuestionOption($newQuestionId, $course_info['real_id']); - $i=0; + $i = 0; if (!empty($destination_options)) { foreach($destination_options as $item) { $fixed_list[$new_option_list[$i]] = $item['id']; @@ -716,7 +716,9 @@ class Answer $answer = $this->answer[$i]; $correct = $this->correct[$i]; - if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ) { + if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE || + self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE + ) { $correct = $fixed_list[intval($correct)]; } @@ -740,6 +742,7 @@ class Answer 'destination' => $destination ]; $id = Database::insert($TBL_REPONSES, $params); + if ($id) { $sql = "UPDATE $TBL_REPONSES SET id = id_auto WHERE id_auto = $id"; Database::query($sql); diff --git a/main/exercice/calculated_answer.class.php b/main/exercice/calculated_answer.class.php index 01cf8fcc7b..6964c6f5e5 100644 --- a/main/exercice/calculated_answer.class.php +++ b/main/exercice/calculated_answer.class.php @@ -128,7 +128,7 @@ class CalculatedAnswer extends Question 'id' => 'answer', 'onkeyup' => 'javascript: updateBlanks(this);' ), - array('ToolbarSet' => 'Test_Question_Description', 'Width' => '100%', 'Height' => '350')); + array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350')); $form->addRule('answer', get_lang('GiveText'),'required'); $form->addRule('answer', get_lang('DefineBlanks'),'regex','/\[.*\]/'); diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index 972e96e3ce..48e0613fe7 100755 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -1249,25 +1249,24 @@ abstract class Question * A subclass can redefine this function to add fields... * @param FormValidator $form */ - public function createForm(&$form, $fck_config=0) + public function createForm(&$form) { echo ''; echo ''; @@ -1283,19 +1282,19 @@ abstract class Question $form->addElement('hidden','answerType', $answerType); // html editor - $editor_config = array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '150'); - if (is_array($fck_config)){ - $editor_config = array_merge($editor_config, $fck_config); - } + $editorConfig = array( + 'ToolbarSet' => 'TestQuestionDescription', + 'Height' => '150' + ); if (!api_is_allowed_to_edit(null,true)) { - $editor_config['UserStatus'] = 'student'; + $editorConfig['UserStatus'] = 'student'; } $form->addButtonAdvancedSettings('advanced_params'); $form->addElement('html', ''); + $form->addElement('html', ''); if (!isset($_GET['fromExercise'])) { switch ($answerType) { @@ -1347,7 +1346,6 @@ abstract class Question } } - // default values $defaults = array(); $defaults['questionName'] = $this->question; diff --git a/main/exercice/tests_category.php b/main/exercice/tests_category.php index 8517fc6070..ecaace03b0 100755 --- a/main/exercice/tests_category.php +++ b/main/exercice/tests_category.php @@ -71,7 +71,13 @@ function edit_category_form($in_action) { $form->addElement('header', get_lang('EditCategory')); $form->addElement('hidden', 'category_id'); $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95')); - $form->addHtmlEditor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Height' => '200')); + $form->addHtmlEditor( + 'category_description', + get_lang('CategoryDescription'), + false, + false, + array('ToolbarSet' => 'test_category', 'Height' => '200') + ); $form->addButtonSave(get_lang('ModifyCategory'), 'SubmitNote'); // setting the defaults diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Documents.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Documents.php index 53df289fe7..8b5ad770d7 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Documents.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Documents.php @@ -10,8 +10,7 @@ namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar; */ class Documents extends Basic { - public $plugins = array( - ); + public $plugins = array(); /** * @return mixed @@ -51,9 +50,10 @@ class Documents extends Basic { $plugins = array(); - if (api_get_setting('show_glossary_in_documents') != 'none') { + if (api_get_setting('show_glossary_in_documents') == 'ismanual') { $plugins[] = 'glossary'; } + return $plugins; } } diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestAnswerFeedback.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestAnswerFeedback.php index 3d6067dbd6..99aeaa449a 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestAnswerFeedback.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestAnswerFeedback.php @@ -5,9 +5,42 @@ namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar; /** * Class TestAnswerFeedback + * * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar */ class TestAnswerFeedback extends Basic { + /** + * @return mixed + */ + public function getConfig() + { + $config['toolbarGroups'] = array( + array('name' => 'document'), + array( + 'name' => 'clipboard', + 'groups' => array('clipboard', 'undo',) + ), + array( + 'name' => 'basicstyles', + 'groups' => array('basicstyles', 'cleanup',) + ), + array( + 'name' => 'paragraph', + 'groups' => array('list', 'indent', 'blocks', 'align') + ), + array('name' => 'links'), + array('name' => 'insert'), + '/', + array('name' => 'styles'), + array('name' => 'colors'), + array('name' => 'mode') + ); + $config['toolbarCanCollapse'] = true; + $config['toolbarStartupExpanded'] = false; + //$config['width'] = '100'; + //$config['height'] = '200'; + return $config; + } } diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestProposedAnswer.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestProposedAnswer.php index 4d60fbaddf..69bf418131 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestProposedAnswer.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestProposedAnswer.php @@ -5,6 +5,7 @@ namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar; /** * Class TestProposedAnswer + * * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar */ class TestProposedAnswer extends Basic @@ -15,22 +16,46 @@ class TestProposedAnswer extends Basic public function getConfig() { $config['toolbarGroups'] = array( - //array('name' => 'document'), - array('name' => 'clipboard', 'groups' =>array('clipboard', 'undo', )), - array('name' => 'basicstyles', 'groups' =>array('basicstyles', 'cleanup', )), - array('name' => 'paragraph', 'groups' =>array('list', 'indent', 'blocks', 'align' )), + array('name' => 'document'), + array( + 'name' => 'clipboard', + 'groups' => array('clipboard', 'undo',) + ), + array( + 'name' => 'basicstyles', + 'groups' => array('basicstyles', 'cleanup',) + ), + array( + 'name' => 'paragraph', + 'groups' => array('list', 'indent', 'blocks', 'align') + ), array('name' => 'links'), array('name' => 'insert'), '/', array('name' => 'styles'), array('name' => 'colors'), - array('name' => 'mode') + array('name' => 'mode'), + array('name' => 'others') ); $config['toolbarCanCollapse'] = true; $config['toolbarStartupExpanded'] = false; + $config['extraPlugins'] = $this->getPluginsToString(); //$config['width'] = '100'; //$config['height'] = '200'; return $config; } + + /** + * @return array + */ + public function getConditionalPlugins() + { + $plugins = array(); + if (api_get_setting('show_glossary_in_documents') == 'ismanual') { + $plugins[] = 'glossary'; + } + + return $plugins; + } } diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestQuestionDescription.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestQuestionDescription.php index 5727a63dea..c6d66622f3 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestQuestionDescription.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestQuestionDescription.php @@ -5,6 +5,7 @@ namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar; /** * Class TestQuestionDescription + * * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar */ class TestQuestionDescription extends Basic @@ -16,12 +17,12 @@ class TestQuestionDescription extends Basic { $config['toolbarGroups'] = array( array('name' => 'document', 'groups' =>array('document', 'doctools')), - array('name' => 'clipboard', 'groups' =>array('clipboard', 'undo', )), - array('name' => 'editing', 'groups' =>array('clipboard', 'undo', )), + array('name' => 'clipboard', 'groups' =>array('clipboard', 'undo')), + array('name' => 'editing', 'groups' =>array('clipboard', 'undo')), //array('name' => 'forms', 'groups' =>array('clipboard', 'undo', )), '/', - array('name' => 'basicstyles', 'groups' =>array('basicstyles', 'cleanup', )), - array('name' => 'paragraph', 'groups' =>array('list', 'indent', 'blocks', 'align' )), + array('name' => 'basicstyles', 'groups' =>array('basicstyles', 'cleanup')), + array('name' => 'paragraph', 'groups' =>array('list', 'indent', 'blocks', 'align')), array('name' => 'links'), array('name' => 'insert'), '/', @@ -30,11 +31,26 @@ class TestQuestionDescription extends Basic array('name' => 'tools'), array('name' => 'others'), array('name' => 'mode') - //array('name' => 'about') ); + $config['extraPlugins'] = $this->getPluginsToString(); + //$config['width'] = '100'; //$config['height'] = '200'; return $config; } + + /** + * @return array + */ + public function getConditionalPlugins() + { + $plugins = array(); + if (api_get_setting('show_glossary_in_documents') == 'ismanual') { + $plugins[] = 'glossary'; + } + + return $plugins; + } + }