Ejemplo n.º 1
0
// @Tilte 查看课程信息
// @router /courseInfo [get]
func (this *ViewTeatherController) 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.GetStudentChecksByTeacherCourse(t_course)
			if homeworks, err := models.GetTeacherCourseHomeworkByTeacherCourse(t_course); err == nil {
				for k, _ := range homeworks {
					homeworks[k].StudentHomeworks, _ = models.GetUploadedStudentHomeworkByTeacherCourseHomework(homeworks[k])
				}
				t_course.Homeworks = homeworks
				this.Data["t_course"] = t_course
			}
		} else {
			this.Redirect("/error", 302)
			this.StopRun()
		}
	} else {
		this.Redirect("/error", 302)
		this.StopRun()
	}

	this.Layout = "teacher/base.html"
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["Head_html"] = "teacher/head/courseInfo_head.html"
	this.LayoutSections["Scripts"] = "teacher/scripts/courseInfo_scripts.html"
	this.TplNames = "teacher/courseInfo.html"
}
Ejemplo n.º 2
0
// @Title 课程作业
// @router /courseHomework [get]
func (this *ViewTeatherController) 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 teacher course homework list
			if homeworks, err := models.GetTeacherCourseHomeworkByTeacherCourse(t_course); err == nil {
				//	get student homework  by teacher course homework
				for k, _ := range homeworks {
					homeworks[k].StudentHomeworks, _ = models.GetUploadedStudentHomeworkByTeacherCourseHomework(homeworks[k])
				}
				t_course.Homeworks = homeworks
				this.Data["t_course"] = t_course
				//	get the term all teachercourse
				if t_courses, err := models.GetTeacherCourseByTerm(t_course.Term, this.Data["teacher"].(*models.Teacher).Id); err == nil {
					this.Data["t_courses"] = t_courses
				} else {
					this.Redirect("/error", 302)
					this.StopRun()
				}
			} else {
				this.Redirect("/error", 302)
				this.StopRun()
			}
		} else {
			this.Redirect("/error", 302)
			this.StopRun()
		}
	} else {
		this.Redirect("/error", 302)
		this.StopRun()
	}

	//	get all term
	term_list, err := models.GetTermListByTeacherCourse(this.Data["teacher"].(*models.Teacher).Id)
	if err != nil {
		this.Redirect("/error", 302)
		this.StopRun()
	}
	this.Data["term_list"] = models.RankingTerm(term_list)

	//	get week
	if week, _ := this.GetInt("week"); week > 0 {
		this.Data["now_week"] = week
	}

	this.Layout = "teacher/base.html"
	this.LayoutSections = make(map[string]string)
	this.LayoutSections["Head_html"] = "teacher/head/courseHomework_head.html"
	this.LayoutSections["Scripts"] = "teacher/scripts/courseHomework_scripts.html"
	this.TplNames = "teacher/courseHomework.html"
}