diff --git a/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php b/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
index ec06be784c..0e36003743 100644
--- a/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
+++ b/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
@@ -77,7 +77,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
.'';
// show column comment when feedback is enable
- if ($objEx->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
+ if ($objEx->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
$html .= '
'.
@@ -196,49 +201,17 @@ class UniqueAnswerImage extends UniqueAnswer
$form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
- if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
- $form->addHtmlEditor(
- 'comment['.$i.']',
- null,
- null,
- false,
- $editorConfig
- );
- // Direct feedback
- // Adding extra feedback fields
- $group = [];
- $group['try'.$i] = $form->createElement('checkbox', 'try'.$i, null, get_lang('TryAgain'));
- $group['lp'.$i] = $form->createElement(
- 'select',
- 'lp'.$i,
- get_lang('SeeTheory').': ',
- $selectLpId
- );
- $group['destination'.$i] = $form->createElement(
- 'select',
- 'destination'.$i,
- get_lang('GoToQuestion').': ',
- $selectQuestion
- );
- $group['url'.$i] = $form->createElement(
- 'text',
- 'url'.$i,
- get_lang('Other').': ',
- [
- 'class' => 'col-md-2',
- 'placeholder' => get_lang('Other'),
- ]
- );
- $form->addGroup($group, 'scenario');
-
- $renderer->setElementTemplate(
- '
{error} {element}',
- 'scenario'
- );
- } else {
- $form->addHtmlEditor('comment['.$i.']', null, null, false, $editorConfig);
+ switch ($objExercise->getFeedbackType()) {
+ case EXERCISE_FEEDBACK_TYPE_DIRECT:
+ $this->setDirectOptions($i, $form, $renderer, $selectLpId, $selectQuestion);
+ break;
+ case EXERCISE_FEEDBACK_TYPE_POPUP:
+ default:
+ $form->addHtmlEditor('comment['.$i.']', null, null, false, $editorConfig);
+ break;
}
- $form->addText('weighting['.$i.']', null, null, ['class' => "col-md-1", 'value' => '0']);
+
+ $form->addText('weighting['.$i.']', null, null, ['class' => 'col-md-1', 'value' => '0']);
$form->addHtml('');
}
diff --git a/main/exercise/admin.php b/main/exercise/admin.php
index 393e9330bc..7a99f35983 100755
--- a/main/exercise/admin.php
+++ b/main/exercise/admin.php
@@ -453,7 +453,7 @@ if (!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspot
// if we are in question authoring, display warning to user is feedback not shown at the end of the test -ref #6619
// this test to display only message in the question authoring page and not in the question list page too
-if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_EXAM) {
+if ($objExercise->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_EXAM) {
echo Display::return_message(get_lang('TestFeedbackNotShown'), 'normal');
}
diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php
index 3e472b2488..c3a85a7204 100755
--- a/main/exercise/exercise.class.php
+++ b/main/exercise/exercise.class.php
@@ -308,14 +308,15 @@ class Exercise
return $this->attempts;
}
- /** returns the number of FeedbackType *
- * 0=>Feedback , 1=>DirectFeedback, 2=>NoFeedback.
+ /**
+ * Returns the number of FeedbackType
+ * 0: Feedback , 1: DirectFeedback, 2: NoFeedback.
*
* @return int - exercise attempts
*/
- public function selectFeedbackType()
+ public function getFeedbackType()
{
- return $this->feedback_type;
+ return (int) $this->feedback_type;
}
/**
@@ -1523,7 +1524,7 @@ class Exercise
// If direct we do not show results
$results_disabled = (int) $this->results_disabled;
- if ($feedback_type == EXERCISE_FEEDBACK_TYPE_DIRECT) {
+ if (in_array($feedback_type, [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
$results_disabled = 0;
}
$expired_time = (int) $this->expired_time;
@@ -1886,14 +1887,13 @@ class Exercise
$type = 'full';
}
- // form title
+ // Form title
+ $form_title = get_lang('NewEx');
if (!empty($_GET['exerciseId'])) {
$form_title = get_lang('ModifyExercise');
- } else {
- $form_title = get_lang('NewEx');
}
- $form->addElement('header', $form_title);
+ $form->addHeader($form_title);
// Title.
if (api_get_configuration_value('save_titles_as_html')) {
@@ -1940,6 +1940,7 @@ class Exercise
'Width' => '100%',
'Height' => '150',
];
+
if (is_array($type)) {
$editor_config = array_merge($editor_config, $type);
}
@@ -1954,56 +1955,9 @@ class Exercise
$skillList = [];
if ($type === 'full') {
- //Can't modify a DirectFeedback question
- if ($this->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_DIRECT) {
- // feedback type
- $radios_feedback = [];
- $radios_feedback[] = $form->createElement(
- 'radio',
- 'exerciseFeedbackType',
- null,
- get_lang('ExerciseAtTheEndOfTheTest'),
- '0',
- [
- 'id' => 'exerciseType_0',
- 'onclick' => 'check_feedback()',
- ]
- );
-
- if (api_get_setting('enable_quiz_scenario') === 'true') {
- // Can't convert a question from one feedback to another
- // if there is more than 1 question already added
- if ($this->selectNbrQuestions() == 0) {
- $radios_feedback[] = $form->createElement(
- 'radio',
- 'exerciseFeedbackType',
- null,
- get_lang('DirectFeedback'),
- '1',
- [
- 'id' => 'exerciseType_1',
- 'onclick' => 'check_direct_feedback()',
- ]
- );
- }
- }
-
- $radios_feedback[] = $form->createElement(
- 'radio',
- 'exerciseFeedbackType',
- null,
- get_lang('NoFeedback'),
- '2',
- ['id' => 'exerciseType_2']
- );
- $form->addGroup(
- $radios_feedback,
- null,
- [
- get_lang('FeedbackType'),
- get_lang('FeedbackDisplayOptions'),
- ]
- );
+ // Can't modify a DirectFeedback question.
+ if (!in_array($this->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
+ $this->setResultFeedbackGroup($form);
// Type of results display on the final page
$this->setResultDisabledGroup($form);
@@ -2037,41 +1991,7 @@ class Exercise
} else {
// if is Direct feedback but has not questions we can allow to modify the question type
if ($this->getQuestionCount() === 0) {
- // feedback type
- $radios_feedback = [];
- $radios_feedback[] = $form->createElement(
- 'radio',
- 'exerciseFeedbackType',
- null,
- get_lang('ExerciseAtTheEndOfTheTest'),
- '0',
- ['id' => 'exerciseType_0', 'onclick' => 'check_feedback()']
- );
-
- if (api_get_setting('enable_quiz_scenario') == 'true') {
- $radios_feedback[] = $form->createElement(
- 'radio',
- 'exerciseFeedbackType',
- null,
- get_lang('DirectFeedback'),
- '1',
- ['id' => 'exerciseType_1', 'onclick' => 'check_direct_feedback()']
- );
- }
- $radios_feedback[] = $form->createElement(
- 'radio',
- 'exerciseFeedbackType',
- null,
- get_lang('NoFeedback'),
- '2',
- ['id' => 'exerciseType_2']
- );
- $form->addGroup(
- $radios_feedback,
- null,
- [get_lang('FeedbackType'), get_lang('FeedbackDisplayOptions')]
- );
-
+ $this->setResultFeedbackGroup($form);
$this->setResultDisabledGroup($form);
// Type of questions disposition on page
@@ -2090,7 +2010,7 @@ class Exercise
$group->freeze();
// we force the options to the DirectFeedback exercisetype
- $form->addElement('hidden', 'exerciseFeedbackType', EXERCISE_FEEDBACK_TYPE_DIRECT);
+ $form->addElement('hidden', 'exerciseFeedbackType', $this->getFeedbackType());
$form->addElement('hidden', 'exerciseType', ONE_PER_PAGE);
// Type of questions disposition on page
@@ -2461,7 +2381,7 @@ class Exercise
$defaults['exerciseTitle'] = $this->get_formated_title();
$defaults['exerciseDescription'] = $this->selectDescription();
$defaults['exerciseAttempts'] = $this->selectAttempts();
- $defaults['exerciseFeedbackType'] = $this->selectFeedbackType();
+ $defaults['exerciseFeedbackType'] = $this->getFeedbackType();
$defaults['results_disabled'] = $this->selectResultsDisabled();
$defaults['propagate_neg'] = $this->selectPropagateNeg();
$defaults['save_correct_answers'] = $this->selectSaveCorrectAnswers();
@@ -2544,6 +2464,71 @@ class Exercise
}
}
+ /**
+ * @param $form
+ */
+ public function setResultFeedbackGroup(FormValidator $form)
+ {
+ // Feedback type.
+ $feedback = [];
+ $feedback[] = $form->createElement(
+ 'radio',
+ 'exerciseFeedbackType',
+ null,
+ get_lang('ExerciseAtTheEndOfTheTest'),
+ EXERCISE_FEEDBACK_TYPE_END,
+ [
+ 'id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_END,
+ 'onclick' => 'check_feedback()',
+ ]
+ );
+
+ if (api_get_setting('enable_quiz_scenario') === 'true') {
+ // Can't convert a question from one feedback to another
+ // if there is more than 1 question already added
+ if ($this->selectNbrQuestions() == 0) {
+ $feedback[] = $form->createElement(
+ 'radio',
+ 'exerciseFeedbackType',
+ null,
+ get_lang('DirectFeedback'),
+ EXERCISE_FEEDBACK_TYPE_DIRECT,
+ [
+ 'id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_DIRECT,
+ 'onclick' => 'check_direct_feedback()',
+ ]
+ );
+ }
+ }
+
+ $feedback[] = $form->createElement(
+ 'radio',
+ 'exerciseFeedbackType',
+ null,
+ get_lang('ExerciseDirectPopUp'),
+ EXERCISE_FEEDBACK_TYPE_POPUP,
+ ['id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_POPUP, 'onclick' => 'check_direct_feedback()']
+ );
+
+ $feedback[] = $form->createElement(
+ 'radio',
+ 'exerciseFeedbackType',
+ null,
+ get_lang('NoFeedback'),
+ EXERCISE_FEEDBACK_TYPE_EXAM,
+ ['id' => 'exerciseType_'.EXERCISE_FEEDBACK_TYPE_EXAM]
+ );
+
+ $form->addGroup(
+ $feedback,
+ null,
+ [
+ get_lang('FeedbackType'),
+ get_lang('FeedbackDisplayOptions'),
+ ]
+ );
+ }
+
/**
* function which process the creation of exercises.
*
@@ -3093,7 +3078,9 @@ class Exercise
$html = $label = '';
$hotspot_get = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null;
- if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) {
+ if (in_array($this->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP]) &&
+ $this->type == ONE_PER_PAGE
+ ) {
$urlTitle = get_lang('ContinueTest');
if ($questionNum == count($this->questionList)) {
$urlTitle = get_lang('EndTest');
@@ -3101,7 +3088,7 @@ class Exercise
$html .= Display::url(
$urlTitle,
- 'exercise_submit_modal.php?'.http_build_query([
+ api_get_path(WEB_CODE_PATH).'exercise/exercise_submit_modal.php?'.http_build_query([
'learnpath_id' => $safe_lp_id,
'learnpath_item_id' => $safe_lp_item_id,
'learnpath_item_view_id' => $safe_lp_item_view_id,
@@ -3348,7 +3335,7 @@ class Exercise
global $learnpath_id, $learnpath_item_id;
require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
$em = Database::getManager();
- $feedback_type = $this->selectFeedbackType();
+ $feedback_type = $this->getFeedbackType();
$results_disabled = $this->selectResultsDisabled();
if ($debug) {
@@ -4816,8 +4803,12 @@ class Exercise
$coords = explode('/', $user_answer);
$user_array = '';
foreach ($coords as $coord) {
- list($x, $y) = explode(';', $coord);
- $user_array .= round($x).';'.round($y).'/';
+ if (!empty($coord)) {
+ $parts = explode(';', $coord);
+ if (!empty($parts)) {
+ $user_array .= round($parts[0]).';'.round($parts[1]).'/';
+ }
+ }
}
$user_array = substr($user_array, 0, -1);
@@ -7200,7 +7191,10 @@ class Exercise
if ($currentQuestion != $i) {
continue;
} else {
- if ($this->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
+ if (!in_array(
+ $this->getFeedbackType(),
+ [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP]
+ )) {
// if the user has already answered this question
if (isset($exerciseResult[$questionId])) {
echo Display::return_message(
@@ -9650,7 +9644,7 @@ class Exercise
['id' => 'result_disabled_2', 'onclick' => 'check_results_disabled()']
);
- if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
+ if (in_array($this->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
$group = $form->addGroup(
$resultDisabledGroup,
null,
diff --git a/main/exercise/exercise_admin.php b/main/exercise/exercise_admin.php
index d1ef916bf5..8b4bd361de 100755
--- a/main/exercise/exercise_admin.php
+++ b/main/exercise/exercise_admin.php
@@ -185,7 +185,6 @@ if ($form->validate()) {
Display::display_header($nameTools, get_lang('Exercise'));
echo '';
-
if ($objExercise->id != 0) {
echo ' '.
Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'';
@@ -199,7 +198,7 @@ if ($form->validate()) {
}
$lp_id = (int) $lp_id;
echo " ".
- Display::return_icon('back.png', get_lang("BackTo").' '.get_lang("LearningPaths"), '', ICON_SIZE_MEDIUM)."";
+ Display::return_icon('back.png', get_lang("BackTo").' '.get_lang('LearningPaths'), '', ICON_SIZE_MEDIUM)."";
} else {
echo ' '.
Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM).
@@ -208,11 +207,11 @@ if ($form->validate()) {
}
echo ' ';
- if ($objExercise->feedback_type == 1) {
+ if (in_array($objExercise->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
echo Display::return_message(get_lang('DirectFeedbackCantModifyTypeQuestion'));
}
- if (api_get_setting('search_enabled') == 'true' &&
+ if (api_get_setting('search_enabled') === 'true' &&
!extension_loaded('xapian')
) {
echo Display::return_message(get_lang('SearchXapianModuleNotInstalled'), 'error');
diff --git a/main/exercise/exercise_result.php b/main/exercise/exercise_result.php
index 019a0e5df0..d1d359de08 100755
--- a/main/exercise/exercise_result.php
+++ b/main/exercise/exercise_result.php
@@ -100,7 +100,7 @@ if (api_is_course_admin() && !in_array($origin, ['learnpath', 'embeddable'])) {
echo '';
}
-$feedback_type = $objExercise->feedback_type;
+$feedback_type = $objExercise->getFeedbackType();
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
if (!empty($exercise_stat_info['data_tracking'])) {
@@ -222,7 +222,7 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) {
Session::erase('duration_time');
}
Display::display_footer();
-} elseif ($origin == 'embeddable') {
+} elseif ($origin === 'embeddable') {
if (api_is_allowed_to_session_edit()) {
Session::erase('objExercise');
Session::erase('exe_id');
@@ -232,14 +232,12 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) {
}
Session::write('attempt_remaining', $remainingMessage);
-
showEmbeddableFinishButton();
-
Display::display_reduced_footer();
} else {
$lp_mode = Session::read('lp_mode');
- $url = '../lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type.'#atoc_'.$learnpath_item_id;
- $href = $lp_mode == 'fullscreen' ? ' window.opener.location.href="'.$url.'" ' : ' top.location.href="'.$url.'"';
+ $url = '../lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->getFeedbackType().'#atoc_'.$learnpath_item_id;
+ $href = $lp_mode === 'fullscreen' ? ' window.opener.location.href="'.$url.'" ' : ' top.location.href="'.$url.'"';
if (api_is_allowed_to_session_edit()) {
Session::erase('objExercise');
diff --git a/main/exercise/exercise_show.php b/main/exercise/exercise_show.php
index 061de86dac..a783542402 100755
--- a/main/exercise/exercise_show.php
+++ b/main/exercise/exercise_show.php
@@ -127,7 +127,7 @@ if (empty($objExercise)) {
$objExercise = new Exercise();
$objExercise->read($exercise_id);
}
-$feedback_type = $objExercise->feedback_type;
+$feedback_type = $objExercise->getFeedbackType();
// Only users can see their own results
if (!$is_allowedToEdit) {
diff --git a/main/exercise/exercise_submit.php b/main/exercise/exercise_submit.php
index 4bc999e282..787cd52ff6 100755
--- a/main/exercise/exercise_submit.php
+++ b/main/exercise/exercise_submit.php
@@ -667,7 +667,7 @@ if ($formSent && isset($_POST)) {
// stores the user answer into the array
$exerciseResult[$key] = $choice[$key];
//saving each question
- if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
+ if (!in_array($objExercise->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
$nro_question = $current_question; // - 1;
$questionId = $key;
// gets the student choice for this question
@@ -1395,7 +1395,7 @@ if (!empty($error)) {
$i++;
continue;
} else {
- if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_DIRECT) {
+ if (!in_array($objExercise->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])) {
// if the user has already answered this question
if (isset($exerciseResult[$questionId])) {
// construction of the Question object
diff --git a/main/exercise/exercise_submit_modal.php b/main/exercise/exercise_submit_modal.php
index 2392c246b3..1cc6825f83 100755
--- a/main/exercise/exercise_submit_modal.php
+++ b/main/exercise/exercise_submit_modal.php
@@ -10,7 +10,7 @@ use ChamiloSession as Session;
*/
require_once __DIR__.'/../inc/global.inc.php';
-api_protect_course_script(false);
+api_protect_course_script();
require_once api_get_path(LIBRARY_PATH).'geometry.lib.php';
@@ -31,23 +31,30 @@ $origin = api_get_origin();
// if origin is learnpath
$learnpath_id = 0;
if (isset($_REQUEST['learnpath_id'])) {
- $learnpath_id = intval($_REQUEST['learnpath_id']);
+ $learnpath_id = (int) $_REQUEST['learnpath_id'];
}
$learnpath_item_id = 0;
if (isset($_REQUEST['learnpath_item_id'])) {
- $learnpath_item_id = intval($_REQUEST['learnpath_item_id']);
+ $learnpath_item_id = (int) $_REQUEST['learnpath_item_id'];
+}
+
+/** @var Exercise $objExercise */
+$objExercise = Session::read('objExercise');
+
+if (empty($objExercise)) {
+ api_not_allowed();
}
$_SESSION['hotspot_coord'] = [];
-$newquestionList = Session::read('newquestionList', []);
+$newQuestionList = Session::read('newquestionList', []);
$questionList = Session::read('questionList');
-$exerciseId = intval($_GET['exerciseId']);
-$exerciseType = intval($_GET['exerciseType']);
-$questionNum = intval($_GET['num']);
-$nbrQuestions = isset($_GET['nbrQuestions']) ? intval($_GET['nbrQuestions']) : null;
+$exerciseId = (int) $_GET['exerciseId'];
+$exerciseType = (int) $_GET['exerciseType'];
+$questionNum = (int) $_GET['num'];
+$nbrQuestions = isset($_GET['nbrQuestions']) ? (int) $_GET['nbrQuestions'] : null;
-//clean extra session variables
+// Clean extra session variables
Session::erase('objExerciseExtra'.$exerciseId);
Session::erase('exerciseResultExtra'.$exerciseId);
Session::erase('questionListExtra'.$exerciseId);
@@ -73,7 +80,6 @@ if (isset($_GET['choice'])) {
}
echo '';
-
// Getting the options by js
if (empty($choice_value)) {
echo "
';
diff --git a/main/exercise/question_pool.php b/main/exercise/question_pool.php
index 2ea1b0b12e..a566870aec 100755
--- a/main/exercise/question_pool.php
+++ b/main/exercise/question_pool.php
@@ -478,7 +478,10 @@ $new_question_list = [];
$new_question_list['-1'] = get_lang('All');
if (!empty($_course)) {
foreach ($question_list as $key => $item) {
- if ($objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_DIRECT) {
+ if (in_array(
+ $objExercise->getFeedbackType(),
+ [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP]
+ )) {
if (!in_array($key, [HOT_SPOT_DELINEATION, UNIQUE_ANSWER])) {
continue;
}
diff --git a/main/exercise/unique_answer.class.php b/main/exercise/unique_answer.class.php
index 54021c66c4..714e65d675 100755
--- a/main/exercise/unique_answer.class.php
+++ b/main/exercise/unique_answer.class.php
@@ -58,12 +58,18 @@ class UniqueAnswer extends Question
*/
$feedback_title = '';
- if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
- //Scenario
- $comment_title = ' | '.get_lang('Comment').' | ';
- $feedback_title = '
'.get_lang('Scenario').' | ';
- } else {
- $comment_title = '
'.get_lang('Comment').' | ';
+ switch ($obj_ex->getFeedbackType()) {
+ case EXERCISE_FEEDBACK_TYPE_DIRECT:
+ // Scenario
+ $comment_title = '
'.get_lang('Comment').' | ';
+ $feedback_title = '
'.get_lang('Scenario').' | ';
+ break;
+ case EXERCISE_FEEDBACK_TYPE_POPUP:
+ $comment_title = '
'.get_lang('Comment').' | ';
+ break;
+ default:
+ $comment_title = '
'.get_lang('Comment').' | ';
+ break;
}
$html = '
@@ -218,52 +224,14 @@ class UniqueAnswer extends Question
'required'
);
- if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
- $form->addHtmlEditor(
- 'comment['.$i.']',
- null,
- null,
- false,
- $editor_config
- );
- // Direct feedback
- //Adding extra feedback fields
- $group = [];
- $group['try'.$i] = $form->createElement(
- 'checkbox',
- 'try'.$i,
- null,
- get_lang('TryAgain')
- );
- $group['lp'.$i] = $form->createElement(
- 'select',
- 'lp'.$i,
- get_lang('SeeTheory').': ',
- $select_lp_id
- );
- $group['destination'.$i] = $form->createElement(
- 'select',
- 'destination'.$i,
- get_lang('GoToQuestion').': ',
- $select_question
- );
- $group['url'.$i] = $form->createElement(
- 'text',
- 'url'.$i,
- get_lang('Other').': ',
- [
- 'class' => 'col-md-2',
- 'placeholder' => get_lang('Other'),
- ]
- );
- $form->addGroup($group, 'scenario');
-
- $renderer->setElementTemplate(
- '{error} {element}',
- 'scenario'
- );
- } else {
- $form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config);
+ switch ($obj_ex->getFeedbackType()) {
+ case EXERCISE_FEEDBACK_TYPE_DIRECT:
+ $this->setDirectOptions($i, $form, $renderer, $select_lp_id, $select_question);
+ break;
+ case EXERCISE_FEEDBACK_TYPE_POPUP:
+ default:
+ $form->addHtmlEditor('comment['.$i.']', null, null, false, $editor_config);
+ break;
}
$form->addText('weighting['.$i.']', null, null, ['value' => '0']);
$form->addHtml('');
@@ -314,6 +282,59 @@ class UniqueAnswer extends Question
$form->setConstants(['nb_answers' => $nb_answers]);
}
+ public function setDirectOptions($i, FormValidator $form, $renderer, $select_lp_id, $select_question)
+ {
+ $editor_config = [
+ 'ToolbarSet' => 'TestProposedAnswer',
+ 'Width' => '100%',
+ 'Height' => '125',
+ ];
+
+ $form->addHtmlEditor(
+ 'comment['.$i.']',
+ null,
+ null,
+ false,
+ $editor_config
+ );
+ // Direct feedback
+ //Adding extra feedback fields
+ $group = [];
+ $group['try'.$i] = $form->createElement(
+ 'checkbox',
+ 'try'.$i,
+ null,
+ get_lang('TryAgain')
+ );
+ $group['lp'.$i] = $form->createElement(
+ 'select',
+ 'lp'.$i,
+ get_lang('SeeTheory').': ',
+ $select_lp_id
+ );
+ $group['destination'.$i] = $form->createElement(
+ 'select',
+ 'destination'.$i,
+ get_lang('GoToQuestion').': ',
+ $select_question
+ );
+ $group['url'.$i] = $form->createElement(
+ 'text',
+ 'url'.$i,
+ get_lang('Other').': ',
+ [
+ 'class' => 'col-md-2',
+ 'placeholder' => get_lang('Other'),
+ ]
+ );
+ $form->addGroup($group, 'scenario');
+
+ $renderer->setElementTemplate(
+ ' | {error} {element}',
+ 'scenario'
+ );
+ }
+
/**
* {@inheritdoc}
*/
diff --git a/main/exercise/unique_answer_no_option.class.php b/main/exercise/unique_answer_no_option.class.php
index 8d8fb56be4..d45fd06aad 100755
--- a/main/exercise/unique_answer_no_option.class.php
+++ b/main/exercise/unique_answer_no_option.class.php
@@ -54,7 +54,7 @@ class UniqueAnswerNoOption extends Question
*/
$feedback_title = '';
- if ($obj_ex->selectFeedbackType() == 1) {
+ if ($obj_ex->getFeedbackType() == 1) {
$editor_config['Width'] = '250';
$editor_config['Height'] = '110';
$comment_title = ' | '.get_lang('Comment').' | ';
diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php
index 8ec7d6696b..629f9699ed 100644
--- a/main/inc/lib/api.lib.php
+++ b/main/inc/lib/api.lib.php
@@ -468,7 +468,8 @@ define('ONE_PER_PAGE', 2);
define('EXERCISE_FEEDBACK_TYPE_END', 0); //Feedback - show score and expected answers
define('EXERCISE_FEEDBACK_TYPE_DIRECT', 1); //DirectFeedback - Do not show score nor answers
-define('EXERCISE_FEEDBACK_TYPE_EXAM', 2); //NoFeedback - Show score only
+define('EXERCISE_FEEDBACK_TYPE_EXAM', 2); // NoFeedback - Show score only
+define('EXERCISE_FEEDBACK_TYPE_POPUP', 3); // Popup BT#15827
define('RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS', 0); //show score and expected answers
define('RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS', 1); //Do not show score nor answers
diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php
index c6593362df..b8ad92f70f 100644
--- a/main/inc/lib/document.lib.php
+++ b/main/inc/lib/document.lib.php
@@ -5052,7 +5052,7 @@ class DocumentManager
if ($filetype == 'file') {
// Check the extension
$ext = explode('.', $path);
- $ext = strtolower($ext[sizeof($ext) - 1]);
+ $ext = strtolower($ext[count($ext) - 1]);
// HTML-files an some other types are shown in a frameset by default.
$is_browser_viewable_file = self::isBrowserViewable($ext);
@@ -5126,19 +5126,19 @@ class DocumentManager
preg_match('/shared_folder_session_'.$sessionId.'\/sf_user_'.api_get_user_id().'$/', urldecode($forcedownload_link)) ||
$isAllowedToEdit || api_is_platform_admin()
) {
- $force_download_html = ($size == 0) ? '' : ''.
+ $force_download_html = $size == 0 ? '' : ''.
Display::return_icon($forcedownload_icon, get_lang('Download'), [], ICON_SIZE_SMALL).'';
}
} elseif (!preg_match('/shared_folder/', urldecode($forcedownload_link)) ||
$isAllowedToEdit ||
api_is_platform_admin()
) {
- $force_download_html = ($size == 0) ? '' : ''.
+ $force_download_html = $size == 0 ? '' : ''.
Display::return_icon($forcedownload_icon, get_lang('Download'), [], ICON_SIZE_SMALL).'';
}
}
} else {
- $force_download_html = ($size == 0) ? '' : ''.
+ $force_download_html = $size == 0 ? '' : ''.
Display::return_icon($forcedownload_icon, get_lang('Download'), [], ICON_SIZE_SMALL).'';
}
@@ -5146,8 +5146,8 @@ class DocumentManager
if (api_get_setting('allow_my_files') === 'true' &&
api_get_setting('users_copy_files') === 'true' && api_is_anonymous() === false
) {
- $copy_myfiles_link = $filetype == 'file' ? $pageUrl.'?'.$courseParams.'&action=copytomyfiles&id='.$document_data['id'] : api_get_self().'?'.$courseParams;
- if ($filetype == 'file') {
+ $copy_myfiles_link = $filetype === 'file' ? $pageUrl.'?'.$courseParams.'&action=copytomyfiles&id='.$document_data['id'] : api_get_self().'?'.$courseParams;
+ if ($filetype === 'file') {
$copyToMyFiles = ''.
Display::return_icon('briefcase.png', get_lang('CopyToMyFiles'), [], ICON_SIZE_SMALL).' ';
@@ -5159,8 +5159,8 @@ class DocumentManager
$pdf_icon = '';
if (!$isAllowedToEdit &&
+ $filetype === 'file' &&
api_get_setting('students_export2pdf') == 'true' &&
- $filetype == 'file' &&
in_array($extension, ['html', 'htm'])
) {
$pdf_icon = ' '.
@@ -5172,7 +5172,7 @@ class DocumentManager
Display::return_icon('open_in_new_window.png', get_lang('OpenInANewWindow'), [], ICON_SIZE_SMALL).' ';
}
- if ($filetype == 'file') {
+ if ($filetype === 'file') {
// Sound preview
if (preg_match('/mp3$/i', urldecode($checkExtension)) ||
(preg_match('/wav$/i', urldecode($checkExtension))) ||
@@ -5195,7 +5195,7 @@ class DocumentManager
$url = 'show_content.php?'.$courseParams.'&id='.$document_data['id'];
$class = 'ajax';
if ($visibility == false) {
- $class = "ajax text-muted";
+ $class = 'ajax text-muted';
}
return Display::url(
@@ -5274,7 +5274,7 @@ class DocumentManager
'';
}
} else {
- if ($filetype == 'file') {
+ if ($filetype === 'file') {
// Sound preview with jplayer
if (preg_match('/mp3$/i', urldecode($checkExtension)) ||
(preg_match('/wav$/i', urldecode($checkExtension))) ||
diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php
index 6061c92b90..8cd4facc92 100644
--- a/main/inc/lib/exercise.lib.php
+++ b/main/inc/lib/exercise.lib.php
@@ -61,7 +61,7 @@ class ExerciseLib
return false;
}
- if ($exercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) {
+ if ($exercise->getFeedbackType() != EXERCISE_FEEDBACK_TYPE_END) {
$show_comment = false;
}
@@ -428,7 +428,7 @@ class ExerciseLib
]
)) {
$header = Display::tag('th', get_lang('Options'));
- if ($exercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END) {
+ if ($exercise->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_END) {
$header .= Display::tag('th', get_lang('Feedback'));
}
$s .= '';
@@ -4409,18 +4409,22 @@ EOT;
// Getting attempt info
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exeId);
- $studentInfo = api_get_user_info($exercise_stat_info['exe_user_id']);
// Getting question list
$question_list = [];
+ $studentInfo = [];
if (!empty($exercise_stat_info['data_tracking'])) {
+ $studentInfo = api_get_user_info($exercise_stat_info['exe_user_id']);
$question_list = explode(',', $exercise_stat_info['data_tracking']);
} else {
// Try getting the question list only if save result is off
if ($save_user_result == false) {
$question_list = $objExercise->get_validated_question_list();
}
- if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
+ if (in_array(
+ $objExercise->getFeedbackType(),
+ [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP]
+ )) {
$question_list = $objExercise->get_validated_question_list();
}
}
@@ -4458,7 +4462,7 @@ EOT;
// Not display expected answer, but score, and feedback
$show_all_but_expected_answer = false;
if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY &&
- $objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END
+ $objExercise->getFeedbackType() == EXERCISE_FEEDBACK_TYPE_END
) {
$show_all_but_expected_answer = true;
$show_results = true;
@@ -4523,7 +4527,7 @@ EOT;
if (($show_results || $show_only_score) && $origin !== 'embeddable') {
if (isset($exercise_stat_info['exe_user_id'])) {
- if ($studentInfo) {
+ if (!empty($studentInfo)) {
// Shows exercise header
echo $objExercise->showExerciseResultHeader(
$studentInfo,
@@ -4549,7 +4553,10 @@ EOT;
$exerciseResultCoordinates = null;
$delineationResults = null;
- if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
+ if (in_array(
+ $objExercise->getFeedbackType(),
+ [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP]
+ )) {
$loadChoiceFromSession = true;
$fromDatabase = false;
$exerciseResult = Session::read('exerciseResult');
@@ -4739,7 +4746,6 @@ EOT;
$totalScoreText = null;
$certificateBlock = '';
-
if (($show_results || $show_only_score) && $showTotalScore) {
if ($result['answer_type'] == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
echo ''.get_lang('YourResults').'
';
@@ -4774,14 +4780,16 @@ EOT;
}
$totalScoreText .= '';
- $certificateBlock = self::generateAndShowCertificateBlock(
- $total_score,
- $total_weight,
- $objExercise,
- $studentInfo['id'],
- $courseCode,
- $sessionId
- );
+ if (!empty($studentInfo)) {
+ $certificateBlock = self::generateAndShowCertificateBlock(
+ $total_score,
+ $total_weight,
+ $objExercise,
+ $studentInfo['id'],
+ $courseCode,
+ $sessionId
+ );
+ }
}
if ($result['answer_type'] == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
@@ -5379,7 +5387,9 @@ EOT;
{
$em = Database::getManager();
- if (ONE_PER_PAGE != $exercise['type'] || EXERCISE_FEEDBACK_TYPE_DIRECT == $exercise['feedback_type']) {
+ if (ONE_PER_PAGE != $exercise['type'] ||
+ in_array($exercise['feedback_type'], [EXERCISE_FEEDBACK_TYPE_DIRECT, EXERCISE_FEEDBACK_TYPE_POPUP])
+ ) {
return false;
}
diff --git a/main/inc/lib/geometry.lib.php b/main/inc/lib/geometry.lib.php
index 967af2310e..a45e51acc4 100755
--- a/main/inc/lib/geometry.lib.php
+++ b/main/inc/lib/geometry.lib.php
@@ -327,9 +327,16 @@ function convert_coordinates($coords, $sep = '|')
{
$points = [];
$pairs = explode($sep, $coords);
- foreach ($pairs as $idx => $pcoord) {
- list($x, $y) = explode(';', $pcoord);
- $points[] = ['x' => $x, 'y' => $y];
+ if (!empty($pairs)) {
+ foreach ($pairs as $idx => $pcoord) {
+ if (empty($pcoord)) {
+ continue;
+ }
+ $parts = explode(';', $pcoord);
+ if (!empty($parts)) {
+ $points[] = ['x' => $parts[0], 'y' => $parts[1]];
+ }
+ }
}
return $points;
diff --git a/main/inc/lib/urlmanager.lib.php b/main/inc/lib/urlmanager.lib.php
index fe37f4e999..ff8a25c8a1 100755
--- a/main/inc/lib/urlmanager.lib.php
+++ b/main/inc/lib/urlmanager.lib.php
@@ -1316,6 +1316,7 @@ class UrlManager
}
}
}
+
$response->addAssign(
'ajax_list_courses',
'innerHTML',