Giter Club home page Giter Club logo

emoji-feedback-py-backend's Introduction

Emoji Feedback Python Backend

Build Status Coverage Status

Dependencies

Usage

The goal of this library is to provide an easy to use python Caliper sensor for the emoji-feedback library. When implementing this library with emoji-feedback, you will need endpoints for the emoji and feedback events. You can then provide Caliper actor, session and edApp context information to complete the event. You may also skip setting these to use anonymous entities.

Setting Caliper host and api key

You can either set the caliper endpoint info when creating the object

feedback_sensor = EmojiFeedbackSensor(
    caliper_host='https://example.caliper.host.com/',
    caliper_api_key='1234567890'
)

Or by environment variables:

EMOJI_FEEDBACK_CALIPER_HOST: Set the Caliper host.

EMOJI_FEEDBACK_CALIPER_API_KEY: Set the Caliper api key.

Emoji Flask endpoint example

from datetime import datetime
@app.route('/emoji', methods=['POST'])
def emoji():
    req_data = request.get_json()
    eventTime = req_data.get('eventTime')
    object = req_data.get('object') # Some Entity or entity id
    selections = req_data.get('selections') # Array of selections
    question = req_data.get('question') # RatingScaleQuestion entity or entity id

    # generate actor based on current user
    actor = {
        'id': ...,
        'type': 'Person',
        ...
    }

    # generate edApp based on
    edApp = {
        'id': ...,
        'type': 'SoftwareApplication',
        ...
    }

    # generate session based on current user session
    session = {
        'id': ...,
        'type': 'Session',
        ...
    }

    feedback_sensor = EmojiFeedbackSensor(
        caliper_host='https://example.caliper.host.com/',
        caliper_api_key='1234567890'
    )

    feedback_sensor.send_emoji_feedback(
        eventTime=eventTime,
        actor=actor,
        object=object,
        edApp=edApp,
        session=session,
        question=question,
        selections=selections
    )

If you would like to handle emitting the event yourself, you can instead generate the event for later use

    feedback_sensor = EmojiFeedbackSensor()

    event = feedback_sensor.generate_emoji_feedback_event(
        eventTime=eventTime,
        actor=actor,
        object=object,
        edApp=edApp,
        session=session,
        question=question,
        selections=selections
    )

Running Unit Tests

python setup.py test

or

nosetests

Changelog

0.1.0

  1. Initial version
  2. Must use -e to install package since imsglobal-caliper is not on PyPI

emoji-feedback-py-backend's People

Contributors

andrew-gardener avatar justin0022 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.