Simon-Initiative / course-digest

Tool to produce a summary or digest of OLI course package contents
MIT License
2 stars 0 forks source link

Updating the objective-skill parent-child relationship is brittle, needs more logging #177

Open normanbier opened 1 year ago

normanbier commented 1 year ago

When attempting to convert a spreadsheet skills map, convert.ts can encounter values that break the conversion. These values in the spreadsheet are potentially mistakes and human correctable, but convert.ts does not provide enough context to locate the issue.

For example, in the attached spreadsheet, the issue is an extra space at the end of skill id (tab: LOs, cell 15:F). But the error message:

/Users/nbier/dev/torus_convert/course-digest/src/convert.ts:180
  m.objectives.forEach((a: Magic.SpreadsheetObjective) => {
               ^
TypeError: Cannot read properties of undefined (reading 'id')
    at /Users/nbier/dev/torus_convert/course-digest/src/convert.ts:188:30
    at Array.map (<anonymous>)
    at /Users/nbier/dev/torus_convert/course-digest/src/convert.ts:187:41
    at Array.forEach (<anonymous>)
    at applyMagic (/Users/nbier/dev/torus_convert/course-digest/src/convert.ts:180:16)
    at Object.applyMagicSpreadsheet (/Users/nbier/dev/torus_convert/course-digest/src/convert.ts:60:12)
    at /Users/nbier/dev/torus_convert/course-digest/src/index.ts:241:31
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

does not provide enough context for me to track down and correct the problem. I finally threw in some really ugly logging into convert.ts at line 181:

 console.log(
     `info: attempting to update the objective-skill parent-child realtionship for  ${JSON.stringify(byObjectiveId[a.id])}`
    );

that helped me tracked down the issue, but it was painful. Suggest additional logging/reporting on errors so that users can see what LO/Skill/Problem was being worked on at the time that the script breaks.

chem2_new.xlsx