Touch Develop retirement postponed until June 22, 2019. Sign-in and access to cloud assets to be removed on May 23, 2018.Learn More..


office mix docs

This is the library for TouchDevelop apps to interact with Office Mix and to build rich Office Mix apps. Using this library, you can create apps that would work in Power Point.
The life cycle of an Office Mix app built in TouchDevelop can be divided into three stages.

write and test

Write a TouchDevelop app using Office Mix library and run it on simulator. When you are satisfied with the performance of your app, publish it.

make a powerpoint slide-deck

Open TouchDevelop Store app in PowerPoint. Search your published app in the store. Select it and configure it, if required by the app.

publish your mix

Turn your PowerPoint presentation into an interactive online lesson.

how to write TouchDevelop apps for Office Mix?

connection

  • Tries to connect to the host. If the script is being tested in TouchDevelop itself, it would start simulation.
 office mix → connect
  • Once connected, you can test which Mode the app is in.
if  office mix → is edit mode then
Display settings UI
else if  office mix → is view mode then
Display slideshow UI
else ... end if

modes

  • The end user would see your app in two different modes. Whenever your app is loaded, it would be in either of these two modes.

edit mode

When the user selects your app in PowerPoint, it starts in Edit Mode. Here, you can allow user to configure the settings.
  • Get the editor, the returned value is invalid in view mode.
var editor :=  office mix → current editor

view mode

When the slide containing your app is activated in the slideshow or in OfficeMix lesson player, your app starts in View Mode. This is the main code of your app, where you execute your task depending upon the settings configured in the Edit Mode.
When the user selects Preview button, again your app is halted and restarted in View Mode.
  • Get the current viewer, the returned value is invalid in edit mode.
var viewer :=  office mix → current viewer
  • When your app has finished its task, you can voluntarily leave resources and change the slide.
viewer → next slide

mode transition

  • You don't have to worry about mode switch. In case of switch of modes, your app would be stopped and then restarted in the new mode.
  • So, when your app is selected by the user while preparing slide show, whenever you query the is edit mode method it will always return true. Now, when your app is activated, it would again start from scratch, except the fact that now whenever you query is view mode, it will always return true.

activities

An activity is the interaction of the end-user with your Touch Develop script.
  • Setting an activity is giving metadata to Office Mix about the activity. This metadata could be the correct answer, maximum score of that activity, an exhaustive list of correct answers or it could be just nothing. This helps Office Mix Analytics to assist you in visualization of the responses.
  • You can create as many activities as you like, starting with index zero. This index is used to uniquely identify an activity. All activities that you use, should have unique index, otherwise, they would be overwritten.
  • You can also save your own data for later use while setting up a simple activity.
  • To use an activity, you have to first set it up in the Edit Mode, and then complete it in the View Mode.
var udata builder := web → create json builder
udata builder → set string("question", "A question to post")
var udata := udata builder → to json
  • After saving this data in Edit Mode, you can retrieve it back anytime.
udata :=  office mix → current configuration(0)

simple activity

Simple Activity is the simplest of all activities. It just represents an activity the user must complete. Examples of this include reading a piece of text, watching a video, or interacting with a simulation.
editor → set simple activity(0, udata)
  • You can submit its attempt in View Mode
viewer → complete simple activity(0)

input activity

Input Activity is the most general of all activities. You can create a free form input, assign score to the user in a manner that you want and submit the response and score to the Analytics. Examples could be free response, essays, math problems etc.
  • You can optionally pass a correct answer and max score to show up in the analytics.
editor → set input activity(1, "Correct Answer", 100, udata)
  • You can submit its attempt in View Mode.
viewer → complete input activity(1, "Wrong Answer", 0, true)

choice activity

Choice Activity is slightly difficult to use. It gives an exhaustive list of answers to the Analytics for having better visualization of the response. Examples include true false, multiple choice, multiple response and poll. In general, it can be used whenever the list of potential answers is limited.
  • Note that choice list is not necessary to be displayed upon the screen. For example you can use a textbox for getting the input of a tricky math problem and use choice activity to see the fraction of user falling for the trick.

choices

This is the format in which you can give metadata about the choices to the analytics
var choices :=  office mix → current editor → create choices
 office mix → add choice(choices, "North", true)
 office mix → add choice(choices, "South", false)
editor → set choice activity(2, choices, 5, udata)
  • You can submit its attempt in View Mode. Note that, you don't have any restrictions on the number of choices to submit in one attempt.
var answer := collections → create string collection
answer → add("North")
viewer → complete choice activity(2, answer, 5, true)

hints

  • Office Mix analytics keeps the track of Hints requested by the user in completing an activity.
  • To use hints, you have to first add them in Edit Mode.
  • The code given below sets 2 hints for the choice activity created above.
var hints := collections → create string collection
hints → add("This direction is perpendicular to the direction of rising sun.")
hints → add("This is the direction of the famous star in Ursa Minor constellation.")
editor → add hints(2, hints)
  • To receive hints, get hint method is to be used.
  • The code below requests for the first hint in the activity with index 2.
var hint := viewer → get hint(0, 0)

miscellaneous

slide state

You can store any data representing the current state of the current slideshow for your use. It does not have any effect on the analytics. It would be reset as soon as the view mode is stopped.
  • Set Slide State
var ustate builder := web → create json builder
ustate builder → set number("BackSpace press counter", 0)
var ustate := ustate builder → to json
viewer → set slide state(ustate)
  • Retrieve back the state at any time in view mode
ustate := viewer → slide state

on skipping the slide

  • If you want, you can have an action to execute, whenever the user skips the slide containing your app before you have freed the Office Mix Lesson Player by using next slide method.
 office mix → current viewer → on skip slide(action)
where action() is
Here you can log that slide containing your app was skipped.
end
end

Run Locally

  • To support testing of the apps you make, inside TouchDevelop itself, we simulate Office environment. For debugging purposes, you may want to know whether the script is executed inside TouchDevelop or from PowerPoint.
var do I run locally :=  office mix → is run locally

more information about Office Mix

For more details on the API provided by Office Mix, you can look up to official Labs.js, the JavaScript API for Office Mix on the top of which, this library was made.