Error creating hotspot question when relpath != "/"

See https://support.chamilo.org/issues/8027
1.10.x
baelmyhu 9 years ago
parent f190655a6a
commit 8baa4bb96c
  1. 7
      main/exercice/hotspot_admin.inc.php
  2. 20
      main/inc/lib/javascript/hotspot/js/hotspot.js

@ -1024,6 +1024,7 @@ if ($modifyAnswers) {
<?php <?php
$swf_loaded = $answerType == HOT_SPOT_DELINEATION ? 'hotspot_delineation_admin' : 'hotspot_admin'; $swf_loaded = $answerType == HOT_SPOT_DELINEATION ? 'hotspot_delineation_admin' : 'hotspot_admin';
$height = 450; $height = 450;
$relPath = api_get_path(REL_PATH);
?> ?>
<div id="hotspot-container" class="center-block"> <div id="hotspot-container" class="center-block">
</div> </div>
@ -1036,13 +1037,15 @@ if ($modifyAnswers) {
new DelineationQuestion({ new DelineationQuestion({
questionId: <?php echo $modifyAnswers ?>, questionId: <?php echo $modifyAnswers ?>,
selector: '#hotspot-container', selector: '#hotspot-container',
for: 'admin' for: 'admin',
relpath: '<?php echo $relPath ?>'
}); });
<?php } else { ?> <?php } else { ?>
new HotspotQuestion({ new HotspotQuestion({
questionId: <?php echo $modifyAnswers ?>, questionId: <?php echo $modifyAnswers ?>,
selector: '#hotspot-container', selector: '#hotspot-container',
for: 'admin' for: 'admin',
relpath: '<?php echo $relPath ?>'
}); });
<?php } ?> <?php } ?>
}); });

@ -1,5 +1,7 @@
window.HotspotQuestion = (function () { window.HotspotQuestion = (function () {
return function (settings) { return function (settings) {
var HotspotModel = function (attributes) { var HotspotModel = function (attributes) {
this.attributes = attributes; this.attributes = attributes;
this.id = 0; this.id = 0;
@ -53,6 +55,9 @@ window.HotspotQuestion = (function () {
this.set('height', y - startY); this.set('height', y - startY);
} }
}; };
SquareModel.decode = function (hotspotInfo) { SquareModel.decode = function (hotspotInfo) {
var coords = hotspotInfo.coord.split('|'), var coords = hotspotInfo.coord.split('|'),
position = coords[0].split(';'), position = coords[0].split(';'),
@ -268,6 +273,7 @@ window.HotspotQuestion = (function () {
self.render(); self.render();
}); });
}; };
HotspotSVG.prototype.render = function () { HotspotSVG.prototype.render = function () {
var newEl = null; var newEl = null;
@ -321,6 +327,7 @@ window.HotspotQuestion = (function () {
self.render(); self.render();
}); });
}; };
AnswerSVG.prototype.render = function () { AnswerSVG.prototype.render = function () {
this.circleEl.setAttribute('cx', this.model.get('x')); this.circleEl.setAttribute('cx', this.model.get('x'));
this.circleEl.setAttribute('cy', this.model.get('y')); this.circleEl.setAttribute('cy', this.model.get('y'));
@ -349,6 +356,7 @@ window.HotspotQuestion = (function () {
$('.input-group').removeClass('active'); $('.input-group').removeClass('active');
}; };
HotspotSelect.prototype.render = function () { HotspotSelect.prototype.render = function () {
var self = this, var self = this,
$el = $(this.el); $el = $(this.el);
@ -1119,13 +1127,13 @@ window.HotspotQuestion = (function () {
switch (config.for) { switch (config.for) {
case 'admin': case 'admin':
xhrQuestion = $.getJSON('/main/exercice/hotspot_actionscript_admin.as.php', { xhrQuestion = $.getJSON(config.relpath+'main/exercice/hotspot_actionscript_admin.as.php', {
modifyAnswers: parseInt(config.questionId) modifyAnswers: parseInt(config.questionId)
}); });
break; break;
case 'user': case 'user':
xhrQuestion = $.getJSON('/main/exercice/hotspot_actionscript.as.php', { xhrQuestion = $.getJSON(config.relpath+'main/exercice/hotspot_actionscript.as.php', {
modifyAnswers: parseInt(config.questionId), modifyAnswers: parseInt(config.questionId),
exe_id: parseInt(config.exerciseId) exe_id: parseInt(config.exerciseId)
}); });
@ -1134,7 +1142,7 @@ window.HotspotQuestion = (function () {
case 'solution': case 'solution':
//no break //no break
case 'preview': case 'preview':
xhrQuestion = $.getJSON('/main/exercice/hotspot_answers.as.php', { xhrQuestion = $.getJSON(config.relPath+'main/exercice/hotspot_answers.as.php', {
modifyAnswers: parseInt(config.questionId), modifyAnswers: parseInt(config.questionId),
exe_id: parseInt(config.exerciseId) exe_id: parseInt(config.exerciseId)
}); });
@ -1732,13 +1740,13 @@ window.DelineationQuestion = (function () {
switch (config.for) { switch (config.for) {
case 'admin': case 'admin':
xhrQuestion = $.getJSON('/main/exercice/hotspot_actionscript_admin.as.php', { xhrQuestion = $.getJSON(config.relpath+'main/exercice/hotspot_actionscript_admin.as.php', {
modifyAnswers: parseInt(config.questionId) modifyAnswers: parseInt(config.questionId)
}); });
break; break;
case 'user': case 'user':
xhrQuestion = $.getJSON('/main/exercice/hotspot_actionscript.as.php', { xhrQuestion = $.getJSON(config.relpath+'main/exercice/hotspot_actionscript.as.php', {
modifyAnswers: parseInt(config.questionId) modifyAnswers: parseInt(config.questionId)
}); });
break; break;
@ -1746,7 +1754,7 @@ window.DelineationQuestion = (function () {
case 'solution': case 'solution':
//no break //no break
case 'preview': case 'preview':
xhrQuestion = $.getJSON('/main/exercice/hotspot_answers.as.php', { xhrQuestion = $.getJSON(config.relpath+'main/exercice/hotspot_answers.as.php', {
modifyAnswers: parseInt(config.questionId), modifyAnswers: parseInt(config.questionId),
exe_id: parseInt(config.exerciseId) exe_id: parseInt(config.exerciseId)
}); });

Loading…
Cancel
Save