Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
update : math float in soring save part
Browse files Browse the repository at this point in the history
  • Loading branch information
minjunj committed Jun 17, 2024
1 parent 66e9600 commit 5267342
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
3 changes: 3 additions & 0 deletions src/scoring/scoring.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ export class ScoringController {
@Param('lecture_id') lecture_id: number,
@Param('prof_id') prof_id?: number,
): Promise<any> {
console.log('ing');
await this.scoringService.scoring(lecture_id, prof_id);
console.log('out scoring func');
await this.scoringService.updateScoring(lecture_id, prof_id);
console.log('out update scoring func');
return await this.scoringService.getScoring(lecture_id, prof_id);
}

Expand Down
32 changes: 19 additions & 13 deletions src/scoring/scoring.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export class ScoringService {
main_lecture_id: number,
prof_id?: number,
) {
console.log('in scoring function');
// let prof_id = prof_i1d;
let i: number;
let diff_sum = 0;
Expand Down Expand Up @@ -260,7 +261,12 @@ export class ScoringService {
inter_sum = inter_sum / i;
lots_sum = lots_sum / i;
sati_sum = sati_sum / i;

console.log('diff sum' + diff_sum);
console.log('stren sum' + stren_sum);
console.log('help sum' + help_sum);
console.log('inter sum' + inter_sum);
console.log('lots sum' + lots_sum);
console.log('sati sum' + sati_sum);
// total_score =
// (diff_sum + stren_sum + help_sum + inter_sum + lots_sum + sati_sum) / 6;
const found = await this.lectureRepository.findOne({
Expand Down Expand Up @@ -288,12 +294,12 @@ export class ScoringService {
const scoring = new Scoring();

scoring.lecture_id = main_lecture_id * 1;
scoring.diff_aver = diff_sum;
scoring.stren_aver = stren_sum;
scoring.help_aver = help_sum;
scoring.inter_aver = inter_sum;
scoring.lots_aver = lots_sum;
scoring.sati_aver = sati_sum;
scoring.diff_aver = Math.floor(diff_sum);
scoring.stren_aver = Math.floor(stren_sum);
scoring.help_aver = Math.floor(help_sum);
scoring.inter_aver = Math.floor(inter_sum);
scoring.lots_aver = Math.floor(lots_sum);
scoring.sati_aver = Math.floor(sati_sum);
scoring.people = people;
scoring.good = good;
scoring.bad = bad;
Expand Down Expand Up @@ -336,12 +342,12 @@ export class ScoringService {
},
});
scoring.lecture_id = main_lecture_id * 1;
scoring.diff_aver = diff_sum;
scoring.stren_aver = stren_sum;
scoring.help_aver = help_sum;
scoring.inter_aver = inter_sum;
scoring.lots_aver = lots_sum;
scoring.sati_aver = sati_sum;
scoring.diff_aver = Math.floor(diff_sum);
scoring.stren_aver = Math.floor(stren_sum);
scoring.help_aver = Math.floor(help_sum);
scoring.inter_aver = Math.floor(inter_sum);
scoring.lots_aver = Math.floor(lots_sum);
scoring.sati_aver = Math.floor(sati_sum);
scoring.people = people;
scoring.good = good;
scoring.bad = bad;
Expand Down

0 comments on commit 5267342

Please sign in to comment.