Esempio n. 1
0
 def startLesson(self, teacher):
     lessonName = self.read("lessonName")
     if lessonName not in objs.getOpenLessonsNames():
         lesson = objs.Lesson()
         lesson.start(lessonName, teacher)
         self.addCookie("schooltagging-lessonID", str(lesson.key.id()))
         return self.redirect("/t/dashboard")
     else:
         message = "lesson_name_in_use"
     return self.renderLoginPage(message)
Esempio n. 2
0
 def login(self):
     student = objs.Student()
     student.fullname = self.read("username")
     student.username = student.fullname.replace(" ", "_")
     student.language = objs.DEFAULT_LANGUAGE
     lessonName = self.read("lessonName")
     if lessonName in objs.getOpenLessonsNames():
         if not objs.studentAlreadyConnected(student.username, lessonName):
             student.save()
             student.connect()
             self.addCookie("schooltagging-role", "student")
             self.addCookie("schooltagging-username", student.username)
             lessonID = student.joinLesson(lessonName)
             self.addCookie("schooltagging-lessonID", lessonID)
             return self.redirect("/s/dashboard")
         else:
             message = "name_already_in_use"
     else:
         message = "lesson_not_started"
     self.renderLoginPage(message)
Esempio n. 3
0
 def login(self):
     fullname = self.read("username")
     username = fullname.replace(" ", "_")
     password = self.read("password")
     if objs.teacherUsernameExists(username):
         teacher = objs.getTeacher(username)
         if password == teacher.password:
             lessonName = self.read("lessonName")
             if lessonName:
                 if lessonName not in objs.getOpenLessonsNames():
                     teacher.connect()
                     self.addCookie("schooltagging-role", "teacher")
                     self.addCookie("schooltagging-username", username)
                     self.startLesson(teacher)
                     return self.redirect("/t/dashboard")
                 else:
                     message = "lesson_name_in_use"
             else:
                 message = "provide_lesson_name"
         else:
             message = "password_not_correct"
     else:
         message = "username_not_existing"
     return self.renderLoginPage(message)