Add solution visibility check to survey
This commit is contained in:
parent
2af5749311
commit
e10b577ac1
|
|
@ -3,6 +3,9 @@ query SurveyQuery($id: ID!) {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
data
|
data
|
||||||
|
module {
|
||||||
|
id
|
||||||
|
}
|
||||||
answer {
|
answer {
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<h1 class="survey-page__title">{{title}}</h1>
|
<h1 class="survey-page__title">{{title}}</h1>
|
||||||
<survey :survey='survey'></survey>
|
<survey :survey='survey'></survey>
|
||||||
|
|
||||||
<solution :value="solution"></solution>
|
<solution :value="solution" v-if="module.solutionsEnabled"></solution>
|
||||||
<div v-if="surveyComplete">
|
<div v-if="surveyComplete">
|
||||||
<a class="button button--primary" @click="reopen">Übung bearbeiten</a>
|
<a class="button button--primary" @click="reopen">Übung bearbeiten</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
import {css} from '@/survey.config'
|
import {css} from '@/survey.config'
|
||||||
|
|
||||||
import SURVEY_QUERY from '@/graphql/gql/surveyQuery.gql';
|
import SURVEY_QUERY from '@/graphql/gql/surveyQuery.gql';
|
||||||
|
import MODULE_QUERY from '@/graphql/gql/moduleByIdQuery.gql';
|
||||||
import UPDATE_ANSWER from '@/graphql/gql/mutations/updateAnswer.gql';
|
import UPDATE_ANSWER from '@/graphql/gql/mutations/updateAnswer.gql';
|
||||||
import Solution from '@/components/content-blocks/Solution';
|
import Solution from '@/components/content-blocks/Solution';
|
||||||
|
|
||||||
|
|
@ -33,7 +34,8 @@
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
survey: this.initSurvey(),
|
survey: this.initSurvey(),
|
||||||
title: ''
|
title: '',
|
||||||
|
module: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -134,6 +136,14 @@
|
||||||
|
|
||||||
this.survey = this.initSurvey(json, answer);
|
this.survey = this.initSurvey(json, answer);
|
||||||
this.title = json.title;
|
this.title = json.title;
|
||||||
|
const module = data.survey.module;
|
||||||
|
|
||||||
|
this.$apollo.addSmartQuery('module', {
|
||||||
|
query: MODULE_QUERY,
|
||||||
|
variables: {
|
||||||
|
id: module.id
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,3 @@ class Module(StrictHierarchyPage):
|
||||||
|
|
||||||
def get_child_ids(self):
|
def get_child_ids(self):
|
||||||
return self.get_children().values_list('id', flat=True)
|
return self.get_children().values_list('id', flat=True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,8 @@ class ModuleNode(DjangoObjectType):
|
||||||
return self.get_parent().specific
|
return self.get_parent().specific
|
||||||
|
|
||||||
def resolve_solutions_enabled(self, info, **kwargs):
|
def resolve_solutions_enabled(self, info, **kwargs):
|
||||||
return self.solutions_enabled_by.filter(pk=info.context.user.pk).exists()
|
teacher = info.context.user.get_teacher()
|
||||||
|
return self.solutions_enabled_by.filter(pk=teacher.pk).exists() if teacher is not None else False
|
||||||
|
|
||||||
|
|
||||||
class TopicNode(DjangoObjectType):
|
class TopicNode(DjangoObjectType):
|
||||||
|
|
@ -187,7 +188,7 @@ class FilteredChapterNode(DjangoObjectType):
|
||||||
class BookQuery(object):
|
class BookQuery(object):
|
||||||
book = relay.Node.Field(BookNode)
|
book = relay.Node.Field(BookNode)
|
||||||
topic = graphene.Field(TopicNode, slug=graphene.String())
|
topic = graphene.Field(TopicNode, slug=graphene.String())
|
||||||
module = graphene.Field(ModuleNode, slug=graphene.String())
|
module = graphene.Field(ModuleNode, slug=graphene.String(), id=graphene.ID())
|
||||||
chapter = relay.Node.Field(FilteredChapterNode)
|
chapter = relay.Node.Field(FilteredChapterNode)
|
||||||
content_block = relay.Node.Field(ContentBlockNode)
|
content_block = relay.Node.Field(ContentBlockNode)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue