diff --git a/main/exercice/multiple_answer.class.php b/main/exercice/multiple_answer.class.php index b19d4ae091..2ceab8e3bb 100644 --- a/main/exercice/multiple_answer.class.php +++ b/main/exercice/multiple_answer.class.php @@ -59,6 +59,15 @@ class MultipleAnswer extends Question { */ function createAnswersForm ($form) { + global $fck_attribute; + + $fck_attribute = array(); + $fck_attribute['Width'] = '300px'; + $fck_attribute['Height'] = '100px'; + $fck_attribute['ToolbarSet'] = 'Small'; + $fck_attribute['Config']['IMUploadPath'] = 'upload/test/'; + $fck_attribute['Config']['FlashUploadPath'] = 'upload/test/'; + $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2; $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); @@ -71,19 +80,19 @@ class MultipleAnswer extends Question { '; @@ -120,8 +129,8 @@ class MultipleAnswer extends Question { $puce->freeze(); $group[] = $puce; $group[] = FormValidator :: createElement ('checkbox', 'correct['.$i.']', null, null, $i); - $group[] = FormValidator :: createElement ('textarea', 'answer['.$i.']',null, 'style="vertical-align:middle" cols="30"'); - $group[] = FormValidator :: createElement ('textarea', 'comment['.$i.']',null, 'style="vertical-align:middle" cols="30"'); + $group[] = FormValidator :: createElement ('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle" cols="30"'); + $group[] = FormValidator :: createElement ('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle" cols="30"'); $group[] = FormValidator :: createElement ('text', 'weighting['.$i.']',null, 'style="vertical-align:middle" size="5" value="0"'); $form -> addGroup($group, null, null, ''; @@ -124,9 +132,10 @@ class UniqueAnswer extends Question { $puce = FormValidator :: createElement ('text', null,null,'value="'.$i.'"'); $puce->freeze(); $group[] = $puce; - $group[] = FormValidator :: createElement ('radio', 'correct', null, null, $i); - $group[] = FormValidator :: createElement ('textarea', 'answer['.$i.']',null, 'style="vertical-align:middle" cols="30"'); - $group[] = FormValidator :: createElement ('textarea', 'comment['.$i.']',null, 'style="vertical-align:middle" cols="30"'); + $group[] = FormValidator :: createElement ('radio', 'correct', null, null, $i); + + $group[] = FormValidator :: createElement ('html_editor', 'answer['.$i.']',null, 'style="vertical-align:middle"'); + $group[] = FormValidator :: createElement ('html_editor', 'comment['.$i.']',null, 'style="vertical-align:middle"'); $group[] = FormValidator :: createElement ('text', 'weighting['.$i.']',null, 'style="vertical-align:middle" size="5" value="0"'); $form -> addGroup($group, null, null, '
- N° + '.get_lang('Number').' - True + '.get_lang('True').' - Answer + '.get_lang('Answer').' - Comment + '.get_lang('Comment').' - Weighting + '.get_lang('Weighting').'
'); diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index 70d6138ccc..182fd28511 100644 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -1,4 +1,4 @@ -
- N° + '.get_lang('Number').' - True + '.get_lang('True').' - Answer + '.get_lang('Answer').' - Comment + '.get_lang('Comment').' - Weighting + '.get_lang('Weighting').'
'); diff --git a/main/inc/lib/formvalidator/Element/html_editor.php b/main/inc/lib/formvalidator/Element/html_editor.php index 046e7f95e6..8a61c0fdf9 100644 --- a/main/inc/lib/formvalidator/Element/html_editor.php +++ b/main/inc/lib/formvalidator/Element/html_editor.php @@ -1,5 +1,5 @@ _persistantFreeze = true; $this->_type = 'html_editor'; $this->fullPage = false; - } - /** - * Check if the browser supports FCKeditor - * - * @access public - * @return boolean - */ - function browserSupported() - { - return FCKeditor :: IsCompatible(); - } - /** - * Return the HTML editor in HTML - * @return string - */ - function toHtml() - { - $value = $this->getValue(); - if ($this->fullPage) - { - if (strlen(trim($value)) == 0) - { - $value = ''; - $this->setValue($value); - } - } - if ($this->_flagFrozen) - { - return $this->getFrozenHtml(); - } - else - { - return $this->build_FCKeditor(); - } - } - /** - * Returns the htmlarea content in HTML - *@return string - */ - function getFrozenHtml() - { - return $this->getValue(); - } - /** - * Build this element using FCKeditor - */ - function build_FCKeditor() - { - global $language_interface, $fck_attribute; - if(! FCKeditor :: IsCompatible()) - { - return parent::toHTML(); - } + + @ $editor_lang = Database :: get_language_isocode($language_interface); $language_file = api_get_path(WEB_PATH).'/main/inc/lib/fckeditor/editor/lang/'.$editor_lang.'.js'; if (empty ($editor_lang) || !file_exists($language_file)) @@ -105,15 +56,18 @@ class HTML_QuickForm_html_editor extends HTML_QuickForm_textarea $editor_lang = 'en'; } $name = $this->getAttribute('name'); + + $this -> fck_editor = new FCKeditor($name); + $this -> fck_editor->BasePath = api_get_path(WEB_PATH).'main/inc/lib/fckeditor/'; - $fck_editor = new FCKeditor($name); - $fck_editor->BasePath = api_get_path(WEB_PATH).'main/inc/lib/fckeditor/'; - - $fck_editor->Width = $fck_attribute['Width'] ? $fck_attribute['Width'] : '990'; - $fck_editor->Height = $fck_attribute['Height'] ? $fck_attribute['Height'] : '400'; - $fck_editor->Value = $this->getValue(); + $this -> fck_editor->Width = $fck_attribute['Width'] ? $fck_attribute['Width'] : '990'; + $this -> fck_editor->Height = $fck_attribute['Height'] ? $fck_attribute['Height'] : '400'; + //We get the optionnals config parameters in $fck_attribute array - $fck_editor->Config = $fck_attribute['Config'] ? $fck_attribute['Config'] : array(); + $this -> fck_editor->Config = $fck_attribute['Config'] ? $fck_attribute['Config'] : array(); + + + $TBL_LANGUAGES = Database::get_main_table(TABLE_MAIN_LANGUAGE); @@ -136,7 +90,7 @@ class HTML_QuickForm_html_editor extends HTML_QuickForm_textarea $result_sql=api_sql_query($sql); $isocode_language=mysql_result($result_sql,0,0); - $fck_editor->Config['DefaultLanguage'] = $isocode_language; + $this -> fck_editor->Config['DefaultLanguage'] = $isocode_language; if($_SESSION['_course']['path']!=''){ @@ -146,34 +100,86 @@ class HTML_QuickForm_html_editor extends HTML_QuickForm_textarea $upload_path = api_get_path(REL_PATH)."main/upload/"; } - $fck_editor->Config['CustomConfigurationsPath'] = api_get_path(REL_PATH)."main/inc/lib/fckeditor/myconfig.js"; + $this -> fck_editor->Config['CustomConfigurationsPath'] = api_get_path(REL_PATH)."main/inc/lib/fckeditor/myconfig.js"; - $fck_editor->ToolbarSet = $fck_attribute['ToolbarSet'] ; + $this -> fck_editor->ToolbarSet = $fck_attribute['ToolbarSet'] ; - $fck_editor->Config['LinkBrowserURL'] = $fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Connector=connectors/php/connector.php&ServerPath=$upload_path"; + $this -> fck_editor->Config['LinkBrowserURL'] = $this -> fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Connector=connectors/php/connector.php&ServerPath=$upload_path"; //for image - $fck_editor->Config['ImageBrowserURL'] = $fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php&ServerPath=$upload_path"; + $this -> fck_editor->Config['ImageBrowserURL'] = $this -> fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php&ServerPath=$upload_path"; - $fck_editor->Config['ImageUploadURL'] = $fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Image&ServerPath=$upload_path" ; + $this -> fck_editor->Config['ImageUploadURL'] = $this -> fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Image&ServerPath=$upload_path" ; //for flash - $fck_editor->Config['FlashBrowserURL'] = $fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/php/connector.php&ServerPath=$upload_path"; + $this -> fck_editor->Config['FlashBrowserURL'] = $this -> fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/php/connector.php&ServerPath=$upload_path"; - $fck_editor->Config['FlashUploadURL'] = $fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Flash&ServerPath=$upload_path" ; + $this -> fck_editor->Config['FlashUploadURL'] = $this -> fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Flash&ServerPath=$upload_path" ; //for MP3 - $fck_editor->Config['MP3BrowserURL'] = $fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=MP3&Connector=connectors/php/connector.php&ServerPath=$upload_path"; + $this -> fck_editor->Config['MP3BrowserURL'] = $this -> fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=MP3&Connector=connectors/php/connector.php&ServerPath=$upload_path"; - $fck_editor->Config['MP3UploadURL'] = $fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=MP3&ServerPath=$upload_path" ; + $this -> fck_editor->Config['MP3UploadURL'] = $this -> fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=MP3&ServerPath=$upload_path" ; //for other media - $fck_editor->Config['VideoBrowserURL'] = $fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Video&Connector=connectors/php/connector.php&ServerPath=$upload_path"; - - $fck_editor->Config['VideoUploadURL'] = $fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Video&ServerPath=$upload_path" ; + $this -> fck_editor->Config['VideoBrowserURL'] = $this -> fck_editor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Video&Connector=connectors/php/connector.php&ServerPath=$upload_path"; - - $result .=$fck_editor->CreateHtml(); + $this -> fck_editor->Config['VideoUploadURL'] = $this -> fck_editor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Video&ServerPath=$upload_path" ; + + } + /** + * Check if the browser supports FCKeditor + * + * @access public + * @return boolean + */ + function browserSupported() + { + return FCKeditor :: IsCompatible(); + } + /** + * Return the HTML editor in HTML + * @return string + */ + function toHtml() + { + $value = $this->getValue(); + if ($this->fullPage) + { + if (strlen(trim($value)) == 0) + { + $value = ''; + $this->setValue($value); + } + } + if ($this->_flagFrozen) + { + return $this->getFrozenHtml(); + } + else + { + return $this->build_FCKeditor(); + } + } + /** + * Returns the htmlarea content in HTML + *@return string + */ + function getFrozenHtml() + { + return $this->getValue(); + } + /** + * Build this element using FCKeditor + */ + function build_FCKeditor() + { + if(! FCKeditor :: IsCompatible()) + { + return parent::toHTML(); + } + $this -> fck_editor->Value = $this->getValue(); + $result .=$this -> fck_editor->CreateHtml(); //Add a link to open the allowed html tags window //$result .= ''.get_lang('AllowedHTMLTags').'';