Пример #1
0
// @Tilte 查看课程信息
// @router /courseInfo [get]
func (this *ViewStudentController) CourseInfo() {
	//	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 teacher course class and student list
			t_course.Classes, _ = models.GetClassesByTeacherCourse(t_course)
			students, _ := models.GetStudentsByTeacherCourse(t_course)
			t_course.Orgs["students"] = students
			t_course.Orgs["s_checks"], _ = models.GetStudentChecksByTeacherCourseAndStudent(t_course, this.Data["student"].(*models.Student).Id)
			if s_homeworks, err := models.GetStudentHomeworkByTeacherCourseAndStudent(t_course, this.Data["student"].(*models.Student).Id); err == nil {
				t_course.Orgs["s_homeworks"] = s_homeworks
				this.Data["t_course"] = t_course
			}
		} 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/courseInfo_head.html"
	this.LayoutSections["Scripts"] = "student/scripts/courseInfo_scripts.html"
	this.TplNames = "student/courseInfo.html"
}
Пример #2
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"
}
Пример #3
0
// @Title 查看课程点名记录
// @router /courseHistory [get]
func (this *ViewStudentController) CourseHistory() {
	//	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 check list
			if s_checks, err := models.GetStudentChecksByTeacherCourseAndStudent(t_course, this.Data["student"].(*models.Student).Id); err == nil {
				t_course.Orgs["s_checks"] = s_checks
				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/courseHistory_head.html"
	this.LayoutSections["Scripts"] = "student/scripts/courseHistory_scripts.html"
	this.TplNames = "student/courseHistory.html"
}
Пример #4
0
// @Title 签到统计
// @router /studentCheck [get]
func (this *ViewStudentController) StudentCheck() {
	//	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_checks, err := models.GetStudentChecksByTeacherCourseAndStudent(v.TeacherCourse, this.Data["student"].(*models.Student).Id); err == nil {
				s_courses[k].Orgs = make(map[string]interface{})
				s_courses[k].Orgs["s_checks"] = s_checks
				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 checks
	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_checks, err := models.GetStudentChecksByTeacherCourseAndStudent(v.TeacherCourse, this.Data["student"].(*models.Student).Id); err == nil {
						s_courses[k].Orgs = make(map[string]interface{})
						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/check_head.html"
	this.LayoutSections["Scripts"] = "student/scripts/check_scripts.html"
	this.TplNames = "student/check.html"
}