function contentItemForContent(ltiLaunchURL, content, extraParams) {
  const params = { ...extraParams };
  switch (content.type) {
    case 'file':
      params.canvas_file = 'true';
      params.file_id = content.file.id;
      break;
    case 'url':
      params.url = content.url;
      break;
    case 'vitalsource':
      params.vitalsource_book = 'true';
      params.book_id = content.bookID;
      params.cfi = content.cfi;
      break;
  }

  const url = new URL(ltiLaunchURL);
  Object.entries(params).forEach(([key, value]) =>
    url.searchParams.append(key, value)
  );

  return {
    '@context': 'http://purl.imsglobal.org/ctx/lti/v1/ContentItem',
    '@graph': [
      {
        '@type': 'LtiLinkItem',
        mediaType: 'application/vnd.ims.lti.v1.ltilink',
        url: url.toString(),
      },
    ],
  };
}
/**
 * Return a JSON-LD `ContentItem` representation of the LTI activity launch
 * URL for a given piece of content.
 *
 * This is used for the `content_items` field of the form submitted to the LMS
 * to configure the LTI launch URL for a new assignment. See
 * https://www.imsglobal.org/specs/lticiv1p0/specification.
 *
 * @param {string} ltiLaunchURL - Base URL for LTI assignment launches
 * @param {Content} content - The assignment content
 * @param {Record<string,string>} [extraParams] - Additional query params to add to the launch URL
 */
Return a JSON-LD `ContentItem` representation of the LTI activity launch
URL for a given piece of content.

This is used for the `content_items` field of the form submitted to the LMS
to configure the LTI launch URL for a new assignment.

@param {string} ltiLaunchURL - Base URL for LTI assignment launches
@param {Content} content - The assignment content
@param {Record} [extraParams] - Additional query params to add to the launch URL
Return a JSON - LD ` ContentItem ` representation of the LTI activity launch URL for a given piece of content . This is used for the ` content_items ` field of the form submitted to the LMS to configure the LTI launch URL for a new assignment . @param { string } ltiLaunchURL - Base URL for LTI assignment launches @param { Content } content - The assignment content @param { Record } [ extraParams ] - Additional query params to add to the launch URL
function contentItemForContent(ltiLaunchURL, content, extraParams) {
  const params = { ...extraParams };
  switch (content.type) {
    case 'file':
      params.canvas_file = 'true';
      params.file_id = content.file.id;
      break;
    case 'url':
      params.url = content.url;
      break;
    case 'vitalsource':
      params.vitalsource_book = 'true';
      params.book_id = content.bookID;
      params.cfi = content.cfi;
      break;
  }
  const url = new URL(ltiLaunchURL);
  Object.entries(params).forEach(([key, value]) =>
    url.searchParams.append(key, value)
  );
  return {
    '@context': 'http://purl.imsglobal.org/ctx/lti/v1/ContentItem',
    '@graph': [
      {
        '@type': 'LtiLinkItem',
        mediaType: 'application/vnd.ims.lti.v1.ltilink',
        url: url.toString(),
      },
    ],
  };
}
function contentItemForContent ( ltiLaunchURL , content , extraParams ) { const params = { ... extraParams } ; switch ( content . type ) { case 'file' : params . canvas_file = 'true' ; params . file_id = content . file . id ; break ; case 'url' : params . url = content . url ; break ; case 'vitalsource' : params . vitalsource_book = 'true' ; params . book_id = content . bookID ; params . cfi = content . cfi ; break ; } const url = new URL ( ltiLaunchURL ) ; Object . entries ( params ) . forEach ( ( [ key , value ] ) => url . searchParams . append ( key , value ) ) ; return { '@context' : 'http://purl.imsglobal.org/ctx/lti/v1/ContentItem' , '@graph' : [ { '@type' : 'LtiLinkItem' , mediaType : 'application/vnd.ims.lti.v1.ltilink' , url : url . toString ( ) , } , ] , } ; }
Return a JSON-LD `ContentItem` representation of the LTI activity launch
 URL for a given piece of content.
Return a JSON - LD ` ContentItem ` representation of the LTI activity launch URL for a given piece of content .