From fd2c869c4ab7b5eec27af98d2c235659abd1f482 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Fri, 19 Nov 2021 15:02:27 -0800 Subject: [PATCH] JS tweaks and doc string updates from review. --- .../core/assets/src/api-resources/masteryLog.js | 10 ++++++---- .../assets/src/views/QuizRenderer/index.vue | 16 ++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/kolibri/core/assets/src/api-resources/masteryLog.js b/kolibri/core/assets/src/api-resources/masteryLog.js index 4ad8032872e..035de4f687d 100644 --- a/kolibri/core/assets/src/api-resources/masteryLog.js +++ b/kolibri/core/assets/src/api-resources/masteryLog.js @@ -7,8 +7,9 @@ export default new Resource({ * Gets the list of mastery logs (tries) for a particular content and user combo, with: * - `correct`: total correct for the try * - * @param {String} content_id - * @param {String} user_id + * @param {Object} parameters - the parameters to be used for the fetch + * @param {String} parameters.content_id - the content_id of the relevant assessment + * @param {String} parameters.user_id - the id of the user * @return {Promise} */ fetchSummary({ content_id, user_id } = {}) { @@ -34,8 +35,9 @@ export default new Resource({ * - `diff`: object or null, with `correct` and `time_spent` diffs * - `attemptlogs`: list of attempt logs with annotated diff with previous try's attempt * - * @param {String} content_id - * @param {String} user_id + * @param {Object} parameters - the parameters to be used for the fetch + * @param {String} parameters.content_id - the content_id of the relevant assessment + * @param {String} parameters.user_id - the id of the user * @return {Promise} */ fetchMostRecentDiff({ content_id, user_id } = {}) { diff --git a/kolibri/plugins/learn/assets/src/views/QuizRenderer/index.vue b/kolibri/plugins/learn/assets/src/views/QuizRenderer/index.vue index 38fe489604f..a66b195d961 100644 --- a/kolibri/plugins/learn/assets/src/views/QuizRenderer/index.vue +++ b/kolibri/plugins/learn/assets/src/views/QuizRenderer/index.vue @@ -432,9 +432,8 @@ this.startTime = Date.now(); if (close) { return this.setAndSaveCurrentExamAttemptLog({ close, interaction }); - } else { - return this.debouncedSetAndSaveCurrentExamAttemptLog({ interaction }); } + return this.debouncedSetAndSaveCurrentExamAttemptLog({ interaction }); } else if (close) { return this.setAndSaveCurrentExamAttemptLog({ close }); } @@ -446,14 +445,11 @@ toggleModal() { // Flush any existing save event to ensure // that the subit modal contains the latest state - if (!this.submitModalOpen) { - const promise = - this.debouncedSetAndSaveCurrentExamAttemptLog.flush() || Promise.resolve(); - return promise.then(() => { - this.submitModalOpen = !this.submitModalOpen; - }); - } - this.submitModalOpen = !this.submitModalOpen; + Promise.resolve( + this.submitModalOpen && this.debouncedSetAndSaveCurrentExamAttemptLog.flush() + ).then(() => { + this.submitModalOpen = !this.submitModalOpen; + }); }, finishExam() { this.saveAnswer(true).then(() => {