Chamilo files changes due ckeditor integration. BT#8968

1.10.x
Julio Montoya 10 years ago
parent bc3eb4a3cf
commit 889cfa4042
  1. 40
      main/css/base.css
  2. 9
      main/document/create_document.php
  3. 39
      main/document/edit_document.php
  4. 19
      main/exercice/calculated_answer.class.php
  5. 15
      main/exercice/exercise.lib.php
  6. 20
      main/exercice/fill_blanks.class.php

@ -3540,7 +3540,6 @@ form .formw .freeze {
margin-bottom: .5em; margin-bottom: .5em;
} }
/* **************************************************** /* ****************************************************
END SKILL END SKILL
**************************************************** */ **************************************************** */
@ -3660,7 +3659,6 @@ form .formw .freeze {
} }
/* END SCORM CSS BASE*/ /* END SCORM CSS BASE*/
.skill_root { .skill_root {
box-shadow: 2px 2px 19px #aaa; box-shadow: 2px 2px 19px #aaa;
-o-box-shadow: 2px 2px 19px #aaa; -o-box-shadow: 2px 2px 19px #aaa;
@ -3715,6 +3713,44 @@ form .formw .freeze {
position:relative; position:relative;
} }
/* ****************************************************
END SKILL
**************************************************** */
/* list template document */
#frmModel{
height: 700px;
min-height: 100%;
overflow-y: scroll;
overflow-x: hidden
}
#frmModel ul{
list-style: none;
margin: 0;
padding: 0 .5em 0 1em;
}
#frmModel ul li:hover{
background-color: #FAFAFA;
border: 1px solid #F2F2F2;
}
#frmModel ul li{
text-align: center;
padding-top: 1em;
padding-bottom: 1em;
}
#frmModel ul li .title, #frmModel ul li .description{
padding-top: .5em;
padding-bottom: .5em;
width: auto;
}
.lp-add-item{
display:block;
height:890px;
width:250px;
position:relative;
}
/* end list template document */
.done_window { .done_window {
background-color: #73982C; background-color: #73982C;
} }

@ -39,6 +39,10 @@ $(document).ready(function() {
$(this).css("background-image", \'url("../img/hide0.png")\'); $(this).css("background-image", \'url("../img/hide0.png")\');
} }
); );
CKEDITOR.on("instanceReady", function (e) {
showTemplates();
});
}); });
function InnerDialogLoaded() { function InnerDialogLoaded() {
@ -223,7 +227,6 @@ if ($is_certificate_mode) {
$dir = '/certificates/'; $dir = '/certificates/';
} }
// Configuration for the FCKEDITOR
$doc_tree = explode('/', $dir); $doc_tree = explode('/', $dir);
$count_dir = count($doc_tree) -2; // "2" because at the begin and end there are 2 "/" $count_dir = count($doc_tree) -2; // "2" because at the begin and end there are 2 "/"
@ -673,8 +676,8 @@ if ($form->validate()) {
} }
// HTML-editor // HTML-editor
echo '<div class="row-fluid" style="overflow:hidden"> echo '<div class="row-fluid" style="overflow:hidden">
<div id="template_col" class="span2" style="width:162px"> <div id="template_col" class="span3" style="width:200px">
<div id="frmModel" style="overflow: visible;"></div> <div id="frmModel" ></div>
</div> </div>
<div id="hide_bar_template"></div> <div id="hide_bar_template"></div>
<div id="doc_form" class="span9"> <div id="doc_form" class="span9">

@ -57,39 +57,12 @@ $(document).ready(function() {
$(this).css("background-image", \'url("../img/hide0.png")\'); $(this).css("background-image", \'url("../img/hide0.png")\');
} }
); );
});
function InnerDialogLoaded() {
/*
var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);
return B.ClickFrame();
*/
var isIE = (navigator.appVersion.indexOf(\'MSIE\') != -1) ? true : false ;
var EditorFrame = null ;
if ( !isIE ) { CKEDITOR.on("instanceReady", function (e) {
EditorFrame = window.frames[0] ; showTemplates();
} else { });
// For this dynamic page window.frames[0] enumerates frames in a different order in IE. });
// We need a sure method to locate the frame that contains the online editor.
for ( var i = 0, n = window.frames.length ; i < n ; i++ ) {
if ( window.frames[i].location.toString().indexOf(\'InstanceName=content\') != -1 ) {
EditorFrame = window.frames[i] ;
}
}
}
if ( !EditorFrame ) {
return null ;
}
var B = new EditorFrame.FCKToolbarButton(\'Templates\', EditorFrame.FCKLang.Templates);
return B.ClickFrame();
};
function FCKeditor_OnComplete( editorInstance) {
document.getElementById(\'frmModel\').innerHTML = "<iframe style=\'height: 525px; width: 180px;\' scrolling=\'no\' frameborder=\'0\' src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";
}
</script>'; </script>';
$_SESSION['whereami'] = 'document/create'; $_SESSION['whereami'] = 'document/create';
@ -479,8 +452,8 @@ if ($owner_id == api_get_user_id() ||
Display::display_warning_message(get_lang('BrowserDontSupportsSVG')); Display::display_warning_message(get_lang('BrowserDontSupportsSVG'));
} }
echo '<div class="row-fluid" style="overflow:hidden"> echo '<div class="row-fluid" style="overflow:hidden">
<div id="template_col" class="span2" style="width:162px"> <div id="template_col" class="span3" style="width:200px">
<div id="frmModel" style="overflow: visible;"></div> <div id="frmModel"></div>
</div> </div>
<div id="hide_bar_template"></div> <div id="hide_bar_template"></div>
<div id="doc_form" class="span9"> <div id="doc_form" class="span9">

@ -48,7 +48,6 @@ class CalculatedAnswer extends Question
// javascript // // javascript //
echo '<script> echo '<script>
function parseTextNumber(textNumber, floatValue) { function parseTextNumber(textNumber, floatValue) {
if (textNumber.indexOf(".") > -1) { if (textNumber.indexOf(".") > -1) {
textNumber = parseFloat(textNumber); textNumber = parseFloat(textNumber);
@ -74,24 +73,28 @@ class CalculatedAnswer extends Question
document.getElementById("randomValue"+index).innerHTML = "'.get_lang("ExampleValue").': " + result; document.getElementById("randomValue"+index).innerHTML = "'.get_lang("ExampleValue").': " + result;
} }
function FCKeditor_OnComplete(editorInstance) { /*function FCKeditor_OnComplete(editorInstance) {
if (window.attachEvent) { if (window.attachEvent) {
editorInstance.EditorDocument.attachEvent("onkeyup", updateBlanks) ; editorInstance.EditorDocument.attachEvent("onkeyup", updateBlanks) ;
} else { } else {
editorInstance.EditorDocument.addEventListener("keyup", updateBlanks, true); editorInstance.EditorDocument.addEventListener("keyup", updateBlanks, true);
} }
} }*/
CKEDITOR.on("instanceCreated", function(e) {
if (e.editor.name === "answer") {
e.editor.on("change", updateBlanks);
}
});
var firstTime = true; var firstTime = true;
function updateBlanks() { function updateBlanks(e) {
if (firstTime) { if (firstTime) {
field = document.getElementById("answer"); field = document.getElementById("answer");
var answer = field.value; var answer = field.value;
} else { } else {
var oEditor = FCKeditorAPI.GetInstance("answer"); var answer = e.editor.getData();
//var answer = oEditor.GetXHTML(true);
var answer = oEditor.EditorDocument.body.innerHTML;
} }
var blanks = answer.match(/\[[^\]]*\]/g); var blanks = answer.match(/\[[^\]]*\]/g);
var fields = "<div class=\"control-group\"><label class=\"control-label\">'.get_lang('VariableRanges').'</label><div class=\"controls\"><table>"; var fields = "<div class=\"control-group\"><label class=\"control-label\">'.get_lang('VariableRanges').'</label><div class=\"controls\"><table>";
@ -125,7 +128,7 @@ class CalculatedAnswer extends Question
// answer // answer
$form->addElement('label', null, '<br /><br />'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank')); $form->addElement('label', null, '<br /><br />'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank'));
$form->addElement('html_editor', 'answer', '<img src="../img/fill_field.png">','id="answer" cols="122" rows="6" onkeyup="javascript: updateBlanks(this);"', array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350')); $form->addElement('html_editor', 'answer', '<img src="../img/fill_field.png">','id="answer" cols="122" rows="6" onkeyup="javascript: updateBlanks(this);"', array('ToolbarSet' => 'Test_Question_Description', 'Width' => '100%', 'Height' => '350'));
$form->addRule('answer', get_lang('GiveText'),'required'); $form->addRule('answer', get_lang('GiveText'),'required');
$form->addRule('answer', get_lang('DefineBlanks'),'regex','/\[.*\]/'); $form->addRule('answer', get_lang('DefineBlanks'),'regex','/\[.*\]/');

@ -12,9 +12,6 @@
* Modified by Hubert Borderiou 2011-10-21 Question Category * Modified by Hubert Borderiou 2011-10-21 Question Category
*/ */
// The initialization class for the online editor is needed here.
require_once dirname(__FILE__).'/../inc/lib/fckeditor/fckeditor.php';
/** /**
* Shows a question * Shows a question
* *
@ -147,17 +144,15 @@ function showQuestion(
} elseif ($answerType == FREE_ANSWER) { } elseif ($answerType == FREE_ANSWER) {
$fck_content = isset($user_choice[0]) && !empty($user_choice[0]['answer']) ? $user_choice[0]['answer']:null; $fck_content = isset($user_choice[0]) && !empty($user_choice[0]['answer']) ? $user_choice[0]['answer']:null;
$oFCKeditor = new FCKeditor("choice[".$questionId."]") ; $oFCKeditor = new CKeditor();
$oFCKeditor->ToolbarSet = 'Test_Free_Answer';
$oFCKeditor->ToolbarSet = 'TestFreeAnswer';
$oFCKeditor->Width = '100%'; $oFCKeditor->Width = '100%';
$oFCKeditor->Height = '200'; $oFCKeditor->Height = '200';
$oFCKeditor->Value = $fck_content; $oFCKeditor->Value = $fck_content;
$s .= $oFCKeditor->CreateHtml(); $s .= $oFCKeditor->editor("choice[".$questionId."]", $oFCKeditor->Value);
} elseif ($answerType == ORAL_EXPRESSION) { } elseif ($answerType == ORAL_EXPRESSION) {
//Add nanog //Add nanog
if (api_get_setting('enable_nanogong') == 'true') { if (api_get_setting('enable_nanogong') == 'true') {
require_once api_get_path(LIBRARY_PATH).'nanogong.lib.php';
//@todo pass this as a parameter //@todo pass this as a parameter
global $exercise_stat_info, $exerciseId, $exe_id; global $exercise_stat_info, $exerciseId, $exe_id;
@ -178,13 +173,13 @@ function showQuestion(
echo $nano->show_button(); echo $nano->show_button();
} }
$oFCKeditor = new FCKeditor("choice[".$questionId."]") ; $oFCKeditor = new CKeditor();
$oFCKeditor->ToolbarSet = 'TestFreeAnswer'; $oFCKeditor->ToolbarSet = 'TestFreeAnswer';
$oFCKeditor->Width = '100%'; $oFCKeditor->Width = '100%';
$oFCKeditor->Height = '150'; $oFCKeditor->Height = '150';
$oFCKeditor->ToolbarStartExpanded = false; $oFCKeditor->ToolbarStartExpanded = false;
$oFCKeditor->Value = '' ; $oFCKeditor->Value = '' ;
$s .= $oFCKeditor->CreateHtml(); $s .= $oFCKeditor->editor("choice[".$questionId."]", $oFCKeditor->Value);
} }
// Now navigate through the possible answers, using the max number of // Now navigate through the possible answers, using the max number of

@ -70,29 +70,23 @@ class FillBlanks extends Question
$setValues .= 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";'; $setValues .= 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";';
} }
} }
// javascript // javascript
echo '<script> echo '<script>
function FCKeditor_OnComplete(editorInstance) { CKEDITOR.on("instanceCreated", function(e) {
if (window.attachEvent) { if (e.editor.name === "answer") {
editorInstance.EditorDocument.attachEvent("onkeyup", updateBlanks) ; e.editor.on("change", updateBlanks);
} else { }
editorInstance.EditorDocument.addEventListener("keyup", updateBlanks, true); });
}
}
var firstTime = true; var firstTime = true;
function updateBlanks() { function updateBlanks(e) {
if (firstTime) { if (firstTime) {
field = document.getElementById("answer"); field = document.getElementById("answer");
var answer = field.value; var answer = field.value;
} else { } else {
var oEditor = FCKeditorAPI.GetInstance("answer"); var answer = e.editor.getData();
//var answer = oEditor.GetXHTML(true);
var answer = oEditor.EditorDocument.body.innerHTML;
} }
var blanks = answer.match(/\[[^\]]*\]/g); var blanks = answer.match(/\[[^\]]*\]/g);

Loading…
Cancel
Save