Skip to content

Commit

Permalink
[Feature:RainbowGrades] Border outline reflects status (#51)
Browse files Browse the repository at this point in the history
fixes Submitty/Submitty#9112
fixes Submitty/Submitty#9331 (EDIT (06.27.2023) - from student.cpp line
474 implementing LookupGradeable etc.


Rainbow Grade will now have border outline for 4 status.
Black border outline = Academic integrity violation
Yellow border outline = Grade override
Green border outline = Grade inquiry in progress
Read border outline = Bad status
 

Works for both individual & instructor (transposed) version
![Screen Shot 2023-06-02 at 12 53 42
PM](https://github.com/Submitty/RainbowGrades/assets/123261952/5e8fb9d3-41d1-40d0-aeec-546b38b0a38d)
![Screen Shot 2023-06-02 at 12 59 50
PM](https://github.com/Submitty/RainbowGrades/assets/123261952/8efc7b45-3c14-4161-b5e9-a989444367fb)

---------

Co-authored-by: Barb Cutler <[email protected]>
  • Loading branch information
ziesski and bmcutler authored Jun 27, 2023
1 parent 3422d41 commit c2ef907
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 17 deletions.
19 changes: 18 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,8 +1460,25 @@ void load_student_grades(std::vector<Student*> &students) {
if (status.find("Bad") != std::string::npos) {
assert (late_days_charged == 0);
}

std::string event;
std::string status_check = itr2->value("status", "");
if (status_check == "Bad")
{
event = "Bad";
}
if (status_check == "Overridden")
{
event = "Overridden";
}
std::string inquiry = itr2->value("inquiry", "");
if ((inquiry != "None") && (inquiry != "Resolved") && (inquiry != ""))
{
assert(inquiry == "Open");
event = "Open";
}
if (GRADEABLES[g].isReleased(gradeable_id)) {
s->setGradeableItemGrade(g,which,score,late_days_charged,other_note,status);
s->setGradeableItemGrade_border(g,which,score,event,late_days_charged,other_note,status);
}
}

Expand Down
7 changes: 5 additions & 2 deletions output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,13 +1056,14 @@ void start_table_output( bool /*for_instructor*/,
std::string details;
details = this_student->getGradeableItemGrade(g,j).getNote();
std::string status = this_student->getGradeableItemGrade(g,j).getStatus();

std::string event = this_student->getGradeableItemGrade(g,j).getEvent();
bool Academic_integrity = this_student->getGradeableItemGrade(g,j).getAcademicIntegrity();
if (status.find("Bad") != std::string::npos) {
details += " " + status;
}
int late_days_used = this_student->getGradeableItemGrade(g,j).getLateDaysUsed();
assert (color.size()==6);
table.set(myrow,counter++,TableCell(color,grade,1,details,late_days_used,visible));
table.set(myrow,counter++,TableCell(grade,color,1,details,late_days_used,visible,event,Academic_integrity));
}
table.set(myrow,counter++,TableCell(grey_divider));

Expand Down Expand Up @@ -1260,6 +1261,8 @@ 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;
// This should only pop up for those who violated policy FIX HERE
// ostr << "<p>@ = Academic Integrity Violation</p>" << std::endl;

if (s != NULL) {
std::ifstream istr("student_poll_reports/"+s->getUserName()+".html");
Expand Down
38 changes: 31 additions & 7 deletions student.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,29 @@ void Student::setGradeableItemGrade(GRADEABLE_ENUM g, int i, float value,
itr->second[i] = ItemGrade(value,late_days_used,note,status);
}

void Student::setGradeableItemGrade_AcademicIntegrity(GRADEABLE_ENUM g, int i, float value, bool academic_integrity,
int late_days_used, const std::string &note, const std::string &status) {
assert (i >= 0 && i < GRADEABLES[g].getCount());
std::map<GRADEABLE_ENUM,std::vector<ItemGrade> >::iterator itr = all_item_grades.find(g);
assert (itr != all_item_grades.end());
assert (int(itr->second.size()) > i);
std::string temp = "";

itr->second[i] = ItemGrade(value,late_days_used,note,status,temp,academic_integrity);
}

void Student::setGradeableItemGrade_border(GRADEABLE_ENUM g, int i, float value, const std::string &event, int late_days_used, const std::string &note, const std::string &status) {
assert (i >= 0 && i < GRADEABLES[g].getCount());
std::map<GRADEABLE_ENUM,std::vector<ItemGrade> >::iterator itr = all_item_grades.find(g);
assert (itr != all_item_grades.end());
assert (int(itr->second.size()) > i);

itr->second[i] = ItemGrade(value,late_days_used,note,status,event);
}






// =============================================================================================
Expand Down Expand Up @@ -448,15 +471,17 @@ void Student::mossify(const std::string &gradeable, float penalty) {
float average_letter_grade = (CUTOFFS["A"]-CUTOFFS["B"] +
CUTOFFS["B"]-CUTOFFS["C"] +
CUTOFFS["C"]-CUTOFFS["D"]) / 3.0;

if (!GRADEABLES[GRADEABLE_ENUM::HOMEWORK].hasCorrespondence(gradeable)) {
GRADEABLE_ENUM g;
int item;
LookupGradeable(gradeable,g,item);
if (!GRADEABLES[g].hasCorrespondence(gradeable)) {
std::cerr << "WARNING -- NO GRADEABLE TO MOSSIFY" << std::endl;
} else {
int which = GRADEABLES[GRADEABLE_ENUM::HOMEWORK].getCorrespondence(gradeable).first;
if (!(getGradeableItemGrade(GRADEABLE_ENUM::HOMEWORK,which).getValue() > 0)) {
std::cerr << "WARNING: the grade for this homework is already 0, moss penalty error?" << std::endl;
int which = GRADEABLES[g].getCorrespondence(gradeable).first;
if (!(getGradeableItemGrade(g,which).getValue() > 0)) {
std::cerr << "WARNING: the grade for this " <<gradeable_to_string(g)<<" is already 0, moss penalty error?" << std::endl;
}
setGradeableItemGrade(GRADEABLE_ENUM::HOMEWORK,which,0);
setGradeableItemGrade_AcademicIntegrity(g,which,0, true);
}

// the penalty is positive
Expand All @@ -465,7 +490,6 @@ void Student::mossify(const std::string &gradeable, float penalty) {

moss_penalty += -0.0000001;
moss_penalty += -average_letter_grade * penalty;

std::stringstream foo;
foo << std::setprecision(2) << std::fixed << penalty;

Expand Down
12 changes: 11 additions & 1 deletion student.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@

class ItemGrade {
public:
ItemGrade(float v, int ldu=0, const std::string& n="", const std::string &s="") {
ItemGrade(float v, int ldu=0, const std::string& n="", const std::string &s="", const std::string &e="", bool ai=false) {
value = v;
late_days_used = ldu;
note = n;
event = e;
academic_integrity = ai;

if (s != "UNKONWN") {
status = s;
}
Expand Down Expand Up @@ -52,11 +55,16 @@ class ItemGrade {
int getLateDaysUsed() const { return late_days_used; }
const std::string& getNote() const { return note; }
const std::string& getStatus() const { return status; }
const std::string& getEvent() const { return event; }
bool getAcademicIntegrity() const { return academic_integrity; }

private:
float value;
int late_days_used;
bool academic_integrity;
std::string note;
std::string status;
std::string event;
};

//====================================================================
Expand Down Expand Up @@ -163,6 +171,8 @@ class Student {
// grade data
void setTestZone(int which_test, const std::string &zone) { zones[which_test] = zone; }
void setGradeableItemGrade(GRADEABLE_ENUM g, int i, float value, int late_days_used=0, const std::string &note="",const std::string &status="");
void setGradeableItemGrade_AcademicIntegrity(GRADEABLE_ENUM g, int i, float value, bool academic_integrity, int late_days_used=0, const std::string &note="",const std::string &status="");
void setGradeableItemGrade_border(GRADEABLE_ENUM g, int i, float value, const std::string &event="", int late_days_used=0, const std::string &note="",const std::string &status="");

void mossify(const std::string &gradeable, float penalty);

Expand Down
67 changes: 62 additions & 5 deletions table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,74 @@ TableCell::TableCell(const std::string& c, float d, int precision, const std::st
rotate = 0;
}


TableCell::TableCell(float d, const std::string& c, int precision, const std::string& n, int ldu,
CELL_CONTENTS_STATUS v,const std::string& e,bool ai, const std::string& a, int s, int /*r*/) {
assert (c.size() == 6);
assert (precision >= 0);
color=c;
if (fabs(d) > 0.0001) {
std::stringstream ss;
ss << std::setprecision(precision) << std::fixed << d;
data=ss.str(); span=s;
} else {
data = "";
}
note=n;
late_days_used=ldu,
visible=v;
align=a;
span=s;
rotate = 0;
academic_integrity = ai;
event = e;
if (event == "Bad"){
bad_status = true;
override = inquiry = false;
} else if ( event == "Overridden"){
override = true;
bad_status = inquiry = false;
} else if (event == "Open"){
inquiry = true;
bad_status = override = false;
} else {
inquiry = bad_status = override = false;
}

}



std::ostream& operator<<(std::ostream &ostr, const TableCell &c) {
assert (c.color.size() == 6);

std::string outline = "";
std::string mark = "";
if (c.academic_integrity){
outline = "outline:4px solid #0a0a0a; outline-offset: -4px;";
mark = "@";
} else if (c.override){
outline = "outline:4px solid #fcca03; outline-offset: -4px;";
} else if (c.inquiry){
outline = "outline:4px dashed #1cfc03; outline-offset: -4px;";
} else if (c.bad_status){
outline = "outline:4px solid #fc0303; outline-offset: -4px;";
}

// ostr << "<td bgcolor=\"" << c.color << "\" align=\"" << c.align << "\">";
ostr << "<td style=\"border:1px solid #aaaaaa; background-color:#" << c.color << ";\" align=\"" << c.align << "\">";
ostr << "<td style=\"border:1px solid #aaaaaa; background-color:#" << c.color << "; " << outline << " \" align=\"" << c.align << "\">";

if (0) { //rotate == 90) {
ostr << "<div style=\"position:relative\"><p class=\"rotate\">";
}
ostr << "<font size=-1>";
std::string mynote = c.getNote();
if ((c.data == "" && mynote=="")

if (c.academic_integrity)
{
ostr << mark;
}
else if ((c.data == "" && mynote=="")
|| c.visible==CELL_CONTENTS_HIDDEN
|| (c.visible==CELL_CONTENTS_VISIBLE_INSTRUCTOR && GLOBAL_instructor_output == false)
|| (c.visible==CELL_CONTENTS_VISIBLE_STUDENT && GLOBAL_instructor_output == true)) {
Expand All @@ -92,6 +150,8 @@ std::ostream& operator<<(std::ostream &ostr, const TableCell &c) {
if (c.late_days_used > 3) { ostr << " (" << std::to_string(c.late_days_used) << "*)"; }
else { ostr << " " << std::string(c.late_days_used,'*'); }
}


if (mynote.length() > 0 &&
mynote != " " &&
(global_details
Expand Down Expand Up @@ -177,10 +237,7 @@ void Table::output(std::ostream& ostr,
ostr << "<em>Information last updated: " << last_update << "</em><br>\n";
}
ostr << "&nbsp;<br>\n";


ostr << "<table style=\"border:1px solid #aaaaaa; background-color:#aaaaaa;\">\n";
// ostr << "<table border=0 cellpadding=3 cellspacing=2 style=\"background-color:#aaaaaa\">\n";
}

if (transpose) {
Expand Down
9 changes: 8 additions & 1 deletion table.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ class TableCell {
CELL_CONTENTS_STATUS v=CELL_CONTENTS_VISIBLE, const std::string& a="left" , int s=1, int r=0);
TableCell(const std::string& c , float d , int precision, const std::string& n="", int ldu=0,
CELL_CONTENTS_STATUS v=CELL_CONTENTS_VISIBLE, const std::string& a="right", int s=1, int r=0);
TableCell(float d ,const std::string& c , int precision, const std::string& n="", int ldu=0,
CELL_CONTENTS_STATUS v=CELL_CONTENTS_VISIBLE, const std::string& e="", bool ai = false, const std::string& a="right", int s=1, int r=0);

std::string make_cell_string(bool csv_mode) const;

std::string color;
std::string data;
std::string event;
int late_days_used;
bool academic_integrity = false;
bool inquiry = false;
bool bad_status = false;
bool override = false;
std::string align;
enum CELL_CONTENTS_STATUS visible;
int span;
Expand Down

0 comments on commit c2ef907

Please sign in to comment.