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")
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()
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
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")