Skip to content

Commit

Permalink
[Evaluation] exposes raw score
Browse files Browse the repository at this point in the history
  • Loading branch information
Elorfin committed Jan 9, 2024
1 parent 37cc851 commit f69a39e
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,9 @@ export default (contextType, contextData, refresher, currentUser) => {
type: 'learning'
}
}, {
name: 'score',
name: 'displayScore',
type: 'score',
label: trans('score'),
calculated: (row) => {
if (row.scoreMax) {
return {
current: row.score,
total: row.scoreMax
}
}

return null
},
displayed: true,
filterable: false
}, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,9 @@ export default (contextType, contextData, refresher, currentUser) => {
type: 'learning'
}
}, {
name: 'score',
name: 'displayScore',
type: 'score',
label: trans('score'),
calculated: (row) => {
if (row.scoreMax) {
return {
current: row.score,
total: row.scoreMax
}
}

return null
},
displayed: true,
filterable: false
}, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class EvaluationUser extends Component {
details={[
[trans('last_activity'), get(this.props.workspaceEvaluation, 'date') ? displayDate(this.props.workspaceEvaluation.date, false, true) : '-'],
[trans('duration'), get(this.props.workspaceEvaluation, 'duration') ? displayDuration(get(this.props.workspaceEvaluation, 'duration')) : '-'],
get(this.props.workspaceEvaluation, 'scoreMax') && [
get(this.props.workspaceEvaluation, 'displayScore') && [
trans('score'),
(get(this.props.workspaceEvaluation, 'score') ? number(get(this.props.workspaceEvaluation, 'score')) : '?') + ' / ' + number(get(this.props.workspaceEvaluation, 'scoreMax'))
(get(this.props.workspaceEvaluation, 'displayScore.current') ? number(get(this.props.workspaceEvaluation, 'displayScore.current')) : '?') + ' / ' + number(get(this.props.workspaceEvaluation, 'displayScore.total'))
]
].filter(value => !!value)}
estimatedDuration={get(this.props, 'workspace.estimatedDuration')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,9 @@ const EvaluationUsers = (props) => {
type: 'learning'
}
}, {
name: 'score',
name: 'displayScore',
type: 'score',
label: trans('score'),
calculated: (row) => {
if (row.scoreMax) {
return {
current: row.score,
total: row.scoreMax
}
}

return null
},
displayed: true,
filterable: false
}, {
Expand Down
26 changes: 17 additions & 9 deletions src/main/evaluation/Serializer/WorkspaceEvaluationSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,25 @@ public function serialize(Evaluation $evaluation, ?array $options = []): array
'duration' => $evaluation->getDuration(),
'progression' => $evaluation->getProgression(),
'estimatedDuration' => $evaluation->getEstimatedDuration(),

'score' => $evaluation->getScore(),
'scoreMin' => $evaluation->getScoreMin(),
'scoreMax' => $evaluation->getScoreMax(),
];

if (!in_array(SerializerInterface::SERIALIZE_TRANSFER, $options)) {
// get defined total score
if ($evaluation->getScoreMax() && $evaluation->getWorkspace() && $evaluation->getWorkspace()->getScoreTotal()) {
$serialized['score'] = ($evaluation->getScore() / $evaluation->getScoreMax()) * $evaluation->getWorkspace()->getScoreTotal();
$serialized['scoreMax'] = $evaluation->getWorkspace()->getScoreTotal();
// evaluation has a score, expose it
if ($evaluation->getScoreMax()) {
$serialized['rawScore'] = [
'current' => $evaluation->getScore(),
'total' => $evaluation->getScoreMax(),
];

if ($evaluation->getWorkspace() && $evaluation->getWorkspace()->getScoreTotal()) {
$serialized['displayScore'] = [
'current' => ($evaluation->getScore() / $evaluation->getScoreMax()) * $evaluation->getWorkspace()->getScoreTotal(),
'total' => $evaluation->getWorkspace()->getScoreTotal(),
];
} else {
$serialized['displayScore'] = [
'current' => $evaluation->getScore(),
'total' => $evaluation->getScoreMax(),
];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

abstract class AbstractEvaluationListExporter extends AbstractListExporter
{
public function supports(string $format, ?array $options = [], ?array $extra = []): bool
{
return in_array($format, ['json', 'csv']);
}

public function getExtraDefinition(?array $options = [], ?array $extra = []): array
{
$extraDef = parent::getExtraDefinition($options, $extra);
Expand Down Expand Up @@ -43,18 +48,6 @@ public function getSchema(?array $options = [], ?array $extra = []): array
'name' => 'duration',
'type' => 'number',
'description' => $this->translator->trans('The evaluation duration', [], 'schema'),
], [
'name' => 'score',
'type' => 'number',
'description' => $this->translator->trans('The evaluation score', [], 'schema'),
], [
'name' => 'scoreMin',
'type' => 'number',
'description' => $this->translator->trans('The evaluation score min', [], 'schema'),
], [
'name' => 'scoreMax',
'type' => 'number',
'description' => $this->translator->trans('The evaluation score max', [], 'schema'),
], [
'name' => 'progression',
'type' => 'number',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ public static function getAction(): array
return ['evaluation', 'resource_evaluation_list'];
}

public function supports(string $format, ?array $options = [], ?array $extra = []): bool
{
return in_array($format, ['json', 'csv']);
}

protected static function getClass(): string
{
return ResourceUserEvaluation::class;
Expand All @@ -26,6 +21,18 @@ public function getSchema(?array $options = [], ?array $extra = []): array
$schema = parent::getSchema($options, $extra);
$schema['properties'] = array_merge($schema['properties'], [
[
'name' => 'score',
'type' => 'number',
'description' => $this->translator->trans('The evaluation score', [], 'schema'),
], [
'name' => 'scoreMin',
'type' => 'number',
'description' => $this->translator->trans('The evaluation score min', [], 'schema'),
], [
'name' => 'scoreMax',
'type' => 'number',
'description' => $this->translator->trans('The evaluation score max', [], 'schema'),
], [
'name' => 'nbAttempts',
'type' => 'number',
'description' => $this->translator->trans('The number of attempts for the evaluation', [], 'schema'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ public function getSchema(?array $options = [], ?array $extra = []): array
$schema = parent::getSchema($options, $extra);
$schema['properties'] = array_merge($schema['properties'], [
[
'name' => 'rawScore.current',
'type' => 'number',
'description' => $this->translator->trans('The evaluation raw user score', [], 'schema'),
], [
'name' => 'rawScore.total',
'type' => 'number',
'description' => $this->translator->trans('The evaluation raw total score ', [], 'schema'),
], [
'name' => 'displayScore.current',
'type' => 'number',
'description' => $this->translator->trans('The evaluation display user score', [], 'schema'),
], [
'name' => 'displayScore.total',
'type' => 'number',
'description' => $this->translator->trans('The evaluation display total score ', [], 'schema'),
], [
'name' => 'workspace.id',
'type' => 'string',
'description' => $this->translator->trans('The workspace id or uuid', [], 'schema'),
Expand Down
13 changes: 3 additions & 10 deletions src/main/transfer/Messenger/ExecuteExportHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,13 @@

class ExecuteExportHandler implements MessageHandlerInterface
{
/** @var ObjectManager */
private $om;
/** @var TransferManager */
private $transferManager;

public function __construct(
ObjectManager $om,
TransferManager $transferManager
private readonly ObjectManager $om,
private readonly TransferManager $transferManager
) {
$this->om = $om;
$this->transferManager = $transferManager;
}

public function __invoke(ExecuteExport $exportMessage)
public function __invoke(ExecuteExport $exportMessage): void
{
$exportFile = $this->om->getRepository(ExportFile::class)->find($exportMessage->getExportId());
if (empty($exportFile)) {
Expand Down
15 changes: 6 additions & 9 deletions src/main/transfer/Transfer/Exporter/AbstractListExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,23 @@

abstract class AbstractListExporter extends AbstractExporter
{
/** @var TranslatorInterface */
protected $translator;
/** @var FinderProvider */
protected $finder;
/** @var SerializerProvider */
protected $serializer;
protected TranslatorInterface $translator;
protected FinderProvider $finder;
protected SerializerProvider $serializer;

abstract protected static function getClass(): string;

public function setTranslator(TranslatorInterface $translator)
public function setTranslator(TranslatorInterface $translator): void
{
$this->translator = $translator;
}

public function setFinder(FinderProvider $finder)
public function setFinder(FinderProvider $finder): void
{
$this->finder = $finder;
}

public function setSerializer(SerializerProvider $serializer)
public function setSerializer(SerializerProvider $serializer): void
{
$this->serializer = $serializer;
}
Expand Down

0 comments on commit f69a39e

Please sign in to comment.