model

package
v0.0.0-...-7f9477d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClassCountPerCourse は科目あたりの講義数 -> used in model/course.go
	ClassCountPerCourse = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Announcement

type Announcement struct {
	ID         string
	CourseID   string
	CourseName string
	Title      string
	Message    string
	// contains filtered or unexported fields
}

type AnnouncementStatus

type AnnouncementStatus struct {
	Announcement *Announcement
	Dirty        bool // リクエストを送ったがタイムアウトになってしまったため、webapp側で既読になったかが定かではないことを表す
	Unread       bool
}

type CapacityCounter

type CapacityCounter struct {
	// contains filtered or unexported fields
}

CapacityCounter はコマごとの、履修可能な学生数をトラックする

func NewCapacityCounter

func NewCapacityCounter() *CapacityCounter

func (*CapacityCounter) Dec

func (c *CapacityCounter) Dec(dayOfWeek, period int)

func (*CapacityCounter) Get

func (c *CapacityCounter) Get(dayOfWeek, period int) int

func (*CapacityCounter) Inc

func (c *CapacityCounter) Inc(dayOfWeek, period int)

func (*CapacityCounter) IncAll

func (c *CapacityCounter) IncAll()

type Class

type Class struct {
	*ClassParam
	ID string
	// contains filtered or unexported fields
}

func NewClass

func NewClass(id string, param *ClassParam) *Class

func (*Class) AddSubmission

func (c *Class) AddSubmission(studentCode string, summary *Submission)

func (*Class) CloseSubmission

func (c *Class) CloseSubmission()

func (*Class) GetSubmissionByStudentCode

func (c *Class) GetSubmissionByStudentCode(code string) *Submission

func (*Class) IntoClassScore

func (c *Class) IntoClassScore(userCode string) *ClassScore

func (*Class) IntoSimpleClassScore

func (c *Class) IntoSimpleClassScore(userCode string) *SimpleClassScore

func (*Class) IsSubmissionClosed

func (c *Class) IsSubmissionClosed() bool

func (*Class) Submissions

func (c *Class) Submissions() map[string]*Submission

type ClassParam

type ClassParam struct {
	Title string
	Desc  string
	Part  uint8 // n回目の講義
}

type ClassScore

type ClassScore struct {
	// 上3つの情報はclassから取得できるので無くてもいいかもしれない
	ClassID string
	Title   string
	Part    uint8

	Score          *int // 0 - 100点
	SubmitterCount int
}

type Course

type Course struct {
	*CourseParam
	ID string
	// contains filtered or unexported fields
}

func NewCourse

func NewCourse(param *CourseParam, id string, teacher *Teacher, capacity int, capacityCounter *CapacityCounter) *Course

func (*Course) AddClass

func (c *Course) AddClass(class *Class)

func (*Course) AddStudent

func (c *Course) AddStudent(student *Student)

for prepare

func (*Course) BroadCastAnnouncement

func (c *Course) BroadCastAnnouncement(a *Announcement)

func (*Course) CalcCourseResultByStudentCode

func (c *Course) CalcCourseResultByStudentCode(code string) *CourseResult

func (*Course) Classes

func (c *Course) Classes() []*Class

func (*Course) CollectClassScores

func (c *Course) CollectClassScores(userCode string) []*ClassScore

func (*Course) CollectSimpleClassScores

func (c *Course) CollectSimpleClassScores(userCode string) []*SimpleClassScore

func (*Course) CommitReservation

func (c *Course) CommitReservation(s *Student)

func (*Course) GetTotalScoreByStudentCode

func (c *Course) GetTotalScoreByStudentCode(code string) int

func (*Course) ReserveIfAvailable

func (c *Course) ReserveIfAvailable() ReservationResult

ReserveIfAvailable は履修受付中なら1枠確保する

func (*Course) RollbackReservation

func (c *Course) RollbackReservation()

func (*Course) SetStatusToClosed

func (c *Course) SetStatusToClosed()

func (*Course) SetStatusToInProgress

func (c *Course) SetStatusToInProgress()

func (*Course) StartTimer

func (c *Course) StartTimer(duration time.Duration)

func (*Course) Status

func (c *Course) Status() api.CourseStatus

func (*Course) Students

func (c *Course) Students() map[string]*Student

func (*Course) Teacher

func (c *Course) Teacher() *Teacher

func (*Course) Wait

func (c *Course) Wait(ctx context.Context, cancel context.CancelFunc, addCourseFunc func()) <-chan struct{}

type CourseManager

type CourseManager struct {
	// contains filtered or unexported fields
}

CourseManager は科目の履修登録を行う。 空き科目の管理 → 履修登録までが責任範囲。

func NewCourseManager

func NewCourseManager(cc *CapacityCounter) *CourseManager

func (*CourseManager) AddNewCourse

func (m *CourseManager) AddNewCourse(course *Course)

func (*CourseManager) ExposeCoursesForValidation

func (m *CourseManager) ExposeCoursesForValidation() map[string]*Course

func (*CourseManager) GetCourseByID

func (m *CourseManager) GetCourseByID(id string) (*Course, bool)

func (*CourseManager) GetCourseCount

func (m *CourseManager) GetCourseCount() int

func (*CourseManager) RemoveRegistrationClosedCourse

func (m *CourseManager) RemoveRegistrationClosedCourse(c *Course)

func (*CourseManager) ReserveCoursesForStudent

func (m *CourseManager) ReserveCoursesForStudent(student *Student, remainingRegistrationCapacity int) []*Course

ReserveCoursesForStudent は学生を受け取って、キュー内の科目に仮登録を行う

type CourseParam

type CourseParam struct {
	Code        string
	Type        string
	Name        string
	Description string
	Credit      int
	Teacher     string
	Period      int
	DayOfWeek   int
	Keywords    string
}

type CourseResult

type CourseResult struct {
	Name             string
	Code             string
	TotalScore       int
	TotalScoreTScore float64 // 偏差値
	TotalScoreAvg    float64 // 平均値
	TotalScoreMax    int     // 最大値
	TotalScoreMin    int     // 最小値
	ClassScores      []*ClassScore
}

type GradeRes

type GradeRes struct {
	Summary       Summary
	CourseResults map[string]*CourseResult
}

func NewGradeRes

func NewGradeRes(summary Summary, courseResults map[string]*CourseResult) GradeRes

type ReservationResult

type ReservationResult int
const (
	Succeeded ReservationResult = iota
	NotAvailable
)

type SearchCourseParam

type SearchCourseParam struct {
	Type      string
	Credit    int
	Teacher   string
	Period    int
	DayOfWeek int
	Keywords  []string
	Status    string
}

func NewCourseParam

func NewCourseParam() *SearchCourseParam

func (*SearchCourseParam) GetParamString

func (p *SearchCourseParam) GetParamString() string

type SimpleClassScore

type SimpleClassScore struct {
	// 上3つの情報はclassから取得できるので無くてもいいかもしれない
	ClassID string
	Title   string
	Part    uint8

	Score *int // 0 - 100点
}

type SimpleCourseResult

type SimpleCourseResult struct {
	Name              string // course name
	Code              string // course code
	SimpleClassScores []*SimpleClassScore
}

CourseResultのうち計算しなくていいやつ

func NewSimpleCourseResult

func NewSimpleCourseResult(name, code string, classScores []*SimpleClassScore) *SimpleCourseResult

type Student

type Student struct {
	*UserAccount
	Agent *agent.Agent
	// contains filtered or unexported fields
}

func NewStudent

func NewStudent(userData *UserAccount, baseURL *url.URL) *Student

func (*Student) AddAnnouncement

func (s *Student) AddAnnouncement(announcement *Announcement)

func (*Student) AddCourse

func (s *Student) AddCourse(course *Course)

func (*Student) AddFinishCourseCount

func (s *Student) AddFinishCourseCount()

func (*Student) AnnouncementCount

func (s *Student) AnnouncementCount() int

func (*Student) Announcements

func (s *Student) Announcements() []*AnnouncementStatus

func (*Student) AnnouncementsMap

func (s *Student) AnnouncementsMap() map[string]*AnnouncementStatus

func (*Student) Courses

func (s *Student) Courses() []*Course

func (*Student) FillTimeslot

func (s *Student) FillTimeslot(course *Course)

FillTimeslot で登録処理を行う場合は別途scheduleMutexでLockすること

func (*Student) FinishCourseCount

func (s *Student) FinishCourseCount() int64

func (*Student) GPA

func (s *Student) GPA() float64

func (*Student) GetAnnouncement

func (s *Student) GetAnnouncement(id string) *AnnouncementStatus

func (*Student) HasFinishedCourse

func (s *Student) HasFinishedCourse() bool

func (*Student) HasUnreadAnnouncement

func (s *Student) HasUnreadAnnouncement() bool

func (*Student) HasUnreadOrDirtyAnnouncementBefore

func (s *Student) HasUnreadOrDirtyAnnouncementBefore(announcementID string) bool

func (*Student) IsEmptyTimeSlots

func (s *Student) IsEmptyTimeSlots(dayOfWeek, period int) bool

IsEmptyTimeSlots でコマを参照する場合は別途scheduleMutexで(R)Lockすること

func (*Student) LockSchedule

func (s *Student) LockSchedule()

func (*Student) MarkAnnouncementReadDirty

func (s *Student) MarkAnnouncementReadDirty(id string)

func (*Student) ReadAnnouncement

func (s *Student) ReadAnnouncement(id string)

func (*Student) RegisteredSchedule

func (s *Student) RegisteredSchedule() [5][6]*Course

func (*Student) RegisteringCount

func (s *Student) RegisteringCount() int

func (*Student) ReleaseTimeslot

func (s *Student) ReleaseTimeslot(dayOfWeek, period int)

func (*Student) TotalCredit

func (s *Student) TotalCredit() int

func (*Student) UnlockSchedule

func (s *Student) UnlockSchedule()

func (*Student) WaitExistUnreadAnnouncement

func (s *Student) WaitExistUnreadAnnouncement(ctx context.Context) <-chan struct{}

WaitExistUnreadAnnouncement は未読おしらせが発生するまでwaitする

func (*Student) WaitReadAnnouncement

func (s *Student) WaitReadAnnouncement(ctx context.Context, id string) <-chan struct{}

func (*Student) WaitReleaseTimeslot

func (s *Student) WaitReleaseTimeslot(ctx context.Context, cancel context.CancelFunc, registerCourseLimit int) <-chan struct{}

type Submission

type Submission struct {
	Title    string
	Checksum uint32
	// contains filtered or unexported fields
}

func NewSubmission

func NewSubmission(title string, data []byte) *Submission

func (*Submission) Score

func (s *Submission) Score() *int

func (*Submission) SetScore

func (s *Submission) SetScore(score int)

type Summary

type Summary struct {
	Credits   int
	GPA       float64
	GpaTScore float64 // 偏差値
	GpaAvg    float64 // 平均値
	GpaMax    float64 // 最大値
	GpaMin    float64 // 最小値
}

type Teacher

type Teacher struct {
	*UserAccount
	Agent      *agent.Agent
	IsLoggedIn bool
	// contains filtered or unexported fields
}

func NewTeacher

func NewTeacher(userData *UserAccount, baseURL *url.URL) *Teacher

func (*Teacher) LoginOnce

func (t *Teacher) LoginOnce(f func(teacher *Teacher)) bool

type UserAccount

type UserAccount struct {
	ID          string // for generate/load initial courses
	Code        string
	Name        string
	RawPassword string
	IsAdmin     bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL