Skip to content

Commit

Permalink
Merge pull request #42 from team-inu/development
Browse files Browse the repository at this point in the history
Student outcome percentage calculation
  • Loading branch information
Porping committed May 4, 2024
2 parents 4da16c1 + 6f1d094 commit 9ab6c98
Show file tree
Hide file tree
Showing 10 changed files with 755 additions and 12 deletions.
3 changes: 3 additions & 0 deletions entity/course.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package entity

import "gorm.io/datatypes"

type CriteriaGrade struct {
A float64 `json:"criteriaGradeA" gorm:"column:criteria_grade_a" validate:"required"`
BP float64 `json:"criteriaGradeBP" gorm:"column:criteria_grade_bp" validate:"required"`
Expand Down Expand Up @@ -70,6 +72,7 @@ type Course struct {
Description string `json:"description"`
ExpectedPassingCloPercentage float64 `json:"expectedPassingCloPercentage"`
IsPortfolioCompleted *bool `json:"isPortfolioCompleted" gorm:"default:false"`
PortfolioData datatypes.JSON

SemesterId string `json:"semesterId"`
UserId string `json:"userId"`
Expand Down
96 changes: 93 additions & 3 deletions entity/course_portfolio.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package entity

import "gorm.io/datatypes"

// [1] Info
type CourseInfo struct {
Name string `json:"courseName"`
Expand All @@ -9,8 +11,8 @@ type CourseInfo struct {

// [2] Summary
type CourseSummary struct {
TeachingMethods []string `json:"teachingMethod"`
OnlineTool string `json:"onlineTool"`
TeachingMethods []string `json:"teachingMethods"`
OnlineTools string `json:"onlineTools"`
Objectives []string `json:"objectives"`
}

Expand Down Expand Up @@ -84,6 +86,7 @@ type CoursePortfolio struct {
CourseSummary CourseSummary `json:"summary"`
CourseResult CourseResult `json:"result"`
CourseDevelopment CourseDevelopment `json:"development"`
Raw datatypes.JSON `json:"raw"`
}

type AssignmentPercentage struct {
Expand Down Expand Up @@ -187,7 +190,7 @@ type PloCoursesGorm struct {
}

type PoCourses struct {
ProgramOutcomeId string `json:"programLearningOutcomeId"`
ProgramOutcomeId string `json:"programOutcomeId"`
Courses []CourseData `json:"courses"`
}

Expand All @@ -201,6 +204,86 @@ type PoCoursesGorm struct {
SemesterSequence string
}

type StudentCourseData struct {
Id string `json:"id"`
Code string `json:"code"`
Name string `json:"name"`
Pass bool `json:"pass"`
Year int `json:"year"`
SemesterSequence string `json:"semesterSequence"`
}

type StudentPloData struct {
ProgramLearningOutcomeId string `json:"programLearningOutcomeId"`
Code string `json:"code"`
DescriptionThai string `json:"descriptionThai"`
Courses []StudentCourseData `json:"courses"`
}

type StudentPoData struct {
ProgramOutcomeId string `json:"programOutcomeId"`
Code string `json:"code"`
Name string `json:"name"`
Courses []StudentCourseData `json:"courses"`
}

type StudentOutcomes struct {
StudentId string `json:"studentId"`
ProgramLearningOutcomes []StudentPloData `json:"programLearningOutcomes"`
ProgramOutcomes []StudentPoData `json:"programOutcomes"`
}

type StudentPlosGorm struct {
StudentId string
ProgramLearningOutcomeId string `gorm:"column:plo_id"`
ProgramLearningOutcomeCode string `gorm:"column:plo_code"`
DescriptionThai string
CourseId string
CourseCode string
CourseName string
Pass bool
Year int
SemesterSequence string
}

type StudentPosGorm struct {
StudentId string
ProgramOutcomeId string `gorm:"column:p_id"`
ProgramOutcomeCode string `gorm:"column:po_code"`
ProgramOutcomeName string `gorm:"column:po_name"`
CourseId string
CourseCode string
CourseName string
Pass bool
Year int
SemesterSequence string
}

// ///

// type NameObject struct {
// Name string `json:"name"`
// }

// type CourseSummmaryForm struct {
// TeachingMethods []NameObject `json:"teachingMethod"`
// OnlineTool string `json:"onlineTool"`
// Objectives []NameObject `json:"objectives"`
// }

// type CourseDevelopmentForm struct {
// Plans []NameObject `json:"plans"`
// DoAndChecks []NameObject `json:"doAndChecks"`
// Acts []NameObject `json:"acts"`
// SubjectComments SubjectComments `json:"subjectComments"`
// OtherComment string `json:"otherComment"`
// }

type PortfolioData struct {
Summary CourseSummary `json:"summary"`
Development CourseDevelopment `json:"development"`
}

type CoursePortfolioRepository interface {
EvaluatePassingAssignmentPercentage(courseId string) ([]AssignmentPercentage, error)
EvaluatePassingPoPercentage(courseId string) ([]PoPercentage, error)
Expand All @@ -210,6 +293,10 @@ type CoursePortfolioRepository interface {
EvaluatePassingPoStudents(courseId string) ([]PoPassingStudentGorm, error)
EvaluateAllPloCourses() ([]PloCoursesGorm, error)
EvaluateAllPoCourses() ([]PoCoursesGorm, error)
EvaluateProgramLearningOutcomesByStudentId(studentId string) ([]StudentPlosGorm, error)
EvaluateProgramOutcomesByStudentId(studentId string) ([]StudentPosGorm, error)

UpdateCoursePortfolio(courseId string, data datatypes.JSON) error
}

type CoursePortfolioUseCase interface {
Expand All @@ -220,4 +307,7 @@ type CoursePortfolioUseCase interface {
GetStudentOutcomesStatusByCourseId(courseId string) ([]StudentOutcomeStatus, error)
GetAllProgramLearningOutcomeCourses() ([]PloCourses, error)
GetAllProgramOutcomeCourses() ([]PoCourses, error)
GetOutcomesByStudentId(studentId string) ([]StudentOutcomes, error)

UpdateCoursePortfolio(courseId string, summary CourseSummary, development CourseDevelopment) error
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/spf13/viper v1.16.0
go.uber.org/zap v1.25.0
golang.org/x/crypto v0.20.0
gorm.io/datatypes v1.2.0
gorm.io/driver/mysql v1.5.1
gorm.io/gorm v1.25.9
)
Expand Down
24 changes: 22 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ github.com/gofiber/contrib/fiberzap/v2 v2.0.0 h1:pgFhveNyFlNzr8AQlRG7o1/EKMi+vOm
github.com/gofiber/contrib/fiberzap/v2 v2.0.0/go.mod h1:NUXSG7SUq6b5NQfAyWCEdaaq3ZKsWz6atunN+NJ4gYY=
github.com/gofiber/fiber/v2 v2.52.1 h1:1RoU2NS+b98o1L77sdl5mboGPiW+0Ypsi5oLmcYlgHI=
github.com/gofiber/fiber/v2 v2.52.1/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ=
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA=
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A=
github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -147,6 +151,12 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.3.0 h1:/NQi8KHMpKWHInxXesC8yD4DhkXPrVhmnwYkjp9AmBA=
github.com/jackc/pgx/v5 v5.3.0/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
Expand Down Expand Up @@ -175,6 +185,10 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/microsoft/go-mssqldb v0.17.0 h1:Fto83dMZPnYv1Zwx5vHHxpNraeEaUlQ/hhHLgZiaenE=
github.com/microsoft/go-mssqldb v0.17.0/go.mod h1:OkoNGhGEs8EZqchVTtochlXruEhEOaO4S0d2sB5aeGQ=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
Expand Down Expand Up @@ -537,11 +551,17 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/datatypes v1.2.0 h1:5YT+eokWdIxhJgWHdrb2zYUimyk0+TaFth+7a0ybzco=
gorm.io/datatypes v1.2.0/go.mod h1:o1dh0ZvjIjhH/bngTpypG6lVRJ5chTBxE09FH/71k04=
gorm.io/driver/mysql v1.5.1 h1:WUEH5VF9obL/lTtzjmML/5e6VfFR/788coz2uaVCAZw=
gorm.io/driver/mysql v1.5.1/go.mod h1:Jo3Xu7mMhCyj8dlrb3WoCaRd1FhsVh+yMXb1jUInf5o=
gorm.io/driver/postgres v1.5.0 h1:u2FXTy14l45qc3UeCJ7QaAXZmZfDDv0YrthvmRq1l0U=
gorm.io/driver/postgres v1.5.0/go.mod h1:FUZXzO+5Uqg5zzwzv4KK49R8lvGIyscBOqYrtI1Ce9A=
gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU=
gorm.io/driver/sqlite v1.4.3/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI=
gorm.io/driver/sqlserver v1.4.1 h1:t4r4r6Jam5E6ejqP7N82qAJIJAht27EGT41HyPfXRw0=
gorm.io/driver/sqlserver v1.4.1/go.mod h1:DJ4P+MeZbc5rvY58PnmN1Lnyvb5gw5NPzGshHDnJLig=
gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.4 h1:iyNd8fNAe8W9dvtlgeRI5zSVZPsq3OpcTu37cYcpCmw=
gorm.io/gorm v1.25.4/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.9 h1:wct0gxZIELDk8+ZqF/MVnHLkA1rvYlBWUMv2EdsK1g8=
gorm.io/gorm v1.25.9/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
30 changes: 30 additions & 0 deletions infrastructure/fiber/controller/course_portfolio.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package controller

import (
"fmt"

"github.com/gofiber/fiber/v2"
"github.com/team-inu/inu-backyard/entity"
"github.com/team-inu/inu-backyard/infrastructure/fiber/request"
"github.com/team-inu/inu-backyard/infrastructure/fiber/response"
"github.com/team-inu/inu-backyard/internal/validator"
)
Expand Down Expand Up @@ -64,3 +67,30 @@ func (c coursePortfolioController) GetAllProgramOutcomeCourses(ctx *fiber.Ctx) e
}
return response.NewSuccessResponse(ctx, fiber.StatusOK, records)
}

func (c coursePortfolioController) Update(ctx *fiber.Ctx) error {
var payload request.SaveCoursePortfolioPayload
if ok, err := c.Validator.Validate(&payload, ctx); !ok {
return err
}

courseId := ctx.Params("courseId")

fmt.Println(payload)
err := c.coursePortfolioUseCase.UpdateCoursePortfolio(courseId, payload.CourseSummary, payload.CourseDevelopment)
if err != nil {
return err
}

return nil
}

func (c coursePortfolioController) GetOutcomesByStudentId(ctx *fiber.Ctx) error {
studentId := ctx.Params("studentId")

records, err := c.coursePortfolioUseCase.GetOutcomesByStudentId(studentId)
if err != nil {
return err
}
return response.NewSuccessResponse(ctx, fiber.StatusOK, records)
}
8 changes: 8 additions & 0 deletions infrastructure/fiber/request/course_portfolio.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package request

import "github.com/team-inu/inu-backyard/entity"

type SaveCoursePortfolioPayload struct {
CourseSummary entity.CourseSummary `json:"summary" validate:"required"`
CourseDevelopment entity.CourseDevelopment `json:"development" validate:"required"`
}
4 changes: 3 additions & 1 deletion infrastructure/fiber/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (f *fiberServer) initUseCase() {
assignmentUseCase := usecase.NewAssignmentUseCase(f.assignmentRepository, courseLearningOutcomeUseCase, courseUseCase)
scoreUseCase := usecase.NewScoreUseCase(f.scoreRepository, enrollmentUseCase, assignmentUseCase, courseUseCase, userUseCase, studentUseCase)
courseStreamUseCase := usecase.NewCourseStreamUseCase(f.courseStreamRepository, courseUseCase)
coursePortfolioUseCase := usecase.NewCoursePortfolioUseCase(f.coursePortfolioRepository, courseUseCase, userUseCase, enrollmentUseCase, assignmentUseCase, scoreUseCase, courseLearningOutcomeUseCase, courseStreamUseCase)
coursePortfolioUseCase := usecase.NewCoursePortfolioUseCase(f.coursePortfolioRepository, courseUseCase, userUseCase, enrollmentUseCase, assignmentUseCase, scoreUseCase, studentUseCase, courseLearningOutcomeUseCase, courseStreamUseCase)
predictionUseCase := usecase.NewPredictionUseCase(f.predictionRepository, f.config)

f.assignmentUseCase = assignmentUseCase
Expand Down Expand Up @@ -196,6 +196,7 @@ func (f *fiberServer) initController() error {
student.Post("/", studentController.Create)
student.Post("/bulk", studentController.CreateMany)
student.Get("/:studentId", studentController.GetById)
student.Get("/:studentId/outcomes", coursePortfolioController.GetOutcomesByStudentId)
student.Patch("/:studentId", studentController.Update)
student.Delete("/:studentId", studentController.Delete)

Expand All @@ -213,6 +214,7 @@ func (f *fiberServer) initController() error {
course.Get("/:courseId/students/outcomes", coursePortfolioController.GetStudentOutcomeStatusByCourseId)
course.Get("/:courseId/enrollments", enrollmentController.GetByCourseId)
course.Get("/:courseId/portfolio", coursePortfolioController.Generate)
course.Patch("/:courseId/portfolio", coursePortfolioController.Update)
course.Get("/:courseId/assignments", assignmentController.GetByCourseId)
course.Get("/:courseId/assignment-groups", assignmentController.GetGroupByCourseId)

Expand Down
Loading

0 comments on commit 9ab6c98

Please sign in to comment.