修复质量裁判规定赛打分为0的情况
This commit is contained in:
parent
3505941935
commit
51ed62dfe5
@ -20,6 +20,18 @@ class ExecutionScoreCriterion {
|
||||
}
|
||||
|
||||
abstract final class PrescribedExecutionRuleCatalog {
|
||||
/// 服务端规定赛评分项编码到平板控件键的映射。
|
||||
/// 按编码匹配可避免“动作的准确性”与“动作准确性”等文案差异丢分。
|
||||
static const serverItemAliases = <String, String>{
|
||||
'CQ_ACCURACY': '动作准确性',
|
||||
'CQ_PROFICIENCY': '动作熟练性',
|
||||
'CQ_SYNCHRONY': '动作合拍性',
|
||||
// 兼容内置规则定义中的旧编码,已部署数据使用 CQ_SYNCHRONY。
|
||||
'CQ_SYNCHRONIZATION': '动作合拍性',
|
||||
'CQ_ABILITY_CONSISTENCY': '运动能力一致性',
|
||||
'CQ_SKILL_CONSISTENCY': '表演技巧一致性',
|
||||
};
|
||||
|
||||
static const individual = <ExecutionScoreCriterion>[
|
||||
ExecutionScoreCriterion(
|
||||
name: '动作准确性',
|
||||
|
||||
@ -379,7 +379,13 @@ class ScoringController extends GetxController {
|
||||
|
||||
if (profile.role == ScoreRole.creative ||
|
||||
profile.role == ScoreRole.execution) {
|
||||
final key = _matchingKey(performanceItems.keys, item.name);
|
||||
final key = _matchingKey(
|
||||
performanceItems.keys,
|
||||
'${item.code} ${item.name}',
|
||||
aliases: profile.role == ScoreRole.execution
|
||||
? PrescribedExecutionRuleCatalog.serverItemAliases
|
||||
: const {},
|
||||
);
|
||||
if (key != null) {
|
||||
performanceItems[key] = score.clamp(0, performanceItemMaximum(key));
|
||||
_itemUiKeys[item.code] = key;
|
||||
@ -460,8 +466,12 @@ class ScoringController extends GetxController {
|
||||
return codeMatch.group(1) == '0_5' ? '0.5' : codeMatch.group(1);
|
||||
}
|
||||
|
||||
String? _matchingKey(Iterable<String> keys, String source) {
|
||||
return ScoreItemKeyMatcher.match(keys, source);
|
||||
String? _matchingKey(
|
||||
Iterable<String> keys,
|
||||
String source, {
|
||||
Map<String, String> aliases = const {},
|
||||
}) {
|
||||
return ScoreItemKeyMatcher.match(keys, source, aliases: aliases);
|
||||
}
|
||||
|
||||
String? _requiredElementKeyOf(JudgeScoreItem item) {
|
||||
|
||||
@ -2,9 +2,32 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:yd_pattern_scoring_system/core/models/deduction_rule_item.dart';
|
||||
import 'package:yd_pattern_scoring_system/core/models/judge_account.dart';
|
||||
import 'package:yd_pattern_scoring_system/core/models/elite_scoring_rule.dart';
|
||||
import 'package:yd_pattern_scoring_system/core/models/prescribed_execution_rule.dart';
|
||||
import 'package:yd_pattern_scoring_system/core/network/score_item_key_matcher.dart';
|
||||
|
||||
void main() {
|
||||
test('规定赛完成质量项按稳定编码匹配平板控件', () {
|
||||
const keys = ['动作准确性', '动作熟练性', '动作合拍性'];
|
||||
const aliases = PrescribedExecutionRuleCatalog.serverItemAliases;
|
||||
|
||||
expect(
|
||||
ScoreItemKeyMatcher.match(keys, 'CQ_ACCURACY 动作的准确性', aliases: aliases),
|
||||
'动作准确性',
|
||||
);
|
||||
expect(
|
||||
ScoreItemKeyMatcher.match(
|
||||
keys,
|
||||
'CQ_PROFICIENCY 动作的熟练性',
|
||||
aliases: aliases,
|
||||
),
|
||||
'动作熟练性',
|
||||
);
|
||||
expect(
|
||||
ScoreItemKeyMatcher.match(keys, 'CQ_SYNCHRONY 动作的合拍性', aliases: aliases),
|
||||
'动作合拍性',
|
||||
);
|
||||
});
|
||||
|
||||
final keys = DeductionRuleCatalog.forCompetition(
|
||||
CompetitionKind.doubleDutch,
|
||||
).map((item) => item.key).toList();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user