service

package
v0.0.0-...-f2f702e Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUserAlreadyInCourse error
	ErrUserAlreadyInCourse = errors.New("user already in course")
)

Functions

This section is empty.

Types

type AssignmentService

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

AssignmentService struct

func NewAssignmentService

func NewAssignmentService(db *sql.DB) *AssignmentService

NewAssignmentService returns a pointer to a new AssignmentService

func (*AssignmentService) Fetch

func (s *AssignmentService) Fetch(id int) (*model.Assignment, error)

Fetch a single assignment

func (*AssignmentService) FetchAll

func (s *AssignmentService) FetchAll() ([]*model.Assignment, error)

FetchAll all assignments

func (*AssignmentService) FetchFromCourse

func (s *AssignmentService) FetchFromCourse(courseID int) ([]*model.Assignment, error)

FetchFromCourse all assignments from a given course

func (*AssignmentService) HasReview

func (s *AssignmentService) HasReview(assignmentID int) (bool, error)

HasReview checks if an assignment has review

func (*AssignmentService) Insert

func (s *AssignmentService) Insert(assignment model.Assignment) (int, error)

Insert an assignment to the database

func (*AssignmentService) IsGroupBased

func (s *AssignmentService) IsGroupBased(assignmentID int) (bool, error)

IsGroupBased checks if assignment is group based

func (*AssignmentService) Update

func (s *AssignmentService) Update(assignment model.Assignment) error

Update an assignment

type CourseService

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

CourseService struct

func NewCourseService

func NewCourseService(db *sql.DB) *CourseService

NewCourseService returns a pointer to a new CourseService

func (*CourseService) AddUser

func (s *CourseService) AddUser(userID, courseID int) error

AddUser to a single course

func (*CourseService) Delete

func (s *CourseService) Delete(id int) error

Delete a course in the database

func (*CourseService) Exists

func (s *CourseService) Exists(hash string) *model.Course

Exists checks if a course exists

func (*CourseService) Fetch

func (s *CourseService) Fetch(id int) (*model.Course, error)

Fetch a single course

func (*CourseService) FetchAll

func (s *CourseService) FetchAll() ([]*model.Course, error)

FetchAll all courses

func (*CourseService) FetchAllForUser

func (s *CourseService) FetchAllForUser(userID int) ([]*model.Course, error)

FetchAllForUser all courses for a given user

func (*CourseService) FetchAllForUserOrdered

func (s *CourseService) FetchAllForUserOrdered(userID int) ([]*model.Course, error)

FetchAllForUserOrdered all courses in order for a given user

func (*CourseService) FetchAllStudentsFromCourse

func (s *CourseService) FetchAllStudentsFromCourse(courseID int) ([]*model.User, error)

FetchAllStudentsFromCourse all students from a course

func (*CourseService) Insert

func (s *CourseService) Insert(course model.Course) (int, error)

Insert course into the database

func (*CourseService) RemoveUser

func (s *CourseService) RemoveUser(userID, courseID int) error

RemoveUser from a course

func (*CourseService) Update

func (s *CourseService) Update(course model.Course) error

Update a course in the database

func (*CourseService) UserInCourse

func (s *CourseService) UserInCourse(userID, courseID int) (bool, error)

UserInCourse checks if user is in given course

type FAQService

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

FAQService struct

func NewFAQService

func NewFAQService(db *sql.DB) *FAQService

NewFAQService func

func (*FAQService) Fetch

func (s *FAQService) Fetch() (*model.Faq, error)

Fetch fetches the one faq in db

func (*FAQService) InsertNew

func (s *FAQService) InsertNew() error

InsertNew inserts a new faq in db, if there isn't one in db already

func (*FAQService) Update

func (s *FAQService) Update(questions string) error

Update updates the one faq in db

type FieldService

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

FieldService struct

func NewFieldService

func NewFieldService(db *sql.DB) *FieldService

NewFieldService returns a new pointer to a FieldService

func (*FieldService) Delete

func (fs *FieldService) Delete(id int) error

Delete field from the database

func (*FieldService) Fetch

func (fs *FieldService) Fetch(id int) (*model.Field, error)

Fetch a sinle field

func (*FieldService) FetchAll

func (fs *FieldService) FetchAll() ([]model.Field, error)

FetchAll all fields

func (*FieldService) FetchAllWithFormID

func (fs *FieldService) FetchAllWithFormID(formID int) ([]model.Field, error)

FetchAllWithFormID fetches all fields from a form with a given ID

func (*FieldService) Insert

func (fs *FieldService) Insert(field model.Field) (int, error)

Insert field to database

func (*FieldService) Update

func (fs *FieldService) Update(id int, field model.Field) error

Update field in the database

type FormService

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

FormService struct

func NewFormService

func NewFormService(db *sql.DB) *FormService

NewFormService returns a pointer to a new FormService

func (*FormService) Delete

func (fs *FormService) Delete(id int) error

Delete a form from the database based on the ID

func (*FormService) Fetch

func (fs *FormService) Fetch(id int) (*model.Form, error)

Fetch a single forms from the database

func (*FormService) FetchAll

func (fs *FormService) FetchAll() ([]*model.Form, error)

FetchAll forms from the database

func (*FormService) Insert

func (fs *FormService) Insert(form model.Form) (int, error)

Insert a form to the database

func (*FormService) Update

func (fs *FormService) Update(id int, form model.Form) error

Update a form in the database

type GroupService

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

GroupService struct service

func NewGroupService

func NewGroupService(db *sql.DB) *GroupService

NewGroupService returns a pointer to a new GroupService

func (*GroupService) AddUser

func (s *GroupService) AddUser(groupID, userID int) error

AddUser to group

func (*GroupService) Fetch

func (s *GroupService) Fetch(groupID, assignmentID int) (*model.Group, error)

Fetch group from assignment

func (*GroupService) FetchAll

func (s *GroupService) FetchAll(assignmentID int) ([]*model.Group, error)

FetchAll groups from an assignment

func (*GroupService) FetchGroupForUser

func (s *GroupService) FetchGroupForUser(userID, assignmentID int) (*model.Group, error)

FetchGroupForUser fetches the group for a user in an assignment

func (*GroupService) FetchUsersFromGroup

func (s *GroupService) FetchUsersFromGroup(groupID int) ([]*model.User, error)

FetchUsersFromGroup fetches all users from an group

func (*GroupService) Insert

func (s *GroupService) Insert(group model.Group) (int64, error)

Insert group to database

func (*GroupService) RemoveUser

func (s *GroupService) RemoveUser(groupID, userID int) error

RemoveUser from group

func (*GroupService) Update

func (s *GroupService) Update(group model.Group) error

Update group in database

func (*GroupService) UserInAnyGroup

func (s *GroupService) UserInAnyGroup(userID, assignmentID int) (bool, error)

UserInAnyGroup checks if user is in any group for a given assignment

type LogsService

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

LogsService struct

func NewLogsService

func NewLogsService(db *sql.DB) *LogsService

NewLogsService func

func (*LogsService) FetchAllWithNameAndRole

func (s *LogsService) FetchAllWithNameAndRole() ([]*model.Logs, error)

FetchAllWithNameAndRole fetches all logs

func (*LogsService) InsertAdminAddUserToGroup

func (s *LogsService) InsertAdminAddUserToGroup(userID int, groupID int, affectedUserID int) error

InsertAdminAddUserToGroup inserts a add user to group log

func (*LogsService) InsertAdminChangeUserPassword

func (s *LogsService) InsertAdminChangeUserPassword(userID int, studentID int) error

InsertAdminChangeUserPassword inserts a change student password log

func (*LogsService) InsertAdminCourse

func (s *LogsService) InsertAdminCourse(userID int, courseID int) error

InsertAdminCourse inserts a new course log

func (*LogsService) InsertAdminCreateAssignment

func (s *LogsService) InsertAdminCreateAssignment(userID int, assignmentID int) error

InsertAdminCreateAssignment inserts a create assignment log

func (*LogsService) InsertAdminCreateFAQ

func (s *LogsService) InsertAdminCreateFAQ(userID int) error

InsertAdminCreateFAQ inserts a create FAQ log

func (*LogsService) InsertAdminCreateGroup

func (s *LogsService) InsertAdminCreateGroup(userID int, groupID int) error

InsertAdminCreateGroup inserts a create group log

func (*LogsService) InsertAdminCreateSubmissionForUser

func (s *LogsService) InsertAdminCreateSubmissionForUser(userID int, assignmentID int, submissionID int, studentID int) error

InsertAdminCreateSubmissionForUser inserts a create submission for student log

func (*LogsService) InsertAdminDeleteAssignment

func (s *LogsService) InsertAdminDeleteAssignment(userID int, assignmentID int) error

InsertAdminDeleteAssignment inserts a change password log

func (*LogsService) InsertAdminDeleteCourse

func (s *LogsService) InsertAdminDeleteCourse(userID int, courseID int) error

InsertAdminDeleteCourse inserts a new delete course log

func (*LogsService) InsertAdminDeleteGroup

func (s *LogsService) InsertAdminDeleteGroup(userID int, groupID int) error

InsertAdminDeleteGroup inserts a delete group log

func (*LogsService) InsertAdminDeleteReviewForm

func (s *LogsService) InsertAdminDeleteReviewForm(userID int, reviewID int) error

InsertAdminDeleteReviewForm inserts a new review form

func (*LogsService) InsertAdminDeleteSubmissionForUser

func (s *LogsService) InsertAdminDeleteSubmissionForUser(userID int, assignmentID int, submissionID int, studentID int) error

InsertAdminDeleteSubmissionForUser inserts a delete submission for student log

func (*LogsService) InsertAdminDeleteSubmissionForm

func (s *LogsService) InsertAdminDeleteSubmissionForm(userID int, submissionID int) error

InsertAdminDeleteSubmissionForm inserts a new submission form

func (*LogsService) InsertAdminEditGroupName

func (s *LogsService) InsertAdminEditGroupName(userID int, groupID int, oldValue string, newValue string) error

InsertAdminEditGroupName inserts a edit group name log

func (*LogsService) InsertAdminRemoveUserFromCourse

func (s *LogsService) InsertAdminRemoveUserFromCourse(userID int, courseID int, studentID int) error

InsertAdminRemoveUserFromCourse inserts a remove student from course log

func (*LogsService) InsertAdminRemoveUserFromGroup

func (s *LogsService) InsertAdminRemoveUserFromGroup(userID int, groupID int, affectedUserID int) error

InsertAdminRemoveUserFromGroup inserts a remove user from group log

func (*LogsService) InsertAdminReviewForm

func (s *LogsService) InsertAdminReviewForm(userID int, reviewID int) error

InsertAdminReviewForm inserts a new review form

func (*LogsService) InsertAdminSubmissionForm

func (s *LogsService) InsertAdminSubmissionForm(userID int, submissionID int) error

InsertAdminSubmissionForm inserts a new submission form

func (*LogsService) InsertAdminUpdateAssignment

func (s *LogsService) InsertAdminUpdateAssignment(userID int, assignmentID int) error

InsertAdminUpdateAssignment inserts a change password log

func (*LogsService) InsertAdminUpdateCourse

func (s *LogsService) InsertAdminUpdateCourse(userID int, courseID int) error

InsertAdminUpdateCourse inserts a new update course log

func (*LogsService) InsertAdminUpdateFAQ

func (s *LogsService) InsertAdminUpdateFAQ(userID int, oldValue string, newValue string) error

InsertAdminUpdateFAQ inserts a updated FAQ log

func (*LogsService) InsertAdminUpdateReviewForm

func (s *LogsService) InsertAdminUpdateReviewForm(userID int, reviewID int) error

InsertAdminUpdateReviewForm inserts a new review form

func (*LogsService) InsertAdminUpdateSubmissionForUser

func (s *LogsService) InsertAdminUpdateSubmissionForUser(userID int, assignmentID int, submissionID int, studentID int) error

InsertAdminUpdateSubmissionForUser inserts a update submission for student log

func (*LogsService) InsertAdminUpdateSubmissionForm

func (s *LogsService) InsertAdminUpdateSubmissionForm(userID int, submissionID int) error

InsertAdminUpdateSubmissionForm inserts a new submission form

func (*LogsService) InsertChangeEmail

func (s *LogsService) InsertChangeEmail(userID int, oldValue string, newValue string) error

InsertChangeEmail inserts a change email log

func (*LogsService) InsertChangePassword

func (s *LogsService) InsertChangePassword(userID int) error

InsertChangePassword inserts a change password log

func (*LogsService) InsertChangePasswordEmail

func (s *LogsService) InsertChangePasswordEmail(userID int) error

InsertChangePasswordEmail inserts a change password with email log

func (*LogsService) InsertCreateGroup

func (s *LogsService) InsertCreateGroup(userID int, groupID int) error

InsertCreateGroup inserts a create group log

func (*LogsService) InsertDeleteGroup

func (s *LogsService) InsertDeleteGroup(userID int, groupID int) error

InsertDeleteGroup inserts a delete group log

func (*LogsService) InsertDeleteSubmission

func (s *LogsService) InsertDeleteSubmission(userID int, assignmentID int, submissionID int) error

InsertDeleteSubmission inserts a delete user submission log

func (*LogsService) InsertEditGroupName

func (s *LogsService) InsertEditGroupName(userID int, groupID int, oldValue string, newValue string) error

InsertEditGroupName inserts a edit group name log

func (*LogsService) InsertEmailStudents

func (s *LogsService) InsertEmailStudents(userID int, courseID int, emails []string) error

InsertEmailStudents inserts a new email students log

func (*LogsService) InsertFinishedOnePeerReview

func (s *LogsService) InsertFinishedOnePeerReview(userID int, assignmentID int, affectedUserID int) error

InsertFinishedOnePeerReview is for when one user has finished peer reviewing another users submission

func (*LogsService) InsertJoinCourse

func (s *LogsService) InsertJoinCourse(userID int, courseID int) error

InsertJoinCourse inserts a new join course log

func (*LogsService) InsertJoinGroup

func (s *LogsService) InsertJoinGroup(userID int, groupID int) error

InsertJoinGroup inserts a join group log

func (*LogsService) InsertLeftCourse

func (s *LogsService) InsertLeftCourse(userID int, courseID int) error

InsertLeftCourse inserts a new join course log

func (*LogsService) InsertLeftGroup

func (s *LogsService) InsertLeftGroup(userID int, groupID int) error

InsertLeftGroup inserts a left group log

func (*LogsService) InsertNewUser

func (s *LogsService) InsertNewUser(userID int) error

InsertNewUser inserts a new user log

func (*LogsService) InsertRemoveUserFromGroup

func (s *LogsService) InsertRemoveUserFromGroup(userID int, groupID int, removedUser int) error

InsertRemoveUserFromGroup inserts a removed user from course log

func (*LogsService) InsertSubmission

func (s *LogsService) InsertSubmission(userID int, assignmentID int, submissionID int) error

InsertSubmission inserts a new user submission log

func (*LogsService) InsertUpdateOnePeerReview

func (s *LogsService) InsertUpdateOnePeerReview(userID int, assignmentID int, affectedUserID int) error

InsertUpdateOnePeerReview is for when one user has updated peer review

func (*LogsService) InsertUpdateSubmission

func (s *LogsService) InsertUpdateSubmission(userID int, assignmentID int, submissionID int) error

InsertUpdateSubmission inserts a update user submission log

type PeerReviewService

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

PeerReviewService struct

func NewPeerReviewService

func NewPeerReviewService(db *sql.DB) *PeerReviewService

NewPeerReviewService returns a pointer to a new PeerReviewService

func (*PeerReviewService) FetchAllFromAssignment

func (s *PeerReviewService) FetchAllFromAssignment(assignmentID int) ([]*model.PeerReview, error)

FetchAllFromAssignment from the database

func (*PeerReviewService) FetchReviewTargetsToUser

func (s *PeerReviewService) FetchReviewTargetsToUser(userID int, assignmentID int) ([]*model.PeerReview, error)

FetchReviewTargetsToUser from the database

func (*PeerReviewService) Insert

func (s *PeerReviewService) Insert(assignmentID int, userID int, targetUserID int) (bool, error)

Insert a new peer review

func (*PeerReviewService) TargetExists

func (s *PeerReviewService) TargetExists(assignmentID int, userID int) (bool, error)

TargetExists checks if the target exist in the table

type ReviewAnswerService

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

ReviewAnswerService struct

func NewReviewAnswerService

func NewReviewAnswerService(db *sql.DB) *ReviewAnswerService

NewReviewAnswerService returns a pointer to a new ReviewAnswerService

func (*ReviewAnswerService) CountReviewsDone

func (s *ReviewAnswerService) CountReviewsDone(userID, assignmentID int) (int, error)

CountReviewsDone return amount of reviews done by an user for a given assignment

func (*ReviewAnswerService) CountReviewsDoneOnAssignment

func (s *ReviewAnswerService) CountReviewsDoneOnAssignment(assignmentID int) (int, error)

CountReviewsDoneOnAssignment return amount of reviews done totally for a given assignment

func (*ReviewAnswerService) FetchForAssignment

func (s *ReviewAnswerService) FetchForAssignment(assignmentID int) ([]*model.ReviewAnswer, error)

FetchForAssignment fetches all for a given assignment

func (*ReviewAnswerService) FetchForReviewUser

func (s *ReviewAnswerService) FetchForReviewUser(userID, assignmentID int) ([][]*model.ReviewAnswer, error)

FetchForReviewUser fetches all for a given reviewer and assignment

func (*ReviewAnswerService) FetchForReviewer

func (s *ReviewAnswerService) FetchForReviewer(reviewer, assignmentID int) ([]*model.ReviewAnswer, error)

FetchForReviewer fetches all for a given reviewer and assignment

func (*ReviewAnswerService) FetchForReviewerAndTarget

func (s *ReviewAnswerService) FetchForReviewerAndTarget(reviewer, target, assignmentID int) ([]*model.ReviewAnswer, error)

FetchForReviewerAndTarget fetches review for a given reviewer, target and assignment

func (*ReviewAnswerService) FetchForTarget

func (s *ReviewAnswerService) FetchForTarget(target, assignmentID int) ([]*model.ReviewAnswer, error)

FetchForTarget fetches all for a given target and assignment

func (*ReviewAnswerService) FetchForUser

func (s *ReviewAnswerService) FetchForUser(userID, assignmentID int) ([][]*model.ReviewAnswer, error)

FetchForUser fetches all for a given user and assignment

func (*ReviewAnswerService) FetchMaxScoreFromAssignment

func (s *ReviewAnswerService) FetchMaxScoreFromAssignment(assignmentID int) (int, error)

FetchMaxScoreFromAssignment returns max score from any reviews

func (*ReviewAnswerService) FetchReviewUsers

func (s *ReviewAnswerService) FetchReviewUsers(target, assignmentID int) ([]int, error)

FetchReviewUsers fetches all users who are reviewers for a target, for a given assignment

func (*ReviewAnswerService) FetchScoreFromReview

func (s *ReviewAnswerService) FetchScoreFromReview(assignmentID, userID int) ([]float64, error)

FetchScoreFromReview return score for reviews for a given assignment and user

func (*ReviewAnswerService) FetchStatisticsForAssignment

func (s *ReviewAnswerService) FetchStatisticsForAssignment(assignmentID int) (*util.Statistics, error)

FetchStatisticsForAssignment return statistics for reviews for a given assignment

func (*ReviewAnswerService) FetchStatisticsForAssignmentAndUser

func (s *ReviewAnswerService) FetchStatisticsForAssignmentAndUser(assignmentID, userID int) (*util.Statistics, error)

FetchStatisticsForAssignmentAndUser return statistics for reviews for a given assignment and user

func (*ReviewAnswerService) FetchUserReportsForAssignment

func (s *ReviewAnswerService) FetchUserReportsForAssignment(assignmentID int) ([]model.RawUserReport, error)

FetchUserReportsForAssignment returns user reports for a given assignment

func (*ReviewAnswerService) FetchUsersTargets

func (s *ReviewAnswerService) FetchUsersTargets(userID, assignmentID int) ([]int, error)

FetchUsersTargets fetches all users (target) for a reviewer for a given assignment

func (*ReviewAnswerService) HasBeenReviewed

func (s *ReviewAnswerService) HasBeenReviewed(target, reviewer, assignmentID int) (bool, error)

HasBeenReviewed checks if a reviewer has reviewed a target for a given assignment

func (*ReviewAnswerService) Insert

func (s *ReviewAnswerService) Insert(answer model.ReviewAnswer) (int, error)

Insert to the database

func (*ReviewAnswerService) Update

func (s *ReviewAnswerService) Update(targetID, reviewerID, assignmentID int, answer model.ReviewAnswer) error

Update review answer and comment

type ReviewService

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

ReviewService struct

func NewReviewService

func NewReviewService(db *sql.DB) *ReviewService

NewReviewService returns a pointer to a new ReviewService

func (*ReviewService) Delete

func (s *ReviewService) Delete(id int) error

Delete review from the database

func (*ReviewService) FetchAll

func (s *ReviewService) FetchAll() ([]model.Review, error)

FetchAll reviews from the database

func (*ReviewService) FetchFromAssignment

func (s *ReviewService) FetchFromAssignment(assignmentID int) (*model.Review, error)

FetchFromAssignment reviews from given assignment

func (*ReviewService) FetchFromFormID

func (s *ReviewService) FetchFromFormID(formID int) (*model.Review, error)

FetchFromFormID fetches review from fromID

func (*ReviewService) FetchReviewUsers

func (s *ReviewService) FetchReviewUsers(userID, assignmentID int) ([]*model.User, error)

FetchReviewUsers fetches reviews for a user

func (*ReviewService) Insert

func (s *ReviewService) Insert(form model.Form) (int, error)

Insert review to the database

func (*ReviewService) IsUsed

func (s *ReviewService) IsUsed(formID int) (bool, error)

IsUsed checks if review-form is in use

func (*ReviewService) IsUserTheReviewer

func (s *ReviewService) IsUserTheReviewer(userID, targetID, assignmentID int) (bool, error)

IsUserTheReviewer checks if user is the reviewer for a target

func (*ReviewService) Update

func (s *ReviewService) Update(form model.Form) error

Update review in the database

func (*ReviewService) UsedInAssignment

func (s *ReviewService) UsedInAssignment(formID int) (int, error)

UsedInAssignment checks if it is used in an assignment

type Services

type Services struct {
	Assignment       *AssignmentService
	Course           *CourseService
	Field            *FieldService
	Form             *FormService
	Review           *ReviewService
	ReviewAnswer     *ReviewAnswerService
	PeerReview       *PeerReviewService
	Submission       *SubmissionService
	SubmissionAnswer *SubmissionAnswerService
	User             *UserService
	Validation       *ValidationService
	UserPending      *UserPendingService
	GroupService     *GroupService
	Logs             *LogsService
	FAQ              *FAQService
}

Services struct collect all services into one struct, for less code in the handlers

func NewServices

func NewServices(db *sql.DB) *Services

NewServices returns a pointer to a new Services

type SubmissionAnswerService

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

SubmissionAnswerService struct

func NewSubmissionAnswerService

func NewSubmissionAnswerService(db *sql.DB) *SubmissionAnswerService

NewSubmissionAnswerService returns a pointer to a new SubmissionAnswerService

func (*SubmissionAnswerService) CountForAssignment

func (s *SubmissionAnswerService) CountForAssignment(assignmentID int) (int, error)

CountForAssignment SubmissionAnswerService done in an assignment

func (*SubmissionAnswerService) Delete

func (s *SubmissionAnswerService) Delete(assignmentID, userID int) error

Delete SubmissionAnswerService from the database

func (*SubmissionAnswerService) DeleteFromAssignment

func (s *SubmissionAnswerService) DeleteFromAssignment(assignmentID int) error

DeleteFromAssignment SubmissionAnswerService from an assingment

func (*SubmissionAnswerService) Fetch

Fetch a single SubmissionAnswerService

func (*SubmissionAnswerService) FetchAll

FetchAll SubmissionAnswerService's

func (*SubmissionAnswerService) FetchAllFromAssignment

func (s *SubmissionAnswerService) FetchAllFromAssignment(assID int) ([]*model.SubmissionAnswer, error)

FetchAllFromAssignment SubmissionAnswerService's from an assignment

func (*SubmissionAnswerService) FetchSubmittedTime

func (s *SubmissionAnswerService) FetchSubmittedTime(userID, assignmentID int) (time.Time, bool, error)

FetchSubmittedTime submitted time for a user on a given assignment

func (*SubmissionAnswerService) FetchUserAnswers

func (s *SubmissionAnswerService) FetchUserAnswers(userID, assignmentID int) ([]*model.SubmissionAnswer, error)

FetchUserAnswers all answers for a SubmissionAnswerService

func (*SubmissionAnswerService) FetchUsersDeliveredFromAssignment

func (s *SubmissionAnswerService) FetchUsersDeliveredFromAssignment(assID int) ([]int, error)

FetchUsersDeliveredFromAssignment SubmissionAnswerService's delivered by users from an assignment

func (*SubmissionAnswerService) HasUserSubmitted

func (s *SubmissionAnswerService) HasUserSubmitted(assignmentID, userID int) (bool, error)

HasUserSubmitted check is a user has submitted for a given assignment

func (*SubmissionAnswerService) Insert

func (s *SubmissionAnswerService) Insert(answers []*model.SubmissionAnswer) error

Insert SubmissionAnswerService to the database

func (*SubmissionAnswerService) Update

func (s *SubmissionAnswerService) Update(answers []*model.SubmissionAnswer) error

Update SubmissionAnswerService in the database

type SubmissionService

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

SubmissionService struct

func NewSubmissionService

func NewSubmissionService(db *sql.DB) *SubmissionService

NewSubmissionService returns a pointer to a new SubmissionService

func (*SubmissionService) Delete

func (s *SubmissionService) Delete(id int) error

Delete submission from the database

func (*SubmissionService) Fetch

func (s *SubmissionService) Fetch(id int) (*model.Submission, error)

Fetch a single submission

func (*SubmissionService) FetchAll

func (s *SubmissionService) FetchAll() ([]model.Submission, error)

FetchAll return all submissions from the database

func (*SubmissionService) FetchFromAssignment

func (s *SubmissionService) FetchFromAssignment(assignmentID int) (*model.Submission, error)

FetchFromAssignment submission-form for a given assignment

func (*SubmissionService) FetchFromFormID

func (s *SubmissionService) FetchFromFormID(formID int) (*model.Submission, error)

FetchFromFormID fetches submission from form id

func (*SubmissionService) Insert

func (s *SubmissionService) Insert(form model.Form) (int, error)

Insert submission-form to the database

func (*SubmissionService) IsUsed

func (s *SubmissionService) IsUsed(formID int) (bool, error)

IsUsed checks if submission-form is in use

func (*SubmissionService) Update

func (s *SubmissionService) Update(form model.Form) error

Update submission-form in the database

func (*SubmissionService) UsedInAssignment

func (s *SubmissionService) UsedInAssignment(formID int) (int, error)

UsedInAssignment checks if submission-for is used by any assignment

type UserPendingService

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

UserPendingService struct

func NewUserPendingService

func NewUserPendingService(db *sql.DB) *UserPendingService

NewUserPendingService returns a pointer to a new UserPendingService

func (*UserPendingService) FetchAll

FetchAll fetches all rows in users_pending

func (*UserPendingService) FetchPassword

func (s *UserPendingService) FetchPassword(id int) (string, error)

FetchPassword fetches one password to one user in users_pending

func (*UserPendingService) Insert

Insert for inserting forgotten user pending

func (*UserPendingService) InsertNewEmail

func (s *UserPendingService) InsertNewEmail(pending model.UserRegistrationPending) (int, error)

InsertNewEmail for inserting new email

type UserService

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

UserService struct

func NewUserService

func NewUserService(db *sql.DB) *UserService

NewUserService returns a pointer to a new UserService

func (*UserService) Authenticate

func (s *UserService) Authenticate(email, password string) (model.User, error)

Authenticate a user

func (*UserService) EmailExists

func (s *UserService) EmailExists(email string) (bool, int, error)

EmailExists checks if the email exists in emailprivate and emailstudent

func (*UserService) Fetch

func (s *UserService) Fetch(id int) (*model.User, error)

Fetch a single user

func (*UserService) FetchAll

func (s *UserService) FetchAll() ([]*model.User, error)

FetchAll all users

func (*UserService) FetchAllFromCourse

func (s *UserService) FetchAllFromCourse(courseID int) ([]*model.User, error)

FetchAllFromCourse all users from a course

func (*UserService) FetchAllStudentEmails

func (s *UserService) FetchAllStudentEmails(courseID int) ([]string, error)

FetchAllStudentEmails Fetches all student emails, primary default or secondary if not null

func (*UserService) FetchHash

func (s *UserService) FetchHash(id int) (string, error)

FetchHash returns hashed password for a user

func (*UserService) Register

func (s *UserService) Register(user model.User, hashedPass string) (int, error)

Register a new user

func (*UserService) RegisterWithHashing

func (s *UserService) RegisterWithHashing(user model.User, password string) (int, error)

RegisterWithHashing registers an user, and hash their password

func (*UserService) Update

func (s *UserService) Update(id int, user model.User) error

Update an user

func (*UserService) UpdatePassword

func (s *UserService) UpdatePassword(id int, password string) error

UpdatePassword for an user

type ValidationService

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

ValidationService struct

func NewValidationService

func NewValidationService(db *sql.DB) *ValidationService

NewValidationService return a pointer to a new ValidationService

func (*ValidationService) Insert

func (s *ValidationService) Insert(forgottenPass model.ValidationEmail) (int, error)

Insert to the database

func (*ValidationService) Match

Match first hashes the hash and then checks if the hash match in the db

func (*ValidationService) UpdateValidation

func (s *ValidationService) UpdateValidation(id int, state bool) error

UpdateValidation updates the validation to a link

Jump to

Keyboard shortcuts

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