Update model to store sequence based on hash_key

This commit is contained in:
Kristin Aoki
2021-07-26 15:09:38 -04:00
parent eb70d3733d
commit e96d885114

View File

@@ -133,7 +133,7 @@ export function normalizeOutlineBlocks(courseId, blocks) {
break;
case 'sequential':
models.sequences[block.id] = {
models.sequences[block.hash_key] = {
complete: block.complete,
description: block.description,
due: block.due,
@@ -148,6 +148,7 @@ export function normalizeOutlineBlocks(courseId, blocks) {
// link to the MFE ourselves).
showLink: !!block.legacy_web_url,
title: block.display_name,
hash_key: block.hash_key,
};
break;
@@ -170,8 +171,15 @@ export function normalizeOutlineBlocks(courseId, blocks) {
Object.values(models.sections).forEach(section => {
if (Array.isArray(section.sequenceIds)) {
section.sequenceIds.forEach(sequenceId => {
if (sequenceId in models.sequences) {
models.sequences[sequenceId].sectionId = section.id;
const modelSequenceIds = {};
Object.values(models.sequences).forEach(sequence => {
if (sequenceId === sequence.id) {
modelSequenceIds[sequenceId] = sequence.hash_key;
}
});
if (sequenceId in modelSequenceIds) {
const sequence = modelSequenceIds[sequenceId];
models.sequences.[sequence].sectionId = section.id;
} else {
logInfo(`Section ${section.id} has child block ${sequenceId}, but that block is not in the list of sequences.`);
}