Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Class Kit

Improve this doc

Plugin for using Apple's ClassKit framework.

Prerequisites: Only works with Xcode 9.4 and iOS 11.4. Your Provisioning Profile must include the ClassKit capability. Read more about how to Request ClassKit Resources (https://developer.apple.com/contact/classkit/) in here: https://developer.apple.com/documentation/classkit/enabling_classkit_in_your_app. Also note that you can’t test ClassKit behavior in Simulator because Schoolwork isn’t available in that environment.

Repo: https://github.com/sebastianbaar/cordova-plugin-classkit.git

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-classkit
    $ npm install --save @ionic-native/class-kit@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { ClassKit, CCKContext, CCKBinaryItem, CCKQuantityItem, CCKScoreItem, CCKContextTopic, CCKContextType, CCKBinaryType } from '@ionic-native/class-kit';

// Init contexts defined in XML file 'CCK-contexts.xml'
constructor( ..., private classKit: ClassKit) {
  platform.ready().then(() => {
    classKit.initContextsFromXml("classkitplugin://")
      .then(() => console.log("success"))
      .catch(e => console.log("error: ", e));
  });
}

...

// Init context with identifier path
const context: CCKContext = {
  identifierPath: ["parent_title_one", "child_one", "child_one_correct_quiz"],
  title: "child one correct quiz",
  type: CCKContextType.exercise,
  topic: CCKContextTopic.science,
  displayOrder: 0
};

this.classKit.addContext("classkitplugin://", context)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Remove all contexts
this.classKit.removeContexts()
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Remove context with identifier path
this.classKit.removeContext(["parent_title_one", "child_one", "child_one_correct_quiz"])
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Begin a new activity or restart an activity for a given context
this.classKit.beginActivity(["parent_title_one", "child_two", "child_two_quiz"], false)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Adds a progress range to the active given activity
this.classKit.setProgressRange(0, 0.66)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Adds a progress to the active given activity
this.classKit.setProgress(0.66)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Adds activity information that is true or false, pass or fail, yes or no
const binaryItem: CCKBinaryItem = {
  identifier: "child_two_quiz_IDENTIFIER_1",
  title: "CHILD TWO QUIZ 1",
  type: CCKBinaryType.trueFalse,
  isCorrect: isCorrect,
  isPrimaryActivityItem: false
};

this.classKit.setBinaryItem(binaryItem)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Adds activity information that signifies a score out of a possible maximum
const scoreItem: CCKScoreItem = {
  identifier: "total_score",
  title: "Total Score :-)",
  score: 0.66,
  maxScore: 1.0,
  isPrimaryActivityItem: true
};

this.classKit.setScoreItem(scoreItem)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));


// Activity information that signifies a quantity
const quantityItem: CCKQuantityItem = {
   identifier: "quantity_item_hints",
   title: "Hints",
   quantity: 12,
   isPrimaryActivityItem: false
};

this.classKit.setQuantityItem(quantityItem)
   .then(() => console.log("success"))
   .catch(e => console.log("error: ", e));

Instance Members

initContextsFromXml(urlPrefix)

Init contexts defined in XML file ‘CCK-contexts.xml’

Param Type Details
urlPrefix string

URL prefix to use for custom URLs to locate activities (deeplink).

Returns: Promise<any>

addContext(urlPrefix, context)

Init context with identifier path

Param Type Details
urlPrefix string

URL prefix to use for custom URLs to locate activities (deeplink).

context CCKContext

Context to initialize.

Returns: Promise<any>

removeContexts()

Remove all contexts

Returns: Promise<any>

removeContext(identifierPath)

Remove context with identifier path

Param Type Details
identifierPath string[]

Full identifier path from root, including the context identifier itself.

Returns: Promise<any>

beginActivity(identifierPath, asNew)

Begin a new activity or restart an activity for a given context

Param Type Details
identifierPath string[]

Full identifier path from root, including the context identifier itself.

asNew boolean

Should a new activity be created (or an old activity be restarted).

Returns: Promise<any>

endActivity()

End the active activity

Returns: Promise<any>

setProgressRange(fromStart, toEnd)

Adds a progress range to the active given activity

Param Type Details
fromStart number

The beginning of the new range to add. This should be fractional value between 0 and 1, inclusive.

toEnd number

The end of the new range to add. This should be larger than the start value and less than or equal to one.

Returns: Promise<any>

setProgress(progress)

Adds a progress to the active given activity

Param Type Details
progress number

A measure of progress through the task, given as a fraction in the range [0, 1].

Returns: Promise<any>

setBinaryItem(binaryItem)

Adds activity information that is true or false, pass or fail, yes or no

Param Type Details
binaryItem CCKBinaryItem

The binary item to add to the activity.

Returns: Promise<any>

setScoreItem(scoreItem)

Adds activity information that signifies a score out of a possible maximum

Param Type Details
scoreItem CCKScoreItem

The score item to add to the activity.

Returns: Promise<any>

setQuantityItem(quantityItem)

Activity information that signifies a quantity.

Param Type Details
quantityItem CCKQuantityItem

The quantity item to add to the activity.

Returns: Promise<any>

CCKContext

Param Type Details
identifierPath string[]

Full identifier path from root, including the context identifier itself..

title string

Title of the context.

type CCKContextType

Optional. Type value for the context.

(optional)
topic string

Optional. Topic value of the context.

(optional)
displayOrder number

Optional. Display order of the context.

(optional)

CCKContextType

Param Type Details
none 0
app
chapter
section
level
page
task
challenge
quiz
exercise
lesson
book
game
document
audio
video

CCKContextTopic

Param Type Details
math 'math'
science 'science'
literacyAndWriting 'literacyAndWriting'
worldLanguage 'worldLanguage'
socialScience 'socialScience'
computerScienceAndEngineering 'computerScienceAndEngineering'
artsAndMusic 'artsAndMusic'
healthAndFitness 'healthAndFitness'

CCKBinaryItem

Param Type Details
identifier string

A unique string identifier for the activity item.

title string

A human readable name for the activity item.

type CCKBinaryType

A type value for the activity item.

isCorrect boolean

The value that the binary activity item takes.

isPrimaryActivityItem boolean

Optional. Should the activity item be added as the primary activity item.

(optional)

CCKBinaryType

Param Type Details
trueFalse 0
passFail
yesNo

CCKScoreItem

Param Type Details
identifier string

A unique string identifier for the activity item.

title string

A human readable name for the activity item.

score number

The score earned during completion of a task.

maxScore number

The maximum possible score, against which the reported score should be judged.

isPrimaryActivityItem boolean

Optional. Should the activity item be added as the primary activity item.

(optional)

CCKQuantityItem

Param Type Details
identifier string

A unique string identifier for the activity item.

title string

A human readable name for the activity item.

quantity number

A quantity associated with the task.

isPrimaryActivityItem boolean

Optional. Should the activity item be added as the primary activity item.

(optional)

API

Native

General