Skip to content

Commit

Permalink
Merge branch 'release-1.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuriy Synyaiev committed Jun 15, 2022
2 parents ce5b6ad + 0c26207 commit 6462f26
Show file tree
Hide file tree
Showing 9 changed files with 776 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oat-sa/tao-item-runner-qti",
"version": "1.3.1",
"version": "1.3.2",
"displayName": "TAO Item Runner QTI",
"description": "TAO QTI Item Runner modules",
"files": [
Expand Down
6 changes: 6 additions & 0 deletions src/qtiCommonRenderer/helpers/Graphic.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ var GraphicHelper = {
* @param {String} [options.id] - the element identifier
* @param {String} [options.style = 'small-text'] - the style name according to the graphic-style.json keys
* @param {String} [options.title] - the text tooltip content
* @param {String} [options.disableEvents] - ignore events for the node
* @param {Boolean} [options.hide = false] - if the text starts hidden
* @returns {Raphael.Element} the created text
*/
Expand All @@ -520,6 +521,7 @@ var GraphicHelper = {
var content = options.content || '';
var style = options.style || 'small-text';
var title = options.title || '';
var disableEvents = options.disableEvents || false;
var factor = 1;

if (paper.width && paper.w) {
Expand All @@ -537,6 +539,10 @@ var GraphicHelper = {

text.attr(gstyle[style]);

if(disableEvents) {
text.node.setAttribute('pointer-events', 'none');
}

if (typeof factor !== 'undefined' && factor !== 1) {
fontSize = parseInt(text.attr('font-size'), 10);
scaledFontSize = Math.floor(fontSize / factor) + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ var _selectShape = function _selectShape(paper, element, $orderList) {
*/
var _unselectShape = function _unselectShape(paper, element, $orderList) {
var number = element.data('number');
var unsetNumbers = [number];

$orderList
.children(':not(.disabled)')
.each(function() {
unsetNumbers.push($(this).data('number'));
});

var activeNumber = Math.min.apply(Math, unsetNumbers) || number;

//update element state
element.active = false;
Expand All @@ -198,7 +207,11 @@ var _unselectShape = function _unselectShape(paper, element, $orderList) {
.children()
.removeClass('active')
.filter('[data-number=' + number + ']')
.removeClass('disabled')
.removeClass('disabled');

// Set (min) active number
$orderList
.find('li[data-number="' + activeNumber + '"]')
.addClass('active');
};

Expand All @@ -220,22 +233,10 @@ var _createTexts = function _createTexts(paper, size) {
content: number,
title: __('Remove'),
style: 'order-text',
hide: true
hide: true,
disableEvents: true
});

//clicking the text will has the same effect that clicking the shape: unselect.
text.click(function() {
paper.forEach(function(element) {
if (element.data('number') === number && element.events) {
//we just need to retrieve the right element
//call the click event
var evt = _.where(element.events, { name: 'click' });
if (evt.length && evt[0] && typeof evt[0].f === 'function') {
evt[0].f.call(element);
}
}
});
});
texts.push(text);
});
return texts;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
257 changes: 257 additions & 0 deletions test/qtiCommonRenderer/interactions/graphicOrder/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
{
"identifier": "i62a3147b138ca32082fe09df0385602",
"serial": "item_62a3b8f627720872170103",
"qtiClass": "assessmentItem",
"attributes": {
"identifier": "i62a3147b138ca32082fe09df0385602",
"title": "Item 1",
"label": "Item 1",
"xml:lang": "en-US",
"adaptive": false,
"timeDependent": false,
"toolName": "TAO",
"toolVersion": "2022.06",
"class": ""
},
"body": {
"serial": "container_containeritembody_62a3b8f62768f074734273",
"body": "\n <div class=\"grid-row\">\n <div class=\"col-12\">\n {{interaction_graphicorderinteraction_62a3b8f62c64e977237153}}\n </div>\n </div>\n ",
"elements": {
"interaction_graphicorderinteraction_62a3b8f62c64e977237153": {
"serial": "interaction_graphicorderinteraction_62a3b8f62c64e977237153",
"qtiClass": "graphicOrderInteraction",
"attributes": {
"responseIdentifier": "RESPONSE",
"class": "responsive"
},
"debug": { "relatedItem": "item_62a3b8f627720872170103" },
"choices": {
"choice_hotspotchoice_62a3b8f62e232454029792": {
"identifier": "hotspot_1",
"serial": "choice_hotspotchoice_62a3b8f62e232454029792",
"qtiClass": "hotspotChoice",
"attributes": {
"identifier": "hotspot_1",
"fixed": false,
"shape": "circle",
"coords": "248,251,42"
},
"debug": { "relatedItem": "item_62a3b8f627720872170103" }
},
"choice_hotspotchoice_62a3b8f62ec0c181204154": {
"identifier": "hotspot_2",
"serial": "choice_hotspotchoice_62a3b8f62ec0c181204154",
"qtiClass": "hotspotChoice",
"attributes": {
"identifier": "hotspot_2",
"fixed": false,
"shape": "rect",
"coords": "209,294,296,471"
},
"debug": { "relatedItem": "item_62a3b8f627720872170103" }
},
"choice_hotspotchoice_62a3b8f62f100134797857": {
"identifier": "hotspot_3",
"serial": "choice_hotspotchoice_62a3b8f62f100134797857",
"qtiClass": "hotspotChoice",
"attributes": {
"identifier": "hotspot_3",
"fixed": false,
"shape": "rect",
"coords": "19,23,125,320"
},
"debug": { "relatedItem": "item_62a3b8f627720872170103" }
},
"choice_hotspotchoice_62a3b8f62f5d3920253778": {
"identifier": "hotspot_4",
"serial": "choice_hotspotchoice_62a3b8f62f5d3920253778",
"qtiClass": "hotspotChoice",
"attributes": {
"identifier": "hotspot_4",
"fixed": false,
"shape": "rect",
"coords": "418,8,523,303"
},
"debug": { "relatedItem": "item_62a3b8f627720872170103" }
},
"choice_hotspotchoice_62a3b8f62fab7800384824": {
"identifier": "hotspot_5",
"serial": "choice_hotspotchoice_62a3b8f62fab7800384824",
"qtiClass": "hotspotChoice",
"attributes": {
"identifier": "hotspot_5",
"fixed": false,
"shape": "rect",
"coords": "160,27,393,182"
},
"debug": { "relatedItem": "item_62a3b8f627720872170103" }
},
"choice_hotspotchoice_62a3b8f62ffcc102585953": {
"identifier": "hotspot_6",
"serial": "choice_hotspotchoice_62a3b8f62ffcc102585953",
"qtiClass": "hotspotChoice",
"attributes": {
"identifier": "hotspot_6",
"fixed": false,
"shape": "ellipse",
"coords": "389,444,50,30"
},
"debug": { "relatedItem": "item_62a3b8f627720872170103" }
},
"choice_hotspotchoice_62a3b8f63048a404677677": {
"identifier": "hotspot_7",
"serial": "choice_hotspotchoice_62a3b8f63048a404677677",
"qtiClass": "hotspotChoice",
"attributes": {
"identifier": "hotspot_7",
"fixed": false,
"shape": "poly",
"coords": "27,424,90,463,144,466,185,392,154,346,82,348,26,392"
},
"debug": { "relatedItem": "item_62a3b8f627720872170103" }
}
},
"prompt": {
"serial": "container_containerstatic_62a3b8f62d5e7942314905",
"body": "",
"elements": {},
"attributes": [],
"debug": { "relatedItem": "item_62a3b8f627720872170103" }
},
"object": {
"serial": "qtiobject_62a3b8f630938679400409",
"qtiClass": "object",
"attributes": {
"data": "assets/sample.png",
"type": "image/png",
"width": 536,
"height": 482
},
"debug": { "relatedItem": "" }
}
}
},
"attributes": [],
"debug": { "relatedItem": "item_62a3b8f627720872170103" }
},
"debug": { "relatedItem": "item_62a3b8f627720872170103" },
"namespaces": {
"": "http://www.imsglobal.org/xsd/imsqti_v2p2",
"m": "http://www.w3.org/1998/Math/MathML",
"xsi": "http://www.w3.org/2001/XMLSchema-instance"
},
"schemaLocations": {
"http://www.imsglobal.org/xsd/imsqti_v2p2": "http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2.xsd"
},
"stylesheets": {},
"outcomes": {
"outcomedeclaration_62a3b8f62a59b199092649": {
"identifier": "SCORE",
"serial": "outcomedeclaration_62a3b8f62a59b199092649",
"qtiClass": "outcomeDeclaration",
"attributes": {
"identifier": "SCORE",
"cardinality": "single",
"baseType": "float",
"normalMaximum": 1
},
"debug": { "relatedItem": "item_62a3b8f627720872170103" },
"defaultValue": null
},
"outcomedeclaration_62a3b8f62b3ac341046782": {
"identifier": "MAXSCORE",
"serial": "outcomedeclaration_62a3b8f62b3ac341046782",
"qtiClass": "outcomeDeclaration",
"attributes": {
"identifier": "MAXSCORE",
"cardinality": "single",
"baseType": "float"
},
"debug": { "relatedItem": "item_62a3b8f627720872170103" },
"defaultValue": "1"
}
},
"responses": {
"responsedeclaration_62a3b8f628d9c119399102": {
"identifier": "RESPONSE",
"serial": "responsedeclaration_62a3b8f628d9c119399102",
"qtiClass": "responseDeclaration",
"attributes": {
"identifier": "RESPONSE",
"cardinality": "ordered",
"baseType": "identifier"
},
"debug": { "relatedItem": "item_62a3b8f627720872170103" },
"defaultValue": [],
"mapping": [],
"areaMapping": [],
"howMatch": "http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct",
"correctResponses": [
"hotspot_7",
"hotspot_2",
"hotspot_6",
"hotspot_3",
"hotspot_5",
"hotspot_4",
"hotspot_1"
],
"mappingAttributes": { "defaultValue": 0 },
"feedbackRules": {}
}
},
"feedbacks": {},
"responseProcessing": {
"serial": "response_templatesdriven_62a3b8f631702800926876",
"qtiClass": "responseProcessing",
"attributes": {},
"debug": { "relatedItem": "item_62a3b8f627720872170103" },
"processingType": "templateDriven",
"responseRules": [
{
"qtiClass": "responseCondition",
"responseIf": {
"qtiClass": "responseIf",
"expression": {
"qtiClass": "match",
"expressions": [
{
"qtiClass": "variable",
"attributes": { "identifier": "RESPONSE" }
},
{
"qtiClass": "correct",
"attributes": { "identifier": "RESPONSE" }
}
]
},
"responseRules": [
{
"qtiClass": "setOutcomeValue",
"attributes": { "identifier": "SCORE" },
"expression": {
"qtiClass": "baseValue",
"attributes": { "baseType": "float" },
"value": "1"
}
}
]
},
"responseElse": {
"qtiClass": "responseElse",
"responseRules": [
{
"qtiClass": "setOutcomeValue",
"attributes": { "identifier": "SCORE" },
"expression": {
"qtiClass": "baseValue",
"attributes": { "baseType": "float" },
"value": "0"
}
}
]
}
}
]
},
"apipAccessibility": ""
}
37 changes: 37 additions & 0 deletions test/qtiCommonRenderer/interactions/graphicOrder/sample.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2.xsd" identifier="i62a3147b138ca32082fe09df0385602" title="Item 1" label="Item 1" xml:lang="en-US" adaptive="false" timeDependent="false" toolName="TAO" toolVersion="2022.06">
<responseDeclaration identifier="RESPONSE" cardinality="ordered" baseType="identifier">
<correctResponse>
<value><![CDATA[hotspot_7]]></value>
<value><![CDATA[hotspot_2]]></value>
<value><![CDATA[hotspot_6]]></value>
<value><![CDATA[hotspot_3]]></value>
<value><![CDATA[hotspot_5]]></value>
<value><![CDATA[hotspot_4]]></value>
<value><![CDATA[hotspot_1]]></value>
</correctResponse>
</responseDeclaration>
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float" normalMaximum="1"/>
<outcomeDeclaration identifier="MAXSCORE" cardinality="single" baseType="float">
<defaultValue>
<value>1</value>
</defaultValue>
</outcomeDeclaration>
<itemBody>
<div class="grid-row">
<div class="col-12">
<graphicOrderInteraction responseIdentifier="RESPONSE" class="responsive">
<object data="assets/sample.png" type="image/png" width="536" height="482"/>
<hotspotChoice identifier="hotspot_1" fixed="false" shape="circle" coords="248,251,42"/>
<hotspotChoice identifier="hotspot_2" fixed="false" shape="rect" coords="209,294,296,471"/>
<hotspotChoice identifier="hotspot_3" fixed="false" shape="rect" coords="19,23,125,320"/>
<hotspotChoice identifier="hotspot_4" fixed="false" shape="rect" coords="418,8,523,303"/>
<hotspotChoice identifier="hotspot_5" fixed="false" shape="rect" coords="160,27,393,182"/>
<hotspotChoice identifier="hotspot_6" fixed="false" shape="ellipse" coords="389,444,50,30"/>
<hotspotChoice identifier="hotspot_7" fixed="false" shape="poly" coords="27,424,90,463,144,466,185,392,154,346,82,348,26,392"/>
</graphicOrderInteraction>
</div>
</div>
</itemBody>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>
</assessmentItem>
Loading

0 comments on commit 6462f26

Please sign in to comment.