Skip to content

Commit

Permalink
Merge pull request #22 from EmTanIT/tanBE
Browse files Browse the repository at this point in the history
automatic 60%
  • Loading branch information
bentran1vn committed Oct 4, 2023
2 parents 93249de + 59a6569 commit 94b5885
Show file tree
Hide file tree
Showing 8 changed files with 1,162 additions and 4 deletions.
5 changes: 5 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions node_modules/fs/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions node_modules/fs/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"fs": "^0.0.1-security",
"jsonwebtoken": "^9.0.2",
"mysql2": "^3.5.2",
"passport": "^0.6.0",
Expand Down
18 changes: 14 additions & 4 deletions routes/examSlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ExamPhase from '../models/ExamPhase.js'
import TimeSlot from '../models/TimeSlot.js'
import ExamSlot from '../models/ExamSlot.js'
import Course from '../models/Course.js'
import fs from 'fs'

const router = express.Router()

Expand Down Expand Up @@ -78,8 +79,12 @@ router.get('/', async (req, res) => {
const course = await Course.findAll()

const slotList = await TimeSlot.findAll()
console.log(slotList.length);

for (const key in examPhaseList) {
let dataT = "----------------------"
fs.appendFileSync("test.txt", dataT + "\n");
//console.log("----------------------");
const startDay = new Date(examPhaseList[key].startDay)
const endDay = new Date(examPhaseList[key].endDay)
const diffInMs = Math.abs(endDay - startDay);
Expand All @@ -101,15 +106,17 @@ router.get('/', async (req, res) => {
let dayCount = 0
let slotCount = 0



for (let i = 0; i < course.length; i++) {
let daySlot = dayList[dayCount]
let slot = slotList[slotCount].id

if (roomSlot > process.env.NUMBER_OF_ROOM_IN_FLOOR * process.env.NUMBER_OF_ROOM_IN_FLOOR){
roomSlot = 0
slotCount++;

if(slotCount > process.env.NUMBER_OF_SLOT){
if(slotCount > process.env.NUMBER_OF_SLOT - 1){
slotCount = 0
dayCount++;
}
Expand All @@ -118,17 +125,20 @@ router.get('/', async (req, res) => {

const val = course[i];
let roomCourse = Math.ceil(val.numOfStu / process.env.NUMBER_OF_STUDENT_IN_ROOM)
console.log(roomCourse);
fs.appendFileSync("test.txt", roomCourse + "\n");
roomSlot += roomCourse
if(roomSlot <= process.env.NUMBER_OF_STUDENT_IN_ROOM* process.env.NUMBER_OF_ROOM_IN_FLOOR){
for (let i = 0; i < roomCourse; i++) {
console.log(val.id + ".." + daySlot.getDate() + ".." + slot);
let data = val.id + ".." + daySlot.getDate() + ".." + slot
fs.appendFileSync("test.txt", data + "\n");
//console.log();
}
} else {
i--
}

}

}
res.json('hihi')
})
Expand Down
Empty file added routes/test.txt
Empty file.
Loading

0 comments on commit 94b5885

Please sign in to comment.