qti3-item-player-vue3 0.2.16 → 0.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -118,7 +118,7 @@ let qtiCustomInteractionContext = {
118
118
  * getInstance.
119
119
  * If the PCI is interested in being notified it will provide a function
120
120
  * to implement setRenderingProperties.
121
-
121
+ *
122
122
  * @param {Object} instance The Custom Interaction Instance.
123
123
  * @param {Object} properties Properties is an Object consisting of two properties:
124
124
  * {
@@ -131,7 +131,23 @@ let qtiCustomInteractionContext = {
131
131
  console.log('[PCI Context] Interaction SetRenderingProperties:', properties)
132
132
  instance.setRenderingProperties(properties)
133
133
  }
134
+ },
135
+
136
+ /**
137
+ * Allow the delivery engine to check the validity of PCI instance.
138
+ * If the PCI provides a checkValidity function then use that function.
139
+ * Otherwise, return boolean true (is valid).
140
+ * @param {Object} instance The Custom Interaction Instance.
141
+ */
142
+ checkValidity (instance) {
143
+ // default to true
144
+ let isValid = true
145
+ if ((typeof instance.checkValidity !== 'undefined') && typeof instance.checkValidity == 'function') {
146
+ isValid = instance.checkValidity()
147
+ }
148
+ return isValid
134
149
  }
150
+
135
151
  }
136
152
 
137
153
  define('qtiCustomInteractionContext',[],function(){
@@ -474,6 +490,10 @@ const QTI_PCI_API = {
474
490
  qtiCustomInteractionContext.setRenderingProperties(this.getInstance(), properties)
475
491
  },
476
492
 
493
+ checkValidity () {
494
+ return qtiCustomInteractionContext.checkValidity(this.getInstance())
495
+ },
496
+
477
497
  NotifyPciChildLoaded () {
478
498
  if (self == top) return
479
499
 
@@ -489,12 +509,13 @@ const QTI_PCI_API = {
489
509
 
490
510
  if (self == top) return
491
511
 
512
+ const isValid = this.checkValidity()
492
513
  const height = this.getDom().clientHeight
493
514
  const computedHeight = (height) ? height : 0
494
515
  const width = this.getDom().clientWidth
495
516
  const computedWidth = (width) ? width : 0
496
517
 
497
- window.parent.postMessage({ message: 'PciReady', identifier: this.getResponseIdentifier(), width: computedWidth, height: computedHeight, success: true },'*')
518
+ window.parent.postMessage({ message: 'PciReady', identifier: this.getResponseIdentifier(), valid: isValid, width: computedWidth, height: computedHeight, success: true },'*')
498
519
  },
499
520
 
500
521
  NotifyPciDone (instance, response, state, status) {
@@ -522,7 +543,7 @@ const QTI_PCI_API = {
522
543
  })
523
544
 
524
545
  window.parent.postMessage({ message: 'PciInteractionChanged', identifier: this.getResponseIdentifier(), state: stringifiedStateObject, success: true },'*')
525
- },
546
+ },
526
547
 
527
548
  /**
528
549
  * @description Generic function for parsing URL params.
@@ -553,9 +574,9 @@ const QTI_PCI_API = {
553
574
  // create a mutation observer instance
554
575
  let observer = new MutationObserver(function(mutations) {
555
576
  mutations.forEach(function(mutation) {
556
- let bounds = element.getBoundingClientRect()
557
- let width = Math.ceil(bounds.right)
558
- let height = Math.ceil(bounds.bottom)
577
+ const bounds = element.getBoundingClientRect()
578
+ const width = bounds.right
579
+ const height = bounds.bottom
559
580
  if (Math.abs(width - this.width) > 15 || Math.abs(height - this.height) > 15) {
560
581
  this.width = width
561
582
  this.height = height