Skip to content

Commit

Permalink
[Feature:RainbowGrades] add support for numeric_ids(#45)
Browse files Browse the repository at this point in the history
Co-authored-by: Barb Cutler <Barb Cutler>
  • Loading branch information
bmcutler authored Feb 1, 2023
1 parent afd85de commit 881a9c3
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 27 deletions.
14 changes: 6 additions & 8 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,6 @@ void processcustomizationfile(const std::string &now_string,

std::string token,token2;

std::string iclicker_remotes_filename;
std::vector<std::vector<std::vector<iClickerQuestion> > > iclicker_questions(MAX_LECTURES+1);

for (nlohmann::json::iterator itr = j.begin(); itr != j.end(); itr++) {
Expand Down Expand Up @@ -1096,8 +1095,6 @@ void processcustomizationfile(const std::string &now_string,
assert (GLOBAL_earned_late_days.size() == 0 || tmp > GLOBAL_earned_late_days.back());
GLOBAL_earned_late_days.push_back(tmp);
}
} else if (token == "iclicker_ids") {
iclicker_remotes_filename = itr.value().get<std::string>();
} else if (token == "iclicker") {
for (nlohmann::json::iterator itr2 = (itr.value()).begin(); itr2 != (itr.value()).end(); itr2++) {
std::string temp = itr2.key();
Expand Down Expand Up @@ -1225,7 +1222,6 @@ void processcustomizationfile(const std::string &now_string,
LoadExamSeatingFile(GLOBAL_EXAM_SEATING_COUNT,GLOBAL_EXAM_SEATING,GLOBAL_SEATING_SPACING,GLOBAL_LEFT_RIGHT_HANDEDNESS,students);
}
MakeRosterFile(students);
MatchClickerRemotes(students, iclicker_remotes_filename);
AddClickerScores(students,iclicker_questions);
}

Expand Down Expand Up @@ -1287,18 +1283,20 @@ void load_student_grades(std::vector<Student*> &students) {
// non gradeables
if (token == "user_id") {
s->setUserName(j[token].get<std::string>());
} else if (token == "legal_first_name") {
} else if (token == "legal_first_name" || token == "legal_given_name") {
s->setLegalFirstName(j[token].get<std::string>());
} else if (token == "legal_last_name") {
} else if (token == "legal_last_name" || token == "legal_family_name") {
s->setLegalLastName(j[token].get<std::string>());
} else if (token == "preferred_first_name") {
} else if (token == "preferred_first_name" || token == "preferred_given_name") {
if (!j[token].is_null()) {
s->setPreferredFirstName(j[token].get<std::string>());
}
} else if (token == "preferred_last_name") {
} else if (token == "preferred_last_name" || token == "preferred_family_name") {
if (!j[token].is_null()) {
s->setPreferredLastName(j[token].get<std::string>());
}
} else if (token == "user_numeric_id") {
s->setNumericID(j[token].get<std::string>());
} else if (token == "last_update") {
s->setLastUpdate(j[token].get<std::string>());
} else if (token == "registration_section") {
Expand Down
56 changes: 56 additions & 0 deletions output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@ void SelectBenchmarks(std::vector<int> &select_students, const std::vector<Stude
}


std::ofstream GLOBAL_EWS_OUTPUT;

std::ofstream GLOBAL_GRADES_OUTPUT;

void start_table_output( bool /*for_instructor*/,
const std::vector<Student*> &students, int rank, int month, int day, int year,
Student *sp, Student *sa, Student *sb, Student *sc, Student *sd, bool csv_mode) {
Expand All @@ -552,6 +556,11 @@ void start_table_output( bool /*for_instructor*/,

Table table;

GLOBAL_EWS_OUTPUT = std::ofstream("ews_output.txt");
assert (GLOBAL_EWS_OUTPUT.good());

GLOBAL_GRADES_OUTPUT = std::ofstream("grades_output.txt");
assert (GLOBAL_GRADES_OUTPUT.good());

// =====================================================================================================
// =====================================================================================================
Expand All @@ -565,6 +574,7 @@ void start_table_output( bool /*for_instructor*/,
table.set(0,counter++,TableCell("ffffff","notes"));
}
student_data.push_back(counter); table.set(0,counter++,TableCell("ffffff","USERNAME"));
student_data.push_back(counter); table.set(0,counter++,TableCell("ffffff","NUMERIC ID"));
if (DISPLAY_INSTRUCTOR_NOTES || DISPLAY_FINAL_GRADE) {
table.set(0,counter++,TableCell("ffffff","LAST (LEGAL)"));
table.set(0,counter++,TableCell("ffffff","FIRST (LEGAL)"));
Expand Down Expand Up @@ -791,8 +801,52 @@ void start_table_output( bool /*for_instructor*/,
std::vector<std::string> ews = this_student->getEarlyWarnings();
for (std::size_t i = 0; i < ews.size(); i++) {
notes += ews[i];

//std::cout << "FOUND EWS " << this_student->getUserName() << ews[i] << std::endl;

}
std::string other_note = this_student->getOtherNote();

// TEMPORARY placeholder code until course section is added
std::string crn = "99999";
if (this_student->getSection() == "1") crn = "55037";
if (this_student->getSection() == "2") crn = "57469";
if (this_student->getSection() == "3") crn = "55038";
if (this_student->getSection() == "4") crn = "57234";
if (this_student->getSection() == "5") crn = "56274";
if (this_student->getSection() == "6") crn = "55039";
if (this_student->getSection() == "7") crn = "55328";
if (this_student->getSection() == "8") crn = "57673";
if (this_student->getSection() == "9") crn = "57871";
if (this_student->getSection() == "10")crn = "58089";

if (other_note != "" && other_note.find("EWS2") != std::string::npos) {

std::string category = "FAILING";
if (other_note.find("TEST") != std::string::npos) { category="TEST_PERFORMANCE"; }
if (other_note.find("HW") != std::string::npos) { category="MISSING_INCOMPLETE_HW"; }
if (other_note.find("ATTENDANCE") != std::string::npos) { category="ATTENDANCE"; }

GLOBAL_EWS_OUTPUT << this_student->getSection() << ","
<< crn << "," << this_student->getUserName() << ","
<< this_student->getNumericID() << ","
<< category << "," << other_note << std::endl;

}

std::string student_grade = this_student->grade(false,sd);

if (this_student->getSection() != "null" &&
this_student->getSection() != "STAFF" &&
this_student->getSection() != "ALAC"
) {

GLOBAL_GRADES_OUTPUT << this_student->getSection() << ","
<< crn << "," << this_student->getUserName() << ","
<< this_student->getNumericID() << ","
<< student_grade << std::endl;
}

std::string recommendation = this_student->getRecommendation();
std::string THING;
if(!csv_mode) {
Expand All @@ -803,6 +857,7 @@ void start_table_output( bool /*for_instructor*/,
}
else{
THING = notes + " " + other_note + " " + recommendation;

}
assert (default_color.size()==6);
table.set(myrow,counter++,TableCell(default_color,THING));
Expand All @@ -811,6 +866,7 @@ void start_table_output( bool /*for_instructor*/,
//counter+=3;
assert (default_color.size()==6);
table.set(myrow,counter++,TableCell(default_color,this_student->getUserName()));
table.set(myrow,counter++,TableCell(default_color,this_student->getNumericID()));
if (DISPLAY_INSTRUCTOR_NOTES || DISPLAY_FINAL_GRADE) {
table.set(myrow,counter++,TableCell(default_color,this_student->getLastName()));
table.set(myrow,counter++,TableCell(default_color,this_student->getFirstName()));
Expand Down
25 changes: 13 additions & 12 deletions student.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Student::Student() {
cached_hw = -1;

// other grade-like data
// (remote id defaults to empty vector)
numeric_id = "";
academic_integrity_form = false;
participation = 0;
understanding = 0;
Expand Down Expand Up @@ -379,7 +379,7 @@ float Student::overall_b4_moss() const {
return answer;
}

std::string Student::grade(bool flag_b4_moss, Student */*lowest_d*/) const {
std::string Student::grade(bool flag_b4_moss, Student *lowest_d) const {

if (section == "null") return "";

Expand All @@ -395,7 +395,7 @@ std::string Student::grade(bool flag_b4_moss, Student */*lowest_d*/) const {
// (instructor can override with manual grade)

//Old (pre Su2019) DS method
/*int failed_lab = (GradeablePercent(GRADEABLE_ENUM::LAB) < 1.01 * lowest_d->GradeablePercent(GRADEABLE_ENUM::LAB) ) ? true : false;
int failed_lab = (GradeablePercent(GRADEABLE_ENUM::LAB) < 1.01 * lowest_d->GradeablePercent(GRADEABLE_ENUM::LAB) ) ? true : false;
int failed_hw = (GradeablePercent(GRADEABLE_ENUM::HOMEWORK) < 0.95 * lowest_d->GradeablePercent(GRADEABLE_ENUM::HOMEWORK) ) ? true : false;
int failed_testA = (GradeablePercent(GRADEABLE_ENUM::TEST) < 0.90 * lowest_d->GradeablePercent(GRADEABLE_ENUM::TEST) ) ? true : false;
int failed_testB = (GradeablePercent(GRADEABLE_ENUM::EXAM) < 0.90 * lowest_d->GradeablePercent(GRADEABLE_ENUM::EXAM) ) ? true : false;
Expand All @@ -405,24 +405,25 @@ std::string Student::grade(bool flag_b4_moss, Student */*lowest_d*/) const {
( failed_testA +
failed_testB +
failed_testC ) > 1) {
//std::cout << "SHOULD AUTO FAIL";
std::cout << "SHOULD AUTO FAIL";

//((Student*)this)->other_note += "SHOULD AUTO FAIL";
((Student*)this)->other_note += "SHOULD AUTO FAIL";
return "F";
}*/

}


/*
for(std::map<GRADEABLE_ENUM,float>::const_iterator it=OVERALL_FAIL_CUTOFFS.begin(); it != OVERALL_FAIL_CUTOFFS.end(); it++){
if(GradeablePercent(it->first)/100.0 < GRADEABLES[it->first].getPercent() * it->second){
/*std::cerr << "Failing student " << this->getUserName() << " due to low " << gradeable_to_string(it->first)
<< " grade of " << GradeablePercent(it->first)/100.0 << " < "
<< GRADEABLES[it->first].getPercent() * it->second << " max is "
<< GRADEABLES[it->first].getPercent() << std::endl;*/
std::cerr << "Failing student " << this->getUserName() << " due to low " << gradeable_to_string(it->first)
<< " grade of " << GradeablePercent(it->first)/100.0 << " < "
<< GRADEABLES[it->first].getPercent() * it->second << " max is "
<< GRADEABLES[it->first].getPercent() << std::endl;
return "F";
}
}

*/

// otherwise apply the cutoffs
if (over >= CUTOFFS["A"]) return "A";
if (over >= CUTOFFS["A-"]) return "A-";
Expand Down
10 changes: 5 additions & 5 deletions student.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,21 @@ class Student {
int getDefaultAllowedLateDays() const { return default_allowed_late_days; }

void add_bonus_late_day(int which_lecture) {
std::cout << "ADD BONUS " << which_lecture << " " << username << std::endl;
//std::cout << "ADD BONUS " << which_lecture << " " << username << std::endl;
bonus_late_days_which_lecture.push_back(which_lecture);
}
bool get_bonus_late_day(int which_lecture) const {
for (unsigned int i = 0; i < bonus_late_days_which_lecture.size(); i++) {
if (bonus_late_days_which_lecture[i] == which_lecture) {
std::cout << "YES BONUS " << which_lecture << " " << username << std::endl;
//std::cout << "YES BONUS " << which_lecture << " " << username << std::endl;
return true;
}
}
return false;
}

// other grade-like data
const std::vector<std::string>& getRemoteID() const { return remote_id; }
const std::string& getNumericID() const { return numeric_id; }
bool getAcademicIntegrityForm() const { return academic_integrity_form; }
float getParticipation() const { return participation; }
float getUnderstanding() const { return understanding; }
Expand Down Expand Up @@ -165,7 +165,7 @@ class Student {
void mossify(const std::string &gradeable, float penalty);

// other grade-like data
void setRemoteID(const std::string& r_id) { remote_id.push_back(r_id); }
void setNumericID(const std::string& r_id) { numeric_id = r_id; }
void setAcademicIntegrityForm() { academic_integrity_form = true; }
void setParticipation(float x) { participation = x; }
void setUnderstanding(float x) { understanding = x; }
Expand Down Expand Up @@ -246,7 +246,7 @@ class Student {
int rank;

// other grade-like data
std::vector<std::string> remote_id;
std::string numeric_id;
bool academic_integrity_form;
float participation;
float understanding;
Expand Down
4 changes: 2 additions & 2 deletions submini_polls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ void SavePollReports(const std::vector<Student*> &students) {
tm local_tm = *localtime(&tt);
std::stringstream ss;
ss << local_tm.tm_year + 1900 << "-"
<< std::setw(2) << std::setfill('-') << local_tm.tm_mon + 1 << "-"
<< std::setw(2) << std::setfill('-') << local_tm.tm_mday;
<< std::setw(2) << std::setfill('0') << local_tm.tm_mon + 1 << "-"
<< std::setw(2) << std::setfill('0') << local_tm.tm_mday;
std::string today_string = ss.str();

std::cout << "TODAY " << today_string << std::endl;
Expand Down
4 changes: 4 additions & 0 deletions zone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ void LoadExamSeatingFile(const std::string &zone_counts_filename,
std::getline(istr_zone_counts,line);
if (istr_zone_counts.eof()) break;
//std::cout << "LINE " << line << std::endl;

if (line[0] == '#') continue;

if (line == "SKIP") break;

if (line.size() == 0) continue;
std::stringstream ss(line);
if (line.substr(0,4) == "zone") {
Expand Down

0 comments on commit 881a9c3

Please sign in to comment.