Introduction

This is the first of several examples that we’ll be sharing in the near future that show how to use the Experience API to do things you couldn’t easily do before. The interoperability of the emerging standard makes this all possible.

The Idea

Handwriting is a big part of a child’s education, and the new wave of touchscreen devices makes ‘handwriting’ digitally possible. Many children learn how to spell and write words using the classic letter outline and guide lines. This example takes that classic worksheet theme of a picture and word exercise and digitizes it with xAPI reporting.
tin-can-api-draw-cat

The Tech

Html5 introduces the canvas upon which you can draw lines and objects using JavaScript code. Coupled with touch events, you can easily create a basic line drawing program with just JavaScript and HTML. Once you have your drawing, canvas gives you the base64 encoded string for the canvas as a PNG image. This example saves that resulting base64/png data as part of a statement’s context. The reporting app simply has to set the contents of the string a the src of an image tag. This takes away the need for a lot of custom code in the report to show the image to the instructor.

The Code

The magic of this example is in simply saving the canvas data as base64 using the built in canvas method ‘toDataURL()’.

     var drawing = {}
     drawing.base64data = canvas.toDataURL();
     drawing.width = canvasWidth;
     drawing.height = canvasHeight;

For this example, I created a basic extension format for my statements that includes this data. This extension format could be extended to hold much more information about the scenario to help the instructor viewing the data determine the best results. UPDATE: I changed this to save the extension data in the more appropriate result object as suggested in the comments.

{
     "id": "e620f85f-d708-4f5a-a1f3-78279c676aee",
     "actor": {
          "name": "Brian Rogers",
          "mbox": "mailto:brian.rogers@scorm.com",
          "objectType": "Agent"
     },
     "verb": {
          "id": "http://scorm.com/verbs/drew",
          "display": {
               "en-US": "drew"
          }
     },
     "result": {
          "completion": true,
          "extensions": {
               "http://scorm.com/extensions/tcdraw-data": {
                    "base64data": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAADICAYAAABS39xVAAAIZ0lEQVR4nO3dPW4kxxkG4C/1KXwPAcoVONVtJECJASeObMAncO7UguCFAx9BdmZFi5UMyIK1P+KKS66D3jHH5FR3zUzPVH9VzwN0tCS3un7eqaquJiMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCh+4h4/+i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+w/NizXFryK45eKLa5SCAmsgZ3ScXfBtdWN66+i3KlfNCzXFt3ENsNr7oS+wBrcd/HQaU8Nr3cR8eW1C37A38Lp/lPth9e5S8dzw2puv0xg8T8fx7Qhfc7M6y6u/1sh3sT8ILuPaROeet/H6X3h1KCam1ntZAusH+JpeX9oWqKO7TboT+mwu/C6xqnqpeMav75CGXp3aAa21nVMP8l2clxgNfA8zlsm1HTYH88o39zM6qszfi7bI7Co9jxO3+9aI9iOeSy+9aUCpxFYnOTLePjVvVt7yiSw+pXtVZdv4ml5v2laIiJiOuawlUfktRu45JPtqZvASuBNtAuv+9AhepZtiSWwknkddU+X1ppV/ek6t0Uj2QLgWTwt77OmJWIVP8bpj83vIuLP1y8yDWQLLGBgZiwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJzpv9oaxHIqoGPpAAAAAElFTkSuQmCC",
                    "width": 300,
                    "height": 200
               }
          }
     },
     "timestamp": "2012-10-30T18:35:50.333Z",
     "stored": "2012-10-30T18:35:50.408Z",
     "authority": {
          "name": "TC Draw",
          "mbox": "mailto:brian.rogers+tcdraw@scorm.com",
          "objectType": "Agent"
     },
     "object": {
          "id": "http://scorm.com/tcdraw-87dab09b-7c33-49a2-9080-06fbe54f1560",
          "definition": {
               "name": {
                    "en-US": "tcdraw"
               }
          },
          "objectType": "Activity"
     }
}

The Future

This example could easily be extended with more worksheets to help a teacher assess and track handwriting over time. The same concept could be used for gathering a signature or for showing your work on a math problem. The ability for a student with an inexpensive stylus and a touchscreen device to draw or write and have it show exactly the same way digitally for an instructor is wide open for many uses.

xAPI makes it easy to record and report on those results with a standard way of storing the data in an LRS. This kind of next generation training/learning will push organizations to adopt an LRS and begin to build out custom views to best use the data that can be collected. You can get started with your own test LRS by signing up for a free account at SCORM Cloud today.
 

See it in Action!

 
[box size=”third” title=”View the Example” url=”http://dev.rusticisoftware.com/tcdraw/index.html”]
[button url=”http://dev.rusticisoftware.com/tcdraw/index.html”]Example[/button]
[/box]
[box size=”third” title=”Scan to View the Mobile Version”]

[/box]
[box size=”third” title=”See the Code” url=”https://github.com/RusticiSoftware/TinCanDraw”]
[button url=”https://github.com/RusticiSoftware/TinCanDraw”]See the Code[/button]
[/box]
[clear /]