Add objective change count
This commit is contained in:
parent
1f85defb2a
commit
c257447748
|
|
@ -156,10 +156,10 @@ class SnapshotNode(DjangoObjectType):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_changes(parent, info, **kwargs):
|
def resolve_changes(parent, info, **kwargs):
|
||||||
return {
|
return {
|
||||||
'hidden_objectives': 0,
|
'hidden_objectives': parent.hidden_objectives.count(),
|
||||||
'new_objectives': 0,
|
'new_objectives': parent.custom_objectives.filter(hidden=False).count(),
|
||||||
'hidden_content_blocks': parent.hidden_content_blocks.count(),
|
'hidden_content_blocks': parent.hidden_content_blocks.count(),
|
||||||
'new_content_blocks': parent.custom_content_blocks.count()
|
'new_content_blocks': parent.custom_content_blocks.filter(hidden=False).count()
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,12 @@ SNAPSHOT_MODULE_QUERY = """
|
||||||
query SnapshotDetail($id: ID!) {
|
query SnapshotDetail($id: ID!) {
|
||||||
snapshot(id: $id) {
|
snapshot(id: $id) {
|
||||||
id
|
id
|
||||||
|
changes {
|
||||||
|
newContentBlocks
|
||||||
|
newObjectives
|
||||||
|
hiddenContentBlocks
|
||||||
|
hiddenObjectives
|
||||||
|
}
|
||||||
objectiveGroups {
|
objectiveGroups {
|
||||||
title
|
title
|
||||||
id
|
id
|
||||||
|
|
@ -174,9 +180,10 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
module=self.module, title=self.title_custom,
|
module=self.module, title=self.title_custom,
|
||||||
slug='cb-c')
|
slug='cb-c')
|
||||||
# content block d is user created, but hidden
|
# content block d is user created, but hidden
|
||||||
self.custom_hidden_content_block = ContentBlockFactory(parent=self.chapter, owner=self.teacher, user_created=True,
|
self.custom_hidden_content_block = ContentBlockFactory(parent=self.chapter, owner=self.teacher,
|
||||||
module=self.module, title=self.title_custom_hidden,
|
user_created=True,
|
||||||
slug='cb-d')
|
module=self.module, title=self.title_custom_hidden,
|
||||||
|
slug='cb-d')
|
||||||
# content block a and c are visible to school class X
|
# content block a and c are visible to school class X
|
||||||
self.hidden_content_block.hidden_for.add(self.skillbox_class)
|
self.hidden_content_block.hidden_for.add(self.skillbox_class)
|
||||||
self.custom_content_block.visible_for.add(self.skillbox_class)
|
self.custom_content_block.visible_for.add(self.skillbox_class)
|
||||||
|
|
@ -339,6 +346,12 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
|
|
||||||
self.assertEqual(objective_group2['hidden'], True)
|
self.assertEqual(objective_group2['hidden'], True)
|
||||||
|
|
||||||
|
changes = snapshot['changes']
|
||||||
|
self.assertEqual(changes['newContentBlocks'], 1)
|
||||||
|
self.assertEqual(changes['hiddenContentBlocks'], 1)
|
||||||
|
self.assertEqual(changes['newObjectives'], 1)
|
||||||
|
self.assertEqual(changes['hiddenObjectives'], 1)
|
||||||
|
|
||||||
def test_apply_initial_snapshot(self):
|
def test_apply_initial_snapshot(self):
|
||||||
teacher2 = User.objects.get(username='teacher2')
|
teacher2 = User.objects.get(username='teacher2')
|
||||||
teacher2_client = self.get_client(user=teacher2)
|
teacher2_client = self.get_client(user=teacher2)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue