コード例 #1
0
ファイル: main.py プロジェクト: erpreciso/school-tagging
 def post(self, kind):
     requester = self.getFromCookie()
     requesterRole = self.getRoleFromCookie()
     if requesterRole == "teacher":
         teacher = requester
         if kind == "teacherValidation":
             valid = self.request.get("valid")
             exercise = objs.getExercise(teacher.currentExercise)
             exercise.addNdbAnswer("teacher", teacher.username, valid)
             exercise.sendFeedbackToStudents()
         if kind == "getSessionStatus":
             exercise = objs.getExercise(teacher.currentExercise)
             exercise.sendStatusToTeacher()
     if requesterRole == "student":
         student = requester
         if kind == "answer":
             answer = self.request.get("answer")
             exerciseIdSent = self.request.get("exerciseID")
             if str(exerciseIdSent) == str(student.currentExercise):
                 exercise = objs.getExercise(student.currentExercise)
                 if student.username not in exercise.students:
                     exercise.addStudent(student)
                 if exercise.addNdbAnswer("student", student.username, answer):
                     logging.info("Answer from <" + student.username + "> saved in datastore")
                     exercise.sendStatusToTeacher()
                 else:
                     logging.error("Warning! Answer not saved")
             else:
                 logging.error("Student " + student.fullname + "Sent answer of a different exercise")    
コード例 #2
0
ファイル: main.py プロジェクト: erpreciso/school-tagging
 def logout(self):
     teacher = self.getFromCookie()
     if teacher:
         self.clearCookies()
         if teacher.currentExercise:
             exercise = objs.getExercise(teacher.currentExercise)
             if exercise:
                 exercise.end()
         if teacher.currentLessonID:
             lesson = objs.getLesson(teacher.currentLessonID)
             if lesson:
                 lesson.end()
             teacher.logout()
     return self.redirect("/t/login")
コード例 #3
0
ファイル: main.py プロジェクト: erpreciso/school-tagging
 def endExercise(self):
     teacher = self.getFromCookie()
     exercise = objs.getExercise(teacher.currentExercise)
     if exercise:
         exercise.end()