Skip to content

Commit

Permalink
Merge pull request #3653 from serlo/api-cohesive
Browse files Browse the repository at this point in the history
refactor: forget about cohesive
  • Loading branch information
elbotho authored Apr 16, 2024
2 parents fd5d3e5 + a57ec4c commit 2a251d9
Show file tree
Hide file tree
Showing 13 changed files with 237 additions and 277 deletions.
418 changes: 216 additions & 202 deletions apps/web/graphql.schema.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions apps/web/src/data/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1056,8 +1056,6 @@ export const loggedInData = {
removeExercise: 'Remove exercise',
addExercise: 'Add exercise',
kindOfExerciseGroup: 'Kind of exercise group',
notCohesive: 'not cohesive',
cohesive: 'cohesive',
addIntermediateTask: 'Add Intermediate Task',
removeIntermediateTask: 'Remove intermediate Task',
intermediateTask: 'Intermediate Task',
Expand Down
47 changes: 20 additions & 27 deletions apps/web/src/fetcher/graphql-types/operations.ts

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions apps/web/src/fetcher/query-fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export const sharedRevisionFragments = gql`
fragment coursePageRevision on CoursePageRevision {
alias
}
fragment exerciseGroupRevision on ExerciseGroupRevision {
cohesive
}
`

export const sharedEventFragments = gql`
Expand Down
7 changes: 0 additions & 7 deletions apps/web/src/fetcher/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ export const dataQuery = gql`
...exercise
}
... on ExerciseGroup {
currentRevision {
...exerciseGroupRevision
}
}
... on Course {
pages(trashed: false) {
alias
Expand Down Expand Up @@ -150,7 +144,6 @@ export const dataQuery = gql`
content
id
date
cohesive
}
licenseId
}
Expand Down
8 changes: 0 additions & 8 deletions apps/web/src/fetcher/revision/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ export const revisionQuery = gql`
}
}
}
... on ExerciseGroupRevision {
...exerciseGroupRevision
repository {
currentRevision {
...exerciseGroupRevision
}
}
}
... on VideoRevision {
...videoRevision
repository {
Expand Down
2 changes: 0 additions & 2 deletions apps/web/src/helper/ai-generated-exercises/data-conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ function createExerciseGroupDocument(
state: [createExerciseHeadingTextDocument(heading)],
},
exercises,
cohesive: false,
intermediateTasks: undefined,
},
}
Expand Down Expand Up @@ -365,7 +364,6 @@ export function transformEditorDataToExerciseGroup(
licenseId: license.id,
changes: '[KI generiert]: ',
revision: 0,
cohesive: false,
//@ts-expect-error ignoring this while exercise group migration is going on
content: JSON.stringify(
createExerciseGroupDocument(editorData.heading, editorData.exercises)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function getAdditionalInputData(
case UuidType.Exercise:
return {}
case UuidType.ExerciseGroup:
return { cohesive: data.cohesive === 'true' }
return {}
case UuidType.Video:
return {
title: getRequiredString(mutationStrings, 'title', data.title),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ export function convertEditorResponseToState(
changes: '',
revision,
content: serializeStaticDocument(parseStaticString(content)),
cohesive: uuid.currentRevision?.cohesive ?? false,
},
}
}
Expand Down Expand Up @@ -425,7 +424,6 @@ interface InputType {

export interface TextExerciseGroupSerializedState extends Entity {
__typename?: UuidType.ExerciseGroup
cohesive?: string
content: SerializedStaticState
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export function revisionResponseToResponse(
id,
content,
title,
cohesive: uuid.cohesive,
date,
},
taxonomyTerms: uuid.repository.taxonomyTerms,
Expand Down
5 changes: 0 additions & 5 deletions packages/editor/src/plugins/exercise-group/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
child,
list,
object,
boolean,
optional,
number,
} from '@editor/plugin'
Expand Down Expand Up @@ -36,10 +35,6 @@ const exerciseGroupState = object({
})
)
),
/* cohesive field would indicate whether the children of a grouped exercise are cohesive
this field might be used in the future, but currently it has no effect and can not be changed
*/
cohesive: boolean(false),
})

export type ExerciseGroupPluginState = typeof exerciseGroupState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
boolean,
type EditorPlugin,
type EditorPluginProps,
PrettyStaticState,
Expand All @@ -21,10 +20,6 @@ export const textExerciseGroupTypeState = entityType(
{
...entity,
content: editorContent(EditorPluginType.ExerciseGroup),
/* cohesive field would indicate whether the children of a grouped exercise are cohesive
this field might be used in the future, but currently it has no effect and can not be changed
*/
cohesive: boolean(false),
},
{}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { store, selectStaticDocument } from '@editor/store'
import { ROOT } from '@editor/store/root/constants'
import { TemplatePluginType } from '@editor/types/template-plugin-type'
import type { SupportedTypesSerializedState } from '@serlo/frontend/src/mutations/use-set-entity-mutation/types'
import { storeStateToLocalStorage } from '@serlo/frontend/src/serlo-editor-integration/components/local-storage-notice'
import { SaveContext } from '@serlo/frontend/src/serlo-editor-integration/context/save-context'
Expand All @@ -27,16 +26,6 @@ export function useHandleSave(
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const serialized = has('state', serializedRoot) ? serializedRoot.state : null

// Currently still needed
if (
serialized !== null &&
serializedRoot?.plugin === TemplatePluginType.TextExerciseGroup &&
has('cohesive', serialized)
) {
// backend can only handle string attributes
serialized.cohesive = String(serialized.cohesive)
}

const handleSave = (
notificationSubscription?: boolean,
emailSubscription?: boolean,
Expand Down

0 comments on commit 2a251d9

Please sign in to comment.