Update exception
This commit is contained in:
parent
cfaa5c9a4f
commit
0ae9ccaa68
|
|
@ -22,7 +22,7 @@
|
|||
<submission-form
|
||||
:user-input="feedback"
|
||||
:saved="!unsaved"
|
||||
:read-only="me.readOnly"
|
||||
:read-only="readOnly"
|
||||
placeholder="Feedback erfassen"
|
||||
action="Feedback teilen"
|
||||
shared-msg="Dieses Feedback wurde geteilt."
|
||||
|
|
@ -63,29 +63,29 @@
|
|||
mixins: [me],
|
||||
components: {
|
||||
StudentSubmissionDocument,
|
||||
SubmissionForm
|
||||
SubmissionForm,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
studentSubmission: {
|
||||
assignment: {
|
||||
title: ''
|
||||
title: '',
|
||||
},
|
||||
student: {
|
||||
firstName: '',
|
||||
lastName: ''
|
||||
lastName: '',
|
||||
},
|
||||
text: '',
|
||||
document: '',
|
||||
submissionFeedback: {
|
||||
text: '',
|
||||
final: false
|
||||
}
|
||||
final: false,
|
||||
},
|
||||
},
|
||||
unsaved: false,
|
||||
saving: 0,
|
||||
emojis: ['👍', '👎', '🙂', '😐', '😕', '🙁', '😮', '😉', '🙄', '❕', '❔', '🧐', '🤩', '🤗', '🤬', '🤢']
|
||||
emojis: ['👍', '👎', '🙂', '😐', '😕', '🙁', '😮', '😉', '🙄', '❕', '❔', '🧐', '🤩', '🤗', '🤬', '🤢'],
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -102,8 +102,11 @@
|
|||
feedback() {
|
||||
return this.studentSubmission.submissionFeedback ? this.studentSubmission.submissionFeedback : {
|
||||
text: '',
|
||||
final: false
|
||||
final: false,
|
||||
};
|
||||
},
|
||||
readOnly() {
|
||||
return this.me.readOnly;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -113,7 +116,7 @@
|
|||
query: STUDENT_SUBMISSIONS_QUERY,
|
||||
variables() {
|
||||
return {
|
||||
id: this.$route.params.id
|
||||
id: this.$route.params.id,
|
||||
};
|
||||
},
|
||||
result({data: {studentSubmission}}) {
|
||||
|
|
@ -121,7 +124,7 @@
|
|||
this.create();
|
||||
}
|
||||
this.studentSubmission = cloneDeep(studentSubmission); // we don't want to update the value when the server updates
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
|
|
@ -140,10 +143,10 @@
|
|||
submissionFeedback: {
|
||||
studentSubmission: this.studentSubmission.id,
|
||||
text: this.studentSubmission.submissionFeedback.text,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
update: this.updateCache
|
||||
update: this.updateCache,
|
||||
}).then(() => {
|
||||
this.saving--;
|
||||
if (this.saving === 0) {
|
||||
|
|
@ -160,53 +163,52 @@
|
|||
this.updateFeedbackText(feedbackText);
|
||||
this._save();
|
||||
},
|
||||
create() {
|
||||
update({withText, text, final}) {
|
||||
if (this.readOnly) {
|
||||
this.$log.debug('read-only');
|
||||
return;
|
||||
}
|
||||
let mutation = withText ? UPDATE_FEEDBACK_WITH_TEXT_MUTATION : UPDATE_FEEDBACK_MUTATION;
|
||||
this.$apollo.mutate({
|
||||
mutation: UPDATE_FEEDBACK_WITH_TEXT_MUTATION,
|
||||
mutation,
|
||||
variables: {
|
||||
input: {
|
||||
submissionFeedback: {
|
||||
studentSubmission: this.studentSubmission.id,
|
||||
text: '',
|
||||
final: false
|
||||
}
|
||||
}
|
||||
text: text,
|
||||
final: final,
|
||||
},
|
||||
},
|
||||
},
|
||||
update: this.updateCache
|
||||
update: this.updateCache,
|
||||
});
|
||||
},
|
||||
create() {
|
||||
this.$log.debug('create');
|
||||
this.update({
|
||||
withText: true,
|
||||
text: '',
|
||||
final: false,
|
||||
});
|
||||
},
|
||||
turnIn() {
|
||||
this.$apollo.mutate({
|
||||
mutation: UPDATE_FEEDBACK_WITH_TEXT_MUTATION,
|
||||
variables: {
|
||||
input: {
|
||||
submissionFeedback: {
|
||||
studentSubmission: this.studentSubmission.id,
|
||||
text: this.studentSubmission.submissionFeedback.text,
|
||||
final: true
|
||||
}
|
||||
}
|
||||
},
|
||||
update: this.updateCache
|
||||
this.$log.debug('turnIn');
|
||||
this.update({
|
||||
withText: true,
|
||||
text: this.studentSubmission.submissionFeedback.text,
|
||||
final: true,
|
||||
});
|
||||
},
|
||||
reopen() {
|
||||
this.$log.debug('reopen');
|
||||
if (!this.studentSubmission.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$apollo.mutate({
|
||||
mutation: UPDATE_FEEDBACK_MUTATION,
|
||||
variables: {
|
||||
input: {
|
||||
submissionFeedback: {
|
||||
studentSubmission: this.studentSubmission.id,
|
||||
text: this.studentSubmission.submissionFeedback.text,
|
||||
final: false
|
||||
}
|
||||
}
|
||||
},
|
||||
update: this.updateCache
|
||||
this.update({
|
||||
withText: false,
|
||||
text: this.studentSubmission.submissionFeedback.text,
|
||||
final: false,
|
||||
});
|
||||
},
|
||||
updateCache(store, {data: {updateSubmissionFeedback: {successful, updatedSubmissionFeedback}}}) {
|
||||
|
|
@ -214,20 +216,20 @@
|
|||
if (successful) {
|
||||
const query = STUDENT_SUBMISSIONS_QUERY;
|
||||
const variables = {
|
||||
id: this.studentSubmission.id
|
||||
id: this.studentSubmission.id,
|
||||
};
|
||||
const data = store.readQuery({query, variables});
|
||||
|
||||
if (data) {
|
||||
if (!data.studentSubmission.submissionFeedback) {
|
||||
data.studentSubmission.submissionFeedback = {
|
||||
'__typename': 'SubmissionFeedbackNode'
|
||||
'__typename': 'SubmissionFeedbackNode',
|
||||
};
|
||||
}
|
||||
|
||||
data.studentSubmission.submissionFeedback = Object.assign({}, data.studentSubmission.submissionFeedback, {
|
||||
id: updatedSubmissionFeedback.id,
|
||||
final: updatedSubmissionFeedback.final
|
||||
final: updatedSubmissionFeedback.final,
|
||||
});
|
||||
|
||||
if (updatedSubmissionFeedback.text !== undefined) {
|
||||
|
|
@ -247,16 +249,15 @@
|
|||
},
|
||||
updateFeedbackText(text) {
|
||||
this.studentSubmission = Object.assign({}, this.studentSubmission, {
|
||||
submissionFeedback: Object.assign({}, this.studentSubmission.submissionFeedback, {text: text})
|
||||
submissionFeedback: Object.assign({}, this.studentSubmission.submissionFeedback, {text: text}),
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import "@/styles/_variables.scss";
|
||||
@import "@/styles/_functions.scss";
|
||||
@import "~styles/helpers";
|
||||
|
||||
.submission-page {
|
||||
&__content {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class UpdateAssignment(relay.ClientIDMutation):
|
|||
student = info.context.user
|
||||
|
||||
if student.read_only:
|
||||
raise NotImplementedError()
|
||||
raise PermissionError('No valid license')
|
||||
|
||||
try:
|
||||
(submission, _created) = assignment.submissions.get_or_create(student=student)
|
||||
|
|
@ -61,7 +61,7 @@ class UpdateSubmissionFeedback(relay.ClientIDMutation):
|
|||
raise PermissionDenied('Missing permissions')
|
||||
|
||||
if user.read_only:
|
||||
raise NotImplementedError()
|
||||
raise PermissionError('No valid license')
|
||||
|
||||
(submission_feedback, created) = SubmissionFeedback.objects.get_or_create(teacher=user,
|
||||
student_submission_id=student_submission_id)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from django.contrib.auth import get_user_model
|
|||
from django.contrib.auth.models import AbstractUser, Permission
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db import models
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from core.hep_client import HepClient, MYSKILLBOX_LICENSES
|
||||
|
|
|
|||
Loading…
Reference in New Issue