コード例 #1
0
// @Title 根据学年度 学期 与 教师 获取教师课程表
// @router /getStudentCourseByTerm [post]
func (this *APIStudentController) GetStudentCourseByTerm() {
	xnd := this.GetString("xnd")
	if len(xnd) > 0 {
		arr := strings.Split(xnd, "-")
		if len(arr) == 2 {
			startYear, _ := strconv.Atoi(arr[0])
			endYear, _ := strconv.Atoi(arr[1])
			xqd, _ := this.GetInt("xqd")
			if term, err := models.SearchTerm(xqd, startYear, endYear); err == nil {
				s_id := this.GetSession("id").(string)
				if s_courses, err := models.GetStudentCourseByTerm(term, s_id); err == nil {
					this.SendSuccessJSON(s_courses)
					return
				} else {
					this.SendFailedJSON(1, "获取教师课程表失败")
					return
				}
			} else {
				this.SendFailedJSON(1, "获取学期数据失败")
				return
			}

		}
	}
	this.SendFailedJSON(1, "学年度不正确")
	return
}
コード例 #2
0
// @Title 课程表视图
// @router /table [get]
func (this *ViewStudentController) Table() {
	change, _ := this.GetBool("change")
	this.Data["change"] = change
	//	get the term list
	term_list, err := models.GetTermListByStudentCourse(this.Data["student"].(*models.Student).Id)
	if err != nil {
		this.Redirect("/error", 302)
		this.StopRun()
	}
	this.Data["term_list"] = models.RankingTerm(term_list)
	var term *models.Term
	xnd := this.GetString("xnd")
	if len(xnd) > 0 {
		xqd, _ := this.GetInt("xqd")
		arr := strings.Split(xnd, "-")
		if len(arr) != 2 {
			this.Redirect("/error", 302)
			this.StopRun()
		}
		startYear, _ := strconv.Atoi(arr[0])
		endYear, _ := strconv.Atoi(arr[1])
		term, err = models.SearchTerm(xqd, startYear, endYear)
		if err != nil {
			this.Redirect("/error", 302)
			this.StopRun()
		}
	} else {
		//	get the now term
		term, err = models.GetTermByTimeNow()
		if err != nil {
			this.Redirect("/error", 302)
			this.StopRun()
		}
	}
	this.Data["term"] = term
	//	get the student course
	s_courses, err := models.GetStudentCourseByTerm(term, this.Data["student"].(*models.Student).Id)
	if err != nil {
		this.Redirect("/error", 302)
		this.StopRun()
	}
	this.Data["course_color"] = []string{"tb-red", "tb-dark-blue", "tb-grey", "tb-violet", "tb-origin", "tb-blue-green", "tb-blue", "tb-yellow",
		"tb-green", "tb-light-blue", "tb-brown", "tb-pink", "tb-light-green", "tb-dark-blue", "tb-rose-red"}
	this.Data["course_time"] = []string{"08:00-08:40", "08:50-09:30", "09:45-10:25", "10:35-11:15", "11:20-12:00",
		"12:50-13:30", "13:40-14:20", "14:30-15:10", "15:15-15:55", "16:10-16:50", "16:55-17:35", "18:45-19:25",
		"19:30-20:10", "20:15-20:55", "21:05-21:45"}
	this.Data["course_week"] = []string{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"}
	this.Data["s_courses"] = models.RangeToMapStudentCourse(s_courses)
	this.Data["now_week"] = this.GetString("week")

	this.Layout = "student/base.html"
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["Head_html"] = "student/head/table_head.html"
	this.LayoutSections["Scripts"] = "student/scripts/table_scripts.html"
	this.TplNames = "student/table.html"
}
コード例 #3
0
// @Tilte 我的统计数据
// @router /echart [get]
func (this *ViewStudentController) Echart() {
	//	get the term list
	term_list, err := models.GetTermListByStudentCourse(this.Data["student"].(*models.Student).Id)
	if err != nil {
		this.Redirect("/error", 302)
		this.StopRun()
	}
	//	get all student course
	for k, _ := range term_list {
		term_list[k].Orgs = make(map[string]interface{})

		if s_courses, err := models.GetStudentCourseByTerm(term_list[k], this.Data["student"].(*models.Student).Id); err == nil {
			s_courses = models.FilterRepeat(s_courses).([]*models.StudentCourse)
			//	get the score
			for k, v := range s_courses {
				if score, err := models.SearchStudentGrade(v.Id); err == nil {
					score.StudentCourse = nil
					s_courses[k].TeacherCourse.Term = nil
					s_courses[k].Score = score
				} else {
					continue
				}
				if s_homeworks, err := models.GetStudentHomeworkByStudentCourse(v, this.Data["student"].(*models.Student).Id); err == nil {
					s_courses[k].Orgs = make(map[string]interface{})
					s_courses[k].Orgs["s_homeworks"] = s_homeworks
				} else {
					continue
				}
				if s_checks, err := models.GetStudentChecksByTeacherCourseAndStudent(v.TeacherCourse, this.Data["student"].(*models.Student).Id); err == nil {
					s_courses[k].Orgs["s_checks"] = s_checks
				} else {
					continue
				}
			}
			term_list[k].Orgs["s_course"] = s_courses
		}
	}
	this.Data["term_list"] = models.RankingTerm(term_list)

	this.Layout = "student/base.html"
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["Head_html"] = "student/head/info_head.html"
	this.LayoutSections["Scripts"] = "student/scripts/echart_scripts.html"
	this.TplNames = "student/echart.html"
}
コード例 #4
0
// @Title 查看课程作业
// @router /courseHomework [get]
func (this *ViewStudentController) CourseHomework() {
	//	get teacher course
	if t_course_id, err := this.GetInt64("course"); err == nil {
		if t_course, err := models.GetTeacherCourseById(t_course_id); err == nil {
			//	get student course homework list
			if homeworks, err := models.GetStudentHomeworkByTeacherCourseAndStudent(t_course, this.Data["student"].(*models.Student).Id); err == nil {
				t_course.Orgs["s_homeworks"] = homeworks
				this.Data["t_course"] = t_course
				//	get the term all teachercourse
				if s_courses, err := models.GetStudentCourseByTerm(t_course.Term, this.Data["student"].(*models.Student).Id); err == nil {
					this.Data["s_courses"] = s_courses
				} else {
					this.Redirect("/error", 302)
					this.StopRun()
				}
				//	get all term
				term_list, err := models.GetTermListByStudentHomework(this.Data["student"].(*models.Student).Id)
				if err != nil {
					this.Redirect("/error", 302)
					this.StopRun()
				}
				this.Data["term_list"] = models.RankingTerm(term_list)
			} else {
				this.Redirect("/error", 302)
				this.StopRun()
			}
		} else {
			this.Redirect("/error", 302)
			this.StopRun()
		}
	} else {
		this.Redirect("/error", 302)
		this.StopRun()
	}

	this.Layout = "student/base.html"
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["Head_html"] = "student/head/courseHomework_head.html"
	this.LayoutSections["Scripts"] = "student/scripts/courseHomework_scripts.html"
	this.TplNames = "student/courseHomework.html"
}
コード例 #5
0
// @Tilte 我的成绩
// @router /studentScore [get]
func (this *ViewStudentController) StudentScore() {
	//	get the term list
	term_list, err := models.GetTermListByStudentCourse(this.Data["student"].(*models.Student).Id)
	if err != nil {
		this.Redirect("/error", 302)
		this.StopRun()
	}

	var term *models.Term
	xnd := this.GetString("xnd")
	if len(xnd) > 0 {
		xqd, _ := this.GetInt("xqd")
		arr := strings.Split(xnd, "-")
		if len(arr) != 2 {
			this.Redirect("/error", 302)
			this.StopRun()
		}
		startYear, _ := strconv.Atoi(arr[0])
		endYear, _ := strconv.Atoi(arr[1])
		term, err = models.SearchTerm(xqd, startYear, endYear)
		if err != nil {
			this.Redirect("/error", 302)
			this.StopRun()
		}
	} else {
		//	get the now term
		term, err = models.GetTermByTimeNow()
		if err != nil {
			this.Redirect("/error", 302)
			this.StopRun()
		}
	}
	this.Data["term"] = term
	//	get the student course
	if s_courses, err := models.GetStudentCourseByTerm(term, this.Data["student"].(*models.Student).Id); err == nil {
		s_courses = models.FilterRepeat(s_courses).([]*models.StudentCourse)
		//	get the score
		for k, v := range s_courses {
			if score, err := models.SearchStudentGrade(v.Id); err == nil {
				s_courses[k].Score = score
			} else {
				continue
			}
		}
		this.Data["s_courses"] = s_courses
		for k, v := range term_list {
			if term.Id == v.Id {
				term_list[k].Orgs = make(map[string]interface{})
				for k1, _ := range s_courses {
					s_courses[k1].TeacherCourse.Term = nil
					s_courses[k1].Score.StudentCourse = nil
				}
				term_list[k].Orgs["s_course"] = s_courses
			}
		}
	} else {
		this.Redirect("/error", 302)
		this.StopRun()
	}
	//	get all student course
	for k, v := range term_list {
		if term.Id != v.Id {
			term_list[k].Orgs = make(map[string]interface{})

			if s_courses, err := models.GetStudentCourseByTerm(term_list[k], this.Data["student"].(*models.Student).Id); err == nil {
				s_courses = models.FilterRepeat(s_courses).([]*models.StudentCourse)
				//	get the score
				for k, v := range s_courses {
					if score, err := models.SearchStudentGrade(v.Id); err == nil {
						score.StudentCourse = nil
						s_courses[k].TeacherCourse.Term = nil
						s_courses[k].Score = score
					} else {
						continue
					}
				}
				term_list[k].Orgs["s_course"] = s_courses
			}
		}
	}
	this.Data["term_list"] = models.RankingTerm(term_list)

	this.Layout = "student/base.html"
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["Head_html"] = "student/head/score_head.html"
	this.LayoutSections["Scripts"] = "student/scripts/score_scripts.html"
	this.TplNames = "student/score.html"
}
コード例 #6
0
// @Title 作业统计
// @router /studentHomework [get]
func (this *ViewStudentController) StudentHomework() {
	//	get the term list
	term_list, err := models.GetTermListByStudentCourse(this.Data["student"].(*models.Student).Id)
	if err != nil {
		this.Redirect("/error", 302)
		this.StopRun()
	}
	var term *models.Term
	xnd := this.GetString("xnd")
	if len(xnd) > 0 {
		xqd, _ := this.GetInt("xqd")
		arr := strings.Split(xnd, "-")
		if len(arr) != 2 {
			this.Redirect("/error", 302)
			this.StopRun()
		}
		startYear, _ := strconv.Atoi(arr[0])
		endYear, _ := strconv.Atoi(arr[1])
		term, err = models.SearchTerm(xqd, startYear, endYear)
		if err != nil {
			this.Redirect("/error", 302)
			this.StopRun()
		}
	} else {
		//	get the now term
		term, err = models.GetTermByTimeNow()
		if err != nil {
			this.Redirect("/error", 302)
			this.StopRun()
		}
	}
	this.Data["term"] = term
	//	get the student course
	s_course_id, _ := this.GetInt64("course")
	if s_course_id > 0 {
		if s_course, err := models.GetStudentCourseById(s_course_id); err == nil {
			this.Data["s_course"] = s_course
		} else {
			this.Redirect("/error", 302)
			this.StopRun()
		}
	}
	//	get the student courses
	if s_courses, err := models.GetStudentCourseByTerm(term, this.Data["student"].(*models.Student).Id); err == nil {
		//	get the student homework
		for k, v := range s_courses {
			if s_homeworks, err := models.GetStudentHomeworkByStudentCourse(v, this.Data["student"].(*models.Student).Id); err == nil {
				s_courses[k].Orgs = make(map[string]interface{})
				s_courses[k].Orgs["s_homeworks"] = s_homeworks
				for k, v := range term_list {
					if term.Id == v.Id {
						term_list[k].Orgs = make(map[string]interface{})
						term_list[k].Orgs["s_course"] = s_courses
					}
				}
			} else {
				continue
			}
		}
		this.Data["s_courses"] = s_courses
	} else {
		this.Redirect("/error", 302)
		this.StopRun()
	}
	//	get all student homework
	for k, v := range term_list {
		if term.Id != v.Id {
			term_list[k].Orgs = make(map[string]interface{})

			if s_courses, err := models.GetStudentCourseByTerm(term_list[k], this.Data["student"].(*models.Student).Id); err == nil {
				//	get the homework
				for k, v := range s_courses {
					if s_homeworks, err := models.GetStudentHomeworkByStudentCourse(v, this.Data["student"].(*models.Student).Id); err == nil {
						s_courses[k].Orgs = make(map[string]interface{})
						s_courses[k].Orgs["s_homeworks"] = s_homeworks
					} else {
						continue
					}
				}
				term_list[k].Orgs["s_course"] = s_courses
			}
		}
	}
	this.Data["term_list"] = models.RankingTerm(term_list)

	this.Layout = "student/base.html"
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["Head_html"] = "student/head/homework_head.html"
	this.LayoutSections["Scripts"] = "student/scripts/homework_scripts.html"
	this.TplNames = "student/homework.html"
}