Skip to content

Commit

Permalink
Make text color can be null
Browse files Browse the repository at this point in the history
  • Loading branch information
Super12138 committed Sep 1, 2024
1 parent 49cf323 commit 54cbb74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ document.addEventListener('testPageLoaded', async () => {
itemName.textContent = item.name;
itemScore.textContent = item.result.toString();
itemComment.textContent = item.range;
itemComment.classList.add(item.color); // 设置文字颜色
if (item.color !== null) {
itemComment.classList.add(item.color); // 设置文字颜色
}

itemContainer.appendChild(itemName);
itemContainer.appendChild(itemScore);
Expand Down
5 changes: 3 additions & 2 deletions src/test/scoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ export function getScore(groupedQuestions: GroupedData, groupedCriteria: Grouped
switch (operator) {
case "plus": // 求和
result = getSum(values);
logHelper.log(`${key}的总和:${result}`);
logHelper.log(`评分组 ${key} 的总和:${result}`);
break;
case "average": // 平均数
result = parseFloat((getSum(values) / values.length).toFixed(2)); // 确保输出结果为小数点后2位
logHelper.log(`${key}的平均值:${result}`);
logHelper.log(`评分组 ${key} 的平均值:${result}`);
break;
case "multiply": // 按照某个值翻倍
const ratio = Number.parseFloat(method[1]);
result = getSum(values) * ratio;
logHelper.log(`评分组 ${key}${ratio} 倍:${result}`);
break;
default:
logHelper.error(`未知计算方法:${operator}`);
Expand Down

0 comments on commit 54cbb74

Please sign in to comment.