예제 #1
0
def new_message(lti=lti):
#def new_message():
    content = request.get_json(silent=True)
    logging.info(content)
    studentId = cgi.escape(content['studentId']) #From Field
    courseId = cgi.escape(content['courseId'])
    text = cgi.escape(content['text'])

    student_key = ndb.Key('Student', courseId + studentId)
    student = student_key.get()
    message = Log(type='text', courseId=courseId, student=studentId)
    message.content = text
    message.put()

    fullName = student.fullName if student else 'Unknown student'
    avatarUrl = student.avatarUrl if student else ''

    newMessage(courseId, {
        'student': studentId, #Broadcast message from:
        'courseId': courseId,
        'id': message.key.id(),
        'type': 'text',
        'content': text,
        'info': student.info(),
        'date': ''
    })
    return "Message received"
예제 #2
0
def new_teacher_message(lti=lti):
#def new_teacher_message():
    content = request.get_json(silent=True)
    logging.info(content)
    studentId = cgi.escape(content['studentId'])
    teacherId = cgi.escape(content['teacherId'])
    courseId = cgi.escape(content['courseId'])
    text = cgi.escape(content['text'])

    student_key = ndb.Key('Student', courseId + studentId)
    student = student_key.get()
    teacher_key = ndb.Key('Student', courseId + teacherId)
    teacher = teacher_key.get()

    message = Log(type='text', courseId=courseId, student=studentId)
    message.content = text
    message.teacher = teacherId
    message.put()

    newStudentMessage(courseId, studentId, {
        'student': teacherId,
        'courseId': courseId,
        'id': message.key.id(),
        'type': 'text',
        'content': text,
        'info': teacher.info(),
        'teacherinfo': student.info(),
        'date': DateTimeJSONEncoder().encode(message.date).replace('"', '')
    })
    newMessage(courseId, {
        'student': studentId,
        'courseId': courseId,
        'id': message.key.id(),
        'type': 'text',
        'content': text,
        'info': teacher.info(),
        'teacherinfo': student.info(),
        'date': DateTimeJSONEncoder().encode(message.date).replace('"', '')
    })
    return "Message received"
예제 #3
0
def new_student_message(lti=lti):
#def new_student_message():
    content = request.get_json(silent=True)
    logging.info(content)
    studentId = cgi.escape(content['studentId'])
    courseId = cgi.escape(content['courseId'])
    text = cgi.escape(content['text'])

    student_key = ndb.Key('Student', courseId + studentId)
    student = student_key.get()
    message = Log(type='text', courseId=courseId, student=studentId)
    message.content = text
    message.put()

    fullName = student.fullName if student else 'Unknown student'
    avatarUrl = student.avatarUrl if student else ''

    newStudentMessage(courseId, studentId, {
        'student': studentId,
        'courseId': courseId,
        'id': message.key.id(),
        'type': 'text',
        'content': text,
        'info': student.info(),
        'date': DateTimeJSONEncoder().encode(message.date).replace('"', '')
    })
    newMessage(courseId, {
        'student': studentId,
        'courseId': courseId,
        'id': message.key.id(),
        'type': 'text',
        'info': student.info(),
        'content': text,
        'date': DateTimeJSONEncoder().encode(message.date).replace('"', '')
    })
    return "Message received"