Skip to content

Commit

Permalink
Fix hotspot creation issue when relpath not empty …
Browse files Browse the repository at this point in the history
See https://support.chamilo.org/issues/8027

Conflicts:
	main/inc/lib/javascript/hotspot/js/hotspot.js
  • Loading branch information
baelmyhu authored and jloguercio committed Feb 24, 2016
1 parent 383576c commit f0c4e72
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
6 changes: 5 additions & 1 deletion main/exercice/exercise.class.php
Expand Up @@ -3956,12 +3956,14 @@ public function manage_answer(
// 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>
Expand All @@ -3970,9 +3972,11 @@ public function manage_answer(
questionId: $questionId,
exerciseId: $exeId,
selector: '#hotspot-solution-$questionId',
for: 'solution'
for: 'solution',
relPath: '$relPath'
});
});
</script>
</td>
</tr>
Expand Down
11 changes: 7 additions & 4 deletions main/exercice/exercise_show.php
Expand Up @@ -369,8 +369,8 @@ function getFCK(vals,marksid) {
$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\">
Expand All @@ -381,7 +381,8 @@ function getFCK(vals,marksid) {
questionId: $questionId,
exerciseId: $id,
selector: '#hotspot-solution',
for: 'solution'
for: 'solution',
relPath: '$relPath'
});
});
</script>
Expand Down Expand Up @@ -511,6 +512,7 @@ function getFCK(vals,marksid) {
$resfree = Database::query($queryfree);
$questionScore= Database::result($resfree,0,"marks");
$totalScore+=$questionScore;
$relPath = api_get_path(REL_PATH);
echo '</table></td></tr>';

echo "
Expand All @@ -523,7 +525,8 @@ function getFCK(vals,marksid) {
questionId: $questionId,
exerciseId: $id,
selector: '#hotspot-solution',
for: 'solution'
for: 'solution',
relPath: '$relPath'
});
});
</script>
Expand Down
4 changes: 3 additions & 1 deletion main/exercice/export/scorm/scorm_classes.php
Expand Up @@ -637,6 +637,7 @@ function export()
$canClick = true;
//$tes = isset($_GET['modifyAnswers']) ? '0' : '1';
//echo $tes;
$relPath = api_get_path(REL_PATH);
$html .= <<<HTML
<tr>
<td>
Expand All @@ -646,7 +647,8 @@ function export()
new HotspotQuestion({
questionId: {$this->questionJSId},
selector: '#hotspot-{$this->questionJSId}',
for: 'user'
for: 'user',
relPath: '$relPath'
});
});
</script>
Expand Down
4 changes: 2 additions & 2 deletions main/exercice/hotspot_admin.inc.php
Expand Up @@ -1038,14 +1038,14 @@
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 } ?>
});
Expand Down
9 changes: 6 additions & 3 deletions main/inc/lib/exercise.lib.php
Expand Up @@ -1118,14 +1118,16 @@ public static function showQuestion(
$questionDescription = $objQuestionTmp->selectDescription();

if ($freeze) {
$relPath = api_get_path(REL_PATH);
echo "
<script>
$(document).on('ready', function () {
new " . ($answerType == HOT_SPOT ? "HotspotQuestion" : "DelineationQuestion" ) . "({
questionId: $questionId,
exerciseId: $exerciseId,
selector: '#hotspot-preview-$questionId',
for: 'preview'
for: 'preview',
relPath: '$relPath'
});
});
</script>
Expand Down Expand Up @@ -1191,7 +1193,7 @@ public static function showQuestion(
}

$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>
Expand All @@ -1201,7 +1203,8 @@ public static function showQuestion(
questionId: $questionId,
exerciseId: $exe_id,
selector: '#question_div_' + $questionId + ' .hotspot-image',
for: 'user'
for: 'user',
relPath: '$relPath'
});
});
</script>
Expand Down
10 changes: 5 additions & 5 deletions main/inc/lib/javascript/hotspot/js/hotspot.js
Expand Up @@ -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)
});
Expand Down Expand Up @@ -1740,21 +1740,21 @@ 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;

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)
});
Expand Down

0 comments on commit f0c4e72

Please sign in to comment.