コード例 #1
0
ファイル: program.go プロジェクト: cristian-sima/Wisply
// GetSubject returns the subject area of the program of study
func (program Program) GetSubject() *education.Subject {
	subject, err := education.NewSubject(strconv.Itoa(program.subject))
	if err != nil {
		fmt.Println(err)
	}
	return subject
}
コード例 #2
0
ファイル: controller.go プロジェクト: cristian-sima/Wisply
func (controller *Controller) loadSubject() {
	ID := controller.Ctx.Input.Param(":subject")
	subject, err := model.NewSubject(ID)
	if err != nil {
		controller.Abort("show-database-error")
	}
	controller.Data["subject"] = subject
	controller.subject = subject
	controller.SetCustomTitle("Admin - " + subject.GetName())
}
コード例 #3
0
ファイル: institution.go プロジェクト: cristian-sima/Wisply
// GetEducationSubjects returns the distinct Subjects
func (institution Institution) GetEducationSubjects() []*education.Subject {
	list := []*education.Subject{}
	fieldList := "`subject`"
	whereClause := "WHERE `institution` = ?"
	sql := "SELECT DISTINCT " + fieldList + " FROM `institution_program` " + whereClause
	rows, _ := database.Connection.Query(sql, strconv.Itoa(institution.ID))
	for rows.Next() {
		ID := ""
		rows.Scan(&ID)
		item, _ := education.NewSubject(ID)
		list = append(list, item)
	}
	return list
}
コード例 #4
0
ファイル: subject.go プロジェクト: cristian-sima/Wisply
// it gets the subjects from database
func (search SubjectSearch) getFromDB() []*education.Subject {
	var list []*education.Subject

	limitClause := search.options.GetLimit()
	fieldsList := "`id`"
	whereClause := "WHERE `name` LIKE ?"
	sql := "SELECT DISTINCT " + fieldsList + " FROM `subject_area` " + whereClause + space + limitClause

	rows, err := database.Connection.Query(sql, search.likeQuery())

	if err != nil {
		fmt.Println(err)
	}
	for rows.Next() {
		var ID string
		rows.Scan(&ID)
		item, _ := education.NewSubject(ID)
		list = append(list, item)
	}
	return list
}
コード例 #5
0
ファイル: institution.go プロジェクト: cristian-sima/Wisply
// GetSubject returns the subject object
func (analyser InstitutionAnalyser) GetSubject() *education.Subject {
	subject, _ := education.NewSubject(analyser.subject)
	return subject
}