From eaf757b2e91a9b29eab8fed153d6818d1dfd6259 Mon Sep 17 00:00:00 2001 From: Ryan Varughese Date: Mon, 21 Oct 2024 23:04:15 -0400 Subject: [PATCH 1/7] Making Preliminary Untested Changes Added a function getCourseDetails(), which returns the base url, term, and course, which helps in getting the total link to a specific gradeable on the output page. These changes are untested. --- output.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/output.cpp b/output.cpp index 0585c3b..6cd47c4 100644 --- a/output.cpp +++ b/output.cpp @@ -140,6 +140,17 @@ int convertMajor(const std::string &major) { // ========================================================== +std::vector getCourseDetails() { + std::vector courseDetails; + std::ifstream i("/var/local/submitty/courses/f24/sample/reports/base_url.json"); + nlohmann::json j; + i >> j; + courseDetails[0] = j["base_url"].get(); + courseDetails[1] = j["term"].get();; + courseDetails[2] = j["course"].get();; + return courseDetails; +} + class Color { public: Color(int r_=0, int g_=0, int b_=0) : r(r_),g(g_),b(b_) {} @@ -638,11 +649,20 @@ void start_table_output( bool /*for_instructor*/, if (g != GRADEABLE_ENUM::NOTE) { student_data.push_back(counter); } + + std::vector courseDetails = getCourseDetails(); + std::string base_url = courseDetails[0]; + std::string semester = courseDetails[1]; + std::string course = courseDetails[2]; + + std::string fullURL = base_url + "courses/" + semester + "/" + course + "/gradeable/" + gradeable_id; + std::string gradeable_id = GRADEABLES[g].getID(j); std::string gradeable_name = ""; if (GRADEABLES[g].hasCorrespondence(gradeable_id)) { gradeable_name = GRADEABLES[g].getCorrespondence(gradeable_id).second; //gradeable_name = spacify(gradeable_name); + gradeable_name = ""; } if (gradeable_name == "") gradeable_name = "future " From 31e1f4852da8fcaadef52fe11d6c19b2c132e600 Mon Sep 17 00:00:00 2001 From: Ryan Varughese Date: Fri, 1 Nov 2024 15:29:42 -0400 Subject: [PATCH 2/7] Added Error Checking to Function --- output.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/output.cpp b/output.cpp index 6cd47c4..653c00c 100644 --- a/output.cpp +++ b/output.cpp @@ -141,8 +141,11 @@ int convertMajor(const std::string &major) { // ========================================================== std::vector getCourseDetails() { - std::vector courseDetails; + std::vector courseDetails; std::ifstream i("/var/local/submitty/courses/f24/sample/reports/base_url.json"); + if(!i){ + return {} + } nlohmann::json j; i >> j; courseDetails[0] = j["base_url"].get(); @@ -651,11 +654,13 @@ void start_table_output( bool /*for_instructor*/, } std::vector courseDetails = getCourseDetails(); - std::string base_url = courseDetails[0]; - std::string semester = courseDetails[1]; - std::string course = courseDetails[2]; + if(courseDetails.size() == 3){ + std::string base_url = courseDetails[0]; + std::string semester = courseDetails[1]; + std::string course = courseDetails[2]; - std::string fullURL = base_url + "courses/" + semester + "/" + course + "/gradeable/" + gradeable_id; + std::string fullURL = base_url + "courses/" + semester + "/" + course + "/gradeable/" + gradeable_id; + } std::string gradeable_id = GRADEABLES[g].getID(j); std::string gradeable_name = ""; From 92031ab32d3268ee5c60f5beca23f48da88febdb Mon Sep 17 00:00:00 2001 From: Ryan Varughese Date: Wed, 6 Nov 2024 18:08:40 -0500 Subject: [PATCH 3/7] Implementing Correct URL From the MakefileHelper, I used REPORTS_DIRECTORY to make the link work for all courses and semesters. Fixed the URL. --- output.cpp | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/output.cpp b/output.cpp index 653c00c..3af0f69 100644 --- a/output.cpp +++ b/output.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "student.h" #include "grade.h" @@ -140,18 +141,18 @@ int convertMajor(const std::string &major) { // ========================================================== -std::vector getCourseDetails() { - std::vector courseDetails; - std::ifstream i("/var/local/submitty/courses/f24/sample/reports/base_url.json"); - if(!i){ - return {} - } +std::tuple getCourseDetails() { + const char* reportsDir = std::getenv("REPORTS_DIRECTORY"); + std::string path = std::string(reportsDir) + "/base_url.json"; + std::ifstream i(path); + nlohmann::json j; i >> j; - courseDetails[0] = j["base_url"].get(); - courseDetails[1] = j["term"].get();; - courseDetails[2] = j["course"].get();; - return courseDetails; + std::string baseUrl = j["base_url"].get(); + std::string term = j["term"].get(); + std::string course = j["course"].get(); + + return {baseUrl, term, course}; } class Color { @@ -652,23 +653,21 @@ void start_table_output( bool /*for_instructor*/, if (g != GRADEABLE_ENUM::NOTE) { student_data.push_back(counter); } - - std::vector courseDetails = getCourseDetails(); - if(courseDetails.size() == 3){ - std::string base_url = courseDetails[0]; - std::string semester = courseDetails[1]; - std::string course = courseDetails[2]; - - std::string fullURL = base_url + "courses/" + semester + "/" + course + "/gradeable/" + gradeable_id; - } - + std::string gradeable_id = GRADEABLES[g].getID(j); std::string gradeable_name = ""; + auto courseDetails = getCourseDetails(); + std::string base_url = std::get<0>(courseDetails); + std::string semester = std::get<1>(courseDetails); + std::string course = std::get<2>(courseDetails); + std::string fullUrl = base_url + "courses/" + semester + "/" + course + "/gradeable/" + gradeable_id; + if (GRADEABLES[g].hasCorrespondence(gradeable_id)) { gradeable_name = GRADEABLES[g].getCorrespondence(gradeable_id).second; - //gradeable_name = spacify(gradeable_name); - gradeable_name = ""; + // gradeable_name = spacify(gradeable_name); + gradeable_name = "" + gradeable_name + "   "; } + if (gradeable_name == "") gradeable_name = "future " + tolower(gradeable_to_string(g)) + ""; From 50dbc4fa628ab247c87624a2cd242ca53be23620 Mon Sep 17 00:00:00 2001 From: Ryan Varughese Date: Wed, 6 Nov 2024 18:27:27 -0500 Subject: [PATCH 4/7] Removing Spacify from Gradeable Name --- output.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/output.cpp b/output.cpp index 3af0f69..cf5a135 100644 --- a/output.cpp +++ b/output.cpp @@ -664,7 +664,6 @@ void start_table_output( bool /*for_instructor*/, if (GRADEABLES[g].hasCorrespondence(gradeable_id)) { gradeable_name = GRADEABLES[g].getCorrespondence(gradeable_id).second; - // gradeable_name = spacify(gradeable_name); gradeable_name = "" + gradeable_name + "   "; } From 8362f62e3a745ed9e923893452f9e1b9e27185e4 Mon Sep 17 00:00:00 2001 From: Ryan Varughese Date: Wed, 13 Nov 2024 00:45:57 -0500 Subject: [PATCH 5/7] Adding an Icon Alongside Each Gradeable Display --- output.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/output.cpp b/output.cpp index cf5a135..4adc26b 100644 --- a/output.cpp +++ b/output.cpp @@ -663,8 +663,9 @@ void start_table_output( bool /*for_instructor*/, std::string fullUrl = base_url + "courses/" + semester + "/" + course + "/gradeable/" + gradeable_id; if (GRADEABLES[g].hasCorrespondence(gradeable_id)) { - gradeable_name = GRADEABLES[g].getCorrespondence(gradeable_id).second; - gradeable_name = "" + gradeable_name + "   "; + gradeable_name = GRADEABLES[g].getCorrespondence(gradeable_id).second; + gradeable_name = gradeable_name + " "; + gradeable_name = "" + gradeable_name + ""; } if (gradeable_name == "") From 10d30cd19c8ef6f1e6bae82cee34ff48ddfb2a09 Mon Sep 17 00:00:00 2001 From: Ryan Varughese Date: Fri, 15 Nov 2024 06:55:48 -0500 Subject: [PATCH 6/7] Adding Additional Check to Construct Link Made an extra check to see that the gradeable has actually been released to view the link to the gradeable itself, otherwise this would be useless. Also, added the blue box permanently to be displayed along with the gradeable names that have links. --- output.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/output.cpp b/output.cpp index 4adc26b..d45dd94 100644 --- a/output.cpp +++ b/output.cpp @@ -663,9 +663,13 @@ void start_table_output( bool /*for_instructor*/, std::string fullUrl = base_url + "courses/" + semester + "/" + course + "/gradeable/" + gradeable_id; if (GRADEABLES[g].hasCorrespondence(gradeable_id)) { - gradeable_name = GRADEABLES[g].getCorrespondence(gradeable_id).second; - gradeable_name = gradeable_name + " "; - gradeable_name = "" + gradeable_name + ""; + gradeable_name = GRADEABLES[g].getCorrespondence(gradeable_id).second; + bool checkReleased = GRADEABLES[g].isReleased(gradeable_id); + if(checkReleased){ + // g != GRADEABLE_ENUM::LAB ... + gradeable_name = gradeable_name + " "; + gradeable_name = "" + gradeable_name + ""; + } } if (gradeable_name == "") From fbef08eef0b449ec4978d9f9c05fb69500e1f3c1 Mon Sep 17 00:00:00 2001 From: Ryan Varughese Date: Tue, 19 Nov 2024 02:59:24 -0500 Subject: [PATCH 7/7] Make a Check so that only Electronic File Uploads Have Links The logic here is that starting from DISPLAY_GRADE_DETAILS, I find a random user (the first user after AVERAGE AND STDDEV, could be the instructor who opened the course). Then, I call the getGreadeableType function to go to their summary json and scan for the gradeable id. If the gradeable id is found, I return the value of gradeable_type. --- output.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/output.cpp b/output.cpp index d45dd94..d270859 100644 --- a/output.cpp +++ b/output.cpp @@ -155,6 +155,40 @@ std::tuple getCourseDetails() { return {baseUrl, term, course}; } +std::string getGradeableType(const std::string &firstUserName, const std::string &gradeableID) { + const char* reportsDir = std::getenv("REPORTS_DIRECTORY"); + + std::string path = std::string(reportsDir) + "/../rainbow_grades/raw_data/all_grades/" + firstUserName + "_summary.json"; + std::ifstream i(path); + + nlohmann::json j; + i >> j; + + std::string gradeableType = ""; + + for (auto it = j.begin(); it != j.end(); ++it) { + if (!it.value().is_array()) { + continue; + } + + for (const auto& item : it.value()) { + if (item.contains("id") && item["id"].is_string() && + item["id"].get() == gradeableID) { + if (item.contains("gradeable_type") && item["gradeable_type"].is_string()) { + gradeableType = item["gradeable_type"].get(); + break; + } + } + } + + if (!gradeableType.empty()) { + break; + } + } + + return gradeableType; +} + class Color { public: Color(int r_=0, int g_=0, int b_=0) : r(r_),g(g_),b(b_) {} @@ -647,6 +681,17 @@ void start_table_output( bool /*for_instructor*/, // ---------------------------- // DETAILS OF EACH GRADEABLE if (DISPLAY_GRADE_DETAILS) { + std::string firstUserName = ""; + for(unsigned int stu = 0; stu < students.size(); stu++){ + Student *this_student = students[stu]; + if(this_student->getUserName() == "AVERAGE" || this_student->getUserName() == "STDDEV"){ + continue; + } + else{ + firstUserName = this_student->getUserName(); + break; + } + } for (unsigned int i = 0; i < ALL_GRADEABLES.size(); i++) { GRADEABLE_ENUM g = ALL_GRADEABLES[i]; for (int j = 0; j < GRADEABLES[g].getCount(); j++) { @@ -662,11 +707,12 @@ void start_table_output( bool /*for_instructor*/, std::string course = std::get<2>(courseDetails); std::string fullUrl = base_url + "courses/" + semester + "/" + course + "/gradeable/" + gradeable_id; + std::string gradeableType = getGradeableType(firstUserName, gradeable_id); + if (GRADEABLES[g].hasCorrespondence(gradeable_id)) { gradeable_name = GRADEABLES[g].getCorrespondence(gradeable_id).second; bool checkReleased = GRADEABLES[g].isReleased(gradeable_id); - if(checkReleased){ - // g != GRADEABLE_ENUM::LAB ... + if(checkReleased && gradeableType == "Electronic File"){ gradeable_name = gradeable_name + " "; gradeable_name = "" + gradeable_name + ""; }