Skip to content

Commit

Permalink
Merge pull request #3720 from Tangerine-Community/custom-scoring-subt…
Browse files Browse the repository at this point in the history
…est-report

fix(client): When Student subtest report uses custom score the score should be the percentage
  • Loading branch information
esurface authored Jul 31, 2024
2 parents ce2f6f0 + 41b610a commit 3e731aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
16 changes: 8 additions & 8 deletions client/src/app/class/_services/dashboard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class DashboardService {

if (item) {
itemCount = item.inputs.length;
customScore = item.customScore? item.customScore: null
customScore = !isNaN(item.customScore)? item.customScore: null
const metadata = item.metadata;
if (metadata) {
lastModified = metadata['lastModified'];
Expand Down Expand Up @@ -388,8 +388,8 @@ export class DashboardService {
maxValueAnswer = maxValueAnswer + max;
}
score = totalCorrect;
scorePercentageCorrect = customScore ? customScore : this.classUtils.round(totalCorrect / maxValueAnswer * 100, 2);
if (customScore) {
scorePercentageCorrect = !isNaN(customScore) ? customScore : this.classUtils.round(totalCorrect / maxValueAnswer * 100, 2);
if (!isNaN(customScore)) {
maxValueAnswer = 100
}
}
Expand Down Expand Up @@ -430,7 +430,7 @@ export class DashboardService {
totalIncorrect: totalIncorrect,
maxValueAnswer: maxValueAnswer,
totalCorrect: totalCorrect,
scorePercentageCorrect: scorePercentageCorrect,
scorePercentageCorrect: !isNaN(customScore) ? customScore : scorePercentageCorrect,
duration: duration,
customScore: customScore
};
Expand Down Expand Up @@ -503,15 +503,15 @@ export class DashboardService {
studentResults.score = score;
// console.log("student: " + studentResults["name"] + " form item: " + studentResults["response"]["formTitle"] + " score: " + score)
}
const max = studentResponse.customScore? 100: studentResponse.max;
const max = !isNaN(studentResponse.customScore)? 100: studentResponse.max;
if (max) {
studentResults.max = max;
classGroupReportMax = max;
}
const totalCorrect = studentResponse.customScore ? studentResponse.customScore : studentResponse.totalCorrect;
const scorePercentageCorrect = studentResponse.customScore ? studentResponse.customScore : studentResponse.scorePercentageCorrect;
const totalCorrect = !isNaN(studentResponse.customScore) ? studentResponse.customScore : studentResponse.totalCorrect;
const scorePercentageCorrect = !isNaN(studentResponse.customScore) ? studentResponse.customScore : studentResponse.scorePercentageCorrect;
studentResults.scorePercentageCorrect = scorePercentageCorrect;
const maxValueAnswer = studentResponse.customScore ? 100: studentResponse.maxValueAnswer;
const maxValueAnswer = !isNaN(studentResponse.customScore) ? 100: studentResponse.maxValueAnswer;
studentResults.maxValueAnswer = maxValueAnswer;
studentResults.customScore = studentResponse.customScore
duration = studentResponse.duration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ <h2>{{subtestReport.label}}</h2>
<td>
<span *ngFor="let res of generateArray(item.value)">
<ng-container *ngIf="res.value">
<ng-container *ngIf="res.value.percentage">
<ng-container *ngIf="res.value.percentage && !res.value.customScore">
({{tNumber(res.value.rawScore)}}/{{tNumber(res.value.totalGridAnswers)}}) {{tNumber(res.value.percentage)}}
</ng-container>
<ng-container *ngIf="!res.value.percentage">
({{tNumber(res.value.rawScore)}}/{{tNumber(res.value.totalGridAnswers)}})
<ng-container *ngIf="res.value.customScore||res.value.customScore===0">
{{(tNumber(res.value.customScore))|number : '1.2-2'}}%
</ng-container>
<!--<span *ngIf="res.value.totalCorrect">{{res.value.totalCorrect}}</span>-->
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ export class StudentSubtestReportComponent implements OnInit, AfterViewChecked {
rawScore: result.score,
totalGridAnswers: result.maxValueAnswer,
percentage: percentage,
totalCorrect: totalCorrect
totalCorrect: totalCorrect,
customScore: result.customScore
};
resultObject[category] = scores;
const currentTotal = this.totals[category];
Expand Down

0 comments on commit 3e731aa

Please sign in to comment.