예제 #1
0
    def initializeDashboard(self):
        teacher = self.getFromCookie()
        if not teacher:
	    return self.redirect("/t/login")
	if not teacher.currentLessonID:
	    return self.redirect("/t/login")
	language = teacher.language or objs.DEFAULT_LANGUAGE
	lesson = objs.getLesson(teacher.currentLessonID)
	if lesson:
	    templ = "teacherDashboard.html"
	    studentLabels = []
	    for studentName in lesson.students:
	        student = objs.getStudent(studentName, teacher.currentLessonID)
                if student:
		    studentLabels.append({"username":studentName,"fullname":student.fullname})
	    return self.renderPage(templ ,
				teacherName=teacher.fullname,
				lessonName=teacher.currentLessonName,
				students=studentLabels,
				token=teacher.token,
				language=language,
				labels=labdict.labels(templ, language),
				)
	else:
	    return self.redirect("/t/login")
예제 #2
0
 def post(self):
     requester = self.getFromCookie()
     requesterRole = self.getRoleFromCookie()
     if requesterRole == "teacher":
         teacher = requester
         studentName = self.read("student")
         student = objs.getStudent(studentName, teacher.currentLessonID)
         if student:
             return student.logout()
예제 #3
0
 def getFromCookie(self):
     username = self.getCookie("schooltagging-username")
     lessonStrID = self.getCookie("schooltagging-lessonID")
     role = self.getCookie("schooltagging-role")
     if not username or not role or not lessonStrID:
         return False
     if role == "student":
         user = objs.getStudent(username, int(lessonStrID))
     elif role == "teacher":
         user = objs.getTeacher(username)
     return user
예제 #4
0
 def produceStudentStats(self, studentName):
     teacher = self.getFromCookie()
     if not teacher:
         return self.redirect("/t/login")
     if not teacher.currentLessonID:
         return self.redirect("/t/login")
     student = objs.getStudent(studentName, teacher.currentLessonID)
     if student:
         return student.produceAndSendOwnStats()
     else:
         return self.redirect("/t/login")