Skip to content

1EdTech/caliper-js-example

Repository files navigation

IMS Global caliper-js-example sample app

This is a sample application that utilizes the IMS Global Javascript sensor caliper-js, a Javascript client for Caliper that provides an implementation of the Caliper SensorAPI™.

caliper-js-example is a toy application modeled as a simple course delivery app that provides a syllabus, reading to annotate and quiz.

Branches

  • master: stable, deployable branch that stores the official release history.
  • develop: unstable development branch. Current work that targets a future release is merged to this branch.

Tags

caliper-js-example releases are tagged and versioned MAJOR.MINOR.PATCH[-label] (e.g., 1.2.0). Pre-release tags are identified with an extensions label (e.g., "1.2.0-RC01"). The tags are stored in this repository.

Contributing

We welcome the posting of issues by non IMS Global Learning Consortium members (e.g., feature requests, bug reports, questions, etc.) but we do not accept contributions in the form of pull requests from non-members. See CONTRIBUTING.md for more information.

Getting started

  1. Read the Caliper Analytics® Specification.
  2. Fork the IMS Global caliper-js-example project to your Github account and clone your copy to a local development machine.
  3. caliper-js-example assumes familiarity both with Javascript and AngularJS (or at least an understanding of MVC).

Creating a Test Endpoint

Establishing a test endpoint is your responsibility. One option is to use Runscope's [RequestBin] (https://github.com/Runscope/requestbin/blob/master/README.md). Previously Runscope provided a public version of the service but has since discontinued it due to "ongoing abuse". However, one can set up a self-hosted instance of RequestBin using Heroku. If you use a Mac, do the following:

  1. Sign up for a free Heroku account.

  2. Install Heroku CLI

    $ brew install heroku/brew/heroku
    
    $ heroku --version
    heroku-cli/6.16.14-583e9cb (darwin-x64) node-v9.10.1
    
  3. Create a local directory for the RequestBin source code then clone the Github repo:

    $ git clone git://github.com/Runscope/requestbin.git
    
    
  4. From your local RequestBin project directory create a Heroku application, including adding Heroku's Redis addon and setting the the REALM environment variable to production:

    $ heroku login
    $ heroku create
    $ heroku addons:add heroku-redis
    $ heroku config:set REALM=prod
    
  5. Do a Git push to deploy to Heroku and return a URL to your private RequestBin instance:

    $ git push heroku master
    ... 
    https://some_random_subdomain.herokuapp.com/ deployed to Heroku
    

Provide HTTP Request Header Field Values

In sampleAppContextService.js uncomment the options variable and define, minimally, the endpoint uri value.

var options = {
      uri: 'https://some_random_subdomain.herokuapp.com/123abc12',
      withCredentials: false,
      headers: {
        "Authorization": "Y2FsaXBlcnYxcDFib290Y2FtcDIwMTc=", <-- optional Bearer Token
        "Content-Type": "application/json"
      },
      method: "POST"
    };

Running the Demo

Run an HTTP server or drop the code into a Plunker instance. On a Mac or Linux box you can run Python's SimpleHTTServer by executing the following command:

$ python -m SimpleHTTPServer 9999

Then in a web browser, navigate to http://localhost:9999/index.html.

Remember to enable CORS in the browser before running the demo.

License

This project is licensed under the terms of the GNU Lesser General Public License (LGPL), version 3. See the LICENSE file for details. For additional information on licensing options for IMS members, please see the NOTICE file.

©2018 IMS Global Learning Consortium, Inc. All Rights Reserved. Trademark Information - http://www.imsglobal.org/copyright.html