moodle_local_treestudyplan/amd/build/studyplan-processor.min.js.map

1 line
6.0 KiB
Plaintext

{"version":3,"file":"studyplan-processor.min.js","sources":["../src/studyplan-processor.js"],"sourcesContent":["/*eslint no-console: \"off\"*/\n/**\n * Copy fields from one object to another\n * @param {Object} target The target to move to\n * @param {Object} source The source to move from\n * @param {Array} fields The field names to copy\n * @returns {Object} The map with strings loaded in\n */\nexport function objCopy(target,source,fields){\n for(const ix in fields) {\n const field = fields[ix];\n target[field] = source[field];\n }\n}\n\n/**\n * Transport items from one object to another\n * @param {Object} target The target to move to\n * @param {Object} source The source to move from\n * @param {*} identifier The value used to match the item\n * @param {string} param The field name to match on (default: 'value')\n */\nexport function transportItem(target,source,identifier,param){\n if(!param){\n param = 'value';\n }\n // find item\n let item;\n let itemindex;\n for(const ix in source){\n if(source[ix][param] == identifier){\n item = source[ix];\n itemindex = ix;\n break;\n }\n }\n if(item){\n target.push(item);\n source.splice(itemindex,1);\n }\n}\n\n/**\n * Do initial conversion on multiple studyplans\n * @param {Array} studyplans The list of studyplans to load\n * @returns {Array} List of updated studyplans\n */\nexport function ProcessStudyplans(studyplans){\n // Unify object references to connections between items, so there are no duplicates\n for(const isx in studyplans)\n {\n const studyplan = studyplans[isx];\n ProcessStudyplan(studyplan);\n }\n\n return studyplans;\n}\n\n/**\n * Perform initial processing on a downloaded studyplan\n * Mainly used to create the proper references between items\n * @param {Object} studyplan The studyplan to process\n * @returns Processed studyplan\n */\nexport function ProcessStudyplan(studyplan){\n let connections = {};\n for(const ip in studyplan.pages){\n const page = studyplan.pages[ip];\n for(const il in page.studylines) {\n const line = page.studylines[il];\n\n for(const is in line.slots ) {\n const slot = line.slots[is];\n\n if(slot.competencies !== undefined){\n for(const ic in slot.competencies){\n const itm = slot.competencies[ic];\n\n for(const idx in itm.connections.in) {\n const conn = itm.connections.in[idx];\n\n if(conn.id in connections){\n itm.connections[idx] = connections[conn.id];\n } else {\n connections[conn.id] = conn;\n }\n }\n for(const idx in itm.connections.out) {\n const conn = itm.connections.out[idx];\n\n if(conn.id in connections){\n itm.connections[idx] = connections[conn.id];\n } else {\n connections[conn.id] = conn;\n }\n }\n }\n }\n\n if(slot.filters !== undefined){\n for(const ix in slot.filters){\n const itm = slot.filters[ix];\n\n for(const idx in itm.connections.in) {\n const conn = itm.connections.in[idx];\n\n if(conn.id in connections){\n itm.connections[idx] = connections[conn.id];\n } else {\n connections[conn.id] = conn;\n }\n }\n for(const idx in itm.connections.out) {\n const conn = itm.connections.out[idx];\n\n if(conn.id in connections){\n itm.connections[idx] = connections[conn.id];\n } else {\n connections[conn.id] = conn;\n }\n }\n }\n }\n }\n }\n }\n return studyplan;\n}\n"],"names":["ProcessStudyplan","studyplan","connections","ip","pages","page","il","studylines","line","is","slots","slot","undefined","competencies","ic","itm","idx","in","conn","id","out","filters","ix","studyplans","isx","target","source","fields","field","identifier","param","item","itemindex","push","splice"],"mappings":"0FAgEgBA,iBAAiBC,eACzBC,YAAc,OACd,IAAMC,MAAMF,UAAUG,MAAM,KACtBC,KAAOJ,UAAUG,MAAMD,QACzB,IAAMG,MAAMD,KAAKE,WAAY,KACvBC,KAAOH,KAAKE,WAAWD,QAEzB,IAAMG,MAAMD,KAAKE,MAAQ,KACnBC,KAAOH,KAAKE,MAAMD,YAECG,IAAtBD,KAAKE,iBACA,IAAMC,MAAMH,KAAKE,aAAa,KACxBE,IAAMJ,KAAKE,aAAaC,QAE1B,IAAME,OAAOD,IAAIb,YAAYe,GAAI,KAC3BC,KAAOH,IAAIb,YAAYe,GAAGD,KAE7BE,KAAKC,MAAMjB,YACVa,IAAIb,YAAYc,KAAOd,YAAYgB,KAAKC,IAExCjB,YAAYgB,KAAKC,IAAMD,SAG3B,IAAMF,QAAOD,IAAIb,YAAYkB,IAAK,KAC5BF,MAAOH,IAAIb,YAAYkB,IAAIJ,MAE9BE,MAAKC,MAAMjB,YACVa,IAAIb,YAAYc,MAAOd,YAAYgB,MAAKC,IAExCjB,YAAYgB,MAAKC,IAAMD,eAMn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