Skip to content

Commit

Permalink
New methods for dynamic sessions, and try again. Also renamed toggleF…
Browse files Browse the repository at this point in the history
…lag() to flag()
  • Loading branch information
michaelsharman committed Feb 1, 2024
1 parent cb12ac2 commit 3af800b
Show file tree
Hide file tree
Showing 24 changed files with 444 additions and 117 deletions.
2 changes: 1 addition & 1 deletion docs/index.html

Large diffs are not rendered by default.

101 changes: 100 additions & 1 deletion docs/module-Activity.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-App.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Diagnostics.html

Large diffs are not rendered by default.

368 changes: 284 additions & 84 deletions docs/module-Items.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Logger.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Player.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Questions.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Sections.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-_Extensions_ariaCountOnNav.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-_Extensions_blockGrammarChecks.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-_Extensions_columnResizer.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-_Extensions_essayLimitByCharacter.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-_Extensions_hideAlternatives.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-_Extensions_keyboardShortcuts.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-_Extensions_magnifier.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-_Extensions_mcqLabelPrefix.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-_Extensions_pageOverlay.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-_Extensions_resetResponse.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 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
@@ -1,6 +1,6 @@
{
"name": "@caspingus/lt",
"version": "1.3.1",
"version": "1.4.0",
"description": "A utility library of helpers and tools for working with Learnosity APIs.",
"main": "src/index.js",
"author": "michael@learnosity.com",
Expand Down
9 changes: 9 additions & 0 deletions src/assessment/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ export function hasSections() {
return activity().hasOwnProperty('sections');
}

/**
* Whether the activity has try again enabled.
* @since 1.4.0
* @returns {boolean}
*/
export function hasTryAgain() {
return activity()?.dynamic_items.hasOwnProperty('try_again');
}

/**
* Whether this activity is adaptive.
* @since 0.1.0
Expand Down
41 changes: 30 additions & 11 deletions src/assessment/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@ import * as sections from './sections';
* @module Items
*/

/**
* The dynamic object for the current item. Useful when
* using dynamic content with try again.
* https://reference.learnosity.com/items-api/methods/item/dynamic
* @since 1.4.0
* @returns {object}
*/
export function dynamic() {
const reference = itemReference();
return app.assessApp().item(reference).dynamic;
}

/**
* Toggles the `user_flagged` state on the current item.
* @since 1.4.0
*/
export function flag() {
const reference = itemReference();
app.assessApp().item(reference).flag();
}

/**
* Whether the current item has dynamic content.
* @since 1.4.0
* @returns {boolean}
*/
export function isDynamicItem() {
return item()?.source.hasOwnProperty('data_table_seed');
}

/**
* Whether the current item is the first item in the activity.
* This ignores sections, so will be a global check.
Expand Down Expand Up @@ -190,14 +220,3 @@ export function itemPosition() {
export function itemReference() {
return app.appInstance().getCurrentItem().reference;
}

/**
* Toggles the `user_flagged` state on the current item.
* @since 0.4.0
*/
export function toggleFlag() {
const el = document.querySelector('.flag-item');
if (el) {
el.click();
}
}
2 changes: 1 addition & 1 deletion src/extensions/accessibility/ux/keyboardShortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,6 @@ function setResponseMask(bindings) {
*/
function toggleFlag(bindings) {
Mousetrap.bind(bindings, (e, combo) => {
items.toggleFlag();
items.flag();
});
}

0 comments on commit 3af800b

Please sign in to comment.