@pocketprep/ui-kit 3.4.74 → 3.4.76

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.
@@ -21,21 +21,23 @@
21
21
  }"
22
22
  v-html="matrixColumnLabelsForRows"
23
23
  />
24
- <div
25
- class="uikit-question-matrix-choices-container__column-header"
26
- :class="{
27
- 'uikit-question-matrix-choices-container__column-header--two-columns':
28
- numberOfMatrixColumnLabels === 2,
29
- 'uikit-question-matrix-choices-container__column-header--radio-btn-three-columns':
30
- question.type === 'Matrix Radio Button' && numberOfMatrixColumnLabels === 3
31
- }"
32
- lang="de"
33
- v-for="(columnLabel, index) in matrixColumnLabels"
34
- :key="index"
35
- v-dark="isDarkMode"
36
- v-breakpoint:questionEl="breakpoints"
37
- v-html="columnLabel"
38
- />
24
+ <div class="uikit-question-matrix-choices-container__column-headers">
25
+ <div
26
+ class="uikit-question-matrix-choices-container__column-header"
27
+ :class="{
28
+ 'uikit-question-matrix-choices-container__column-header--two-columns':
29
+ numberOfMatrixColumnLabels === 2,
30
+ 'uikit-question-matrix-choices-container__column-header--radio-btn-three-columns':
31
+ question.type === 'Matrix Radio Button' && numberOfMatrixColumnLabels === 3
32
+ }"
33
+ lang="de"
34
+ v-for="(columnLabel, index) in matrixColumnLabels"
35
+ :key="index"
36
+ v-dark="isDarkMode"
37
+ v-breakpoint:questionEl="breakpoints"
38
+ v-html="columnLabel"
39
+ />
40
+ </div>
39
41
  </div>
40
42
  <div
41
43
  class="uikit-question-matrix-choices-container__choices-container"
@@ -404,16 +406,10 @@ export default class MatrixChoicesContainer extends Vue {
404
406
  return matrixChoiceKeys
405
407
  }
406
408
 
407
- @Emit('emitAnsweredMatrixRowIndex')
408
- emitAnsweredMatrixRowIndex (answeredRowIndexes: number[]) {
409
- return answeredRowIndexes
410
- }
411
-
412
409
  @Watch('matrixCheckboxGrid', { deep: true })
413
410
  matrixCheckboxGridChange () {
414
411
  if (this.matrixChoiceLayout && this.matrixCheckboxGrid) {
415
412
  const selectedCheckboxChoices: TMatrixChoiceKey[] = []
416
- const answeredCheckBoxRowIndexes: number[] = []
417
413
 
418
414
  this.matrixCheckboxGrid.forEach((row, rowIndex) => {
419
415
  row.forEach((choice, choiceIndex) => {
@@ -424,14 +420,10 @@ export default class MatrixChoicesContainer extends Vue {
424
420
  ) {
425
421
  const choiceKey = this.matrixChoiceLayout[rowIndex][choiceIndex] as TMatrixChoiceKey
426
422
  selectedCheckboxChoices.push(choiceKey)
427
- if (!answeredCheckBoxRowIndexes.some(index => index === rowIndex)) {
428
- answeredCheckBoxRowIndexes.push(rowIndex)
429
- }
430
423
  }
431
424
  })
432
425
  })
433
426
  this.emitSelectedMatrixChoice(selectedCheckboxChoices)
434
- this.emitAnsweredMatrixRowIndex(answeredCheckBoxRowIndexes)
435
427
  }
436
428
  }
437
429
 
@@ -439,16 +431,11 @@ export default class MatrixChoicesContainer extends Vue {
439
431
  matrixRadioGridChange () {
440
432
  if (this.matrixChoiceLayout && this.matrixRadioGrid) {
441
433
  const selectedRadioButtonChoices: TMatrixChoiceKey[] = []
442
- const answeredRadioBtnRowIndexes: number[] = []
443
434
 
444
435
  this.matrixRadioGrid.forEach((row, rowIndex) => {
445
436
  const choiceKey = row.value
446
437
  if (choiceKey && this.matrixChoiceLayout[rowIndex]) {
447
438
  selectedRadioButtonChoices.push(choiceKey)
448
- if (!answeredRadioBtnRowIndexes.some(index => index === rowIndex)) {
449
- answeredRadioBtnRowIndexes.push(rowIndex)
450
- }
451
- this.emitAnsweredMatrixRowIndex(answeredRadioBtnRowIndexes)
452
439
  }
453
440
  })
454
441
  this.emitSelectedMatrixChoice(selectedRadioButtonChoices)
@@ -477,6 +464,7 @@ export default class MatrixChoicesContainer extends Vue {
477
464
 
478
465
  .uikit-question-matrix-choices-container {
479
466
  width: 100%;
467
+
480
468
  &__columns {
481
469
  display: flex;
482
470
  padding: 0px 1px 0px 14px;
@@ -516,6 +504,12 @@ export default class MatrixChoicesContainer extends Vue {
516
504
  }
517
505
  }
518
506
 
507
+ &__column-headers {
508
+ display: flex;
509
+ align-items: flex-end;
510
+ min-width: 214px;
511
+ }
512
+
519
513
  &__column-header {
520
514
  width: 56px;
521
515
  hyphens: auto;
@@ -626,7 +620,6 @@ export default class MatrixChoicesContainer extends Vue {
626
620
 
627
621
  &__choice-text {
628
622
  width: 279px;
629
- min-width: 279px;
630
623
  min-height: fit-content;
631
624
  color: $brand-black;
632
625
  font-size: 16.5px;
@@ -669,6 +662,7 @@ export default class MatrixChoicesContainer extends Vue {
669
662
 
670
663
  &__checkboxes {
671
664
  display: flex;
665
+ min-width: 201px;
672
666
 
673
667
  &--three-columns {
674
668
  margin-left: -8px;
@@ -699,6 +693,11 @@ export default class MatrixChoicesContainer extends Vue {
699
693
  &:not(&:last-child) {
700
694
  margin-right: 4px;
701
695
  }
696
+
697
+ &:last-child {
698
+ width: 40px;
699
+ min-width: 40px;
700
+ }
702
701
  }
703
702
 
704
703
  .uikit-checkbox--disabled {
@@ -753,6 +752,8 @@ export default class MatrixChoicesContainer extends Vue {
753
752
  }
754
753
 
755
754
  &__radio-btns {
755
+ min-width: 201px;
756
+
756
757
  &--three-columns {
757
758
  position: relative;
758
759
  left: 6px;
@@ -475,16 +475,11 @@ export default class MobileMatrixChoicesContainer extends Vue {
475
475
  return matrixChoiceKeys
476
476
  }
477
477
 
478
- @Emit('emitAnsweredMatrixRowIndex')
479
- emitAnsweredMatrixRowIndex (answeredRowIndexes: number[]) {
480
- return answeredRowIndexes
481
- }
482
478
 
483
479
  @Watch('matrixCheckboxGrid', { deep: true })
484
480
  matrixCheckboxGridChange () {
485
481
  if (this.matrixChoiceLayout && this.matrixCheckboxGrid && (!this.reviewMode || !this.showMatrixAnswers)) {
486
482
  const selectedCheckboxChoices: TMatrixChoiceKey[] = []
487
- const answeredCheckBoxRowIndexes: number[] = []
488
483
 
489
484
  this.matrixCheckboxGrid.forEach((row, rowIndex) => {
490
485
  row.forEach((choice, choiceIndex) => {
@@ -495,15 +490,11 @@ export default class MobileMatrixChoicesContainer extends Vue {
495
490
  ) {
496
491
  const choiceKey = this.matrixChoiceLayout[rowIndex][choiceIndex] as TMatrixChoiceKey
497
492
  selectedCheckboxChoices.push(choiceKey)
498
- if (!answeredCheckBoxRowIndexes.some(index => index === rowIndex)) {
499
- answeredCheckBoxRowIndexes.push(rowIndex)
500
- }
501
493
  }
502
494
  })
503
495
  })
504
496
 
505
497
  this.emitSelectedMatrixChoice(selectedCheckboxChoices)
506
- this.emitAnsweredMatrixRowIndex(answeredCheckBoxRowIndexes)
507
498
  }
508
499
  }
509
500
 
@@ -511,19 +502,14 @@ export default class MobileMatrixChoicesContainer extends Vue {
511
502
  matrixRadioGridChange () {
512
503
  if (this.matrixChoiceLayout && this.matrixRadioGrid && (!this.reviewMode || !this.showMatrixAnswers)) {
513
504
  const selectedRadioButtonChoices: TMatrixChoiceKey[] = []
514
- const answeredRadioBtnRowIndexes: number[] = []
515
505
 
516
- this.matrixRadioGrid.forEach((row, index) => {
506
+ this.matrixRadioGrid.forEach((row) => {
517
507
  if (row.value) {
518
508
  selectedRadioButtonChoices.push(row.value)
519
- if (!answeredRadioBtnRowIndexes.some(rowIndex => rowIndex === index)) {
520
- answeredRadioBtnRowIndexes.push(index)
521
- }
522
509
  }
523
510
  })
524
511
 
525
512
  this.emitSelectedMatrixChoice(selectedRadioButtonChoices)
526
- this.emitAnsweredMatrixRowIndex(answeredRadioBtnRowIndexes)
527
513
  }
528
514
  }
529
515
 
@@ -258,7 +258,6 @@
258
258
  :breakpoints="breakpoints"
259
259
  :is-teach-group-review="isTeachGroupReview"
260
260
  @emitSelectedMatrixChoice="selectMatrixChoice"
261
- @emitAnsweredMatrixRowIndex="answeredMatrixRowIndex"
262
261
  >
263
262
  <template #motivationalMoment="{
264
263
  isCorrect,
@@ -295,7 +294,6 @@
295
294
  :question-el="questionEl"
296
295
  :breakpoints="breakpoints"
297
296
  @emitSelectedMatrixChoice="selectMatrixChoice"
298
- @emitAnsweredMatrixRowIndex="answeredMatrixRowIndex"
299
297
  >
300
298
  <template
301
299
  #motivationalMoment="{
@@ -399,7 +397,7 @@
399
397
  </PocketButton>
400
398
  <PocketButton
401
399
  v-else-if="isMatrixQuestion && !showMatrixAnswers && !hideAnswer"
402
- :disabled="!allMatrixRowsAreAnswered"
400
+ :disabled="!isMatrixQuestionAnswered"
403
401
  :is-dark-mode="isDarkMode"
404
402
  @click="clickCheckMatrixAnswer"
405
403
  >
@@ -579,8 +577,6 @@ export default class Question extends Vue {
579
577
  choiceStrikes: TChoiceKey[] = []
580
578
  selectedChoices: TChoiceKey[] = []
581
579
  selectedMatrixChoices: TMatrixChoiceKey[] = []
582
- answeredMatrixRowIndexes: number[] = []
583
- allMatrixRowsAreAnswered = false
584
580
  showAnswers = false
585
581
  showMatrixAnswers = false
586
582
  showExplanation = false
@@ -828,11 +824,33 @@ export default class Question extends Vue {
828
824
  return scores
829
825
  }
830
826
 
827
+ get isMatrixQuestionAnswered () {
828
+ // Matrix questions are answered if each row has a selected choice
829
+ if (this.isMatrixQuestion) {
830
+ const answeredRowNums = this.selectedMatrixChoices.map(choice => {
831
+ if (choice as TMatrixChoiceKey) {
832
+ return Number(choice.split('_')[0]?.slice(1))
833
+ }
834
+ return
835
+ })
836
+
837
+ const matrixRows = this.question.matrixChoiceLayout || []
838
+ const isEveryRowAnswered = matrixRows.every((row, index) => {
839
+ const rowNum = index + 1
840
+ const hasSelectedChoiceForRow = answeredRowNums.includes(rowNum)
841
+ return hasSelectedChoiceForRow
842
+ })
843
+ return isEveryRowAnswered
844
+ }
845
+ return false
846
+ }
847
+
831
848
  get isUnanswered () {
832
849
  if (!this.isMatrixQuestion) {
833
850
  return this.selectedChoices.length === 0
834
851
  }
835
- return (this.selectedMatrixChoices.length === 0 || !this.allMatrixRowsAreAnswered)
852
+
853
+ return !this.isMatrixQuestionAnswered
836
854
  }
837
855
 
838
856
  get prompt () {
@@ -1191,14 +1209,6 @@ export default class Question extends Vue {
1191
1209
  this.selectedMatrixChoices = matrixChoiceKeys
1192
1210
  }
1193
1211
 
1194
- answeredMatrixRowIndex (answeredRowIndexes: number[]) {
1195
- if (this.showMatrixAnswers) {
1196
- return
1197
- }
1198
- this.answeredMatrixRowIndexes = answeredRowIndexes
1199
- this.allMatrixRowsAreAnswered = this.answeredMatrixRowIndexes.length === this.question.matrixLabels?.rows.length
1200
- }
1201
-
1202
1212
  togglePassageImageLongAlt () {
1203
1213
  this.showPassageImageLongAlt = !this.showPassageImageLongAlt
1204
1214
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pocketprep/ui-kit",
3
- "version": "3.4.74",
3
+ "version": "3.4.76",
4
4
  "description": "Pocket Prep UI Kit",
5
5
  "author": "pocketprep",
6
6
  "scripts": {