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(plugin-input-exercise): Add feedback placeholder text #2979

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/data/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@ export const loggedInData = {
unit: 'Unit',
addAnswer: 'Add answer',
enterTheValue: 'Enter the value',
feedbackPlaceholder: 'Add a feedback message for this answer',
yourSolution: 'Your solution',
types: {
'input-string-normalized-match-challenge': "Text (exact, e.g. 'tiger')",
Expand Down
10 changes: 9 additions & 1 deletion src/serlo-editor-integration/create-plugins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,15 @@ export function createPlugins({
{ type: EditorPluginType.H5p, plugin: H5pPlugin },
{
type: EditorPluginType.InputExercise,
plugin: createInputExercisePlugin({}),
plugin: createInputExercisePlugin({
feedback: {
plugin: EditorPluginType.Text,
config: {
placeholder:
editorStrings.templatePlugins.inputExercise.feedbackPlaceholder,
},
},
}),
},
{ type: EditorPluginType.Layout, plugin: layoutPlugin },
{ type: EditorPluginType.Rows, plugin: createRowsPlugin() },
Expand Down
12 changes: 6 additions & 6 deletions src/serlo-editor/plugins/input-exercise/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type InputExercisePluginState = ReturnType<
>

export interface InputExerciseConfig {
feedback?: ChildStateTypeConfig
feedback: ChildStateTypeConfig
}

export type InputExerciseProps = EditorPluginProps<
Expand All @@ -43,12 +43,12 @@ export type InputExerciseProps = EditorPluginProps<

const defaultFeedback = { plugin: EditorPluginType.Text }
AsterMiha marked this conversation as resolved.
Show resolved Hide resolved

export function createInputExercisePlugin({
feedback = defaultFeedback,
}): EditorPlugin<InputExercisePluginState, InputExerciseConfig> {
export function createInputExercisePlugin(
config: InputExerciseConfig = { feedback: defaultFeedback }
): EditorPlugin<InputExercisePluginState, InputExerciseConfig> {
return {
Component: InputExerciseEditor,
config: { feedback },
state: createInputExerciseState(feedback),
config: config,
state: createInputExerciseState(config.feedback),
}
}