added dynamic number of learning sequences
This commit is contained in:
parent
84bf372a58
commit
c3481c22d7
|
|
@ -3,7 +3,7 @@ import * as d3 from 'd3';
|
|||
|
||||
export default {
|
||||
props: {
|
||||
learningSequeces: {required: false,
|
||||
learningSequences: {required: false,
|
||||
default: [{title: '', done: false}, {title: '', done: false}, {title: '', done: false}, {title: '', done: false}]},
|
||||
width: {
|
||||
default: 250,
|
||||
|
|
@ -16,7 +16,7 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
pieData () {
|
||||
return new Array(this.learningSequeces.length).fill(1);
|
||||
return new Array(Math.max(this.learningSequences.length, 1)).fill(1);
|
||||
},
|
||||
viewBox() {
|
||||
return `0 0 ${this.width} ${this.height}`;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ export default {
|
|||
<div class="font-bold text-blue-900 mb-4">{{topic.title}}</div>
|
||||
<div class="flex flex-row">
|
||||
<button class="circle mr-8" aria-label="circle.title" v-for="circle in topic.circles">
|
||||
<SimpleCircleDiagram class="w-48 h-48"></SimpleCircleDiagram>
|
||||
<SimpleCircleDiagram class="w-48 h-48" :learning-sequences="circle.learning_sequences"></SimpleCircleDiagram>
|
||||
<div class="text-center text-xl text-blue-900 font-bold mt-4">{{ circle.title }}</div>
|
||||
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -28,12 +28,11 @@ class LearningPath(Page):
|
|||
|
||||
|
||||
class Topic(Page):
|
||||
# title = models.TextField(default='')
|
||||
# title = models.TextField(default='')
|
||||
is_visible = models.BooleanField(default=True)
|
||||
|
||||
parent_page_types = ['learnpath.LearningPath']
|
||||
|
||||
|
||||
panels = [FieldPanel('title'),
|
||||
FieldPanel('is_visible'),
|
||||
]
|
||||
|
|
@ -43,7 +42,6 @@ class Topic(Page):
|
|||
APIField('is_visible'),
|
||||
]
|
||||
|
||||
|
||||
# content_panels = Page.content_panels + [
|
||||
# FieldPanel('is_visible', classname="full"),
|
||||
# PageChooserPanel('learning_path', 'learnpath.LearningPath'),
|
||||
|
|
@ -57,14 +55,13 @@ class Topic(Page):
|
|||
print(self.slug)
|
||||
super(Topic, self).full_clean(*args, **kwargs)
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_serializer_class(cls):
|
||||
return get_it_serializer_class(cls, field_names=['id', 'title', 'slug', 'type', 'translation_key', 'is_visible'])
|
||||
|
||||
return get_it_serializer_class(cls,
|
||||
field_names=['id', 'title', 'slug', 'type', 'translation_key', 'is_visible', ])
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Topic"
|
||||
verbose_name = "Topic"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.title}"
|
||||
|
|
@ -74,14 +71,6 @@ class Circle(Page):
|
|||
description = models.TextField(default="", blank=True)
|
||||
goals = models.TextField(default="", blank=True)
|
||||
|
||||
# topic = models.ForeignKey(
|
||||
# 'learnpath.Topic',
|
||||
# null=True,
|
||||
# blank=True,
|
||||
# on_delete=models.SET_NULL,
|
||||
# related_name='circles'
|
||||
# )
|
||||
|
||||
parent_page_types = ['learnpath.LearningPath']
|
||||
subpage_types = ['learnpath.LearningSequence', 'learnpath.LearningUnit']
|
||||
|
||||
|
|
@ -93,12 +82,16 @@ class Circle(Page):
|
|||
api_fields = [
|
||||
APIField('title'),
|
||||
APIField('description'),
|
||||
APIField('learning_sequences'),
|
||||
]
|
||||
|
||||
@property
|
||||
def learning_sequences(self):
|
||||
return self.get_children().filter(content_type__model='learningsequence').values('id', 'title')
|
||||
|
||||
@classmethod
|
||||
def get_serializer_class(cls):
|
||||
return get_it_serializer_class(cls, field_names=['id', 'title', 'slug', 'type', 'translation_key'])
|
||||
return get_it_serializer_class(cls, field_names=['id', 'title', 'slug', 'type', 'translation_key', 'learning_sequences'])
|
||||
|
||||
def full_clean(self, *args, **kwargs):
|
||||
self.slug = find_available_slug(Circle, slugify(self.title, allow_unicode=True))
|
||||
|
|
@ -192,7 +185,9 @@ class LearningUnit(Page):
|
|||
|
||||
@classmethod
|
||||
def get_serializer_class(cls):
|
||||
return get_it_serializer_class(cls, field_names=['id', 'title', 'minutes', 'package', 'contents', 'slug', 'type', 'translation_key'])
|
||||
return get_it_serializer_class(cls,
|
||||
field_names=['id', 'title', 'minutes', 'package', 'contents', 'slug', 'type',
|
||||
'translation_key'])
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.title}"
|
||||
|
|
|
|||
|
|
@ -7,3 +7,6 @@ class TestCreateDefaultCompetences(TestCase):
|
|||
def test_create_default_competeneces(self):
|
||||
create_default_competences()
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,14 @@ from django.conf import settings
|
|||
from django.test import TestCase
|
||||
from wagtail.core.models import Locale
|
||||
|
||||
from vbv_lernwelt.core.create_default_users import create_default_users
|
||||
from vbv_lernwelt.learnpath.models import LearningPath
|
||||
from vbv_lernwelt.learnpath.tests.create_default_learning_path import create_default_learning_path
|
||||
|
||||
|
||||
class TestCreateDefaultLearningPaths(TestCase):
|
||||
def setUp(self) -> None:
|
||||
create_default_users()
|
||||
create_locales_for_wagtail()
|
||||
|
||||
def test_create_learning_path(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue