Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow deletion of all activities independent of status and distinguish between hard and soft deletion in backend #4294

Merged
merged 8 commits into from
Oct 5, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ function GroupActivityElement({
),
}

const deletionItem = {
label: (
<div className="flex cursor-pointer flex-row items-center gap-1 text-red-600">
<FontAwesomeIcon icon={faTrashCan} className="w-[1.1rem]" />
<div>{t('manage.course.deleteGroupActivity')}</div>
</div>
),
onClick: () => setDeletionModal(true),
data: {
cy: `delete-groupActivity-${groupActivity.name}`,
},
}

return (
<div
className="border-uzh-grey-80 flex w-full flex-row justify-between rounded border border-solid p-2"
Expand Down Expand Up @@ -221,21 +234,7 @@ function GroupActivityElement({
}),
data: { cy: `edit-groupActivity-${groupActivity.name}` },
},
{
label: (
<div className="flex cursor-pointer flex-row items-center gap-1 text-red-600">
<FontAwesomeIcon
icon={faTrashCan}
className="w-[1.1rem]"
/>
<div>{t('manage.course.deleteGroupActivity')}</div>
</div>
),
onClick: () => setDeletionModal(true),
data: {
cy: `delete-groupActivity-${groupActivity.name}`,
},
},
deletionItem,
]}
triggerIcon={faHandPointer}
/>
Expand Down Expand Up @@ -287,6 +286,16 @@ function GroupActivityElement({
</div>
</Button>
)}
<Dropdown
data={{ cy: `groupActivity-actions-${groupActivity.name}` }}
className={{
item: 'p-1 hover:bg-gray-200',
viewport: 'bg-white',
}}
trigger={t('manage.course.otherActions')}
items={[deletionItem]}
triggerIcon={faHandPointer}
/>
</>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ function MicroLearningElement({
),
}

const deletionElement = {
label: (
<div className="flex cursor-pointer flex-row items-center gap-1 text-red-600">
<FontAwesomeIcon icon={faTrashCan} className="w-4" />
<div>{t('manage.course.deleteMicrolearning')}</div>
</div>
),
onClick: () => setDeletionModal(true),
data: { cy: `delete-microlearning-${microLearning.name}` },
}

return (
<div
className="border-uzh-grey-80 flex w-full flex-row justify-between rounded border border-solid p-2"
Expand Down Expand Up @@ -218,16 +229,7 @@ function MicroLearningElement({
cy: `duplicate-microlearning-${microLearning.name}`,
},
}),
{
label: (
<div className="flex cursor-pointer flex-row items-center gap-1 text-red-600">
<FontAwesomeIcon icon={faTrashCan} className="w-4" />
<div>{t('manage.course.deleteMicrolearning')}</div>
</div>
),
onClick: () => setDeletionModal(true),
data: { cy: `delete-microlearning-${microLearning.name}` },
},
deletionElement,
].flat()}
triggerIcon={faHandPointer}
/>
Expand Down Expand Up @@ -286,6 +288,7 @@ function MicroLearningElement({
cy: `unpublish-microlearning-${microLearning.name}`,
},
},
deletionElement,
].flat()}
triggerIcon={faHandPointer}
/>
Expand Down Expand Up @@ -389,6 +392,7 @@ function MicroLearningElement({
},
]
: []),
deletionElement,
].flat()}
triggerIcon={faHandPointer}
/>
Expand Down
29 changes: 15 additions & 14 deletions apps/frontend-manage/src/components/courses/PracticeQuizElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Dropdown } from '@uzh-bf/design-system'
import dayjs from 'dayjs'
import { useTranslations } from 'next-intl'
import { useRouter } from 'next/router'
import { useState } from 'react'
import React, { useState } from 'react'
import { WizardMode } from '../sessions/creation/ElementCreation'
import CopyConfirmationToast from '../toasts/CopyConfirmationToast'
import StatusTag from './StatusTag'
Expand Down Expand Up @@ -164,6 +164,17 @@ function PracticeQuizElement({
),
}

const deletionItem = {
label: (
<div className="flex cursor-pointer flex-row items-center gap-1 text-red-600">
<FontAwesomeIcon icon={faTrashCan} className="w-[1.1rem]" />
<div>{t('manage.course.deletePracticeQuiz')}</div>
</div>
),
onClick: () => setDeletionModal(true),
data: { cy: `delete-practice-quiz-${practiceQuiz.name}` },
}

return (
<div
className="border-uzh-grey-80 flex w-full flex-row justify-between rounded border border-solid p-2"
Expand Down Expand Up @@ -259,19 +270,7 @@ function PracticeQuizElement({
cy: `duplicate-practice-quiz-${practiceQuiz.name}`,
},
}),
{
label: (
<div className="flex cursor-pointer flex-row items-center gap-1 text-red-600">
<FontAwesomeIcon
icon={faTrashCan}
className="w-[1.1rem]"
/>
<div>{t('manage.course.deletePracticeQuiz')}</div>
</div>
),
onClick: () => setDeletionModal(true),
data: { cy: `delete-practice-quiz-${practiceQuiz.name}` },
},
deletionItem,
].flat()}
triggerIcon={faHandPointer}
/>
Expand Down Expand Up @@ -319,6 +318,7 @@ function PracticeQuizElement({
cy: `unpublish-practiceQuiz-${practiceQuiz.name}`,
},
},
deletionItem,
].flat()}
triggerIcon={faHandPointer}
/>
Expand Down Expand Up @@ -371,6 +371,7 @@ function PracticeQuizElement({
cy: `duplicate-practice-quiz-${practiceQuiz.name}`,
},
}),
deletionItem,
].flat()}
triggerIcon={faHandPointer}
/>
Expand Down
104 changes: 103 additions & 1 deletion cypress/cypress/e2e/G-microlearning-workflow.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,34 @@ describe('Different microlearning workflows', () => {
)
cy.get('[data-cy="read-content-element-2"]').click()
cy.get('[data-cy="practice-quiz-stack-submit"]').click()

cy.viewport('macbook-16')

// navigate to the lecturer view and delete the microlearning
cy.clearAllCookies()
cy.loginLecturer()
cy.get('[data-cy="courses"]').click()
cy.findByText(courseName).click()
cy.get('[data-cy="tab-microLearnings"]').click()
cy.get(`[data-cy="microlearning-actions-${microLearningName}"]`).click()
cy.get(`[data-cy="delete-microlearning-${microLearningName}"]`).click()
cy.get(`[data-cy="confirm-delete-microlearning"]`).click()
cy.get(`[data-cy="microlearning-actions-${microLearningName}"]`).should(
'not.exist'
)

// make sure that the microlearning is no longer accessible to students
cy.clearAllCookies()
cy.visit(Cypress.env('URL_STUDENT'))
cy.get('[data-cy="username-field"]')
.click()
.type(Cypress.env('STUDENT_USERNAME'))
cy.get('[data-cy="password-field"]')
.click()
.type(Cypress.env('STUDENT_PASSWORD'))
cy.get('[data-cy="submit-login"]').click()
cy.contains('[data-cy="microlearnings"]', microLearningDisplayName).should(
'not.exist'
)
})

it('creates and publishes a future micro learning that should not be visible to students and tests unpublishing it', () => {
Expand Down Expand Up @@ -434,6 +460,14 @@ describe('Different microlearning workflows', () => {
cy.get(`[data-cy="microlearning-${microLearningName}"]`).contains(
messages.shared.generic.draft
)

// delete the microlearning
cy.get(`[data-cy="microlearning-actions-${microLearningName}"]`).click()
cy.get(`[data-cy="delete-microlearning-${microLearningName}"]`).click()
cy.get(`[data-cy="confirm-delete-microlearning"]`).click()
cy.get(`[data-cy="microlearning-actions-${microLearningName}"]`).should(
'not.exist'
)
})

it('creates and publishes a past micro learning that should not be visible to students', () => {
Expand Down Expand Up @@ -533,6 +567,19 @@ describe('Different microlearning workflows', () => {
cy.contains('[data-cy="microlearnings"]', microLearningDisplayName).should(
'not.exist'
)

// navigate to the lecturer view and delete the microlearning
cy.clearAllCookies()
cy.loginLecturer()
cy.get('[data-cy="courses"]').click()
cy.findByText(courseName).click()
cy.get('[data-cy="tab-microLearnings"]').click()
cy.get(`[data-cy="microlearning-actions-${microLearningName}"]`).click()
cy.get(`[data-cy="delete-microlearning-${microLearningName}"]`).click()
cy.get(`[data-cy="confirm-delete-microlearning"]`).click()
cy.get(`[data-cy="microlearning-actions-${microLearningName}"]`).should(
'not.exist'
)
})

it('creates and edits a micro learning, which should then be accessible by students', () => {
Expand Down Expand Up @@ -804,6 +851,33 @@ describe('Different microlearning workflows', () => {
cy.get('[data-cy="practice-quiz-continue"]').click()
cy.wait(500)
cy.get('[data-cy="finish-microlearning"]').click()

// navigate to the lecturer view and delete the microlearning
cy.clearAllCookies()
cy.loginLecturer()
cy.get('[data-cy="courses"]').click()
cy.findByText(courseName).click()
cy.get('[data-cy="tab-microLearnings"]').click()
cy.get(`[data-cy="microlearning-actions-${newMicroLearningName}"]`).click()
cy.get(`[data-cy="delete-microlearning-${newMicroLearningName}"]`).click()
cy.get(`[data-cy="confirm-delete-microlearning"]`).click()
cy.get(`[data-cy="microlearning-actions-${newMicroLearningName}"]`).should(
'not.exist'
)

// make sure that the microlearning is no longer accessible to students
cy.clearAllCookies()
cy.visit(Cypress.env('URL_STUDENT'))
cy.get('[data-cy="username-field"]')
.click()
.type(Cypress.env('STUDENT_USERNAME'))
cy.get('[data-cy="password-field"]')
.click()
.type(Cypress.env('STUDENT_PASSWORD'))
cy.get('[data-cy="submit-login"]').click()
cy.contains('[data-cy="microlearnings"]', microLearningDisplayName).should(
'not.exist'
)
})

it('respond to a microlearning with all element types', () => {
Expand Down Expand Up @@ -1350,6 +1424,34 @@ describe('Different microlearning workflows', () => {
cy.get('[data-cy="practice-quiz-continue"]').click()
cy.wait(500)
cy.get('[data-cy="finish-microlearning"]').click()

// navigate to the lecturer view and delete the microlearning
cy.clearAllCookies()
cy.loginLecturer()
cy.get('[data-cy="courses"]').click()
cy.findByText(courseName).click()
cy.get('[data-cy="tab-microLearnings"]').click()
cy.get(`[data-cy="microlearning-actions-${microLearningNameDupl}"]`).click()
cy.get(`[data-cy="delete-microlearning-${microLearningNameDupl}"]`).click()
cy.get(`[data-cy="confirm-delete-microlearning"]`).click()
cy.get(`[data-cy="microlearning-actions-${microLearningNameDupl}"]`).should(
'not.exist'
)

// make sure that the microlearning is no longer accessible to students
cy.clearAllCookies()
cy.visit(Cypress.env('URL_STUDENT'))
cy.get('[data-cy="username-field"]')
.click()
.type(Cypress.env('STUDENT_USERNAME'))
cy.get('[data-cy="password-field"]')
.click()
.type(Cypress.env('STUDENT_PASSWORD'))
cy.get('[data-cy="submit-login"]').click()
cy.contains(
'[data-cy="microlearnings"]',
microLearningDisplayNameDupl
).should('not.exist')
})

it('extends a seeded and running microlearning', () => {
Expand Down
Loading
Loading