Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
349 changes: 286 additions & 63 deletions docs/README.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions docs/modules/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* [discussion](recipes.md#discussion)
* [nonInteractive](recipes.md#noninteractive)
* [openAnswer](recipes.md#openanswer)
* [scorm](recipes.md#scorm)

---

Expand Down Expand Up @@ -61,4 +62,13 @@ ___
*Defined in src/recipes/recipes.ts:4*

___
<a id="scorm"></a>

### `<Const>` scorm

**● scorm**: *"https://w3id.org/xapi/smart/activity/recipe/scorm"* = categoryIdentifiers.smart.recipeScorm

*Defined in src/recipes/recipes.ts:9*

___

64 changes: 64 additions & 0 deletions docs/modules/scormtypes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[SMART xAPI DSL](../README.md) > [scormTypes](../modules/scormtypes.md)

# Module: scormTypes

## Index

### Variables

* [choice](scormtypes.md#choice)
* [genericScorm](scormtypes.md#genericscorm)
* [inlineChoice](scormtypes.md#inlinechoice)
* [multipleChoice](scormtypes.md#multiplechoice)
* [textEntry](scormtypes.md#textentry)

---

## Variables

<a id="choice"></a>

### `<Const>` choice

**● choice**: *"http://imsglobal.org/qti/choice"* = types.qti.choice

*Defined in src/activity-types/activity-types.ts:74*

___
<a id="genericscorm"></a>

### `<Const>` genericScorm

**● genericScorm**: *"https://w3id.org/xapi/smart/activity/scorm"* = types.smart.scorm

*Defined in src/activity-types/activity-types.ts:78*

___
<a id="inlinechoice"></a>

### `<Const>` inlineChoice

**● inlineChoice**: *"http://imsglobal.org/qti/inlineChoice"* = types.qti.inlineChoice

*Defined in src/activity-types/activity-types.ts:76*

___
<a id="multiplechoice"></a>

### `<Const>` multipleChoice

**● multipleChoice**: *"http://imsglobal.org/qti/choiceMultiple"* = types.qti.multipleChoice

*Defined in src/activity-types/activity-types.ts:75*

___
<a id="textentry"></a>

### `<Const>` textEntry

**● textEntry**: *"http://imsglobal.org/qti/textEntry"* = types.qti.textEntry

*Defined in src/activity-types/activity-types.ts:77*

___

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"index.d.ts"
],
"dependencies": {
"@gradiant/xapi-dsl": "^1.8.0"
"@gradiant/xapi-dsl": "^1.9.0"
},
"devDependencies": {
"@types/chai": "^4.1.7",
Expand Down
16 changes: 15 additions & 1 deletion src/activity-types/activity-type.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
discussionTypes,
feedbackTypes,
nonInteractiveTypes,
openAnswerTypes
openAnswerTypes,
scormTypes
} from './activity-types';

export type EssayActivityType = typeof openAnswerTypes.essay;
Expand Down Expand Up @@ -46,3 +47,16 @@ export type QuestionType = typeof feedbackTypes.question;
export type ReviewType = typeof feedbackTypes.review;
export type SurveyType = typeof feedbackTypes.survey;
export type FeedbackType = QuestionType | ReviewType | SurveyType;

export type ScormChoiceActivityType = typeof scormTypes.choice;
export type ScormMultipleChoiceActivityType = typeof scormTypes.multipleChoice;
export type ScormInlineChoiceActivityType = typeof scormTypes.inlineChoice;
export type ScormTextEntryActivityType = typeof scormTypes.textEntry;
export type ScormGenericActivityType = typeof scormTypes.genericScorm;

export type ScormType =
| ScormChoiceActivityType
| ScormMultipleChoiceActivityType
| ScormInlineChoiceActivityType
| ScormTextEntryActivityType
| ScormGenericActivityType;
48 changes: 47 additions & 1 deletion src/activity-types/activity-types.checkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
feedbackTypes,
nonInteractiveTypes,
openAnswerTypes,
otherTypes
otherTypes,
scormTypes
} from './activity-types';

export type ActivityTypeChecker = (activityType: string) => boolean;
Expand Down Expand Up @@ -271,3 +272,48 @@ export const isSurvey = isActivityType(feedbackTypes.survey);
* - {@link feedbackTypes.survey}
*/
export const isFeedback: ActivityTypeChecker = anyPass([isQuestion, isReview, isSurvey]);

// Scorm Types
// --------------

/**
* Check if the given activity type if {@link scormTypes.choice}
*/
export const isScormGeneric = isActivityType(scormTypes.genericScorm);

/**
* Check if the given activity type if {@link scormTypes.choice}
*/
export const isScormChoice = isActivityType(scormTypes.choice);

/**
* Check if the given activity type if {@link scormTypes.multipleChoice}
*/
export const isScormMultipleChoice = isActivityType(scormTypes.multipleChoice);

/**
* Check if the given activity type if {@link scormTypes.multipleChoice}
*/
export const isScormInlineChoice = isActivityType(scormTypes.inlineChoice);

/**
* Check if the given activity type if {@link scormTypes.textEntry}
*/
export const isScormTextEntry = isActivityType(scormTypes.textEntry);

/**
* Check if the given activity type is one of:
*
* - {@link scormTypes.genericScorm}
* - {@link scormTypes.choice}
* - {@link scormTypes.multipleChoice}
* - {@link scormTypes.textEntry}
* - {@link scormTypes.inlineChoice}
*/
export const isScorm: ActivityTypeChecker = anyPass([
isScormGeneric,
isScormChoice,
isScormInlineChoice,
isScormMultipleChoice,
isScormTextEntry
]);
11 changes: 10 additions & 1 deletion src/activity-types/activity-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ export namespace feedbackTypes {
export const survey = types.tincan.survey;
}

export namespace scormTypes {
export const choice = types.qti.choice;
export const multipleChoice = types.qti.multipleChoice;
export const inlineChoice = types.qti.inlineChoice;
export const textEntry = types.qti.textEntry;
export const genericScorm = types.smart.scorm;
}

/**
* Every activity type combined into a single object
*/
Expand All @@ -81,7 +89,8 @@ export const activityTypes = {
...nonInteractiveTypes,
...bookTypes,
...otherTypes,
...feedbackTypes
...feedbackTypes,
...scormTypes
};

/**
Expand Down
5 changes: 5 additions & 0 deletions src/recipes/recipes.checkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ export const isDiscussionRecipe = isRecipe(recipes.discussion);
* Check if the given recipe identifier is {@link recipes.nonInteractive}
*/
export const isNonInteractiveRecipe = isRecipe(recipes.nonInteractive);

/**
* Check if the given recipe identifier is {@link recipes.scorm}
*/
export const isScormRecipe = isRecipe(recipes.scorm);
1 change: 1 addition & 0 deletions src/recipes/recipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export namespace recipes {
export const audioVideo = categoryIdentifiers.smart.recipeAudioVideo;
export const discussion = categoryIdentifiers.smart.recipeDiscussion;
export const nonInteractive = categoryIdentifiers.smart.recipeNoInteractive;
export const scorm = categoryIdentifiers.smart.recipeScorm;
}
18 changes: 17 additions & 1 deletion tests/activity-types/activity-types.checkers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import {
isLaeProcessable,
isNonInteractive,
isOpenAnswer,
isScorm,
nonInteractiveTypes,
openAnswerTypes
openAnswerTypes,
scormTypes
} from '../../src/activity-types';
import { difference, values } from '../helpers';

Expand Down Expand Up @@ -156,6 +158,20 @@ describe('Activity Type Checkers', () => {
});
});
});

describe('isScorm()', () => {
it('should return true for any scorm type', () => {
values(scormTypes).forEach(activityType => {
expect(isScorm(activityType)).to.be.true;
});
});

it('should return false for any other type', () => {
getDifference(scormTypes).forEach(activityType => {
expect(isScorm(activityType)).to.be.false;
});
});
});
});

const getDifference = (types: object) => difference(values(activityTypes), values(types));
Expand Down
30 changes: 27 additions & 3 deletions tests/activity-types/activiy-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
feedbackTypes,
nonInteractiveTypes,
openAnswerTypes,
otherTypes
otherTypes,
scormTypes
} from '../../src/activity-types';

describe('Activity Types', () => {
Expand Down Expand Up @@ -75,7 +76,7 @@ describe('Activity Types', () => {
});
});

describe('ÇFeedback', () => {
describe('Feedback', () => {
it('should include question', () => {
expect(feedbackTypes.question).to.be.equal(types.activityStream.v1.question);
});
Expand All @@ -89,6 +90,28 @@ describe('Activity Types', () => {
});
});

describe('Scorm', () => {
it('should include scorm (generic)', () => {
expect(scormTypes.genericScorm).to.be.equal(types.smart.scorm);
});

it('should include choice', () => {
expect(scormTypes.choice).to.be.equal(types.qti.choice);
});

it('should include multipleChoice', () => {
expect(scormTypes.multipleChoice).to.be.equal(types.qti.multipleChoice);
});

it('should include textEntry', () => {
expect(scormTypes.textEntry).to.be.equal(types.qti.textEntry);
});

it('should include inlineChoice', () => {
expect(scormTypes.inlineChoice).to.be.equal(types.qti.inlineChoice);
});
});

it('should aggregate every type', () => {
expect(activityTypes).to.be.deep.equal({
...openAnswerTypes,
Expand All @@ -98,7 +121,8 @@ describe('Activity Types', () => {
...discussionTypes,
...bookTypes,
...otherTypes,
...feedbackTypes
...feedbackTypes,
...scormTypes
});
});
});
13 changes: 13 additions & 0 deletions tests/recipes/recipes.checkers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
isNonInteractiveRecipe,
isOpenAnswerRecipe,
isRecipe,
isScormRecipe,
recipes
} from '../../src/recipes';
import { difference, values } from '../helpers';
Expand Down Expand Up @@ -90,6 +91,18 @@ describe('Recipes Checkers', () => {
});
});
});

describe('isScormRecipe()', () => {
it('should return `true` for scorm recipe', () => {
expect(isScormRecipe(recipes.scorm)).to.be.true;
});

it('should return `false` for any other type', () => {
getDifference(recipes.scorm).forEach(recipe => {
expect(isScormRecipe(recipe)).to.be.false;
});
});
});
});

const getDifference = (recipe: string) => difference(values(recipes), [recipe]);
Expand Down
4 changes: 4 additions & 0 deletions tests/recipes/recipes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ describe('Recipes', () => {
it('should include non-interactive', () => {
expect(recipes.nonInteractive).to.be.equal(categoryIdentifiers.smart.recipeNoInteractive);
});

it('should include scorm', () => {
expect(recipes.scorm).to.be.equal(categoryIdentifiers.smart.recipeScorm);
});
});