upload documents in user assignment
This commit is contained in:
parent
b870c4b35c
commit
8420d8aab1
|
|
@ -34,7 +34,8 @@
|
||||||
<div
|
<div
|
||||||
class="assignment__file-upload"
|
class="assignment__file-upload"
|
||||||
v-if="inputType === 'file'">
|
v-if="inputType === 'file'">
|
||||||
File Input goes here
|
<p>{{assignment.submission.document}}</p>
|
||||||
|
<button @click="documentTestClick">just click me</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -51,7 +52,8 @@
|
||||||
import ASSIGNMENT_QUERY from '@/graphql/gql/assignmentQuery.gql';
|
import ASSIGNMENT_QUERY from '@/graphql/gql/assignmentQuery.gql';
|
||||||
import UPDATE_ASSIGNMENT_MUTATION from '@/graphql/gql/mutations/updateAssignmentMutation.gql';
|
import UPDATE_ASSIGNMENT_MUTATION from '@/graphql/gql/mutations/updateAssignmentMutation.gql';
|
||||||
import UPDATE_ASSIGNMENT_MUTATION_WITH_SUCCESS from '@/graphql/gql/mutations/updateAssignmentMutationWithSuccess.gql';
|
import UPDATE_ASSIGNMENT_MUTATION_WITH_SUCCESS from '@/graphql/gql/mutations/updateAssignmentMutationWithSuccess.gql';
|
||||||
import debounce from 'debounce';
|
import debounce from 'lodash/debounce';
|
||||||
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
|
|
||||||
import FinalSubmission from '@/components/content-blocks/assignment/FinalSubmission';
|
import FinalSubmission from '@/components/content-blocks/assignment/FinalSubmission';
|
||||||
import SubmissionForm from '@/components/content-blocks/assignment/SubmissionForm';
|
import SubmissionForm from '@/components/content-blocks/assignment/SubmissionForm';
|
||||||
|
|
@ -74,14 +76,15 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
_save: debounce(function (answer) {
|
_save: debounce(function () {
|
||||||
this.$apollo.mutate({
|
this.$apollo.mutate({
|
||||||
mutation: UPDATE_ASSIGNMENT_MUTATION_WITH_SUCCESS,
|
mutation: UPDATE_ASSIGNMENT_MUTATION_WITH_SUCCESS,
|
||||||
variables: {
|
variables: {
|
||||||
input: {
|
input: {
|
||||||
assignment: {
|
assignment: {
|
||||||
id: this.assignment.id,
|
id: this.assignment.id,
|
||||||
answer: answer
|
answer: this.assignment.submission.text,
|
||||||
|
document: this.assignment.submission.document,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -95,13 +98,12 @@
|
||||||
We update the assignment on this component, so the changes are reflected on it. The server does not return
|
We update the assignment on this component, so the changes are reflected on it. The server does not return
|
||||||
the updated entity, to prevent the UI to update when the user is entering his input
|
the updated entity, to prevent the UI to update when the user is entering his input
|
||||||
*/
|
*/
|
||||||
this.assignment = Object.assign({}, this.assignment, {
|
this.assignment.submission.text = answer;
|
||||||
submission: {
|
this._save();
|
||||||
...this.submission,
|
},
|
||||||
text: answer
|
documentTestClick() {
|
||||||
}
|
this.assignment.submission.document = 'https://google.ch';
|
||||||
});
|
this._save();
|
||||||
this._save(answer);
|
|
||||||
},
|
},
|
||||||
turnIn() {
|
turnIn() {
|
||||||
this.$apollo.mutate({
|
this.$apollo.mutate({
|
||||||
|
|
@ -116,6 +118,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
initialSubmission() {
|
||||||
|
return {
|
||||||
|
text: '',
|
||||||
|
document: '',
|
||||||
|
final: false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -127,21 +136,22 @@
|
||||||
id: this.value.id
|
id: this.value.id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
result ({ data }) {
|
||||||
|
this.assignment = cloneDeep(data.assignment);
|
||||||
|
this.assignment.submission = Object.assign(this.initialSubmission(), this.assignment.submission);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
assignment: {
|
assignment: {
|
||||||
submission: {
|
submission: this.initialSubmission(),
|
||||||
text: '',
|
|
||||||
final: false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
inputType: 'text',
|
inputType: 'text',
|
||||||
unsaved: false
|
unsaved: false
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,6 @@ fragment AssignmentParts on AssignmentNode {
|
||||||
id
|
id
|
||||||
text
|
text
|
||||||
final
|
final
|
||||||
|
document
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,5 @@ from graphene import InputObjectType
|
||||||
class AssignmentInput(InputObjectType):
|
class AssignmentInput(InputObjectType):
|
||||||
id = graphene.ID(required=True)
|
id = graphene.ID(required=True)
|
||||||
answer = graphene.String(required=True)
|
answer = graphene.String(required=True)
|
||||||
|
document = graphene.String()
|
||||||
final = graphene.Boolean()
|
final = graphene.Boolean()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
from graphene import relay
|
|
||||||
import graphene
|
import graphene
|
||||||
|
from graphene import relay
|
||||||
|
|
||||||
from api.utils import get_object
|
from api.utils import get_object
|
||||||
from assignments.models import Assignment
|
from assignments.models import Assignment
|
||||||
|
|
@ -20,7 +20,8 @@ class UpdateAssignment(relay.ClientIDMutation):
|
||||||
assignment_data = kwargs.get('assignment')
|
assignment_data = kwargs.get('assignment')
|
||||||
assignment = get_object(Assignment, assignment_data.get('id'))
|
assignment = get_object(Assignment, assignment_data.get('id'))
|
||||||
(submission, created) = assignment.submissions.get_or_create(student=info.context.user)
|
(submission, created) = assignment.submissions.get_or_create(student=info.context.user)
|
||||||
submission.text = assignment_data.get('answer')
|
submission.text = assignment_data.get('answer', '')
|
||||||
|
submission.document = assignment_data.get('document', '')
|
||||||
final = assignment_data.get('final')
|
final = assignment_data.get('final')
|
||||||
if final is not None:
|
if final is not None:
|
||||||
submission.final = final
|
submission.final = final
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue