Parcourir la source

Allow create multiple instances for Hotspot Questions - refs #7705

Angel Fernando Quiroz Campos il y a 9 ans
Parent
commit
cf6f3983ec

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

@@ -3933,7 +3933,7 @@ class Exercise
 
                                 <script>
                                     $(document).on('ready', function () {
-                                        HotspotQuestion.init({
+                                        new HotspotQuestion({
                                             questionId: $questionId,
                                             exerciseId: $exeId,
                                             selector: '#hotspot-solution-$questionId',

+ 2 - 2
main/exercice/exercise_show.php

@@ -377,7 +377,7 @@ foreach ($questionList as $questionId) {
                             <div id=\"hotspot-solution\"></div>
                             <script>
                                 $(document).on('ready', function () {
-                                    HotspotQuestion.init({
+                                    new HotspotQuestion({
                                         questionId: $questionId,
                                         exerciseId: $id,
                                         selector: '#hotspot-solution',
@@ -519,7 +519,7 @@ foreach ($questionList as $questionId) {
                             <div id=\"hotspot-solution\"></div>
                             <script>
                                 $(document).on('ready', function () {
-                                    HotspotQuestion.init({
+                                    new HotspotQuestion({
                                         questionId: $questionId,
                                         exerciseId: $id,
                                         selector: '#hotspot-solution',

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

@@ -643,7 +643,7 @@ class ScormAnswerHotspot extends Answer
                     <div id="hotspot-{$this->questionJSId}"></div>
                     <script>
                         document.addEventListener('DOMContentListener', function () {
-                            HotspotQuestion.init({
+                            new HotspotQuestion({
                                 questionId: {$this->questionJSId},
                                 selector: '#hotspot-{$this->questionJSId}',
                                 for: 'user'

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

@@ -1033,13 +1033,13 @@ if ($modifyAnswers) {
     <script>
         $(document).on('ready', function () {
             <?php if ($answerType == HOT_SPOT_DELINEATION) { ?>
-                DelineationQuestion.init({
+                new DelineationQuestion({
                     questionId: <?php echo $modifyAnswers ?>,
                     selector: '#hotspot-container',
                     for: 'admin'
                 });
             <?php } else { ?>
-                HotspotQuestion.init({
+                new HotspotQuestion({
                     questionId: <?php echo $modifyAnswers ?>,
                     selector: '#hotspot-container',
                     for: 'admin'

+ 1 - 1
main/inc/lib/exercise.lib.php

@@ -1177,7 +1177,7 @@ HOTSPOT;
                                 <div class=\"hotspot-image\"></div>
                                 <script>
                                     $(document).on('ready', function () {
-                                        " . ($answerType == HOT_SPOT_DELINEATION ? 'DelineationQuestion' : 'HotspotQuestion') . ".init({
+                                        new " . ($answerType == HOT_SPOT_DELINEATION ? 'DelineationQuestion' : 'HotspotQuestion') . "({
                                             questionId: $questionId,
                                             selector: '#question_div_' + $questionId + ' .hotspot-image',
                                             for: 'user'

+ 3 - 8
main/inc/lib/javascript/hotspot/js/hotspot.js

@@ -1,4 +1,5 @@
-var HotspotQuestion = (function () {
+window.HotspotQuestion = (function () {
+    return function (settings) {
     var HotspotModel = function (attributes) {
         this.attributes = attributes;
         this.id = 0;
@@ -1139,9 +1140,6 @@ var HotspotQuestion = (function () {
     };
 
     var config, lang, selectedHotspotIndex = 0, contextMenu;
-
-    return {
-        init: function (settings) {
             config = $.extend({
                 questionId: 0,
                 selector: ''
@@ -1187,7 +1185,6 @@ var HotspotQuestion = (function () {
                         startHotspotsSolution(questionInfo);
                 }
             });
-        }
     };
 })();
 
@@ -1677,8 +1674,7 @@ var DelineationQuestion = (function () {
         };
     };
 
-    return {
-        init: function (settings) {
+    return function (settings) {
             config = $.extend({
                 questionId: 0,
                 selector: ''
@@ -1724,6 +1720,5 @@ var DelineationQuestion = (function () {
                         break;
                 }
             });
-        }
     };
 })();