Skip to content

Commit

Permalink
[Bugfix:RainbowGrades] small tweaks for Submini Polls (#43)
Browse files Browse the repository at this point in the history
Co-authored-by: Barb Cutler <Barb Cutler>
  • Loading branch information
bmcutler authored Oct 3, 2022
1 parent 9137f22 commit 09fbe43
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
12 changes: 10 additions & 2 deletions student.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,19 @@ class Student {

int getDefaultAllowedLateDays() const { return default_allowed_late_days; }

void add_bonus_late_day(int which_lecture) { bonus_late_days_which_lecture.push_back(which_lecture); }
void add_bonus_late_day(int which_lecture) {
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)
if (bonus_late_days_which_lecture[i] == which_lecture) {
std::cout << "YES BONUS " << which_lecture << " " << username << std::endl;
return true;
}
}
if (username == "said") {
std::cout << "NO BONUS" << which_lecture << " " << username << std::endl;
}
return false;
}
Expand Down
19 changes: 17 additions & 2 deletions submini_polls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <sstream>
#include <cassert>
#include <iomanip>
#include <ctime>
#include <chrono>

#include <nlohmann/json.hpp>

Expand Down Expand Up @@ -187,7 +189,7 @@ void LoadPolls(const std::vector<Student*> &students) {
assert (c_options.size() >= 1);
assert (w_options.size() == 0);
assert (correct_choices <= 1);
assert (incorrect_choices == 0);
//assert (incorrect_choices == 0);
full_credit = (correct_choices == 1);
} else if (question_type == "multiple-response-exact") {
assert (c_options.size() >= 1);
Expand All @@ -198,7 +200,7 @@ void LoadPolls(const std::vector<Student*> &students) {
} else if (question_type == "multiple-response-survey") {
assert (c_options.size() >= 1);
assert (w_options.size() == 0);
assert (incorrect_choices == 0);
//assert (incorrect_choices == 0);
full_credit = (correct_choices >= 1);
} else {
std::cout << "OOPS: unknown question type '" << question_type << "'" << std::endl;
Expand Down Expand Up @@ -233,6 +235,17 @@ void LoadPolls(const std::vector<Student*> &students) {
// into their individual rainbow grades report).
//
void SavePollReports(const std::vector<Student*> &students) {

// make a string representing today's date: yyyy-mm-dd
static std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now();
time_t tt = std::chrono::system_clock::to_time_t(now);
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::string today_string = ss.str();

std::ofstream late_days_ostr("late_days.csv");
if (GLOBAL_lectures.size() == 0) return;
system ("mkdir -p student_poll_reports");
Expand All @@ -258,6 +271,8 @@ void SavePollReports(const std::vector<Student*> &students) {
which_lecture++;
int num = it->second.size();
std::string lect = it->first;

if (lect > today_string) continue;
int correct = s->second[lect].correct;
int wrong = s->second[lect].wrong;
total += correct;
Expand Down

0 comments on commit 09fbe43

Please sign in to comment.