Skip to content

Commit

Permalink
Fix NaN in SCL-90 scroing
Browse files Browse the repository at this point in the history
  • Loading branch information
Super12138 committed Aug 29, 2024
1 parent 2620edc commit ff35c1c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const logHelper = LogHelper.getInstance();
document.addEventListener('listPageLoaded', async () => {
const mduiList: List = document.querySelector('#questionnaireList')!;
// const searchBar: TextField = document.querySelector('#searchBar')!;
getFile('https://cdn.jsdelivr.net/gh/Super12138/AY-Questionnaires-DB/list.json')
getFile(`https://cdn.jsdelivr.net/gh/Super12138/AY-Questionnaires-DB/list.json?${new Date().getTime()}`)
.then((response: string) => {
const json: QuestionnairesList = JSON.parse(response);
const catogories: Category[] = json.categories; // 获取分组
Expand Down
2 changes: 1 addition & 1 deletion src/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ document.addEventListener('testPageLoaded', async () => {
setUpNextButton(nextBtn, 2);

// 获取量表json
getFile(`https://cdn.jsdelivr.net/gh/Super12138/AY-Questionnaires-DB/questionnaires/${questionnaire}.json`)
getFile(`https://cdn.jsdelivr.net/gh/Super12138/AY-Questionnaires-DB/questionnaires/${questionnaire}.json?${new Date().getTime()}`)
.then((response: string) => {
// 加载完了显示答题页面,隐藏加载提示
show(container);
Expand Down
4 changes: 3 additions & 1 deletion src/test/scoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ export function SCL90Score(groupRadio: NodeListOf<RadioGroup>): BasicScoreResult
sum += value;
if (value > 0) positiveCount++;
});

const average: number = sum / groupRadio.length;
const positivePainLevel: number = sum / positiveCount;
const positivePainLevel: number = sum / (positiveCount > 0 ? positiveCount : 1);

scl90Score.push({ name: '总分', result: sum });
scl90Score.push({ name: '总均分', result: Number.parseInt(average.toFixed(2), 10) });
scl90Score.push({ name: '阳性项目数', result: positiveCount });
Expand Down

0 comments on commit ff35c1c

Please sign in to comment.