Ejemplo n.º 1
0
def trigger_reward():
    studentId = cgi.escape(request.form['studentId'])

    reward = Log(type=LogType.REWARD, student=studentId)
    reward.put()

    p.trigger('private-status', 'client-reward', {'studentId': studentId})
    return "Reward received"
Ejemplo n.º 2
0
def trigger_register():
    studentId = cgi.escape(request.form['studentId'])

    register = Log(type=LogType.REGISTERED, student=studentId)
    register.put()

    p.trigger('private-status', 'registered', {'studentId': studentId})
    return "Registration received"
Ejemplo n.º 3
0
def trigger_help():
    studentId = cgi.escape(request.form['studentId'])

    help = Log(type=LogType.HELP_NEEDED, student=studentId)
    help.put()

    p.trigger('private-status', 'help', {'studentId': studentId})
    return "Help received"
Ejemplo n.º 4
0
def trigger_ping():
    studentId = cgi.escape(request.form['studentId'])

    pinged = Log(type=LogType.PINGED, student=studentId)
    pinged.put()

    p.trigger('private-status', 'client-ping', {'studentId': studentId})
    return "Ping received"


#endregion
Ejemplo n.º 5
0
def trigger_reward():
    studentId = cgi.escape(request.form['studentId'])
    student = getStudent(studentId)

    reward = Log(type='reward', student=studentId)
    reward.put()

    p.trigger('private-status', 'client-reward', {
        'studentId': studentId,
        'student': student
    })
    return "Reward received"
Ejemplo n.º 6
0
def trigger_ping():
    studentId = cgi.escape(request.form['studentId'])
    student = getStudent(studentId)

    pinged = Log(type='ping', student=studentId)
    pinged.put()

    p.trigger('private-status', 'client-ping', {
        'studentId': studentId,
        'student': student
    })
    return "Ping received"


#endregion
Ejemplo n.º 7
0
def trigger_notification():
    header = cgi.escape(request.form['header'])
    body = cgi.escape(request.form['body'])
    type = cgi.escape(request.form['type'])

    poll = Poll()
    poll.type = type
    poll.question = header
    poll.html = body
    poll_key = poll.put()
    id = poll_key.id()

    if type == "poll":
        p.trigger('polls', 'new_poll', {
            'id': id,
            'header': header,
            'body': body,
            'title': header
        })
    elif type == "alert":
        if not body:
            p.trigger('polls', 'new_alert', {
                'id': id,
                'title': 'New Announcement',
                'body': header
            })
        else:
            p.trigger('polls', 'new_alert', {
                'id': id,
                'title': header,
                'body': body
            })
    elif type == "link":
        p.trigger('polls', 'new_link', {
            'id': id,
            'header': header,
            'link': body
        })
    elif type == "quiz":
        p.trigger('polls', 'quiz', {'id': id})
    else:
        p.trigger('polls', 'new_survey', {
            'id': id,
            'header': header,
            'body': body
        })
    return redirect("/allpolls")