Skip to content

An experimental F# implementation of the xAPI specification with a focus on type safety and immutability.

License

Notifications You must be signed in to change notification settings

gowithfloat/xapi

Repository files navigation

An experimental F# implementation of the xAPI specification with a focus on type safety and immutability. Wherever possible, we have strived to translate the xAPI specification directly to code, with requirements embedded as type checks.

Status

This library is currently in a pre-release state. Feedback is welcome but active development continues and this library should not be considered ready for production use. However, we hope that the existing code base will provide an indication of the implementation goals for this project.

C# Example

To craft a simple statement, you first need an actor:

var address = new MailAddress("[email protected]");
var mailbox = new Mailbox(address);
var actor = new Agent(mailbox, "Example Learner");

A verb is a URI paired with a language map:

var id = new Uri("http://adlnet.gov/expapi/verbs/completed");
var definition = new LanguageMap(new LanguageTag(Language.English, Region.UnitedStates), "completed");
var verb = new Verb(id, definition);

An activity requires a definition and identifier; the definition needs a name, description, and type:

var name = LanguageMap.EnglishUS("Example Activity");
var description = LanguageMap.EnglishUS("An example activity.");
var theType = new Uri("http://adlnet.gov/expapi/activities/course");
var definition = new ActivityDefinition(name, description, theType);
var activityId = new Uri("http://www.example.com/example-activity");
var activity = new Activity(activityId, definition);

Combine the actor, verb, and activity into a statement:

var statement = new Statement(actor, verb, activity);

About

Existing implementations of the xAPI specification for .NET do not leverage the type system to ensure code will run safely. Furthermore, many implementations allow a high degree of mutability, leading to undesired and unpredictable behavior.

This library is an attempt to address these challenges and leverage functional programming paradigms to create a reusable xAPI implementation that is suitable for a variety of .NET runtimes such as ASP.NET and Xamarin, while leveraging the unique capabilities of the F# language to create safe and predictable code. Furthermore, future improvements to this library could use F* to create code with verified runtime behavior, or leverage compilers such as Fable to generate JavaScript variants of this library.

This implementation is influenced by the existing TinCan.NET and years of working with the xAPI specification.

Roadmap

  • Provide serialization logic
  • Add implementation and interface for an LRS
  • Improve build pipeline with Fake
  • Provide a minimal example server implementation that passes the LRS Test Suite
  • Add support for xAPI Profiles
  • Determine viability of Fable compiler for JavaScript target
  • Investigate use of F* to improve library with formal verification

Notes

  • C# does not allow structs to have a parameterless default constructor defined, and auto-generates one for all structs. As a result, all struct types can be instantiated with a parameterless constructor, which for most of this library, will create an invalid instance. Note that this may conflict with the CLI specification and could be revised in future versions of C#. This is generally not an issue in F# as that language prevents initialization via default constructor when properties don't also support default constructors.

License

All content in this repository is shared under an MIT license. See license.md for details.

About

An experimental F# implementation of the xAPI specification with a focus on type safety and immutability.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages