add version and test updates
This commit is contained in:
1 parent
5a45bb0a7f
commit
0fd16b62f2
4 files changed
+58
-30
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/SowinskiBraeden/school-management-api/routes"
|
"github.com/SowinskiBraeden/school-management-api/routes"
|
||||||
@@ -10,7 +11,10 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2/middleware/cors"
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const version string = "\nv0.8.2-Alpha"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
fmt.Println(version)
|
||||||
app := fiber.New()
|
app := fiber.New()
|
||||||
|
|
||||||
app.Use(cors.New(cors.Config{
|
app.Use(cors.New(cors.Config{
|
||||||
|
|||||||
+3
-3
@@ -99,8 +99,8 @@ courses = {
|
|||||||
"teachers": 3
|
"teachers": 3
|
||||||
},
|
},
|
||||||
"SC-ES": {
|
"SC-ES": {
|
||||||
"name": "SC-ES",
|
"name": "Earth Science",
|
||||||
"code": "cl12",
|
"code": "SC-ES",
|
||||||
"credits": 4,
|
"credits": 4,
|
||||||
"gradelevel": 11,
|
"gradelevel": 11,
|
||||||
"totalrequests": 0,
|
"totalrequests": 0,
|
||||||
@@ -109,7 +109,7 @@ courses = {
|
|||||||
},
|
},
|
||||||
"M": {
|
"M": {
|
||||||
"name": "Music",
|
"name": "Music",
|
||||||
"code": "Ms",
|
"code": "M",
|
||||||
"credits": 4,
|
"credits": 4,
|
||||||
"gradelevel": 11,
|
"gradelevel": 11,
|
||||||
"totalrequests": 0,
|
"totalrequests": 0,
|
||||||
|
|||||||
+12
-12
@@ -4,18 +4,18 @@ let students = require('./students.json');
|
|||||||
// console.table(schedule)
|
// console.table(schedule)
|
||||||
|
|
||||||
// Display first semester
|
// Display first semester
|
||||||
// console.table(schedule.block1)
|
console.table(schedule.block1)
|
||||||
// console.table(schedule.block2)
|
console.table(schedule.block2)
|
||||||
// console.table(schedule.block3)
|
console.table(schedule.block3)
|
||||||
// console.table(schedule.block4)
|
console.table(schedule.block4)
|
||||||
|
|
||||||
// // Display second semester
|
// Display second semester
|
||||||
// console.table(schedule.block5)
|
console.table(schedule.block5)
|
||||||
// console.table(schedule.block6)
|
console.table(schedule.block6)
|
||||||
// console.table(schedule.block7)
|
console.table(schedule.block7)
|
||||||
// console.table(schedule.block8)
|
console.table(schedule.block8)
|
||||||
|
|
||||||
// Display each students schedule
|
// Display each students schedule
|
||||||
for (let i = 0; i < students.length; i++) {
|
// for (let i = 0; i < students.length; i++) {
|
||||||
console.table(students[i].schedule)
|
// console.table(students[i].schedule)
|
||||||
}
|
// }
|
||||||
+39
-15
@@ -50,7 +50,7 @@ running: {
|
|||||||
# Error 2: No more room in schedule for another class
|
# Error 2: No more room in schedule for another class
|
||||||
|
|
||||||
# 400 by default
|
# 400 by default
|
||||||
studentsNum = 500
|
studentsNum = 1000
|
||||||
|
|
||||||
err1, err2, = 0,0
|
err1, err2, = 0,0
|
||||||
minReq, classCap, blockClassLimit = 18, 30, 18
|
minReq, classCap, blockClassLimit = 18, 30, 18
|
||||||
@@ -219,24 +219,29 @@ def generateScheduleV2():
|
|||||||
if (activeCourses[index]["totalrequests"] % classCap) > minReq: classRunCount += 1
|
if (activeCourses[index]["totalrequests"] % classCap) > minReq: classRunCount += 1
|
||||||
activeCourses[index]["classRunCount"] = classRunCount
|
activeCourses[index]["classRunCount"] = classRunCount
|
||||||
|
|
||||||
blockIndex = 1
|
newBlockIndex = 1
|
||||||
|
newCourseNum = 1
|
||||||
while classRunCount > 0:
|
while classRunCount > 0:
|
||||||
block = f"block{blockIndex}"
|
block = f"block{newBlockIndex}"
|
||||||
if activeCourses[index]["code"] not in running[block] and len(running[block]) < blockClassLimit:
|
cname = f"{activeCourses[index]['name']}-{newCourseNum}"
|
||||||
|
if cname not in running[block] and len(running[block]) < blockClassLimit:
|
||||||
# Generate class and sub 1 from classRunCount
|
# Generate class and sub 1 from classRunCount
|
||||||
running[block][activeCourses[index]["code"]] = {
|
running[block][cname] = {
|
||||||
"name": activeCourses[index]["name"],
|
"name": activeCourses[index]["name"],
|
||||||
"students": []
|
"students": []
|
||||||
}
|
}
|
||||||
classRunCount -= 1
|
classRunCount -= 1
|
||||||
else:
|
else:
|
||||||
if blockIndex == 8:
|
if newBlockIndex == 8:
|
||||||
|
if (activeCourses[index]["teachers"] - newCourseNum) > 0:
|
||||||
|
newCourseNum += 1
|
||||||
|
newBlockIndex = 1
|
||||||
|
else:
|
||||||
# No room in school for more classes
|
# No room in school for more classes
|
||||||
# print(f"\nError 2: No more room in school for another class")
|
# print(f"\nError 2: No more room in school for another class")
|
||||||
err2 += 1
|
err2 += 1
|
||||||
classRunCount = 0
|
classRunCount = 0
|
||||||
else:
|
else: newBlockIndex += 1
|
||||||
blockIndex += 1
|
|
||||||
|
|
||||||
for student in mockStudents:
|
for student in mockStudents:
|
||||||
alternateOffset = len(student["requests"])-8
|
alternateOffset = len(student["requests"])-8
|
||||||
@@ -244,21 +249,31 @@ def generateScheduleV2():
|
|||||||
for i in range(len(student["requests"])-alternateOffset): # Subtract x classes as they are alternatives
|
for i in range(len(student["requests"])-alternateOffset): # Subtract x classes as they are alternatives
|
||||||
currentCourse = student["requests"][i]
|
currentCourse = student["requests"][i]
|
||||||
generate = True
|
generate = True
|
||||||
|
courseNum = 1
|
||||||
while generate:
|
while generate:
|
||||||
# If class is allowed to run
|
# If class is allowed to run
|
||||||
if currentCourse in activeCourses:
|
if currentCourse in activeCourses:
|
||||||
blockIndex = 1
|
blockIndex = 1
|
||||||
getFreeBlock = True
|
getFreeBlock = True
|
||||||
|
cname = f"{courses[currentCourse]['name']}-{courseNum}"
|
||||||
while getFreeBlock:
|
while getFreeBlock:
|
||||||
block = f"block{blockIndex}"
|
block = f"block{blockIndex}"
|
||||||
if currentCourse in running[block]:
|
if cname in running[block]:
|
||||||
if student["schedule"][block] == "": # Add student to class
|
if student["schedule"][block] == "": # Add student to class
|
||||||
if len(running[block][currentCourse]["students"]) < classCap:
|
if len(running[block][cname]["students"]) < classCap:
|
||||||
running[block][currentCourse]["students"].append(student["name"])
|
running[block][cname]["students"].append(student["name"])
|
||||||
student["schedule"][block] = courses[currentCourse]["name"]
|
student["schedule"][block] = cname
|
||||||
getFreeBlock = False
|
getFreeBlock = False
|
||||||
else: # Find next available class or create new one
|
else: # Find next available class or create new one
|
||||||
if blockIndex == 8: # No available classes
|
if blockIndex == 8: # No available classes
|
||||||
|
if (activeCourses[index]["teachers"] - newCourseNum) > 0:
|
||||||
|
newCourseNum += 1
|
||||||
|
newBlockIndex = 1
|
||||||
|
else:
|
||||||
|
# No room in school for more classes
|
||||||
|
# print(f"\nError 2: No more room in school for another class")
|
||||||
|
err2 += 1
|
||||||
|
classRunCount = 0
|
||||||
if len(student["requests"]) == 8:
|
if len(student["requests"]) == 8:
|
||||||
# This student never had any alternatives
|
# This student never had any alternatives
|
||||||
# How to solve?
|
# How to solve?
|
||||||
@@ -294,7 +309,12 @@ def generateScheduleV2():
|
|||||||
err1 += 1
|
err1 += 1
|
||||||
generate = False
|
generate = False
|
||||||
getFreeBlock = False
|
getFreeBlock = False
|
||||||
else: blockIndex += 1
|
else:
|
||||||
|
if (courses[currentCourse]["teachers"] - courseNum) > 0:
|
||||||
|
courseNum += 1
|
||||||
|
else:
|
||||||
|
blockIndex += 1
|
||||||
|
courseNum = 1
|
||||||
else:
|
else:
|
||||||
if blockIndex == 8:
|
if blockIndex == 8:
|
||||||
# Class does not exists
|
# Class does not exists
|
||||||
@@ -307,7 +327,12 @@ def generateScheduleV2():
|
|||||||
err1 += 1
|
err1 += 1
|
||||||
generate = False
|
generate = False
|
||||||
break
|
break
|
||||||
else: blockIndex += 1
|
else:
|
||||||
|
if (courses[currentCourse]["teachers"] - courseNum) > 0:
|
||||||
|
courseNum += 1
|
||||||
|
else:
|
||||||
|
blockIndex += 1
|
||||||
|
courseNum = 1
|
||||||
break
|
break
|
||||||
elif currentCourse not in activeCourses:
|
elif currentCourse not in activeCourses:
|
||||||
if len(student["requests"]) == 8:
|
if len(student["requests"]) == 8:
|
||||||
@@ -327,7 +352,6 @@ def generateScheduleV2():
|
|||||||
generate = False
|
generate = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
print("Missing argument")
|
print("Missing argument")
|
||||||
|
|||||||
Reference in new issue
Block a user