+
+
+
{{module.title}}
![]()
Lernziele
-
+
@@ -30,6 +37,7 @@
import ObjectiveGroupControl from '@/components/objective-groups/ObjectiveGroupControl.vue';
import AddObjectiveGroupButton from '@/components/AddObjectiveGroupButton';
import Chapter from '@/components/Chapter.vue';
+ import ToggleSolutionsForModule from '@/components/ToggleSolutionsForModule.vue';
import UPDATE_OBJECTIVE_PROGRESS_MUTATION from '@/graphql/gql/mutations/updateObjectiveProgress.gql';
import OBJECTIVE_QUERY from '@/graphql/gql/objectiveQuery.gql';
@@ -42,7 +50,8 @@
ObjectiveGroups,
ObjectiveGroupControl,
AddObjectiveGroupButton,
- Chapter
+ Chapter,
+ ToggleSolutionsForModule
},
props: {
diff --git a/client/src/graphql/client.js b/client/src/graphql/client.js
index c7031b1a..87c3b65a 100644
--- a/client/src/graphql/client.js
+++ b/client/src/graphql/client.js
@@ -45,7 +45,8 @@ const cache = new InMemoryCache({
chapter: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ChapterNode', id: args.id}),
assignment: (_, args, {getCacheKey}) => getCacheKey({__typename: 'AssignmentNode', id: args.id}),
objective: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ObjectiveNode', id: args.id}),
- objectiveGroup: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ObjectiveGroupNode', id: args.id})
+ objectiveGroup: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ObjectiveGroupNode', id: args.id}),
+ module: (_, args, {getCacheKey}) => getCacheKey({__typename: 'ModuleNode', id: args.id})
}
}
});
diff --git a/client/src/graphql/gql/fragments/moduleParts.gql b/client/src/graphql/gql/fragments/moduleParts.gql
index 8afb905a..e6fdd20b 100644
--- a/client/src/graphql/gql/fragments/moduleParts.gql
+++ b/client/src/graphql/gql/fragments/moduleParts.gql
@@ -5,4 +5,5 @@ fragment ModuleParts on ModuleNode {
teaser
slug
heroImage
+ solutionsEnabled
}
diff --git a/client/src/graphql/gql/moduleByIdQuery.gql b/client/src/graphql/gql/moduleByIdQuery.gql
index 731f49da..8ac81682 100644
--- a/client/src/graphql/gql/moduleByIdQuery.gql
+++ b/client/src/graphql/gql/moduleByIdQuery.gql
@@ -1,11 +1,7 @@
+#import "./fragments/moduleParts.gql"
query ModuleQuery($id: ID!) {
module(id: $id) {
- id
- slug
- title
- metaTitle
- teaser
- intro
+ ...ModuleParts
chapters {
edges {
node {
diff --git a/client/src/graphql/gql/moduleDetailsQuery.gql b/client/src/graphql/gql/moduleDetailsQuery.gql
index ff4b71eb..296f61d2 100644
--- a/client/src/graphql/gql/moduleDetailsQuery.gql
+++ b/client/src/graphql/gql/moduleDetailsQuery.gql
@@ -1,15 +1,10 @@
#import "./fragments/chapterParts.gql"
#import "./fragments/assignmentParts.gql"
#import "./fragments/objectiveGroupParts.gql"
+#import "./fragments/moduleParts.gql"
query ModulesQuery($slug: String!) {
module(slug: $slug) {
- id
- slug
- title
- metaTitle
- teaser
- intro
- heroImage
+ ...ModuleParts
assignments {
edges {
node {
diff --git a/client/src/graphql/gql/mutations/updateSolutionVisibility.gql b/client/src/graphql/gql/mutations/updateSolutionVisibility.gql
new file mode 100644
index 00000000..218558ce
--- /dev/null
+++ b/client/src/graphql/gql/mutations/updateSolutionVisibility.gql
@@ -0,0 +1,7 @@
+mutation UpdateSolutionVisibility($input: UpdateSolutionVisibilityInput!) {
+ updateSolutionVisibility(input: $input) {
+ errors
+ success
+ solutionsEnabled
+ }
+}
diff --git a/server/books/schema/mutations/module.py b/server/books/schema/mutations/module.py
index 4d1bc815..9e590181 100644
--- a/server/books/schema/mutations/module.py
+++ b/server/books/schema/mutations/module.py
@@ -11,6 +11,7 @@ class UpdateSolutionVisibility(relay.ClientIDMutation):
enabled = graphene.Boolean()
success = graphene.Boolean()
+ solutions_enabled = graphene.Boolean()
errors = graphene.List(graphene.String)
@classmethod
@@ -29,11 +30,11 @@ class UpdateSolutionVisibility(relay.ClientIDMutation):
module.solutions_enabled_by.remove(user)
module.save()
- return cls(success=True)
+ return cls(success=True, solutions_enabled=enabled)
except PermissionError:
errors = ["You don't have the permission to do that."]
except Exception as e:
errors = ['Error: {}'.format(e)]
- return cls(success=False, errors=errors)
+ return cls(success=False, solutions_enabled=None, errors=errors)
diff --git a/server/books/schema/queries.py b/server/books/schema/queries.py
index f77a8787..1ad58f69 100644
--- a/server/books/schema/queries.py
+++ b/server/books/schema/queries.py
@@ -74,6 +74,7 @@ class ModuleNode(DjangoObjectType):
pk = graphene.Int()
chapters = DjangoFilterConnectionField(ChapterNode)
hero_image = graphene.String()
+ solutions_enabled = graphene.Boolean()
class Meta:
model = Module
@@ -96,6 +97,9 @@ class ModuleNode(DjangoObjectType):
def resolve_chapters(self, info, **kwargs):
return Chapter.get_by_parent(self)
+ def resolve_solutions_enabled(self, info, **kwargs):
+ return self.solutions_enabled_by.filter(pk=info.context.user.pk).exists()
+
def resolve_objective_groups(self, info, **kwargs):
user = info.context.user
school_classes = user.school_classes.values_list('pk')