Help
ContentFrame API
The ContentFrame API is a Javascript API that you include in a content frame VHTML file with the <%ContentFrameAPI%> replacement tag. BrainHoney replaces the tag with a Javascript object that defines a common set of properties and methods, and depending on the content item type being displayed, additional type-specific properties and methods.

When the content item type is assessment or homework, the object additionally contains the methods and properties defined in Assessment API and Homework API, respectively.
Properties
NameTypeMeaning
actionsAction[]Gets an array of Action objects, which are actions that can be performed on the currently displayed content. See performAction for a list of available action types.
enrollmentIdIDGets the enrollment ID for the current user.
itemIdstringGets the item ID of the currently displayed content item.
privateobjectProperties and methods for internal use only.
statusstringGets the localized status text for the current enrollment for the currently displayed content. This status includes things like submission status, whether the user can re-submit, and a due date, if any.
scoreHtmlstringGets the score for the current enrollment for the currently displayed content item formatted according to the item's score-display settings, containing elements such as the score, submission status icons, tooltips, and time spent. Also see the renderScore method.
I18NobjectGets an object containing strings in the language of the current user. These are the object properties with their accompanying English text:
  • Cancel - Cancel
  • Confirm - Confirm
  • Error - Error
  • OK - OK
Methods
enableButton
Enables or disables a button created with renderButton.
Syntax
enableButton(string id, boolean enable) : void
Parameters
  • idID of the button to enable or disable. The value must match the id that was specified in renderButton call.
  • enableSpecify true to enable the button, false to disable it.
Example
Disable the button with id 'mystartbutton'.
api.enableButton('mystartbutton',false);
getAction
A convenience method that finds an Action by type in the actions property.
Syntax
getAction(string type) : Action
Parameters
  • typeType of the action to get.
Returns
First Action in the actions property where action.type == type. Returns null if not found.
Example
This example checks for the existence of the 'detail' action.
var action = api.getAction('detail');
if (action) ...
performAction
Performs an action for the content displayed within the content frame.
Syntax
performAction(string type, various param) : void
Parameters
  • type Type of the action to perform. All content item types can perform the following listed actions. Additional item-specific action types are defined in their respective APIs (Assessment API, Homework API, etc.)
  • NameMeaning
    detailDisplays grade details for the current user for the current item in a popup window.
  • paramAdditional, action-specific data, if any. See individual action types for descriptions of param data that the action requires.
Example
Perform the 'detail' action to show the grade detail.
api.performAction('detail');
renderButton
Renders a button to an existing DOM element. The button is styled so that it looks like other buttons in the BrainHoney user interface.
Syntax
renderButton(ButtonConfig config) : void
Parameters
  • configA ButtonConfig object that configures the button.
Example
Renders a "Print" split button to the DOM element with id 'printButtonDiv'.
api.renderButton({ 
    id: 'printButtonDiv',
    text: 'Print',
    tooltip: 'Print the Assessment',
    enabled: true,
    handler: function() { this.performAction('print',1) },
    scope: api,
    items: [
        { text: 'Student', handler: function(){ this.performAction('print',1) } },
        { text: 'Teacher', handler: function(){ this.performAction('print',2) } },
        { text: 'Both', handler: function(){ this.performAction('print',3) } },
    ]
});
renderScore
Renders the specified score HTML and some accompanying style wrappers to an existing DOM element. The wrapping styles cause the score to appear like other scores in BrainHoney content frames, including showing where the score would appear even when no score exists yet (currently a bordered box, but that style could change).
Syntax
renderScore(string id, string scoreHtml) : void
Parameters
  • idID of the existing DOM element to render the score to.
  • scoreHtmlHTML score string to render; you typically pass the scoreHtml property.
Example
Render the current score to the the DOM element with id 'scoreDiv'.
api.renderScore('scoreDiv', api.scoreHtml);
See Also
Content Frames Assessment API Homework API ButtonConfig