diff --git a/kolibri/plugins/learn/assets/src/composables/__tests__/useProgressTracking.spec.js b/kolibri/plugins/learn/assets/src/composables/__tests__/useProgressTracking.spec.js index 73760e0f920..97d9e850bf6 100644 --- a/kolibri/plugins/learn/assets/src/composables/__tests__/useProgressTracking.spec.js +++ b/kolibri/plugins/learn/assets/src/composables/__tests__/useProgressTracking.spec.js @@ -1,4 +1,4 @@ -import { get } from '@vueuse/core'; +import { get, set } from '@vueuse/core'; import client from 'kolibri.client'; import { coreStoreFactory as makeStore } from 'kolibri.coreVue.vuex.store'; import useProgressTracking from '../useProgressTracking'; @@ -373,6 +373,15 @@ describe('useProgressTracking composable', () => { expect(get(progress)).toEqual(1); expect(client.mock.calls[0][0].data.progress_delta).toEqual(0.5); }); + it('should max progress and store progress_delta if progress is updated over threshold and over max value and progress_delta is greater than 0', async () => { + const { updateContentSession, progress, progress_delta } = await initStore({ + progress: 0.167, + }); + set(progress_delta, 0.5); + await updateContentSession({ progress: 1 }); + expect(get(progress)).toEqual(1); + expect(client.mock.calls[0][0].data.progress_delta).toEqual(1); + }); it('should not update progress and store progress_delta if progress is updated under current value', async () => { const { updateContentSession, progress, progress_delta } = await initStore(); await updateContentSession({ progress: 0.4 }); diff --git a/kolibri/plugins/learn/assets/src/composables/useProgressTracking.js b/kolibri/plugins/learn/assets/src/composables/useProgressTracking.js index 32a6f43e67a..78ce4b96afe 100644 --- a/kolibri/plugins/learn/assets/src/composables/useProgressTracking.js +++ b/kolibri/plugins/learn/assets/src/composables/useProgressTracking.js @@ -350,8 +350,9 @@ export default function useProgressTracking(store) { progress = _zeroToOne(progress); progress = threeDecimalPlaceRoundup(progress); if (get(progress_state) < progress) { - const newProgressDelta = - get(progress_delta) + threeDecimalPlaceRoundup(progress - get(progress_state)); + const newProgressDelta = _zeroToOne( + get(progress_delta) + threeDecimalPlaceRoundup(progress - get(progress_state)) + ); set(progress_delta, newProgressDelta); set(progress_state, progress); } diff --git a/kolibri/plugins/pdf_viewer/assets/src/views/PdfRendererIndex.vue b/kolibri/plugins/pdf_viewer/assets/src/views/PdfRendererIndex.vue index 1bbfe1edb3a..349bf981a07 100644 --- a/kolibri/plugins/pdf_viewer/assets/src/views/PdfRendererIndex.vue +++ b/kolibri/plugins/pdf_viewer/assets/src/views/PdfRendererIndex.vue @@ -17,7 +17,6 @@