Browse Source

Fix hotspot creation issue when relpath not empty …

See https://support.chamilo.org/issues/8027

Conflicts:
	main/inc/lib/javascript/hotspot/js/hotspot.js
baelmyhu 9 years ago
parent
commit
f0c4e728ba

+ 5 - 1
main/exercice/exercise.class.php

@@ -3956,12 +3956,14 @@ class Exercise
                 // We made an extra table for the answers
 
                 if ($show_result) {
+                    $relPath = api_get_path(REL_PATH);
                     //	if ($origin != 'learnpath') {
                     echo '</table></td></tr>';
                     echo "
                         <tr>
                             <td colspan=\"2\">
                                 <p><em>" . get_lang('HotSpot') . "</em></p>
+
                                 <div id=\"hotspot-solution-$questionId\"></div>
 
                                 <script>
@@ -3970,9 +3972,11 @@ class Exercise
                                             questionId: $questionId,
                                             exerciseId: $exeId,
                                             selector: '#hotspot-solution-$questionId',
-                                            for: 'solution'
+                                            for: 'solution',
+                                            relPath: '$relPath'
                                         });
                                     });
+
                                 </script>
                             </td>
                         </tr>

+ 7 - 4
main/exercice/exercise_show.php

@@ -369,8 +369,8 @@ foreach ($questionList as $questionId) {
         $totalScore    += $question_result['score'];
 
         if ($show_results) {
-			echo '</table></td></tr>';
-
+            $relPath = api_get_path(REL_PATH);
+            echo '</table></td></tr>';
             echo "
                     <tr>
                         <td colspan=\"2\">
@@ -381,7 +381,8 @@ foreach ($questionList as $questionId) {
                                         questionId: $questionId,
                                         exerciseId: $id,
                                         selector: '#hotspot-solution',
-                                        for: 'solution'
+                                        for: 'solution',
+                                        relPath: '$relPath'
                                     });
                                 });
                             </script>
@@ -511,6 +512,7 @@ foreach ($questionList as $questionId) {
             $resfree = Database::query($queryfree);
             $questionScore= Database::result($resfree,0,"marks");
             $totalScore+=$questionScore;
+            $relPath = api_get_path(REL_PATH);
             echo '</table></td></tr>';
 
             echo "
@@ -523,7 +525,8 @@ foreach ($questionList as $questionId) {
                                         questionId: $questionId,
                                         exerciseId: $id,
                                         selector: '#hotspot-solution',
-                                        for: 'solution'
+                                        for: 'solution',
+                                        relPath: '$relPath'
                                     });
                                 });
                             </script>

+ 3 - 1
main/exercice/export/scorm/scorm_classes.php

@@ -637,6 +637,7 @@ class ScormAnswerHotspot extends Answer
 		$canClick = true;
 		//$tes = isset($_GET['modifyAnswers']) ? '0' : '1';
 		//echo $tes;
+		$relPath = api_get_path(REL_PATH);
         $html .= <<<HTML
             <tr>
                 <td>
@@ -646,7 +647,8 @@ class ScormAnswerHotspot extends Answer
                             new HotspotQuestion({
                                 questionId: {$this->questionJSId},
                                 selector: '#hotspot-{$this->questionJSId}',
-                                for: 'user'
+                                for: 'user',
+                                relPath: '$relPath'
                             });
                         });
                     </script>

+ 2 - 2
main/exercice/hotspot_admin.inc.php

@@ -1038,14 +1038,14 @@ if ($modifyAnswers) {
                     questionId: <?php echo $modifyAnswers ?>,
                     selector: '#hotspot-container',
                     for: 'admin',
-                    relpath: '<?php echo $relPath ?>'
+                    relPath: '<?php echo $relPath ?>'
                 });
             <?php } else { ?>
                 new HotspotQuestion({
                     questionId: <?php echo $modifyAnswers ?>,
                     selector: '#hotspot-container',
                     for: 'admin',
-                    relpath: '<?php echo $relPath ?>'
+                    relPath: '<?php echo $relPath ?>'
                 });
             <?php } ?>
         });

+ 6 - 3
main/inc/lib/exercise.lib.php

@@ -1118,6 +1118,7 @@ HTML;
             $questionDescription = $objQuestionTmp->selectDescription();
 
             if ($freeze) {
+                $relPath = api_get_path(REL_PATH);
                 echo "
                     <script>
                         $(document).on('ready', function () {
@@ -1125,7 +1126,8 @@ HTML;
                                 questionId: $questionId,
                                 exerciseId: $exerciseId,
                                 selector: '#hotspot-preview-$questionId',
-                                for: 'preview'
+                                for: 'preview',
+                                relPath: '$relPath'
                             });
                         });
                     </script>
@@ -1191,7 +1193,7 @@ HOTSPOT;
             }
 
             $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
-
+            $relPath = api_get_path(REL_PATH);
             $s .= "
                             <div class=\"col-sm-8 col-md-9\">
                                 <div class=\"hotspot-image\"></div>
@@ -1201,7 +1203,8 @@ HOTSPOT;
                                             questionId: $questionId,
                                             exerciseId: $exe_id,
                                             selector: '#question_div_' + $questionId + ' .hotspot-image',
-                                            for: 'user'
+                                            for: 'user',
+                                            relPath: '$relPath'
                                         });
                                     });
                                 </script>

+ 5 - 5
main/inc/lib/javascript/hotspot/js/hotspot.js

@@ -1127,13 +1127,13 @@ window.HotspotQuestion = (function () {
 
         switch (config.for) {
             case 'admin':
-                xhrQuestion = $.getJSON(config.relpath + 'main/exercice/hotspot_actionscript_admin.as.php', {
+                xhrQuestion = $.getJSON(config.relPath+'main/exercice/hotspot_actionscript_admin.as.php', {
                     modifyAnswers: parseInt(config.questionId)
                 });
                 break;
 
             case 'user':
-                xhrQuestion = $.getJSON(config.relpath + 'main/exercice/hotspot_actionscript.as.php', {
+                xhrQuestion = $.getJSON(config.relPath+'main/exercice/hotspot_actionscript.as.php', {
                     modifyAnswers: parseInt(config.questionId),
                     exe_id: parseInt(config.exerciseId)
                 });
@@ -1740,13 +1740,13 @@ window.DelineationQuestion = (function () {
 
             switch (config.for) {
                 case 'admin':
-                    xhrQuestion = $.getJSON(config.relpath + 'main/exercice/hotspot_actionscript_admin.as.php', {
+                    xhrQuestion = $.getJSON(config.relPath+'main/exercice/hotspot_actionscript_admin.as.php', {
                         modifyAnswers: parseInt(config.questionId)
                     });
                     break;
 
                 case 'user':
-                    xhrQuestion = $.getJSON(config.relpath + 'main/exercice/hotspot_actionscript.as.php', {
+                    xhrQuestion = $.getJSON(config.relPath+'main/exercice/hotspot_actionscript.as.php', {
                         modifyAnswers: parseInt(config.questionId)
                     });
                     break;
@@ -1754,7 +1754,7 @@ window.DelineationQuestion = (function () {
                 case 'solution':
                     //no break
                 case 'preview':
-                    xhrQuestion = $.getJSON(config.relpath + 'main/exercice/hotspot_answers.as.php', {
+                    xhrQuestion = $.getJSON(config.relPath+'main/exercice/hotspot_answers.as.php', {
                         modifyAnswers: parseInt(config.questionId),
                         exe_id: parseInt(config.exerciseId)
                     });