Skip to content

Commit 92031ab

Browse files
committed
Implementing Correct URL
From the MakefileHelper, I used REPORTS_DIRECTORY to make the link work for all courses and semesters. Fixed the URL.
1 parent 31e1f48 commit 92031ab

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

output.cpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <algorithm>
1111
#include <ctime>
1212
#include <cmath>
13+
#include <cstdlib>
1314

1415
#include "student.h"
1516
#include "grade.h"
@@ -140,18 +141,18 @@ int convertMajor(const std::string &major) {
140141

141142
// ==========================================================
142143

143-
std::vector<string> getCourseDetails() {
144-
std::vector<std::string> courseDetails;
145-
std::ifstream i("/var/local/submitty/courses/f24/sample/reports/base_url.json");
146-
if(!i){
147-
return {}
148-
}
144+
std::tuple<std::string, std::string, std::string> getCourseDetails() {
145+
const char* reportsDir = std::getenv("REPORTS_DIRECTORY");
146+
std::string path = std::string(reportsDir) + "/base_url.json";
147+
std::ifstream i(path);
148+
149149
nlohmann::json j;
150150
i >> j;
151-
courseDetails[0] = j["base_url"].get<std::string>();
152-
courseDetails[1] = j["term"].get<std::string>();;
153-
courseDetails[2] = j["course"].get<std::string>();;
154-
return courseDetails;
151+
std::string baseUrl = j["base_url"].get<std::string>();
152+
std::string term = j["term"].get<std::string>();
153+
std::string course = j["course"].get<std::string>();
154+
155+
return {baseUrl, term, course};
155156
}
156157

157158
class Color {
@@ -652,23 +653,21 @@ void start_table_output( bool /*for_instructor*/,
652653
if (g != GRADEABLE_ENUM::NOTE) {
653654
student_data.push_back(counter);
654655
}
655-
656-
std::vector<string> courseDetails = getCourseDetails();
657-
if(courseDetails.size() == 3){
658-
std::string base_url = courseDetails[0];
659-
std::string semester = courseDetails[1];
660-
std::string course = courseDetails[2];
661-
662-
std::string fullURL = base_url + "courses/" + semester + "/" + course + "/gradeable/" + gradeable_id;
663-
}
664-
656+
665657
std::string gradeable_id = GRADEABLES[g].getID(j);
666658
std::string gradeable_name = "";
659+
auto courseDetails = getCourseDetails();
660+
std::string base_url = std::get<0>(courseDetails);
661+
std::string semester = std::get<1>(courseDetails);
662+
std::string course = std::get<2>(courseDetails);
663+
std::string fullUrl = base_url + "courses/" + semester + "/" + course + "/gradeable/" + gradeable_id;
664+
667665
if (GRADEABLES[g].hasCorrespondence(gradeable_id)) {
668666
gradeable_name = GRADEABLES[g].getCorrespondence(gradeable_id).second;
669-
//gradeable_name = spacify(gradeable_name);
670-
gradeable_name = "<a href=\"" + fullURL + "\"" gradeable_name + "&nbsp;&nbsp; <i class='fas fa-external-link-alt'></i></a>";
667+
// gradeable_name = spacify(gradeable_name);
668+
gradeable_name = "<a href=\"" + fullUrl + "\" style=\"color:black;\">" + gradeable_name + "&nbsp;&nbsp; <i class='fas fa-external-link-alt'></i></a>";
671669
}
670+
672671
if (gradeable_name == "")
673672
gradeable_name = "<em><font color=\"aaaaaa\">future "
674673
+ tolower(gradeable_to_string(g)) + "</font></em>";

0 commit comments

Comments
 (0)