From a39f5de67db77570c6537d24948917f705a0adc9 Mon Sep 17 00:00:00 2001 From: Lorenz Padberg Date: Wed, 8 Jun 2022 12:06:47 +0200 Subject: [PATCH] added topics to learnpath visualisation --- client/src/views/LearningPathView.vue | 62 ++++++++++++++++--- .../learnpath/migrations/0001_initial.py | 33 +++++----- server/vbv_lernwelt/learnpath/models.py | 44 ++++++------- server/vbv_lernwelt/learnpath/tests/bla.json | 9 --- .../tests/create_default_learning_path.py | 12 ++-- .../tests/learning_path_factories.py | 2 +- 6 files changed, 96 insertions(+), 66 deletions(-) delete mode 100644 server/vbv_lernwelt/learnpath/tests/bla.json diff --git a/client/src/views/LearningPathView.vue b/client/src/views/LearningPathView.vue index 59f53dad..0cd084e5 100644 --- a/client/src/views/LearningPathView.vue +++ b/client/src/views/LearningPathView.vue @@ -12,6 +12,7 @@ export default { return { count: 0, learningPathData: {}, + learningPathContents: {}, circles: [], learningSequences: [], } @@ -23,19 +24,50 @@ export default { url: `/learnpath/api/learningpath/${this.learningPathSlug}/`, }).then((response) => { log.debug(response.data); - this.learningPathData = response.data; + this.learningPathData = response.data + + + let learningPathContents = { topics: [] } + let topic = { + id : 0, + title : '', + slug : '', + type : 'learnpath.Topic', + translation_key : '', + is_visible : false, + cirlces : [] + } + + response.data.children.forEach((child) => { + console.log(child, '////') + if (child.type === 'learnpath.Topic') { + if (topic.id != 0){ + learningPathContents.topics.push(topic) + } + + topic = child + topic.circles = [] + } + if (child.type === 'learnpath.Circle') { + console.log(child) + topic.circles.push(child) + } + }); + learningPathContents.topics.push(topic) + + + this.learningPathContents = learningPathContents; + console.log(learningPathContents) // extract cirlces - this.learningPathData.children.forEach((child) => { - if (child.type === 'learnpath.Circle') { - this.circles.push(child); - } - }); + }); } } + +