Skip to content

Commit 87d9dd2

Browse files
authored
[Feature:RainbowGrades] rotating sections in grade summaries (#28)
* supporting polls... * add rotating section
1 parent 8c2b7ab commit 87d9dd2

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

main.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,12 @@ void load_student_grades(std::vector<Student*> &students) {
13201320
a = "null";
13211321
}
13221322
s->setSection(a);
1323-
1323+
} else if (token == "rotating_section") {
1324+
int a = -1;
1325+
if (!j[token].is_null()) {
1326+
a = j[token].get<int>();
1327+
}
1328+
s->setRotatingSection(a);
13241329
} else if (token == "default_allowed_late_days") {
13251330
int value = 0;
13261331
if (!j[token].is_null()) {
@@ -1776,6 +1781,35 @@ void initialize_time(std::string &now_string, int &year, int &month, int &day) {
17761781
}
17771782

17781783

1784+
void loadAllowedLateDays(std::vector<Student*> &students) {
1785+
std::ifstream istr("polls/late_days.csv");
1786+
if (!istr.good()) return;
1787+
std::string s;
1788+
while (istr >> s) {
1789+
int x = s.find(',');
1790+
std::string username = s.substr(0,x);
1791+
s = s.substr(x+1,100);
1792+
1793+
x = s.find(',');
1794+
std::string date = s.substr(0,x);
1795+
s = s.substr(x+1,100);
1796+
1797+
int allowed = std::stoi(s);
1798+
1799+
//std::cout << "foo " << s << " --- " << username << " - " <<date << " - " << allowed <<std::endl;
1800+
1801+
for (int i = 0; i < students.size(); i++) {
1802+
Student* s = students[i];
1803+
if (s->getUserName() == username) {
1804+
s->setCurrentAllowedLateDays(allowed);
1805+
break;
1806+
}
1807+
}
1808+
1809+
}
1810+
}
1811+
1812+
17791813
int main(int argc, char* argv[]) {
17801814

17811815
//std::string sort_order = "by_overall";
@@ -1793,6 +1827,8 @@ int main(int argc, char* argv[]) {
17931827
std::vector<Student*> students;
17941828
processcustomizationfile(now_string,students);
17951829

1830+
loadAllowedLateDays(students);
1831+
17961832
// ======================================================================
17971833
// SUGGEST CURVES
17981834
suggest_curves(students);

output.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ std::string coloritcolor(float val,
160160
//check for nan
161161
if (val != val) return "ffffff";
162162
if (std::isinf(val)) return "00ff00";
163+
if (std::isnan(perfect)) return "00ff00";
163164

164165
//std::cout << "coloritcolor " << val << " " << perfect << " " << a << " " << b << " " << c << " " << d << std::endl;
165166
assert (perfect >= a &&
@@ -1163,8 +1164,17 @@ void start_table_output( bool for_instructor,
11631164

11641165
void end_table(std::ofstream &ostr, bool for_instructor, Student *s) {
11651166

1167+
ostr << "<p>* = 1 late day used</p>" << std::endl;
11661168

1167-
ostr << "<p>* = 1 late day used</p>" << std::endl;
1169+
if (s != NULL) {
1170+
std::ifstream istr("polls/student_files/"+s->getUserName()+".html");
1171+
if (istr.good()) {
1172+
std::string tmp_s;
1173+
while (getline(istr,tmp_s)) {
1174+
ostr << tmp_s;
1175+
}
1176+
}
1177+
}
11681178

11691179
if (GLOBAL_instructor_output == false &&
11701180
DISPLAY_ICLICKER) {

student.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Student::Student() {
2929
}
3030
// (iclicker defaults to empty map)
3131

32+
rotating_section = -1;
3233
zones = std::vector<std::string>(GRADEABLES[GRADEABLE_ENUM::TEST].getCount(),"");
3334
moss_penalty = 0;
3435
cached_hw = -1;

student.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class Student {
8585

8686
// registration status
8787
const std::string& getSection() const { return section; }
88+
int getRotatingSection() const { return rotating_section; }
8889
bool getAudit() const { return audit; }
8990
bool getWithdraw() const { return withdraw; }
9091
bool getIndependentStudy() const { return independentstudy; }
@@ -138,6 +139,7 @@ class Student {
138139

139140
// registration status
140141
void setSection(std::string x) { section = x; }
142+
void setRotatingSection(int x) { rotating_section = x; }
141143
void setAudit() { audit = true; }
142144
void setWithdraw() { withdraw = true; }
143145
void setIndependentStudy() { independentstudy = true; }
@@ -213,6 +215,7 @@ class Student {
213215

214216
// registration status
215217
std::string section;
218+
int rotating_section;
216219
bool audit;
217220
bool withdraw;
218221
bool independentstudy;

0 commit comments

Comments
 (0)