Merge branch '1.10.x' of github.com:chamilo/chamilo-lms into 1.10.x

1.10.x
Yannick Warnier 9 years ago
commit 939c682c2b
  1. 32
      app/Migrations/Schema/V110/Version20151214164000.php
  2. 9
      main/exercice/hotspot_actionscript_admin.as.php
  3. 7
      main/exercice/question_list_admin.inc.php
  4. 15
      main/inc/lib/exercise.lib.php
  5. 87
      main/inc/lib/javascript/hotspot/js/hotspot.js

@ -0,0 +1,32 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V110;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Add indexes
*/
class Version20151214164000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$extraFieldValueTable = $schema->getTable('extra_field_values');
$extraFieldValueTable->addIndex(['field_id', 'item_id']);
$extraFieldTable = $schema->getTable('extra_field');
$extraFieldTable->addIndex(['extra_field_type']);
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

@ -8,6 +8,15 @@
*/
require_once '../inc/global.inc.php';
api_protect_course_script(false);
$isAllowedToEdit = api_is_allowed_to_edit(null,true);
if (!$isAllowedToEdit) {
api_not_allowed(true);
exit;
}
// set vars
$questionId = intval($_GET['modifyAnswers']);
$objQuestion = Question::read($questionId);

@ -248,14 +248,9 @@ if (!$inATest) {
echo $actions;
echo '</div>';
echo '<div class="question-list-description-block">';
echo '<p>';
//echo get_lang($question_class.$label);
echo get_lang($question_class);
echo '<br />';
echo '<p class="lead">' . get_lang($question_class) . '</p>';
//echo get_lang('Level').': '.$objQuestionTmp->selectLevel();
echo '<br />';
ExerciseLib::showQuestion($id, false, null, null, false, true, false, true, $objExercise->feedback_type, true);
echo '</p>';
echo '</div>';
echo '</div>';
unset($objQuestionTmp);

@ -1083,6 +1083,7 @@ HTML;
return $s;
}
} elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
global $exerciseId;
// Question is a HOT_SPOT
//checking document/images visibility
if (api_is_platform_admin() || api_is_course_admin()) {
@ -1110,7 +1111,19 @@ HTML;
$questionDescription = $objQuestionTmp->selectDescription();
if ($freeze) {
echo Display::img($objQuestionTmp->selectPicturePath());
echo "
<script>
$(document).on('ready', function () {
new " . ($answerType == HOT_SPOT ? "HotspotQuestion" : "DelineationQuestion" ) . "({
questionId: $questionId,
exerciseId: $exerciseId,
selector: '#hotspot-preview-$questionId',
for: 'preview'
});
});
</script>
<div id=\"hotspot-preview-$questionId\"></div>
";
return;
}

@ -990,8 +990,10 @@ window.HotspotQuestion = (function () {
$(config.selector).parent().prepend('\n\
<div id="hotspot-messages-' + config.questionId + '" class="alert alert-info">\n\
<span class="fa fa-info-circle" aria-hidden="true"></span>\n\
<span></span>\n\
<h4>\n\
<span class="fa fa-info-circle" aria-hidden="true"></span>\n\
<span></span>\n\
</h4>\n\
</div>\n\
');
@ -1170,10 +1172,13 @@ window.HotspotQuestion = (function () {
break;
case 'solution':
//no break
case 'preview':
xhrQuestion = $.getJSON('/main/exercice/hotspot_answers.as.php', {
modifyAnswers: parseInt(config.questionId),
exe_id: parseInt(config.exerciseId)
});
break;
}
$.when(xhrQuestion).done(function (questionInfo) {
@ -1187,15 +1192,16 @@ window.HotspotQuestion = (function () {
break;
case 'solution':
//no break
case 'preview':
startHotspotsSolution(questionInfo);
break;
}
});
};
})();
var DelineationQuestion = (function () {
'use strict';
window.DelineationQuestion = (function () {
var PolygonModel = function (attributes) {
this.id = 0;
this.name = '';
@ -1530,7 +1536,10 @@ var DelineationQuestion = (function () {
$(config.selector).parent().prepend('\n\
<div id="delineation-messages" class="alert alert-info">\n\
<span class="fa fa-info-circle" aria-hidden="true"> <span></span>' + lang.DelineationStatus1 + '</span>\n\
<h4>\n\
<span class="fa fa-info-circle" aria-hidden="true"></span>\n\
<span>' + lang.DelineationStatus1 + '</span>\n\
</h4>\n\
</div>\n\
');
@ -1651,7 +1660,10 @@ var DelineationQuestion = (function () {
$(config.selector).parent().prepend('\n\
<div id="delineation-messages" class="alert alert-info">\n\
<span class="fa fa-info-circle" aria-hidden="true"> <span></span>' + lang.DelineationStatus1 + '</span>\n\
<h4>\n\
<span class="fa fa-info-circle" aria-hidden="true"></span>\n\
<span>' + lang.DelineationStatus1 + '</span>\n\
</h4>\n\
</div>\n\
');
@ -1666,6 +1678,61 @@ var DelineationQuestion = (function () {
lang = questionInfo.lang;
};
var PreviewSVG = function (polygonCollection, image) {
this.collection = polygonCollection;
this.el = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
var self = this,
$el = $(this.el);
this.collection.onAdd(function (polygonModel) {
self.renderPolygon(polygonModel);
});
this.render = function () {
var imageSvg = document.createElementNS('http://www.w3.org/2000/svg', 'image');
imageSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', image.src);
imageSvg.setAttributeNS(null, 'width', image.width);
imageSvg.setAttributeNS(null, 'height', image.height);
this.el.setAttributeNS(null, 'version', '1.1');
this.el.setAttributeNS(null, 'viewBox', '0 0 ' + image.width + ' ' + image.height);
this.el.appendChild(imageSvg);
};
this.renderPolygon = function (oarModel) {
var oarSVG = new PolygonSvg(oarModel);
$el.append(oarSVG.render().el);
return this;
};
};
var startPreviewSvg = function (questionInfo) {
var image = new Image();
image.onload = function () {
var polygonCollection = new PolygonCollection(),
previewSvg = new AdminSvg(polygonCollection, image);
$(config.selector)
.css('width', this.width)
.append(
previewSvg.render().el
);
$.each(questionInfo.hotspots, function (index, hotspotInfo) {
var polygonModel = PolygonModel.decode(hotspotInfo);
polygonModel.id = index;
polygonCollection.add(polygonModel);
});
};
image.src = questionInfo.image;
lang = questionInfo.lang;
};
var config = {
questionId: 0,
exerciseId: 0,
@ -1717,10 +1784,13 @@ var DelineationQuestion = (function () {
break;
case 'solution':
//no break
case 'preview':
xhrQuestion = $.getJSON('/main/exercice/hotspot_answers.as.php', {
modifyAnswers: parseInt(config.questionId),
exe_id: parseInt(config.exerciseId)
});
break;
}
$.when(xhrQuestion).done(function (questionInfo) {
@ -1734,6 +1804,9 @@ var DelineationQuestion = (function () {
break;
case 'solution':
//no break
case 'preview':
startPreviewSvg(questionInfo);
break;
}
});

Loading…
Cancel
Save