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