-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReportCard.cpp
More file actions
50 lines (41 loc) · 1.55 KB
/
Copy pathReportCard.cpp
File metadata and controls
50 lines (41 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include"Header.hpp"
void ReportCard::display() {
if (questions.empty()) {
cout << "No exam results to display.\n";
return;
}
// Header
cout << "\nLine No. Question Student Answer Correct Answer Result Score\n";
cout << "---------------------------------------------------------------------------------\n";
for (int i = 0; i < questions.size(); ++i) {
string result = "[SKIPPED]";
string color_code = "";
double score = 0.0;
if (i < Student_Answers.size() && i < Correct_Answers.size()) {
if (Student_Answers[i] == Correct_Answers[i] || Student_Answers[i] == "--Approved--") {
color_code = "\033[32m";
result = "CORRECT";
}
else if(Student_Answers[i]=="Student_Answers[i]"){
color_code = "\033[31m";
result = "WRONG ";
}
else {
color_code = "\033[31m";
result = "WRONG ";
}
}
if (i < scores.size()) {
score = scores[i];
}
// Print with score column
printf("%-8d %-16.16s %-16.16s %-16.16s %s%s \033[0m %7.2f\n",
static_cast<int>(i + 1),
questions[i].c_str(),
(i < Student_Answers.size()) ? Student_Answers[i].c_str() : "N/A",
(i < Correct_Answers.size()) ? Correct_Answers[i].c_str() : "N/A",
color_code.c_str(),
result.c_str(),
score);
}
}