-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into quickFix
- Loading branch information
Showing
4 changed files
with
57 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -43,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() { | ||
|
@@ -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: '[email protected]', | ||
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 | ||
} | ||
} | ||
|
@@ -134,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 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters