From 15e7823116e11bb8627dd948c6909ab93387653d Mon Sep 17 00:00:00 2001 From: jvJUCA Date: Fri, 19 Apr 2024 16:57:48 -0300 Subject: [PATCH 1/4] fix: Evaluators order random --- .../organisms/HeuristicsTestAnswer.vue | 48 ++++++++++++------- src/store/modules/Answer.js | 3 ++ src/utils/statistics.js | 35 ++++++++------ 3 files changed, 55 insertions(+), 31 deletions(-) diff --git a/src/components/organisms/HeuristicsTestAnswer.vue b/src/components/organisms/HeuristicsTestAnswer.vue index 256503c7..e845b335 100644 --- a/src/components/organisms/HeuristicsTestAnswer.vue +++ b/src/components/organisms/HeuristicsTestAnswer.vue @@ -180,7 +180,13 @@ " :data="evaluatorStatistics.items.map((item) => item.result)" /> - + The graphic can only be generated with 3 or more evaluators, please colect more data from your research to procede. @@ -189,7 +195,13 @@ - + {{ item.percentage }} @@ -326,25 +340,29 @@ align="center" width="970px" > - This page needs weight function (python) to be running, can be in - emulators or in deploy mode, and the weights to be full marked on your creating test page. + This page needs weight function (python) to be running, + can be in emulators or in deploy mode, and the weights + to be full marked on your creating test page.
- + - Usability Percentage
+ Usability Percentage
With Weights
- +

{{ usabilityTotalFix }}

@@ -366,9 +384,7 @@ ) " :data=" - weightsStatistics.items.map( - (item) => item.rw, - ) + weightsStatistics.items.map((item) => item.rw) " :maxValue="maxValue" /> @@ -461,7 +477,9 @@ export default { value: 'heuristic', }) if (this.resultEvaluator) { + let evaluatorIndex = 1 this.resultEvaluator.forEach((evaluator) => { + evaluator.id = `Ev${evaluatorIndex}` const header = table.header.find((h) => h.text == evaluator.id) if (!header) { table.header.push({ @@ -485,6 +503,7 @@ export default { }) } }) + evaluatorIndex++ }) } return table @@ -603,7 +622,6 @@ export default { usabilityTotalFix() { const usabilityTotalFix = parseFloat(this.usability_total).toFixed(2) - console.log(this.maxValue) return usabilityTotalFix }, @@ -612,11 +630,10 @@ export default { let maxValue = relative[0] for (let i = 1; i < relative.length; i++) { if (relative[i] > maxValue) { - maxValue = relative[i] + maxValue = relative[i] } } const maxplus = parseFloat(maxValue).toFixed(1) - console.log(maxplus) return maxplus }, @@ -733,7 +750,6 @@ export default { console.error('Erro ao chamar Cloud Function:', erro) } }, - }, } diff --git a/src/store/modules/Answer.js b/src/store/modules/Answer.js index d3864258..6c913ea3 100644 --- a/src/store/modules/Answer.js +++ b/src/store/modules/Answer.js @@ -188,7 +188,9 @@ export default { ] if (payload.resultEvaluator) { + let evaluatorIndex = 1 payload.resultEvaluator.forEach((evaluator) => { + evaluator.id = `Ev${evaluatorIndex}` let totalNoAplication = 0 let totalNoReply = 0 let totalQuestions = 0 @@ -210,6 +212,7 @@ export default { ).toFixed(2), lastUpdate: new Date(evaluator.lastUpdate).toLocaleString(), }) + evaluatorIndex++ }) } diff --git a/src/utils/statistics.js b/src/utils/statistics.js index 52cf6ca3..69b102fd 100644 --- a/src/utils/statistics.js +++ b/src/utils/statistics.js @@ -14,7 +14,10 @@ function percentage(value, result) { } function standardDeviation(array) { - const average = array.reduce((total, value) => total + value / array.length, 0) + const average = array.reduce( + (total, value) => total + value / array.length, + 0, + ) return Math.sqrt( array.reduce( (total, valor) => total + Math.pow(average - valor, 2) / array.length, @@ -66,43 +69,43 @@ function created(resultEvaluator) { function statistics() { if (store.getters.testAnswerDocument?.type === 'HEURISTICS') { const resultEvaluator = [] - const answersA = answers() //Get Evaluator answers - let evaluatorIndex = 1 - answersA.forEach((evaluator) => { + answers().forEach((evaluator) => { let SelectEvaluator = resultEvaluator.find( - (e) => e.userDocId == `Ev${evaluatorIndex}`, + (e) => e.userDocId == evaluator.userDocId, ) + if (!SelectEvaluator) { resultEvaluator.push({ userDocId: evaluator.userDocId, - email: 'noemail@email.com', - id: `Ev${evaluatorIndex}`, + id: evaluator.userDocId, heuristics: [], result: 0, lastUpdate: evaluator.lastUpdate, }) SelectEvaluator = resultEvaluator[resultEvaluator.length - 1] + } else { + // Update lastUpdate if evaluator already exists + SelectEvaluator.lastUpdate = evaluator.lastUpdate } + //Get Heuristics for evaluators let heurisIndex = 1 evaluator.heuristicQuestions.forEach((heuristic) => { - //Get Questions for heuristic - let noAplication = 0 let noReply = 0 let res = heuristic.heuristicQuestions.reduce( (totalQuestions, question) => { - //grouping of answers if (question.heuristicAnswer === null) { noAplication++ - } //count answers no aplication + } if (question.heuristicAnswer === '') noReply++ - return totalQuestions + Number(question.heuristicAnswer) //sum of responses + return totalQuestions + Number(question.heuristicAnswer) }, 0, ) + if (noAplication == heuristic.heuristicQuestions.length) res = null SelectEvaluator.heuristics.push({ @@ -114,15 +117,17 @@ function statistics() { }) heurisIndex++ }) - evaluatorIndex++ }) - //Calc Final result + // Sort resultEvaluator based on lastUpdate + resultEvaluator.sort((a, b) => b.lastUpdate - a.lastUpdate) + + // Calc Final result resultEvaluator.forEach((ev) => { ev.result = calcFinalResult(ev.heuristics) }) - // created(resultEvaluator) + console.log(resultEvaluator) return resultEvaluator } } From 29bba09a0142749802484d2c0526f2bcf5e83dca Mon Sep 17 00:00:00 2001 From: jvJUCA Date: Fri, 19 Apr 2024 16:58:23 -0300 Subject: [PATCH 2/4] fix: v-selected item-value is NaN --- src/views/public/TestView.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/views/public/TestView.vue b/src/views/public/TestView.vue index 404b968c..8e75e40a 100644 --- a/src/views/public/TestView.vue +++ b/src/views/public/TestView.vue @@ -401,7 +401,6 @@ " class="optionSelect" :items="test.testOptions" - :item-value="i.toString()" label="Respuestas/Answers" outlined dense From 14a8eb3518390e79113b2ace58057e7aca2a2ed7 Mon Sep 17 00:00:00 2001 From: jvJUCA Date: Fri, 19 Apr 2024 17:22:02 -0300 Subject: [PATCH 3/4] fix: index changing wrongly --- src/components/organisms/HeuristicsTestAnswer.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/organisms/HeuristicsTestAnswer.vue b/src/components/organisms/HeuristicsTestAnswer.vue index e845b335..8066f60b 100644 --- a/src/components/organisms/HeuristicsTestAnswer.vue +++ b/src/components/organisms/HeuristicsTestAnswer.vue @@ -21,16 +21,16 @@ color="#FCA326" class="ml-4" > - + Statistics - + Evaluators - + Heuristics - + Analytics From 6f885c416762d038494880217ac90d641f7dfba6 Mon Sep 17 00:00:00 2001 From: jvJUCA Date: Fri, 19 Apr 2024 18:01:45 -0300 Subject: [PATCH 4/4] fix: change the toFixed to 2 --- src/utils/statistics.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/statistics.js b/src/utils/statistics.js index 69b102fd..467dfcaa 100644 --- a/src/utils/statistics.js +++ b/src/utils/statistics.js @@ -46,7 +46,7 @@ function calcFinalResult(array) { }) const perfectResult = (qtdQuestion - qtdNoAplication) * maxOption - return ((result * 100) / perfectResult).toFixed(1) + return ((result * 100) / perfectResult).toFixed(2) } function answers() { @@ -139,19 +139,19 @@ function finalResult() { return total + value.result / evaluatorStatistics.items.length }, 0) - testData.average = `${Math.fround(res).toFixed(1)}%` + testData.average = `${Math.fround(res).toFixed(2)}%` testData.max = `${Math.max( ...evaluatorStatistics.items.map((item) => item.result), - ).toFixed(1)}%` + ).toFixed(2)}%` testData.min = `${Math.min( ...evaluatorStatistics.items.map((item) => item.result), - ).toFixed(1)}%` + ).toFixed(2)}%` testData.sd = `${standardDeviation( evaluatorStatistics.items.map((item) => item.result), - ).toFixed(1)}%` + ).toFixed(2)}%` } return testData }