Merge branch 'master' of bitbucket.org:iterativ/skillbox

This commit is contained in:
Christian Cueni 2018-10-09 09:57:35 +02:00
commit 6d988d3a5c
16 changed files with 166 additions and 77 deletions

View File

@ -0,0 +1,39 @@
<template>
<div class="assignment-with-submissions">
<h1 class="assignment-with-submissions__title">{{assignment.title}}</h1>
<student-submission class="assignment-with-submissions__submission"
v-for="(submission, index) in assignment.submissions"
:key="index"
:submission="submission"
>
</student-submission>
</div>
</template>
<script>
import StudentSubmission from '@/components/StudentSubmission';
export default {
props: ['assignment'],
components: {
StudentSubmission
}
}
</script>
<style scoped lang="scss">
@import "@/styles/_variables.scss";
@import "@/styles/_functions.scss";
.assignment-with-submissions {
&__title {
font-size: toRem(35px);
}
&__submission:first-of-type {
border-top: 1px solid $color-grey;
}
}
</style>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="student-submission"> <div class="student-submission">
<div class="student-submission__student-name"> <div class="student-submission__student-name">
{{submission.name}} {{name}}
</div> </div>
<div class="student-submission__entry"> <div class="student-submission__entry">
{{submission.text}} {{submission.text}}
@ -11,7 +11,14 @@
<script> <script>
export default { export default {
props: ['submission'] props: ['submission'],
computed: {
name() {
return this.submission && this.submission.student
? `${this.submission.student.firstName} ${this.submission.student.lastName}` : '';
}
}
} }
</script> </script>

View File

@ -1,14 +1,20 @@
<template> <template>
<div class="user-widget"> <div class="user-widget">
<img class="user-widget__avatar" :src="avatar"> <user-icon class="user-widget__avatar" :src="avatar"></user-icon>
<span class="user-widget__name">{{firstName}} {{lastName}}</span> <span class="user-widget__name">{{firstName}} {{lastName}}</span>
<span class="user-widget__date" v-if="date">{{date}}</span> <span class="user-widget__date" v-if="date">{{date}}</span>
</div> </div>
</template> </template>
<script> <script>
import UserIcon from '@/components/icons/UserIcon';
export default { export default {
props: ['firstName', 'lastName', 'avatar', 'date'] props: ['firstName', 'lastName', 'avatar', 'date'],
components: {
UserIcon
}
} }
</script> </script>

View File

@ -0,0 +1,8 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<path
d="M50,0A50.12,50.12,0,0,0,.07,46.65S0,48.23,0,50s.07,3.25.07,3.36A50,50,0,1,0,50,0ZM24.14,86V79.84A15.18,15.18,0,0,1,39.31,64.67H60.69A15.18,15.18,0,0,1,75.86,79.84V86a44.27,44.27,0,0,1-51.72,0Zm57.47-5V79.84A20.94,20.94,0,0,0,60.69,58.93H39.31A20.94,20.94,0,0,0,18.39,79.84v1.31a44.4,44.4,0,1,1,63.22-.06Z"/>
<path
d="M50,20.26A17.54,17.54,0,1,0,67.55,37.81,17.57,17.57,0,0,0,50,20.26ZM50,49.6a11.8,11.8,0,1,1,11.81-11.8A11.82,11.82,0,0,1,50,49.6Z"/>
</svg>
</template>

View File

@ -1,8 +1,14 @@
<template> <template>
<div> <div>
<nav class="module-navigation"> <nav class="module-navigation">
<h3 class="module-navigation__heading">Inhalte: {{module.metaTitle}}</h3> <div class="module-navigation__module-content">
<div class="module-navigation__anchors"> <router-link
tag="h3"
:to="moduleContentLink"
class="module-navigation__heading"
>Inhalte: {{module.metaTitle}}
</router-link>
<div class="module-navigation__anchors" v-if="onModulePage">
<a href="#" class="module-navigation__anchor module-navigation__anchor--active">Einleitung</a> <a href="#" class="module-navigation__anchor module-navigation__anchor--active">Einleitung</a>
<a href="#" v-scroll-to="'#objectives'" class="module-navigation__anchor">Lernziele</a> <a href="#" v-scroll-to="'#objectives'" class="module-navigation__anchor">Lernziele</a>
@ -12,17 +18,23 @@
:key="chapter.id">{{chapter.title}}</a> :key="chapter.id">{{chapter.title}}</a>
<a href="#" class="module-navigation__anchor">Lernzielkontrolle</a> <a href="#" class="module-navigation__anchor">Lernzielkontrolle</a>
</div> </div>
<router-link tag="h3" to="/module/submissions" class="module-navigation__heading">Ergebnisse: {{module.metaTitle}} </div>
<div class="module-navigation__module-submissions">
<router-link tag="h3" to="/module/submissions" class="module-navigation__heading">Ergebnisse:
{{module.metaTitle}}
</router-link> </router-link>
<div class="module-navigation__anchors"> <div class="module-navigation__anchors">
<router-link <router-link
to="/module/geld/submissions" :to="submissionsLink(assignment)"
v-for="assignment in module.assignments" v-for="assignment in module.assignments"
:key="assignment.id" :key="assignment.id"
class="module-navigation__anchor" class="module-navigation__anchor"
exact-active-class="module-navigation__anchor--active"
>{{assignment.title}} >{{assignment.title}}
</router-link> </router-link>
</div> </div>
</div>
</nav> </nav>
</div> </div>
@ -37,6 +49,15 @@
module: moduleQuery module: moduleQuery
}, },
computed: {
onModulePage() {
return this.$route.name === 'module';
},
moduleContentLink() {
return `/module/${this.module.slug}`;
}
},
data() { data() {
return { return {
module: {} module: {}
@ -46,6 +67,9 @@
methods: { methods: {
chapterId(index) { chapterId(index) {
return `#chapter-${index}` return `#chapter-${index}`
},
submissionsLink(assignment) {
return `/module/${this.module.slug}/submissions/${assignment.id}`;
} }
} }
} }
@ -65,15 +89,20 @@
position: sticky; position: sticky;
top: 32px; top: 32px;
&__module-content {
margin-bottom: 18px;
}
&__heading { &__heading {
@include module-navigation-typography; @include module-navigation-typography;
margin: 0; margin: 0;
font-size: 1.0625rem; font-size: 1.0625rem;
cursor: pointer;
} }
&__anchors { &__anchors {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 16px 24px; padding: 16px 24px 0;
} }
&__anchor { &__anchor {
@include module-navigation-typography; @include module-navigation-typography;

View File

@ -41,8 +41,8 @@
update: (store, {data: {addRoom: {room}}}) => { update: (store, {data: {addRoom: {room}}}) => {
try { try {
const data = store.readQuery({query: ROOMS_QUERY}); const data = store.readQuery({query: ROOMS_QUERY});
if (data.allRooms) { if (data.rooms) {
data.allRooms.edges.push({ data.rooms.edges.push({
node: room, node: room,
__typename: 'RoomNode' __typename: 'RoomNode'
}); });

View File

@ -60,7 +60,7 @@
try { try {
if (success) { if (success) {
const data = store.readQuery({query: ROOMS_QUERY}); const data = store.readQuery({query: ROOMS_QUERY});
data.allRooms.edges.splice(data.allRooms.edges.findIndex(edge => edge.node.id === id), 1); data.rooms.edges.splice(data.rooms.edges.findIndex(edge => edge.node.id === id), 1);
store.writeQuery({query: ROOMS_QUERY, data}); store.writeQuery({query: ROOMS_QUERY, data});
} }
} catch (e) { } catch (e) {

View File

@ -0,0 +1,14 @@
query AssignmentWithSubmissions($id: ID!) {
assignment(id: $id) {
title
submissions {
id
text
document
student {
firstName
lastName
}
}
}
}

View File

@ -1,6 +1,6 @@
#import "./fragments/roomParts.gql" #import "./fragments/roomParts.gql"
query RoomsQuery { query RoomsQuery {
allRooms { rooms {
edges { edges {
node { node {
...RoomParts ...RoomParts

View File

@ -33,13 +33,10 @@
}, },
apollo: { apollo: {
roomQuery: { rooms: {
query: ROOMS_QUERY, query: ROOMS_QUERY,
manual: true, update(data) {
result({data, loading, networkStatus}) { return this.$getRidOfEdges(data).rooms
if (!loading) {
this.rooms = this.$getRidOfEdges(data).allRooms
}
} }
} }
}, },

View File

@ -1,61 +1,49 @@
<template> <template>
<div class="submissions-page"> <div class="submissions-page">
<h1 class="submissions-page__title">Auftrag 2 - Aufgabe Interview</h1> <assignment-with-submissions v-if="!$apollo.queries.assignment.loading"
:assignment="assignment"></assignment-with-submissions>
<student-submission class="submissions-page__submission"
v-for="(submission, index) in submissions"
:key="index"
:submission="submission"
>
</student-submission>
</div> </div>
</template> </template>
<script> <script>
import StudentSubmission from '@/components/StudentSubmission'; import AssignmentWithSubmissions from '@/components/AssignmentWithSubmissions';
import ASSIGNMENT_WITH_SUBMISSIONS_QUERY from '@/graphql/gql/assignmentWithSubmissionsQuery.gql';
export default { export default {
components: { components: {
StudentSubmission AssignmentWithSubmissions
},
apollo: {
assignment() {
return {
query: ASSIGNMENT_WITH_SUBMISSIONS_QUERY,
variables() {
return {
id: this.$route.params.id
}
},
update(result) {
return result.assignment;
}
}
},
}, },
data() { data() {
return { return {
submissions: [ assignment: {
{name: 'Hans Muster', text: 'Äusserlich erkennbare Schäden bitten wir sofort bei Lieferung…'}, submissions: []
{name: 'Max Steiner', text: 'Als Kommentar wird eine meinungsbildende und… '}, }
{name: 'Corinne Stalder', text: 'interview-LG.pdf'},
{name: 'Hans Muster', text: 'Äusserlich erkennbare Schäden bitten wir sofort bei Lieferung…'},
{name: 'Max Steiner', text: 'Als Kommentar wird eine meinungsbildende und… '},
{name: 'Corinne Stalder', text: 'interview-LG.pdf'},
{name: 'Hans Muster', text: 'Äusserlich erkennbare Schäden bitten wir sofort bei Lieferung…'},
{name: 'Max Steiner', text: 'Als Kommentar wird eine meinungsbildende und… '},
{name: 'Corinne Stalder', text: 'interview-LG.pdf'},
{name: 'Hans Muster', text: 'Äusserlich erkennbare Schäden bitten wir sofort bei Lieferung…'},
{name: 'Max Steiner', text: 'Als Kommentar wird eine meinungsbildende und… '},
{name: 'Corinne Stalder', text: 'interview-LG.pdf'}
]
} }
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import "@/styles/_variables.scss";
@import "@/styles/_functions.scss";
.submissions-page { .submissions-page {
/*grid-column: span 2;*/
width: 800px; width: 800px;
/*padding-left: 150px;*/
&__title {
font-size: toRem(35px);
}
&__submission:first-of-type {
border-top: 1px solid $color-grey;
}
} }
</style> </style>

View File

@ -28,7 +28,7 @@ const routes = [
meta: {filter: true} meta: {filter: true}
}, },
{ {
path: 'submissions', path: 'submissions/:id',
name: 'submissions', name: 'submissions',
component: submissions, component: submissions,
meta: {filter: true} meta: {filter: true}

View File

@ -1,5 +1,4 @@
from graphene import relay from graphene import relay
import graphene
from graphene_django.filter import DjangoFilterConnectionField from graphene_django.filter import DjangoFilterConnectionField
from assignments.schema.types import AssignmentNode from assignments.schema.types import AssignmentNode

View File

@ -23,5 +23,6 @@ class AssignmentNode(DjangoObjectType):
def resolve_submission(self, info, **kwargs): def resolve_submission(self, info, **kwargs):
return self.submissions.filter(student=info.context.user).first() # returns None if it doesn't exist yet return self.submissions.filter(student=info.context.user).first() # returns None if it doesn't exist yet
#todo: restrict for students
def resolve_submissions(self, info, **kwargs): def resolve_submissions(self, info, **kwargs):
return self.submissions.all() return self.submissions.all()

View File

@ -44,7 +44,7 @@ class RoomsQuery(object):
room_entry = relay.Node.Field(RoomEntryNode) room_entry = relay.Node.Field(RoomEntryNode)
room = graphene.Field(RoomNode, slug=graphene.String(), id=graphene.ID(), appearance=graphene.String()) room = graphene.Field(RoomNode, slug=graphene.String(), id=graphene.ID(), appearance=graphene.String())
all_rooms = DjangoFilterConnectionField(RoomNode) rooms = DjangoFilterConnectionField(RoomNode)
all_room_entries = DjangoFilterConnectionField(RoomEntryNode) all_room_entries = DjangoFilterConnectionField(RoomEntryNode)
def resolve_room(self, info, **kwargs): def resolve_room(self, info, **kwargs):

View File

@ -29,7 +29,8 @@ class UserNode(DjangoObjectType):
# todo: wayyyy to complicated, do we need such a sophisticated role system? # todo: wayyyy to complicated, do we need such a sophisticated role system?
def resolve_role(self, info, **kwargs): def resolve_role(self, info, **kwargs):
return self.userschoolrole_set.first().school_role.key role = self.userschoolrole_set.first()
return role.school_role.key if role is not None else 'student'
class SchoolClassNode(DjangoObjectType): class SchoolClassNode(DjangoObjectType):