From 52534acfe0040e9ca756f889102be4ed89fcc972 Mon Sep 17 00:00:00 2001 From: EmTanIT Date: Thu, 5 Oct 2023 22:29:59 +0700 Subject: [PATCH] complete 90% automatic althorigm --- routes/examSlot.js | 1 + routes/room.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/routes/examSlot.js b/routes/examSlot.js index 8fc2da71..7079ebbc 100644 --- a/routes/examSlot.js +++ b/routes/examSlot.js @@ -211,6 +211,7 @@ router.get('/', async (req, res) => { // fs.appendFileSync("test.txt", data1 + "\n"); // fs.appendFileSync("test.txt", data + "\n"); */ + console.log(room.id); await ExamRoom.create({ sSId: subjectInSlot.id, roomId: room.id diff --git a/routes/room.js b/routes/room.js index 3b488ab6..59999a0f 100644 --- a/routes/room.js +++ b/routes/room.js @@ -46,7 +46,8 @@ router.delete('/', async (req, res) => { export async function randomRoom(){ let roomList = await Room.findAll() - let ranId = Math.floor(Math.random()*(roomList.length)) + let ranId = Math.floor(Math.random()*(roomList.length - 1)) + 1 + console.log("log Function ranId: " + ranId); let room = await Room.findOne({ where : { id : ranId