From eac541615cad219845af16e6c8a3cc9b3761d8a7 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 9 Dec 2015 12:05:58 -0500 Subject: [PATCH 01/12] Add Bootstrap style to Delineation form - refs #7705 --- main/exercice/hotspot_admin.inc.php | 239 +++++++++++++++------------- 1 file changed, 125 insertions(+), 114 deletions(-) diff --git a/main/exercice/hotspot_admin.inc.php b/main/exercice/hotspot_admin.inc.php index 5c7563d749..70316011eb 100755 --- a/main/exercice/hotspot_admin.inc.php +++ b/main/exercice/hotspot_admin.inc.php @@ -569,7 +569,7 @@ if ($modifyAnswers) { - @@ -594,10 +594,6 @@ if ($modifyAnswers) {   * ' . get_lang('Thresholds') . ''; - } - if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> @@ -679,71 +675,73 @@ if ($modifyAnswers) { $selected2 = 'selected="selected"'; if ($k == $threadhold3[$i]) $selected3 = 'selected="selected"'; - $option1.=''; - $option2.=''; - $option3.=''; + $option1.=''; + $option2.=''; + $option3.=''; } ?> -
+ -

-

-

-

- - -

- % -

- % -

- % -
+

+

+ + +

+

+ + +

+

+ + +

-
- +

+ + +

-
- selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> - - - - -
+
+

+

+ + +

+ +

+ + +

+

+ + +

+

+ + +

  @@ -765,30 +763,38 @@ if ($modifyAnswers) { - - + + selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
- /> - -

- -
- -

-
- -

-
- +
+

+ +

+
+

+ + +

+

+
+ +

+

+
+ +

@@ -816,14 +822,13 @@ if ($modifyAnswers) { -
+ - - + +

+ +

+ +

+ + +

+

+ + +

+

+ + +

  @@ -895,7 +903,7 @@ if ($modifyAnswers) { if ($answerType == HOT_SPOT_DELINEATION) { if ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'oar') { ?> - + - + selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?> - - - - -
+
+

+

+ +

+ +

+
+ +

+

+
+ +

+

+
+ +

  From 60ababa9128186eaae52d881e067f92583609e0e Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Thu, 10 Dec 2015 07:59:49 +0100 Subject: [PATCH 02/12] Fix SOAP-ENC definition see BT#10566 --- main/webservices/courses_list.soap.php | 2 +- main/webservices/registration.soap.php | 2 +- main/webservices/user_info.soap.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main/webservices/courses_list.soap.php b/main/webservices/courses_list.soap.php index 9e1be78e11..d98b6641fb 100755 --- a/main/webservices/courses_list.soap.php +++ b/main/webservices/courses_list.soap.php @@ -44,7 +44,7 @@ $server->wsdl->addComplexType( 'SOAP-ENC:Array', array(), array( - array('ref'=>'SOAP:ENC:arrayType', + array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:courseDetails[]') ), 'tns:courseDetails' diff --git a/main/webservices/registration.soap.php b/main/webservices/registration.soap.php index 0bb6a0f074..6aee97b3e8 100755 --- a/main/webservices/registration.soap.php +++ b/main/webservices/registration.soap.php @@ -6299,7 +6299,7 @@ $server->wsdl->addComplexType( 'SOAP-ENC:Array', array(), array( - array('ref'=>'SOAP:ENC:arrayType', + array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:certificateDetails[]') ), 'tns:certificateDetails' diff --git a/main/webservices/user_info.soap.php b/main/webservices/user_info.soap.php index 2c08c83c58..8eddd3f9b3 100755 --- a/main/webservices/user_info.soap.php +++ b/main/webservices/user_info.soap.php @@ -42,7 +42,7 @@ $server->wsdl->addComplexType( 'SOAP-ENC:Array', array(), array( - array('ref'=>'SOAP:ENC:arrayType', + array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:courseDetails[]') ), 'tns:courseDetails' @@ -120,7 +120,7 @@ $server->wsdl->addComplexType( 'SOAP-ENC:Array', array(), array( - array('ref'=>'SOAP:ENC:arrayType', + array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType'=>'tns:eventDetails[]') ), 'tns:eventDetails' From 3b081e01f63239f5a80676c39ec6dd0bbbe72093 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 10 Dec 2015 17:49:39 -0500 Subject: [PATCH 03/12] Add library to create Delineation questions - refs #7705 --- main/plugin/hotspot2/js/hotspot.js | 538 ++++++++++++++++++++++++++++- 1 file changed, 537 insertions(+), 1 deletion(-) diff --git a/main/plugin/hotspot2/js/hotspot.js b/main/plugin/hotspot2/js/hotspot.js index 3d2325104a..e74c3d5035 100755 --- a/main/plugin/hotspot2/js/hotspot.js +++ b/main/plugin/hotspot2/js/hotspot.js @@ -399,7 +399,7 @@ var HotspotQuestion = (function () {
\n\ \n\ \n\ - ' + (this.hotspotSVG.model.get('name') ? this.hotspotSVG.model.get('name') : 'hotspot ' + this.hotspotIndex) + '\n\ + ' + (this.hotspotSVG.model.name ? this.hotspotSVG.model.name : 'hotspot ' + this.hotspotIndex) + '\n\ \n\ \n\ + \n\ + \n\ +
\n\ + '; + + $el.html(template); + + $el.find('select') + .on('focus', function () { + $('.input-group').removeClass('active'); + + $el.find('.input-group').addClass('active'); + + selectedPolygonIndex = self.model.id; + }); + + return this; + }; + }; + + var ContextMenu = function () { + this.el = $('
    ', { + id: 'hotspot-context-menu' + }).addClass('dropdown-menu').get(0); + + var self = this, + $el = $(this.el); + + this.onHide = function (callback) { + $(this).on('hide', function () { + callback(); + }); + }; + + this.render = function () { + var template = '\n\ +
  • \n\ + ' + 'ClosePolygon' + '\n\ +
  • \n\ + '; + + $el.html(template); + + $el.find('a') + .on('click', function (e) { + e.preventDefault(); + + $(self).trigger('hide'); + + $el.hide(); + }); + + return this; + }; + + this.show = function (x, y) { + $el.css({ + left: x, + top: y + }).show(); + }; + }; + + var AdminSvg = 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); + + var isDrawing = false; + + var contextMenu = new ContextMenu(); + contextMenu.onHide(function () { + var currentHotspot = self.collection.get(selectedPolygonIndex); + + $('[name="hotspot_coordinates[' + (currentHotspot.id + 1) + ']"]').val( + currentHotspot.encode() + ); + + isDrawing = false; + }); + + $el.on({ + 'dragstart': function (e) { + e.preventDefault(); + }, + 'click': function (e) { + e.preventDefault(); + + var currentPoint = getPointOnImage(self.el, e.clientX, e.clientY), + points = []; + + if (!isDrawing) { + isDrawing = true; + } else { + points = self.collection.get(selectedPolygonIndex).get('points'); + } + + points.push([currentPoint.x, currentPoint.y]); + + self.collection.get(selectedPolygonIndex).set('points', points); + }, + 'contextmenu': function (e) { + e.preventDefault(); + + if (!contextMenu.el.parentNode) { + $el.parent().append(contextMenu.render().el); + } + + var currentPoint = getPointOnImage(self.el, e.clientX, e.clientY); + + contextMenu.show(currentPoint.x, currentPoint.y); + } + }); + + return this; + }; + + this.renderPolygon = function (oarModel) { + var oarSVG = new PolygonSvg(oarModel); + + $el.append(oarSVG.render().el); + + var oarSelect = new HotspotSelect(oarModel); + + $el.parent().parent().find('.row').append( + oarSelect.render().el + ); + + return this; + }; + }; + + var startAdminSvg = function (questionInfo) { + var image = new Image(); + image.onload = function () { + var polygonCollection = new PolygonCollection(), + adminSvg = new AdminSvg(polygonCollection, image); + + $(config.selector) + .css('width', this.width) + .append( + adminSvg.render().el + ); + + $(config.selector).parent().prepend('
    '); + + $.each(questionInfo.hotspots, function (index, hotspotInfo) { + $('.input-group').removeClass('active'); + + var polygonModel = PolygonModel.decode(hotspotInfo); + polygonModel.id = index; + + polygonCollection.add(polygonModel); + }); + }; + image.src = questionInfo.image; + + lang = questionInfo.lang; + }; + + var UserSvg = function (answerModel, image) { + this.el = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + this.model = answerModel; + + var self = this, + $el = $(this.el); + + 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.renderDelineation(); + + var isDrawing = false; + + var contextMenu = new ContextMenu(); + contextMenu.onHide(function () { + var answerInput = $('hotspot[' + config.questionId + '][1]'), + choiceInput = $('choice[' + config.questionId + '][1]'); + + if (!answerInput.length) { + answerInput = $('', { + type: 'hidden', + name: 'hotspot[' + config.questionId + '][1]' + }).insertAfter($el); + } + + if (!choiceInput.length) { + choiceInput = $('', { + type: 'hidden', + name: 'choice[' + config.questionId + '][1]' + }).insertAfter($el); + } + + answerInput.val(self.model.encode()); + choiceInput.val(1); + + isDrawing = false; + }); + + $el.on({ + 'dragstart': function (e) { + e.preventDefault(); + }, + 'click': function (e) { + console.log(isDrawing); + e.preventDefault(); + + var currentPoint = getPointOnImage(self.el, e.clientX, e.clientY), + points = []; + + if (!isDrawing) { + isDrawing = true; + } else { + points = self.model.get('points'); + } + + points.push([currentPoint.x, currentPoint.y]); + + self.model.set('points', points); + }, + 'contextmenu': function (e) { + e.preventDefault(); + + if (!contextMenu.el.parentNode) { + $el.parent().append(contextMenu.render().el); + } + + var currentPoint = getPointOnImage(self.el, e.clientX, e.clientY); + + contextMenu.show(currentPoint.x, currentPoint.y); + } + }); + + return this; + }; + + this.renderDelineation = function () { + var delineationSvg = new PolygonSvg(this.model); + + $el.append( + delineationSvg.render().el + ); + }; + }; + + var startUserSvg = function (questionInfo) { + var image = new Image(); + image.onload = function () { + var answerModel = new AnswerModel({ + points: [] + }), + userSvg = new UserSvg(answerModel, image); + + $(config.selector) + .css('width', this.width) + .append( + userSvg.render().el + ); + }; + image.src = questionInfo.image; + }; + + var config = { + questionId: 0, + exerciseId: 0, + selector: null, + for: '' + }, + lang = {}, + selectedPolygonIndex = -1; + + var getPointOnImage = function (referenceElement, x, y) { + var pointerPosition = { + left: x + window.scrollX, + top: y + window.scrollY + }, + canvasOffset = { + x: referenceElement.getBoundingClientRect().left + window.scrollX, + y: referenceElement.getBoundingClientRect().top + window.scrollY + }; + + return { + x: Math.round(pointerPosition.left - canvasOffset.x), + y: Math.round(pointerPosition.top - canvasOffset.y) + }; + }; + + return { + init: function (settings) { + config = $.extend({ + questionId: 0, + selector: '' + }, settings); + + if (!config.questionId || !config.selector) { + return; + } + + var xhrQuestion = null; + + switch (config.for) { + case 'admin': + xhrQuestion = $.getJSON('/main/exercice/hotspot_actionscript_admin.as.php', { + modifyAnswers: parseInt(config.questionId) + }); + break; + + case 'user': + xhrQuestion = $.getJSON('/main/exercice/hotspot_actionscript.as.php', { + modifyAnswers: parseInt(config.questionId) + }); + break; + + case 'solution': + xhrQuestion = $.getJSON('/main/exercice/hotspot_answers.as.php', { + modifyAnswers: parseInt(config.questionId), + exe_id: parseInt(config.exerciseId) + }); + } + + $.when(xhrQuestion).done(function (questionInfo) { + switch (questionInfo.type) { + case 'admin': + startAdminSvg(questionInfo); + break; + + case 'user': + startUserSvg(questionInfo); + break; + + case 'solution': + break; + } + }); + } + }; +})(); From 86e4725e21789f2ddea38fa0093595118b7feff5 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 10 Dec 2015 17:50:17 -0500 Subject: [PATCH 04/12] Fix exercise_submit modal and remove E_NOTICE - refs #7705 --- main/exercice/exercise_submit_modal.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/main/exercice/exercise_submit_modal.php b/main/exercice/exercise_submit_modal.php index 3d71e914fd..84fbba8dc4 100755 --- a/main/exercice/exercise_submit_modal.php +++ b/main/exercice/exercise_submit_modal.php @@ -12,6 +12,9 @@ api_protect_course_script(false); require_once api_get_path(LIBRARY_PATH).'geometry.lib.php'; Display::display_reduced_header(); + +echo '
    '; + $message = null; $dbg_local = 0; $gradebook = null; @@ -29,14 +32,20 @@ if (empty ($exerciseResult)) { $exerciseResultCoordinates = isset($_REQUEST['exerciseResultCoordinates']) ? $_REQUEST['exerciseResultCoordinates'] : null; +$origin = ''; + if (empty($origin)) { $origin = Security::remove_XSS($_REQUEST['origin']); } // if origin is learnpath +$learnpath_id = 0; + if (empty($learnpath_id)) { $learnpath_id = Security::remove_XSS($_REQUEST['learnpath_id']); } +$learnpath_item_id = 0; + if (empty($learnpath_item_id)) { $learnpath_item_id = Security::remove_XSS($_REQUEST['learnpath_item_id']); } @@ -67,6 +76,8 @@ if (is_array($coords) && count($coords) > 0) { } } +$choice_value = ''; + $user_array = substr($user_array,0,-1); if (isset($_GET['choice'])){ @@ -109,8 +120,10 @@ if (empty($choice_value)) { //this is the real redirect function //echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";'; echo ' url = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";'; - echo "$('#dialog').load(url); "; + echo "$('#global-modal .modal-body').load(url);"; echo ''; + + exit; } $choice = array(); @@ -574,3 +587,7 @@ if ($links!='') { //self.parent.tb_remove(); '; } + +echo '
    '; + +Display::display_footer(); From 922876838a37a8f80047918675ecc6ffc8e1ac88 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 10 Dec 2015 17:51:29 -0500 Subject: [PATCH 05/12] Allow create Delineation questions - refs #7705 --- main/exercice/admin.php | 1 - main/exercice/exercise.class.php | 1 - main/exercice/hotspot_admin.inc.php | 18 +++++++++++++----- main/inc/lib/exercise.lib.php | 13 +++++++------ 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/main/exercice/admin.php b/main/exercice/admin.php index a38429d898..67fb8fb01a 100755 --- a/main/exercice/admin.php +++ b/main/exercice/admin.php @@ -348,7 +348,6 @@ $htmlHeadXtra[] = ''; $htmlHeadXtra[] = " - '; $header .= ''; //because this header closes so many times the '; +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; if ($show_headers) { $interbreadcrumb[] = array( diff --git a/main/plugin/hotspot2/css/hotspot.css b/main/inc/lib/javascript/hotspot/css/hotspot.css similarity index 100% rename from main/plugin/hotspot2/css/hotspot.css rename to main/inc/lib/javascript/hotspot/css/hotspot.css diff --git a/main/plugin/hotspot2/js/hotspot.js b/main/inc/lib/javascript/hotspot/js/hotspot.js similarity index 100% rename from main/plugin/hotspot2/js/hotspot.js rename to main/inc/lib/javascript/hotspot/js/hotspot.js From bfb797c5a4e110d28d7bad2d39133af1a0084969 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 10 Dec 2015 18:23:37 -0500 Subject: [PATCH 07/12] Remove old Hotspot library - refs #7705 --- main/exercice/admin.php | 112 ---- main/exercice/exercise.class.php | 112 +--- main/exercice/export/scorm/scorm_classes.php | 3 - main/plugin/hotspot/JavaScriptFlashGateway.js | 455 ----------------- .../plugin/hotspot/JavaScriptFlashGateway.swf | Bin 420 -> 0 bytes .../macromedia/javascript/JavaScriptProxy.as | 199 -------- .../javascript/JavaScriptSerializer.as | 478 ------------------ main/plugin/hotspot/hotspot.js | 104 ---- main/plugin/hotspot/hotspot_admin.fla | Bin 868864 -> 0 bytes main/plugin/hotspot/hotspot_admin.swf | Bin 67863 -> 0 bytes .../hotspot/hotspot_delineation_admin.fla | Bin 1005056 -> 0 bytes .../hotspot/hotspot_delineation_admin.swf | Bin 67739 -> 0 bytes .../hotspot/hotspot_delineation_user.fla | Bin 904704 -> 0 bytes .../hotspot/hotspot_delineation_user.swf | Bin 67443 -> 0 bytes main/plugin/hotspot/hotspot_solution.fla | Bin 1134080 -> 0 bytes main/plugin/hotspot/hotspot_solution.fla.as | 349 ------------- main/plugin/hotspot/hotspot_solution.swf | Bin 65589 -> 0 bytes main/plugin/hotspot/hotspot_user.fla | Bin 943104 -> 0 bytes main/plugin/hotspot/hotspot_user.swf | Bin 67942 -> 0 bytes main/plugin/hotspot/jsmethods.js | 86 ---- main/plugin/hotspot/vbmethods.vbscript | 13 - 21 files changed, 1 insertion(+), 1910 deletions(-) delete mode 100755 main/plugin/hotspot/JavaScriptFlashGateway.js delete mode 100755 main/plugin/hotspot/JavaScriptFlashGateway.swf delete mode 100755 main/plugin/hotspot/com/macromedia/javascript/JavaScriptProxy.as delete mode 100755 main/plugin/hotspot/com/macromedia/javascript/JavaScriptSerializer.as delete mode 100755 main/plugin/hotspot/hotspot.js delete mode 100755 main/plugin/hotspot/hotspot_admin.fla delete mode 100755 main/plugin/hotspot/hotspot_admin.swf delete mode 100755 main/plugin/hotspot/hotspot_delineation_admin.fla delete mode 100755 main/plugin/hotspot/hotspot_delineation_admin.swf delete mode 100755 main/plugin/hotspot/hotspot_delineation_user.fla delete mode 100755 main/plugin/hotspot/hotspot_delineation_user.swf delete mode 100755 main/plugin/hotspot/hotspot_solution.fla delete mode 100755 main/plugin/hotspot/hotspot_solution.fla.as delete mode 100755 main/plugin/hotspot/hotspot_solution.swf delete mode 100755 main/plugin/hotspot/hotspot_user.fla delete mode 100755 main/plugin/hotspot/hotspot_user.swf delete mode 100755 main/plugin/hotspot/jsmethods.js delete mode 100755 main/plugin/hotspot/vbmethods.vbscript diff --git a/main/exercice/admin.php b/main/exercice/admin.php index be489debb7..828b9df3fb 100755 --- a/main/exercice/admin.php +++ b/main/exercice/admin.php @@ -347,118 +347,6 @@ $htmlHeadXtra[] = api_get_js('d3/jquery.xcolor.js'); $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; -$htmlHeadXtra[] = " - - - -"; - Display::display_header($nameTools,'Exercise'); /* if ($objExercise->exercise_was_added_in_lp) { diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index c39d8d2e3d..b83bfe8142 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -2101,117 +2101,7 @@ class Exercise */ public function show_lp_javascript() { - return " - - - - "; + return ""; } /** diff --git a/main/exercice/export/scorm/scorm_classes.php b/main/exercice/export/scorm/scorm_classes.php index 5d9f3cb4e5..17393c7105 100755 --- a/main/exercice/export/scorm/scorm_classes.php +++ b/main/exercice/export/scorm/scorm_classes.php @@ -566,9 +566,6 @@ class ScormAnswerHotspot extends Answer { if ($this->standalone) { $header = ''; - $header .= ''; //because this header closes so many times the