Add read only on a per school class basis to assignments
This commit is contained in:
parent
b50ba068a0
commit
26cda08d94
|
|
@ -2,11 +2,15 @@ import mocks from '../../../fixtures/mocks';
|
||||||
|
|
||||||
const myText = 'Mein Feedback';
|
const myText = 'Mein Feedback';
|
||||||
|
|
||||||
const getOperations = ({readOnly}) => ({
|
const getOperations = ({readOnly, classReadOnly = false}) => ({
|
||||||
MeQuery: {
|
MeQuery: {
|
||||||
me: {
|
me: {
|
||||||
onboardingVisited: true,
|
onboardingVisited: true,
|
||||||
readOnly,
|
readOnly,
|
||||||
|
selectedClass: {
|
||||||
|
id: 'selectedClassId',
|
||||||
|
readOnly: classReadOnly
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
StudentSubmissions: {
|
StudentSubmissions: {
|
||||||
|
|
@ -57,6 +61,7 @@ describe('Assignment feedback read-only - Teacher', () => {
|
||||||
cy.isSubmissionReadOnly(myText);
|
cy.isSubmissionReadOnly(myText);
|
||||||
cy.getByDataCy('final-submission-reopen').should('not.exist');
|
cy.getByDataCy('final-submission-reopen').should('not.exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can edit', () => {
|
it('can edit', () => {
|
||||||
cy.mockGraphqlOps({
|
cy.mockGraphqlOps({
|
||||||
operations: getOperations({readOnly: false}),
|
operations: getOperations({readOnly: false}),
|
||||||
|
|
@ -66,4 +71,15 @@ describe('Assignment feedback read-only - Teacher', () => {
|
||||||
|
|
||||||
cy.getByDataCy('final-submission-reopen').should('exist');
|
cy.getByDataCy('final-submission-reopen').should('exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can not edit for inactive class', () => {
|
||||||
|
cy.mockGraphqlOps({
|
||||||
|
operations: getOperations({readOnly: false, classReadOnly: true}),
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.visit('submission/submission-id');
|
||||||
|
|
||||||
|
cy.isSubmissionReadOnly(myText);
|
||||||
|
cy.getByDataCy('final-submission-reopen').should('not.exist');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import mocks from '../../../fixtures/mocks';
|
|
||||||
import minimalModule from '../../../fixtures/module.minimal';
|
import minimalModule from '../../../fixtures/module.minimal';
|
||||||
|
|
||||||
const module = {
|
const module = {
|
||||||
|
|
@ -34,11 +33,15 @@ const module = {
|
||||||
|
|
||||||
const myText = 'submission text';
|
const myText = 'submission text';
|
||||||
|
|
||||||
const getOperations = ({final, readOnly}) => ({
|
const getOperations = ({final, readOnly, classReadOnly = false}) => ({
|
||||||
MeQuery: {
|
MeQuery: {
|
||||||
me: {
|
me: {
|
||||||
onboardingVisited: true,
|
onboardingVisited: true,
|
||||||
readOnly
|
readOnly,
|
||||||
|
selectedClass: {
|
||||||
|
id: 'selectedClassId',
|
||||||
|
readOnly: classReadOnly
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ModuleDetailsQuery: {
|
ModuleDetailsQuery: {
|
||||||
|
|
@ -58,14 +61,7 @@ const getOperations = ({final, readOnly}) => ({
|
||||||
|
|
||||||
describe('Assignments read-only - Student', () => {
|
describe('Assignments read-only - Student', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.fakeLogin('rahel.cueni', 'test');
|
cy.setup();
|
||||||
cy.server();
|
|
||||||
cy.task('getSchema').then(schema => {
|
|
||||||
cy.mockGraphql({
|
|
||||||
schema,
|
|
||||||
mocks
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can edit and turn in', () => {
|
it('can edit and turn in', () => {
|
||||||
|
|
@ -112,4 +108,14 @@ describe('Assignments read-only - Student', () => {
|
||||||
cy.getByDataCy('final-submission').should('exist');
|
cy.getByDataCy('final-submission').should('exist');
|
||||||
cy.getByDataCy('final-submission-reopen').should('not.exist');
|
cy.getByDataCy('final-submission-reopen').should('not.exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can not edit or turn in in inactive class', () => {
|
||||||
|
cy.mockGraphqlOps({
|
||||||
|
operations: getOperations({final: false, readOnly: false, classReadOnly: true})
|
||||||
|
});
|
||||||
|
cy.visit('module/module-with-assignment');
|
||||||
|
|
||||||
|
cy.isSubmissionReadOnly(myText);
|
||||||
|
cy.getByDataCy('final-submission-reopen').should('not.exist');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
:spellcheck-loading="spellcheckLoading"
|
:spellcheck-loading="spellcheckLoading"
|
||||||
:saved="!unsaved"
|
:saved="!unsaved"
|
||||||
:spellcheck="true"
|
:spellcheck="true"
|
||||||
:read-only="me.readOnly"
|
:read-only="me.readOnly || me.selectedClass.readOnly"
|
||||||
placeholder="Ergebnis erfassen"
|
placeholder="Ergebnis erfassen"
|
||||||
action="Ergebnis mit Lehrperson teilen"
|
action="Ergebnis mit Lehrperson teilen"
|
||||||
shared-msg="Das Ergebnis wurde mit der Lehrperson geteilt."
|
shared-msg="Das Ergebnis wurde mit der Lehrperson geteilt."
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import "@/styles/_helpers.scss";
|
@import "~styles/helpers";
|
||||||
|
|
||||||
.submission-form {
|
.submission-form {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
readOnly() {
|
readOnly() {
|
||||||
return this.me.readOnly;
|
return this.me.readOnly || this.me.selectedClass.readOnly;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue