@@ -11,7 +11,7 @@ enum Grade {
11
11
S = "S" ,
12
12
}
13
13
14
- export type AllGrades = Grade | "Absent" | "Withheld" ;
14
+ export type AllGrades = Grade | "Absent" | "Withheld" | "Malpractice" ;
15
15
16
16
export interface ResultType {
17
17
registerNo : number ;
@@ -21,7 +21,11 @@ export interface ResultType {
21
21
course : string ;
22
22
examType : "Regular" | "Supplementary" ;
23
23
attendance : "Present" | "Absent" ;
24
- withheld : "Withheld" | "With held for Malpractice" | null ;
24
+ withheld :
25
+ | "Withheld"
26
+ | "With held for Malpractice"
27
+ | '"With held for Malpractice"'
28
+ | null ;
25
29
iMark : number | null ;
26
30
grade : Grade | null ;
27
31
result : "P" | "F" | null ;
@@ -37,7 +41,7 @@ interface FormattedType {
37
41
grades : {
38
42
[ key : courseName ] : AllGrades | null ;
39
43
} ;
40
- withheld : "Withheld" | "With held for Malpractice" | null ;
44
+ // withheld: "Withheld" | "With held for Malpractice" | null;
41
45
}
42
46
43
47
export const parseCsv = (
@@ -103,17 +107,37 @@ export const formatData = (data: ResultType[]): FormattedType[] => {
103
107
: item . attendance === "Absent"
104
108
? "Absent"
105
109
: item . withheld === "With held for Malpractice"
106
- ? Grade . F
110
+ ? "Malpractice"
111
+ : item . withheld === '"With held for Malpractice"'
112
+ ? "Malpractice"
107
113
: item . withheld === "Withheld"
108
114
? "Withheld"
109
115
: null ,
110
116
} ,
111
- withheld : item . withheld ,
117
+ // withheld:
118
+ // item.withheld === "With held for Malpractice"
119
+ // ? "With held for Malpractice"
120
+ // : item.withheld === '"With held for Malpractice"'
121
+ // ? "With held for Malpractice"
122
+ // : item.withheld === "Withheld"
123
+ // ? "Withheld"
124
+ // : null,
112
125
} ) ;
113
126
} else {
114
- formattedData [ index ] . grades [ item . course ] = item . grade ;
127
+ formattedData [ index ] . grades [ item . course ] = item . grade
128
+ ? item . grade
129
+ : item . attendance === "Absent"
130
+ ? "Absent"
131
+ : item . withheld === "With held for Malpractice"
132
+ ? "Malpractice"
133
+ : item . withheld === '"With held for Malpractice"'
134
+ ? "Malpractice"
135
+ : item . withheld === "Withheld"
136
+ ? "Withheld"
137
+ : null ;
115
138
}
116
139
} ) ;
140
+
117
141
return formattedData ;
118
142
} ;
119
143
@@ -171,7 +195,7 @@ const calculateGradesCountInEachCourse = (data: FormattedType[]) => {
171
195
E : 0 ,
172
196
F : 0 ,
173
197
Withheld : 0 ,
174
- "With held for Malpractice" : 0 ,
198
+ Malpractice : 0 ,
175
199
Absent : 0 ,
176
200
} ;
177
201
} ) ;
@@ -193,7 +217,7 @@ const calculateGradesCountInEachCourse = (data: FormattedType[]) => {
193
217
E : number ;
194
218
F : number ;
195
219
Withheld : number ;
196
- "With held for Malpractice" : number ;
220
+ Malpractice : number ;
197
221
Absent : number ;
198
222
} [ ] = [ ] ;
199
223
@@ -349,7 +373,7 @@ const createResultWorksheet = (data: FormattedType[]) => {
349
373
xlsx . utils . sheet_add_json ( ws , gradeData , {
350
374
// skipHeader: false,
351
375
origin : {
352
- c : 3 , // start from 4th column so later it can be merged
376
+ c : 2 , // start from 4th column so later it can be merged
353
377
r : reFormattedData . length + 7 ,
354
378
} ,
355
379
@@ -363,7 +387,7 @@ const createResultWorksheet = (data: FormattedType[]) => {
363
387
"E" ,
364
388
"F" ,
365
389
"Withheld" ,
366
- "With held for Malpractice" ,
390
+ "Malpractice" ,
367
391
"Absent" ,
368
392
] ,
369
393
} ) ;
@@ -434,8 +458,11 @@ const createResultWorksheet = (data: FormattedType[]) => {
434
458
if ( cell . t === "s" && cell . v === "Withheld" ) {
435
459
cell . s = { ...cell . s , fill : { fgColor : { rgb : "fba7cf" } } } ;
436
460
}
461
+ if ( cell . t === "s" && cell . v === "Malpractice" ) {
462
+ cell . s = { ...cell . s , fill : { fgColor : { rgb : "d7fc00" } } } ;
463
+ }
437
464
// set cell width to minimum text width
438
- if ( R == 4 ) console . log ( cell ) ;
465
+ // if (R == 4) console.log(cell);
439
466
if ( cell . t === "s" && [ 1 , 2 ] . includes ( C ) ) {
440
467
if ( ! ws [ "!cols" ] ) ws [ "!cols" ] = [ ] ;
441
468
ws [ "!cols" ] [ C ] = { wch : cell . v . length + 5 } ;
0 commit comments