attachItem - Methods - Grading API

Grading API Methods

attachItem()

Adds the learner's answered Item to the current grading session.

You would want to use this method to attach a new Item of a learner's assessment for grading.

The attached Item will have the Question's responses in a review state with a grader form where you can re-score and post feedback.

Examples

// Example of attaching an Item from a learner assessment session
const payload = {
    sessionId: 'session-uuid',
    userId:   'user-id',
    items: ['item-reference']
};
// The wrapper element where the Item will be attached
const gradingWrapperElement = document.querySelector('#grading-wrapper-element');

// Using a async and await function to attach the Item and return the session object
const attachedItems = await gradingApp.attachItem(payload, gradingWrapperElement);

// Or using a promise function to attach the Item and return the session object
gradingApp.attachItem(payload, gradingWrapperElement)
.then((sessions) => {
    console.log(sessions);
})
.catch((error) => {
    console.error(error);
});

Arguments

  • options object

    • items array[string|object]

      An array of Item references (or Item objects). Each array element specifies one single Item to be added to the grading.

      When using string references, each Item reference in the array will be fetched and added to the grading.

      When using objects, each Item object in the array provides the content that will be added to the grading.

    • sessionId string

      The learner unique session ID.

    • userId string

      The learner unique user ID.

  • wrapperElement object

    The DOM element where the Item will be attached.

    Important An empty container element must be placed on the page with a unique ID where the grading inline be rendered.

Return value

Type Promise | object

When the promise resolves, it will return the session with all the attached Items including the newly attached Item.

  • items array[object]

    An array of Item objects. Each array element specifies one single Item attached to the DOM.

    The Item object will have the reference of the Item and the element DOM where it has been attached.

  • sessionId string

    The session ID of the attached Item.

  • userId string

    The user ID of the attached Item.

Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.