This repository was archived by the owner on Mar 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
85 lines (69 loc) · 2.07 KB
/
main.cpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <algorithm>
#include <fstream>
#include <set>
#include <string>
#include <vector>
#include "GradingStatsWorker.h"
#include "HelpInstance.h"
#include "TeachingAssistant.h"
int index(const vector<TeachingAssistant> &teachingAssistants, string name) {
for (int i = 0; i < teachingAssistants.size(); ++i) {
if (teachingAssistants.at(i).getName() == name) {
return i;
}
}
return -1;
}
void writeInLabResults(vector<TeachingAssistant> teachingAssistants) {
std::sort(teachingAssistants.begin(), teachingAssistants.end());
ofstream file;
file.open("help-results.csv");
file << "Name";
file << ',' << "Total Time";
file << ',' << "Helped";
file << endl;
for (TeachingAssistant &ta : teachingAssistants) {
if (ta.getName() != "Themselves") {
file << ta.getName();
file << ',' << ta.getTotalHoursStr();
file << ',' << ta.getHelpInstanceTotal();
file << '\n';
}
}
file.close();
}
vector<HelpInstance> extractInLabFile(string fileloc) {
vector<HelpInstance> inLab;
ifstream inLabFile;
string row;
inLabFile.open(fileloc);
while (inLabFile.good()) {
getline(inLabFile, row);
if (row != ",,,,,,," && row != "") {
inLab.push_back(HelpInstance(row));
}
}
inLabFile.close();
return inLab;
}
vector<TeachingAssistant> assignInstancesToTA(vector<HelpInstance> instances) {
vector<TeachingAssistant> teachingAssistants;
for (HelpInstance inst : instances) {
int thisTA = index(teachingAssistants, inst.getTaName());
if (thisTA == -1) {
teachingAssistants.push_back(TeachingAssistant(inst.getTaName()));
teachingAssistants.back().addHelpInstance(inst);
} else {
teachingAssistants.at(thisTA).addHelpInstance(inst);
}
}
return teachingAssistants;
}
int main(int argc, char *argv[]) {
string inLabFileLoc = "help-data.csv";
string gradingFileLoc = "grade-data.csv";
writeInLabResults(assignInstancesToTA(extractInLabFile(inLabFileLoc)));
GradingStatsWorker gradeWorker;
gradeWorker.readInStats(gradingFileLoc);
gradeWorker.writeOutStats("grade-results.csv");
}