From 5f701c2450492e33046c3bce0c64e323e46d9dc7 Mon Sep 17 00:00:00 2001 From: Corey Peterson Date: Tue, 16 Apr 2024 10:10:48 -0400 Subject: [PATCH 1/2] Adds update callback method. Implements setHeight method to scale score screen based on content. --- src/controllers/ctl-scoreScreen.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/controllers/ctl-scoreScreen.js b/src/controllers/ctl-scoreScreen.js index ec97841..2428483 100644 --- a/src/controllers/ctl-scoreScreen.js +++ b/src/controllers/ctl-scoreScreen.js @@ -4,6 +4,8 @@ export const ControllerThisOrThatScorescreen = function($scope, $sce) { const materiaCallbacks = {} + const getHeight = () => Math.ceil(parseFloat(window.getComputedStyle(document.querySelector('html')).height)) + const getQuestionIndex = (qset, id) => { for (let i = 0; i < qset.items.length; i++) { if (qset.items[i].id == id) return i @@ -21,7 +23,7 @@ export const ControllerThisOrThatScorescreen = function($scope, $sce) { return parseInt((overallDeduction / numIncorrect) * 100) } - materiaCallbacks.start = (instance, qset, scoreTable, isPreview, qsetVersion) => { + materiaCallbacks.update = (qset, scoreTable) => { $scope.$apply(() => { $scope.items = scoreTable.map((question, index) => { @@ -60,6 +62,12 @@ export const ControllerThisOrThatScorescreen = function($scope, $sce) { return item }) }) + + Materia.ScoreCore.setHeight(getHeight()) + } + + materiaCallbacks.start = (instance, qset, scoreTable, isPreview, qsetVersion) => { + materiaCallbacks.update(qset, scoreTable) } Materia.ScoreCore.hideResultsTable() From fc8ff55bf575f0f690337fa86fab09db1ac82ac1 Mon Sep 17 00:00:00 2001 From: Corey Peterson Date: Tue, 16 Apr 2024 10:17:10 -0400 Subject: [PATCH 2/2] Mocks scorecore setheight method in tests --- src/scoreScreen.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scoreScreen.test.js b/src/scoreScreen.test.js index bdcb967..0d76552 100644 --- a/src/scoreScreen.test.js +++ b/src/scoreScreen.test.js @@ -145,6 +145,7 @@ describe('Score Screen Controller', function() { start: jest.fn(methods => { publicMethods = methods }), + setHeight: jest.fn(), // alert: jest.fn(), // cancelSave: jest.fn(), // save: jest.fn().mockImplementation((title, qset) => {