Picture of Ignacio Cinalli
Re: Question IDs in Assessment
by Ignacio Cinalli - Friday, 5 January 2024, 6:13 PM
 

Hi Marie-Eve,
I'm not sure if this is the best way, but you can do it by modifying the adapt-contrib-spoor extension.
Modify the recordInteractionScorm12 and recordInteractionScorm2004 functions as follows:

recordInteractionScorm12(id, response, correct, latency, type) {
    id = id.trim();
    const titleId =
      Data.findById(id)
        .get('title')
        .replace(/[^a-zA-Z0-9]/g, '_')
        .toLowerCase() || id;

    const cmiPrefix = `cmi.interactions.${this.getInteractionCount()}`;

    this.setValue(`${cmiPrefix}.id`, titleId);
    this.setValue(`${cmiPrefix}.type`, type);
    this.setValue(`${cmiPrefix}.student_response`, response);
    this.setValue(`${cmiPrefix}.result`, correct ? 'correct' : 'wrong');
    if (latency !== null && latency !== undefined) this.setValue(`${cmiPrefix}.latency`, this.convertToSCORM12Time(latency));
    this.setValue(`${cmiPrefix}.time`, this.getCMITime());
  }

  recordInteractionScorm2004(id, response, correct, latency, type) {
    id = id.trim();
    const titleId =
      Data.findById(id)
        .get('title')
        .replace(/[^a-zA-Z0-9]/g, '_')
        .toLowerCase() || id;
    const cmiPrefix = `cmi.interactions.${this.getInteractionCount()}`;

    this.setValue(`${cmiPrefix}.id`, titleId);
    this.setValue(`${cmiPrefix}.type`, type);
    this.setValue(`${cmiPrefix}.learner_response`, response);
    this.setValue(`${cmiPrefix}.result`, correct ? 'correct' : 'incorrect');
    if (latency !== null && latency !== undefined) this.setValue(`${cmiPrefix}.latency`, this.convertToSCORM2004Time(latency));
    this.setValue(`${cmiPrefix}.timestamp`, this.getISO8601Timestamp());
  } 

This will allow you to use the component/question title instead of the ID.

Hope this helps!