Make assignments read only in client
This commit is contained in:
parent
e4bb4cc9ee
commit
949f656079
|
|
@ -16,7 +16,6 @@ const module = {
|
||||||
},
|
},
|
||||||
id: 'bla-123',
|
id: 'bla-123',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
type: 'assignment',
|
type: 'assignment',
|
||||||
value: {
|
value: {
|
||||||
|
|
@ -35,10 +34,11 @@ const module = {
|
||||||
|
|
||||||
const myText = 'submission text';
|
const myText = 'submission text';
|
||||||
|
|
||||||
const operations = {
|
const getOperations = ({final, readOnly}) => ({
|
||||||
MeQuery: {
|
MeQuery: {
|
||||||
me: {
|
me: {
|
||||||
onboardingVisited: true,
|
onboardingVisited: true,
|
||||||
|
readOnly
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ModuleDetailsQuery: {
|
ModuleDetailsQuery: {
|
||||||
|
|
@ -48,13 +48,17 @@ const operations = {
|
||||||
assignment: {
|
assignment: {
|
||||||
submission: {
|
submission: {
|
||||||
text: myText,
|
text: myText,
|
||||||
final: false,
|
final,
|
||||||
document: '',
|
document: '',
|
||||||
submissionFeedback: null
|
submissionFeedback: null
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
|
|
||||||
|
Cypress.Commands.add('canNotReopen', () => {
|
||||||
|
cy.getByDataCy('final-submission-reopen').should('not.exist');
|
||||||
|
});
|
||||||
|
|
||||||
describe('Assignments read-only - Student', () => {
|
describe('Assignments read-only - Student', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
@ -63,20 +67,58 @@ describe('Assignments read-only - Student', () => {
|
||||||
cy.task('getSchema').then(schema => {
|
cy.task('getSchema').then(schema => {
|
||||||
cy.mockGraphql({
|
cy.mockGraphql({
|
||||||
schema,
|
schema,
|
||||||
mocks,
|
mocks
|
||||||
operations,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can not edit', () => {
|
it('can edit and turn in', () => {
|
||||||
|
cy.mockGraphqlOps({
|
||||||
|
operations: getOperations({final: false, readOnly: false})
|
||||||
|
});
|
||||||
cy.visit('module/module-with-assignment');
|
cy.visit('module/module-with-assignment');
|
||||||
|
|
||||||
cy.get('.submission-form__textarea').invoke('val').should('contain', myText);
|
cy.get('.submission-form__textarea').as('textarea');
|
||||||
cy.getByDataCy('submission-form-submit').should('not.exist');
|
|
||||||
|
cy.get('@textarea').invoke('val').should('contain', myText);
|
||||||
|
cy.get('@textarea').clear().type('Hello');
|
||||||
|
cy.get('@textarea').should('not.have.attr', 'readonly');
|
||||||
|
|
||||||
|
cy.getByDataCy('submission-form-submit').should('exist');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can not turn in', () => {
|
it('can not edit or turn in', () => {
|
||||||
cy.get('.not-implemented');
|
cy.mockGraphqlOps({
|
||||||
|
operations: getOperations({final: false, readOnly: true})
|
||||||
|
});
|
||||||
|
cy.visit('module/module-with-assignment');
|
||||||
|
|
||||||
|
cy.get('.submission-form__textarea--readonly').as('textarea');
|
||||||
|
|
||||||
|
cy.get('@textarea').invoke('val').should('contain', myText);
|
||||||
|
cy.get('@textarea').should('have.attr', 'readonly');
|
||||||
|
|
||||||
|
cy.getByDataCy('submission-form-submit').should('not.exist');
|
||||||
|
cy.canNotReopen();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can revoke turn in', () => {
|
||||||
|
cy.mockGraphqlOps({
|
||||||
|
operations: getOperations({final: true, readOnly: false})
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.visit('module/module-with-assignment');
|
||||||
|
cy.getByDataCy('final-submission').should('exist');
|
||||||
|
cy.getByDataCy('final-submission-reopen').should('exist');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can not revoke turn in', () => {
|
||||||
|
cy.mockGraphqlOps({
|
||||||
|
operations: getOperations({final: true, readOnly: true})
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.visit('module/module-with-assignment');
|
||||||
|
cy.getByDataCy('final-submission').should('exist');
|
||||||
|
cy.canNotReopen();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
:spellcheck-loading="spellcheckLoading"
|
:spellcheck-loading="spellcheckLoading"
|
||||||
:saved="!unsaved"
|
:saved="!unsaved"
|
||||||
:spellcheck="true"
|
:spellcheck="true"
|
||||||
|
:read-only="me.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."
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="final-submission">
|
<div
|
||||||
|
class="final-submission"
|
||||||
|
data-cy="final-submission">
|
||||||
<document-block
|
<document-block
|
||||||
:value="{url: userInput.document}"
|
:value="{url: userInput.document}"
|
||||||
class="final-submission__document"
|
class="final-submission__document"
|
||||||
|
|
@ -10,6 +12,8 @@
|
||||||
<span class="final-submission__explanation-text">{{ sharedMsg }}</span>
|
<span class="final-submission__explanation-text">{{ sharedMsg }}</span>
|
||||||
<a
|
<a
|
||||||
class="final-submission__reopen"
|
class="final-submission__reopen"
|
||||||
|
data-cy="final-submission-reopen"
|
||||||
|
v-if="showReopen"
|
||||||
@click="$emit('reopen')">Bearbeiten</a>
|
@click="$emit('reopen')">Bearbeiten</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -21,7 +25,20 @@
|
||||||
import {newLineToParagraph} from '@/helpers/text';
|
import {newLineToParagraph} from '@/helpers/text';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['userInput', 'sharedMsg'],
|
props: {
|
||||||
|
userInput: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
},
|
||||||
|
showReopen: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
sharedMsg: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
InfoIcon,
|
InfoIcon,
|
||||||
|
|
@ -37,9 +54,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import "@/styles/_variables.scss";
|
@import "~styles/helpers";
|
||||||
@import "@/styles/_mixins.scss";
|
|
||||||
@import "@/styles/_functions.scss";
|
|
||||||
|
|
||||||
.final-submission {
|
.final-submission {
|
||||||
&__text {
|
&__text {
|
||||||
|
|
@ -66,18 +81,21 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__explanation-icon {
|
&__explanation-icon {
|
||||||
width: 40px;
|
width: 40px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
fill: $color-brand;
|
fill: $color-brand;
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__explanation-text {
|
&__explanation-text {
|
||||||
color: $color-brand;
|
color: $color-brand;
|
||||||
font-family: $sans-serif-font-family;
|
font-family: $sans-serif-font-family;
|
||||||
font-weight: $font-weight-regular;
|
font-weight: $font-weight-regular;
|
||||||
margin-right: $medium-spacing;
|
margin-right: $medium-spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__reopen {
|
&__reopen {
|
||||||
@include small-text;
|
@include small-text;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,15 @@
|
||||||
<submission-input
|
<submission-input
|
||||||
:input-text="userInput.text"
|
:input-text="userInput.text"
|
||||||
:saved="saved"
|
:saved="saved"
|
||||||
:final="final"
|
:readonly="isReadOnly"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:reopen="reopenSubmission"
|
|
||||||
@input="saveInput"
|
@input="saveInput"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="submission-form-container__actions"
|
class="submission-form-container__actions"
|
||||||
v-if="!final">
|
v-if="!isReadOnly">
|
||||||
<button
|
<button
|
||||||
class="submission-form-container__submit button button--primary button--white-bg"
|
class="submission-form-container__submit button button--primary button--white-bg"
|
||||||
data-cy="submission-form-submit"
|
data-cy="submission-form-submit"
|
||||||
|
|
@ -46,7 +45,8 @@
|
||||||
<final-submission
|
<final-submission
|
||||||
:user-input="userInput"
|
:user-input="userInput"
|
||||||
:shared-msg="sharedMsg"
|
:shared-msg="sharedMsg"
|
||||||
v-if="final"
|
:show-reopen="!readOnly"
|
||||||
|
v-if="isReadOnly"
|
||||||
@reopen="$emit('reopen')"/>
|
@reopen="$emit('reopen')"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -65,6 +65,10 @@
|
||||||
action: String,
|
action: String,
|
||||||
reopen: Function,
|
reopen: Function,
|
||||||
document: String,
|
document: String,
|
||||||
|
readOnly: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
spellcheck: {
|
spellcheck: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
|
@ -87,6 +91,9 @@
|
||||||
final() {
|
final() {
|
||||||
return !!this.userInput && this.userInput.final;
|
return !!this.userInput && this.userInput.final;
|
||||||
},
|
},
|
||||||
|
isReadOnly() {
|
||||||
|
return this.final || this.readOnly;
|
||||||
|
},
|
||||||
allowsDocuments() {
|
allowsDocuments() {
|
||||||
return 'document' in this.userInput;
|
return 'document' in this.userInput;
|
||||||
},
|
},
|
||||||
|
|
@ -118,7 +125,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import '@/styles/_mixins.scss';
|
@import '~styles/helpers';
|
||||||
|
|
||||||
.submission-form-container {
|
.submission-form-container {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@
|
||||||
<textarea
|
<textarea
|
||||||
v-auto-grow
|
v-auto-grow
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:readonly="final"
|
:readonly="readonly"
|
||||||
:value="inputText"
|
:value="inputText"
|
||||||
|
:class="{'submission-form__textarea--readonly': readonly}"
|
||||||
rows="1"
|
rows="1"
|
||||||
class="submission-form__textarea"
|
class="submission-form__textarea"
|
||||||
@input="$emit('input', $event.target.value)"
|
@input="$emit('input', $event.target.value)"
|
||||||
|
|
@ -30,7 +31,7 @@
|
||||||
props: {
|
props: {
|
||||||
inputText: String,
|
inputText: String,
|
||||||
saved: Boolean,
|
saved: Boolean,
|
||||||
final: Boolean,
|
readonly: Boolean,
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'Ergebnis erfassen'
|
default: 'Ergebnis erfassen'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue