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