Skip to content

Commit

Permalink
[Evaluation] rounds score to 100
Browse files Browse the repository at this point in the history
  • Loading branch information
Elorfin committed Feb 17, 2023
1 parent ae66a2a commit 967fbfe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public function listByWorkspaceAction(Workspace $workspace, Request $request): J
// don't show all users evaluations if no right
if (!$this->checkToolAccess('SHOW_EVALUATIONS', $workspace, false)) {
/** @var User $user */
$user = $this->tokenStorage->getToken()->getUser();
$hiddenFilters['user'] = $user->getUuid();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {DataCard} from '#/main/app/data/components/card'

import {constants} from '#/main/evaluation/constants'
import {ResourceEvaluation as ResourceEvaluationTypes} from '#/main/evaluation/resource/prop-types'
import {displayScore} from '#/main/evaluation/utils'

const ResourceCard = (props) =>
<DataCard
Expand Down Expand Up @@ -57,7 +58,7 @@ const ResourceCard = (props) =>
icon: 'fa fa-fw fa-award',
label: trans('score'),
displayed: !!props.data.scoreMax,
value: (number(props.data.score) || 0) + ' / ' + number(props.data.scoreMax)
value: !!props.data.scoreMax && displayScore(props.data.scoreMax, props.data.score, 100) + ' / 100'
}
]
.filter(item => undefined === item.displayed || item.displayed)
Expand Down
13 changes: 13 additions & 0 deletions src/main/evaluation/Resources/modules/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {number} from '#/main/app/intl'

function displayScore(scoreMax, score, displayScore) {
if (score) {
return number((score / scoreMax) * displayScore) + ''
}

return '0';
}

export {
displayScore
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {DataCard} from '#/main/app/data/components/card'

import {constants} from '#/main/evaluation/constants'
import {WorkspaceEvaluation as WorkspaceEvaluationTypes} from '#/main/evaluation/workspace/prop-types'
import {displayScore} from '#/main/evaluation/utils'

const WorkspaceCard = (props) =>
<DataCard
Expand Down Expand Up @@ -49,7 +50,7 @@ const WorkspaceCard = (props) =>
icon: 'fa fa-fw fa-award',
label: trans('score'),
displayed: !!props.data.scoreMax,
value: (number(props.data.score) || 0) + ' / ' + number(props.data.scoreMax)
value: !!props.data.scoreMax && displayScore(props.data.scoreMax, props.data.score, 100) + ' / 100'
}
]
.filter(item => undefined === item.displayed || item.displayed)
Expand Down

0 comments on commit 967fbfe

Please sign in to comment.