Skip to content

Commit

Permalink
[Feature:RainbowGrades] rotating sections in grade summaries (#28)
Browse files Browse the repository at this point in the history
* supporting polls...

* add rotating section
  • Loading branch information
bmcutler authored Dec 1, 2020
1 parent 8c2b7ab commit 87d9dd2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
38 changes: 37 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,12 @@ void load_student_grades(std::vector<Student*> &students) {
a = "null";
}
s->setSection(a);

} else if (token == "rotating_section") {
int a = -1;
if (!j[token].is_null()) {
a = j[token].get<int>();
}
s->setRotatingSection(a);
} else if (token == "default_allowed_late_days") {
int value = 0;
if (!j[token].is_null()) {
Expand Down Expand Up @@ -1776,6 +1781,35 @@ void initialize_time(std::string &now_string, int &year, int &month, int &day) {
}


void loadAllowedLateDays(std::vector<Student*> &students) {
std::ifstream istr("polls/late_days.csv");
if (!istr.good()) return;
std::string s;
while (istr >> s) {
int x = s.find(',');
std::string username = s.substr(0,x);
s = s.substr(x+1,100);

x = s.find(',');
std::string date = s.substr(0,x);
s = s.substr(x+1,100);

int allowed = std::stoi(s);

//std::cout << "foo " << s << " --- " << username << " - " <<date << " - " << allowed <<std::endl;

for (int i = 0; i < students.size(); i++) {
Student* s = students[i];
if (s->getUserName() == username) {
s->setCurrentAllowedLateDays(allowed);
break;
}
}

}
}


int main(int argc, char* argv[]) {

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

loadAllowedLateDays(students);

// ======================================================================
// SUGGEST CURVES
suggest_curves(students);
Expand Down
12 changes: 11 additions & 1 deletion output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ std::string coloritcolor(float val,
//check for nan
if (val != val) return "ffffff";
if (std::isinf(val)) return "00ff00";
if (std::isnan(perfect)) return "00ff00";

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

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

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

ostr << "<p>* = 1 late day used</p>" << std::endl;
if (s != NULL) {
std::ifstream istr("polls/student_files/"+s->getUserName()+".html");
if (istr.good()) {
std::string tmp_s;
while (getline(istr,tmp_s)) {
ostr << tmp_s;
}
}
}

if (GLOBAL_instructor_output == false &&
DISPLAY_ICLICKER) {
Expand Down
1 change: 1 addition & 0 deletions student.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Student::Student() {
}
// (iclicker defaults to empty map)

rotating_section = -1;
zones = std::vector<std::string>(GRADEABLES[GRADEABLE_ENUM::TEST].getCount(),"");
moss_penalty = 0;
cached_hw = -1;
Expand Down
3 changes: 3 additions & 0 deletions student.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Student {

// registration status
const std::string& getSection() const { return section; }
int getRotatingSection() const { return rotating_section; }
bool getAudit() const { return audit; }
bool getWithdraw() const { return withdraw; }
bool getIndependentStudy() const { return independentstudy; }
Expand Down Expand Up @@ -138,6 +139,7 @@ class Student {

// registration status
void setSection(std::string x) { section = x; }
void setRotatingSection(int x) { rotating_section = x; }
void setAudit() { audit = true; }
void setWithdraw() { withdraw = true; }
void setIndependentStudy() { independentstudy = true; }
Expand Down Expand Up @@ -213,6 +215,7 @@ class Student {

// registration status
std::string section;
int rotating_section;
bool audit;
bool withdraw;
bool independentstudy;
Expand Down

0 comments on commit 87d9dd2

Please sign in to comment.