diff --git a/assets/js/app.js b/assets/js/app.js
index c25793ac3d..beb15e5db6 100644
--- a/assets/js/app.js
+++ b/assets/js/app.js
@@ -20,6 +20,16 @@ window.luxon = global.luxon = DateTime;
import 'select2/dist/js/select2.full.min';
import 'select2/dist/css/select2.min.css';
+// Gets HTML content from tinymce
+window.getContentFromEditor = function (id) {
+ let content = '';
+ if (tinymce.get(id)) {
+ content = tinymce.get(id).getContent();
+ }
+
+ return content;
+};
+
//require('flatpickr');
//import('bootstrap-vue');
import('bootstrap');
diff --git a/assets/vue/main.js b/assets/vue/main.js
index c1b028d771..57d252d4d7 100644
--- a/assets/vue/main.js
+++ b/assets/vue/main.js
@@ -123,11 +123,8 @@ const app = createApp(App);
import { Quasar } from 'quasar'
import quasarUserOptions from './quasar-user-options'
-
// Tinymce
import Editor from './components/Editor';
-//window.tinymce = Editor;
-
// Prime
import PrimeVue from 'primevue/config'
diff --git a/assets/vue/views/documents/List.vue b/assets/vue/views/documents/List.vue
index 0006baa623..a019dfa141 100644
--- a/assets/vue/views/documents/List.vue
+++ b/assets/vue/views/documents/List.vue
@@ -190,9 +190,9 @@
-
-
-
+
+
+
diff --git a/assets/vue/views/documents/Update.vue b/assets/vue/views/documents/Update.vue
index 04cc767392..6e4b2039b0 100644
--- a/assets/vue/views/documents/Update.vue
+++ b/assets/vue/views/documents/Update.vue
@@ -1,4 +1,4 @@
-2222
+
'
- .'| '.get_lang('Question').' | '
- .''.$question.' | '
- .''
- .''
- .'| '.get_lang('Answer').' | '
- .''.$answer.' | '
- .'
';
+ '
+ | '.get_lang('Question').' |
+ '.$question.' |
+
+
+ | '.get_lang('Answer').' |
+ '.$answer.' |
+
';
}
}
@@ -10734,7 +10734,7 @@ class Exercise
$msg
);
- if ('learnpath' != $origin) {
+ if ('learnpath' !== $origin) {
$msg .= '
'.get_lang(
'Click this link to check the answer and/or give feedback'
).'';
diff --git a/public/main/exercise/exercise_report.php b/public/main/exercise/exercise_report.php
index 776b22c615..0747dd7f6f 100644
--- a/public/main/exercise/exercise_report.php
+++ b/public/main/exercise/exercise_report.php
@@ -546,7 +546,7 @@ if (($is_allowedToEdit || $is_tutor || api_is_coach()) &&
// Security token to protect deletion
$token = Security::get_token();
-$actions = Display::div($actions, ['class' => 'actions']);
+$actions = Display::toolbarAction('exercise_report', [$actions]);
$extra = '';
+ $htmlHeadXtra[] = '';
$htmlHeadXtra[] = api_get_js('jquery.highlight.js');
}
@@ -1241,7 +1241,9 @@ if ($objExercise->review_answers) {
echo '';
- echo '
';
+ echo '
';
}
// Get number of hotspot questions for javascript validation
$number_of_hotspot_questions = 0;
@@ -1353,14 +1355,11 @@ $loading = Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin');
}
});
-
$(".main_question").mouseout(function() {
$(this).removeClass("question_highlight");
});
$(".no_remind_highlight").hide();
-
-
$("form#exercise_form").prepend($("#exercise-description"));
$(\'button[name="previous_question_and_save"]\').on("touchstart click", function (e) {
@@ -1387,44 +1386,11 @@ $loading = Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin');
e.preventDefault();
e.stopPropagation();
var $this = $(this);
- var urlExtra = $this.data(\'url\') || null;
var questionId = parseInt($this.data(\'question\')) || 0;
save_now(questionId, "check_answers");
-
- var checkUrl = "'.$checkAnswersUrl.'";
-
- $("#global-modal").attr("data-keyboard", "false");
- $("#global-modal").attr("data-backdrop", "static");
- $("#global-modal").find(".close").hide();
-
- $("#global-modal .modal-body").load(checkUrl, function() {
- $("#global-modal .modal-body").append("");
- var continueTest = $("",{
- text: "'.addslashes(get_lang('ContinueTest')).'",
- title: "'.addslashes(get_lang('ContinueTest')).'",
- href: "javascript:void(0);",
- click: function(){
- $(this).attr("disabled", "disabled");
- $("#global-modal").modal("hide");
- $("#global-modal .modal-body").html("");
- }
- }).addClass("btn btn-default").appendTo("#global-modal .modal-body .btn-group");
-
- $("",{
- text: "'.addslashes(get_lang('EndTest')).'",
- title: "'.addslashes(get_lang('EndTest')).'",
- href: "javascript:void(0);",
- click: function() {
- $(this).attr("disabled", "disabled");
- continueTest.attr("disabled", "disabled");
- save_now(questionId, urlExtra);
- $("#global-modal .modal-body").html("'.addslashes($loading).addslashes(get_lang('Loading')).'");
- }
- }).addClass("btn btn-primary").appendTo("#global-modal .modal-body .btn-group");
- });
- $("#global-modal").modal("show");
});
+
$(\'button[name="save_now"]\').on(\'touchstart click\', function (e) {
e.preventDefault();
e.stopPropagation();
@@ -1494,12 +1460,12 @@ $loading = Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin');
// 4. choice for degree of certainty
var my_choiceDc = $(\'*[name*="choiceDegreeCertainty[\'+question_id+\']"]\').serialize();
- // Checking CkEditor
+ // Checking Editor
if (question_id) {
- if (CKEDITOR.instances["choice["+question_id+"]"]) {
- var ckContent = CKEDITOR.instances["choice["+question_id+"]"].getData();
+ const content = getContentFromEditor("choice"+question_id);
+ if (content) {
my_choice = {};
- my_choice["choice["+question_id+"]"] = ckContent;
+ my_choice["choice["+question_id+"]"] = content;
my_choice = $.param(my_choice);
}
}
@@ -1523,13 +1489,13 @@ $loading = Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin');
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&a=save_exercise_by_now",
data: dataparam,
success: function(return_value) {
- if (return_value == "ok") {
+ if (return_value.ok) {
$("#save_for_now_"+question_id).html(\''.
Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\');
- } else if (return_value == "error") {
+ } else if (return_value.error) {
$("#save_for_now_"+question_id).html(\''.
Display::return_icon('error.png', get_lang('Error'), [], ICON_SIZE_SMALL).'\');
- } else if (return_value == "one_per_page") {
+ } else if (return_value.type == "one_per_page") {
var url = "";
if ('.$reminder.' == 1 ) {
url = "exercise_reminder.php?'.$params.'&num='.$current_question.'";
@@ -1551,9 +1517,45 @@ $loading = Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin');
}
$("#save_for_now_"+question_id).html(\''.
- Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\');
+ Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\' + return_value.savedAnswerMessage);
+ // Show popup
if ("check_answers" === url_extra) {
+ var button = $(\'button[name="check_answers"]\');
+ var questionId = parseInt(button.data(\'question\')) || 0;
+ var urlExtra = button.data(\'url\') || null;
+ var checkUrl = "'.$checkAnswersUrl.'";
+
+ $("#global-modal").attr("data-keyboard", "false");
+ $("#global-modal").attr("data-backdrop", "static");
+ $("#global-modal").find(".close").hide();
+
+ $("#global-modal .modal-body").load(checkUrl, function() {
+ $("#global-modal .modal-body").append("");
+ var continueTest = $("",{
+ text: "'.addslashes(get_lang('ContinueTest')).'",
+ title: "'.addslashes(get_lang('ContinueTest')).'",
+ href: "javascript:void(0);",
+ click: function(){
+ $(this).attr("disabled", "disabled");
+ $("#global-modal").modal("hide");
+ $("#global-modal .modal-body").html("");
+ }
+ }).addClass("btn btn-default").appendTo("#global-modal .modal-body .btn-group");
+
+ $("",{
+ text: "'.addslashes(get_lang('EndTest')).'",
+ title: "'.addslashes(get_lang('EndTest')).'",
+ href: "javascript:void(0);",
+ click: function() {
+ $(this).attr("disabled", "disabled");
+ continueTest.attr("disabled", "disabled");
+ save_now(questionId, urlExtra);
+ $("#global-modal .modal-body").html("'.addslashes($loading).addslashes(get_lang('Loading')).'");
+ }
+ }).addClass("btn btn-primary").appendTo("#global-modal .modal-body .btn-group");
+ });
+ $("#global-modal").modal("show");
return true;
}
// window.quizTimeEnding will be reset in exercise.class.php
@@ -1585,11 +1587,11 @@ $loading = Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin');
var question_list = ['.implode(',', $questionList).'];
var free_answers = {};
$.each(question_list, function(index, my_question_id) {
- // Checking Ckeditor
+ // Checking editor
if (my_question_id) {
- if (CKEDITOR.instances["choice["+my_question_id+"]"]) {
- var ckContent = CKEDITOR.instances["choice["+my_question_id+"]"].getData();
- free_answers["free_choice["+my_question_id+"]"] = ckContent;
+ const content = getContentFromEditor("choice"+my_question_id);
+ if (content) {
+ free_answers["free_choice["+my_question_id+"]"] = content;
}
}
});
@@ -1608,8 +1610,9 @@ $loading = Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin');
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&a=save_exercise_by_now",
data: requestData,
success: function(return_value) {
- if (return_value == "ok") {
+ if (return_value.ok) {
if (validate == "validate") {
+ $("#save_all_response").html(return_value.savedAnswerMessage);
window.location = "'.$script_php.'?'.$params.'";
} else {
$("#save_all_response").html(\''.Display::return_icon('accept.png').'\');
@@ -1803,7 +1806,11 @@ $loading = Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin');
Display::button(
'save_now',
get_lang('Save and continue'),
- ['type' => 'button', 'class' => 'btn btn-info', 'data-question' => $questionId]
+ [
+ 'type' => 'button',
+ 'class' => 'btn btn-info',
+ 'data-question' => $questionId,
+ ]
),
' ',
];
@@ -1846,7 +1853,7 @@ $loading = Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin');
break;
}
}
- // end foreach()
+
if (ALL_ON_ONE_PAGE == $objExercise->type) {
$exerciseActions = $objExercise->show_button(
$questionId,
diff --git a/public/main/exercise/fill_blanks.class.php b/public/main/exercise/fill_blanks.class.php
index 0be6443bb6..cfe0a9222c 100644
--- a/public/main/exercise/fill_blanks.class.php
+++ b/public/main/exercise/fill_blanks.class.php
@@ -85,7 +85,7 @@ class FillBlanks extends Question
var field = document.getElementById("answer");
answer = field.value;
} else {
- answer = CKEDITOR.instances["answer"].getData();
+ answer = getContentFromEditor("answer");
}
// disable the save button, if not blanks have been created
@@ -220,7 +220,7 @@ class FillBlanks extends Question
var field = document.getElementById("answer");
answer = field.value;
} else {
- answer = CKEDITOR.instances["answer"].getData();
+ answer = getContentFromEditor("answer");
}
var blanks = answer.match(eval(blanksRegexp));
diff --git a/public/main/exercise/freeanswer.class.php b/public/main/exercise/freeanswer.class.php
index ce1b31afdf..a904d96374 100644
--- a/public/main/exercise/freeanswer.class.php
+++ b/public/main/exercise/freeanswer.class.php
@@ -23,7 +23,7 @@ class FreeAnswer extends Question
public function createAnswersForm($form)
{
- $form->addElement('text', 'weighting', get_lang('Score'));
+ $form->addText('weighting', get_lang('Score'));
global $text;
// setting the save button here and not in the question class.php
$form->addButtonSave($text, 'submitQuestion');
diff --git a/public/main/exercise/live_stats.php b/public/main/exercise/live_stats.php
index dd4f6625c4..902c807216 100644
--- a/public/main/exercise/live_stats.php
+++ b/public/main/exercise/live_stats.php
@@ -110,7 +110,7 @@ $(function() {
$actions = ''.
Display::return_icon('back.png', get_lang('Go back to the questions list'), '', ICON_SIZE_MEDIUM).'';
-echo $actions = Display::div($actions, ['class' => 'actions']);
+$actions = Display::toolbarAction('exercise_report', [$actions]);
echo Display::grid_html('live_stats');
diff --git a/public/main/exercise/question.class.php b/public/main/exercise/question.class.php
index 1e1b845f5a..c69dc8286e 100644
--- a/public/main/exercise/question.class.php
+++ b/public/main/exercise/question.class.php
@@ -1192,12 +1192,11 @@ abstract class Question
$file = api_get_path(SYS_PATH).$filePart;
$includeFile = '';
if (file_exists($file)) {
- $includeFile = '';
+ $includeFile = '';
$language = $iso;
}
echo $includeFile;
-
- echo '