Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
id="learning_activities"
ref="learning_activities"
v-model="contentLearningActivities"
:disabled="isTopic"
@focus="trackClick('Learning activities')"
/>
<!-- Level -->
Expand Down Expand Up @@ -127,7 +128,7 @@
</VLayout>

<!-- Completion section for all resources -->
<VLayout row wrap class="section">
<VLayout v-if="!isTopic" row wrap class="section">
<VFlex xs12>
<h1 class="subheading">
{{ $tr('completionLabel') }}
Expand Down Expand Up @@ -513,7 +514,9 @@
return this.firstNode.original_channel_name;
},
requiresAccessibility() {
return this.nodes.every(node => node.kind !== ContentKindsNames.AUDIO);
return this.nodes.every(
node => node.kind !== ContentKindsNames.AUDIO && node.kind !== ContentKindsNames.TOPIC
);
},
audioAccessibility() {
return this.oneSelected && this.firstNode.kind === 'audio';
Expand Down Expand Up @@ -658,7 +661,7 @@
}
},
videoSelected() {
return this.oneSelected && this.firstNode.kind === 'video';
return this.oneSelected && this.firstNode.kind === ContentKindsNames.VIDEO;
},
newContent() {
return !this.nodes.some(n => n[NEW_OBJECT]);
Expand All @@ -667,7 +670,10 @@
return this.$store.getters.hasFeatureEnabled(FeatureFlagKeys.channel_quizzes);
},
isDocument() {
return this.firstNode.kind === 'document';
return this.firstNode.kind === ContentKindsNames.DOCUMENT;
},
isTopic() {
return this.firstNode.kind === ContentKindsNames.TOPIC;
},
},
watch: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<VSelect
v-model="learningActivity"
:items="learningActivities"
:disabled="disabled"
box
chips
clearable
Expand Down Expand Up @@ -33,14 +34,23 @@
type: Array,
default: () => [],
},
disabled: {
type: Boolean,
default: false,
},
},
computed: {
learningActivity: {
get() {
return this.value;
if (!this.disabled) {
return this.value;
}
return null;
},
set(value) {
this.$emit('input', value);
if (!this.disabled) {
this.$emit('input', value);
}
},
},
learningActivities() {
Expand All @@ -50,7 +60,7 @@
}));
},
learningActivityRules() {
return getLearningActivityValidators().map(translateValidator);
return this.disabled ? [] : getLearningActivityValidators().map(translateValidator);
},
},
};
Expand Down
99 changes: 95 additions & 4 deletions contentcuration/contentcuration/tests/test_exportchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
from kolibri_content import models as kolibri_models
from kolibri_content.router import get_active_content_database
from kolibri_content.router import set_active_content_database
from le_utils.constants.labels import accessibility_categories
from le_utils.constants.labels import learning_activities
from le_utils.constants.labels import levels
from le_utils.constants.labels import needs
from le_utils.constants.labels import resource_type
from le_utils.constants.labels import subjects
from mock import patch

from .base import StudioTestCase
Expand All @@ -21,7 +27,6 @@
from .testdata import slideshow
from contentcuration import models as cc
from contentcuration.utils.publish import convert_channel_thumbnail
from contentcuration.utils.publish import create_bare_contentnode
from contentcuration.utils.publish import create_content_database
from contentcuration.utils.publish import create_slideshow_manifest
from contentcuration.utils.publish import fill_published_fields
Expand Down Expand Up @@ -91,6 +96,42 @@ def setUp(self):
new_video.parent = self.content_channel.main_tree
new_video.save()

first_topic = self.content_channel.main_tree.get_descendants().first()
first_topic.accessibility_labels = {
accessibility_categories.AUDIO_DESCRIPTION: True,
}
first_topic.learning_activities = {
learning_activities.WATCH: True,
}
first_topic.grade_levels = {
levels.LOWER_SECONDARY: True,
}
first_topic.learner_needs = {
needs.PRIOR_KNOWLEDGE: True,
}
first_topic.resource_types = {
resource_type.LESSON_PLAN: True,
}
first_topic.categories = {
subjects.MATHEMATICS: True,
}
first_topic.save()

first_topic_first_child = first_topic.children.first()
first_topic_first_child.accessibility_labels = {
accessibility_categories.CAPTIONS_SUBTITLES: True,
}
first_topic_first_child.categories = {
subjects.ALGEBRA: True,
}
first_topic_first_child.learner_needs = {
needs.FOR_BEGINNERS: True,
}
first_topic_first_child.learning_activities = {
learning_activities.LISTEN: True,
}
first_topic_first_child.save()

set_channel_icon_encoding(self.content_channel)
self.tempdb = create_content_database(self.content_channel, True, self.admin_user.id, True)

Expand Down Expand Up @@ -189,6 +230,58 @@ def test_assessment_metadata(self):
self.assertTrue(isinstance(json.loads(asm.assessment_item_ids), list))
self.assertTrue(isinstance(json.loads(asm.mastery_model), dict))

def test_inherited_category(self):
first_topic_node_id = self.content_channel.main_tree.get_descendants().first().node_id
for child in kolibri_models.ContentNode.objects.filter(parent_id=first_topic_node_id)[1:]:
self.assertEqual(child.categories, subjects.MATHEMATICS)

def test_inherited_category_no_overwrite(self):
first_topic_node_id = self.content_channel.main_tree.get_descendants().first().node_id
first_child = kolibri_models.ContentNode.objects.filter(parent_id=first_topic_node_id).first()
self.assertEqual(first_child.categories, subjects.ALGEBRA)

def test_inherited_needs(self):
first_topic_node_id = self.content_channel.main_tree.get_descendants().first().node_id
for child in kolibri_models.ContentNode.objects.filter(parent_id=first_topic_node_id)[1:]:
self.assertEqual(child.learner_needs, needs.PRIOR_KNOWLEDGE)

def test_inherited_needs_no_overwrite(self):
first_topic_node_id = self.content_channel.main_tree.get_descendants().first().node_id
first_child = kolibri_models.ContentNode.objects.filter(parent_id=first_topic_node_id).first()
self.assertEqual(first_child.learner_needs, needs.FOR_BEGINNERS)

def test_topics_no_accessibility_label(self):
first_topic_node_id = self.content_channel.main_tree.get_descendants().first().node_id
topic = kolibri_models.ContentNode.objects.get(id=first_topic_node_id)
self.assertIsNone(topic.accessibility_labels)

def test_child_no_inherit_accessibility_label(self):
first_topic_node_id = self.content_channel.main_tree.get_descendants().first().node_id
first_child = kolibri_models.ContentNode.objects.filter(parent_id=first_topic_node_id).first()
# Should only be the learning activities we set on the child directly, not any parent ones.
self.assertEqual(first_child.accessibility_labels, accessibility_categories.CAPTIONS_SUBTITLES)

def test_inherited_grade_levels(self):
first_topic_node_id = self.content_channel.main_tree.get_descendants().first().node_id
for child in kolibri_models.ContentNode.objects.filter(parent_id=first_topic_node_id):
self.assertEqual(child.grade_levels, levels.LOWER_SECONDARY)

def test_inherited_resource_types(self):
first_topic_node_id = self.content_channel.main_tree.get_descendants().first().node_id
for child in kolibri_models.ContentNode.objects.filter(parent_id=first_topic_node_id):
self.assertEqual(child.resource_types, resource_type.LESSON_PLAN)

def test_topics_no_learning_activity(self):
first_topic_node_id = self.content_channel.main_tree.get_descendants().first().node_id
topic = kolibri_models.ContentNode.objects.get(id=first_topic_node_id)
self.assertIsNone(topic.learning_activities)

def test_child_no_inherit_learning_activity(self):
first_topic_node_id = self.content_channel.main_tree.get_descendants().first().node_id
first_child = kolibri_models.ContentNode.objects.filter(parent_id=first_topic_node_id).first()
# Should only be the learning activities we set on the child directly, not any parent ones.
self.assertEqual(first_child.learning_activities, learning_activities.LISTEN)


class ChannelExportUtilityFunctionTestCase(StudioTestCase):
@classmethod
Expand Down Expand Up @@ -240,10 +333,8 @@ def test_convert_channel_thumbnail_encoding_invalid(self):
self.assertEqual("this is a test", convert_channel_thumbnail(channel))

def test_create_slideshow_manifest(self):
content_channel = cc.Channel.objects.create()
ccnode = cc.ContentNode.objects.create(kind_id=slideshow(), extra_fields={}, complete=True)
kolibrinode = create_bare_contentnode(ccnode, ccnode.language, content_channel.id, content_channel.name)
create_slideshow_manifest(ccnode, kolibrinode)
create_slideshow_manifest(ccnode)
manifest_collection = cc.File.objects.filter(contentnode=ccnode, preset_id=u"slideshow_manifest")
assert len(manifest_collection) == 1

Expand Down
Loading