fixed editor bug

This commit is contained in:
JBB0807 2025-05-06 13:28:01 -07:00
parent ee04a7e8ef
commit fd993102a0
4 changed files with 55 additions and 5 deletions

View file

@ -132,7 +132,33 @@ intructorRouter.delete(
// passport.authenticate("jwt", { session: false }),
async (req, res) => {
try {
const assignmentId = req.params.id;
//get the assignment data from the database
console.log("Fetching assignment data for ID:", assignmentId);
const assignmentResponse = await axios.get(
`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${assignmentId}`
);
const assignmentData = assignmentResponse.data;
console.log("Assignment data:", assignmentData);
if (!assignmentData) {
return res.status(404).json({ error: "Assignment not found" });
}
// Delete the Battlesnake API
console.log('Deploying a new Battlesnake API');
console.log("DEPLOY_API_URL:", DEPLOY_API_URL, assignmentData.appname);
const deployResponse = await axios.post(`${DEPLOY_API_URL}/${assignmentData.appname}/delete`, {
"appName": assignmentData.appname
});
//throw error if the response is not 200
if (deployResponse.status !== 200) {
throw new Error(`Failed to delete Battlesnake API: ${deployResponse.statusText}`);
}
console.log('Response from DEPLOY_API_URL:', deployResponse.data);
const response = await axios.delete(
`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${assignmentId}`
);

View file

@ -14,7 +14,7 @@ studentRouter.get("/assignment/:qrnum", (req, res) => {
const qrnum = req.params.qrnum;
console.log("Fetching details for qr number:", qrnum);
axios
.get(`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${qrnum}`)
.get(`${DB_ASSIGNMENT_SERVICE_URL}/assignments/qr/${qrnum}`)
.then((response) => {
console.log("Response from DB_ASSIGNMENT_SERVICE_URL:", response.data);
res.status(response.status).json(response.data);
@ -40,7 +40,7 @@ studentRouter.post("/verify", async (req, res) => {
console.log(`Fetching from URL: ${DB_ASSIGNMENT_SERVICE_URL}/assignments/${qrNumber}`);
const response = await axios.get(
`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${qrNumber}`
`${DB_ASSIGNMENT_SERVICE_URL}/assignments/qr/${qrNumber}`
);
console.log("Response from DB_ASSIGNMENT_SERVICE_URL:", response.data);