From f26490b95dc9b25ababb27966fb7742dd427c47a Mon Sep 17 00:00:00 2001 From: jurei733 Date: Wed, 17 Jun 2026 06:17:51 +0200 Subject: [PATCH] Add residual auto manual instructions --- .../src/lib/services/schemer-code-ops.spec.ts | 10 +++ .../src/lib/services/schemer-code-ops.ts | 14 ++-- .../src/lib/translations/de.json | 2 +- .../var-coding/code-instruction.component.ts | 7 +- .../lib/var-coding/single-code.component.html | 16 ++--- .../var-coding/single-code.component.spec.ts | 67 +++++++++++++++++++ .../lib/var-coding/single-code.component.ts | 35 +++++++++- .../lib/var-coding/var-coding.component.html | 1 + .../var-coding/var-coding.component.spec.ts | 22 ++++++ .../lib/var-coding/var-coding.component.ts | 12 ++++ src/assets/de.json | 4 +- 11 files changed, 173 insertions(+), 17 deletions(-) create mode 100644 projects/ngx-coding-components/src/lib/var-coding/single-code.component.spec.ts diff --git a/projects/ngx-coding-components/src/lib/services/schemer-code-ops.spec.ts b/projects/ngx-coding-components/src/lib/services/schemer-code-ops.spec.ts index 515cd40..03fabbe 100644 --- a/projects/ngx-coding-components/src/lib/services/schemer-code-ops.spec.ts +++ b/projects/ngx-coding-components/src/lib/services/schemer-code-ops.spec.ts @@ -1,5 +1,6 @@ import { CodeData, CodeType } from '@iqbspecs/coding-scheme/coding-scheme.interface'; import { + DEFAULT_RESIDUAL_MANUAL_INSTRUCTION, addCode, canEdit, canPasteSingleCodeInto, @@ -123,9 +124,18 @@ describe('schemer-code-ops', () => { const list: CodeData[] = []; const created = addCode(list, 'RESIDUAL', 'RW_MAXIMAL', orderOfCodeTypes) as CodeData; expect(created.id).toBe(0); + expect(created.manualInstruction).toBe(DEFAULT_RESIDUAL_MANUAL_INSTRUCTION); expect(list.length).toBe(1); }); + it('should create RESIDUAL_AUTO with default manualInstruction', () => { + const list: CodeData[] = []; + const created = addCode(list, 'RESIDUAL_AUTO', 'RW_MAXIMAL', orderOfCodeTypes) as CodeData; + + expect(created.type).toBe('RESIDUAL_AUTO'); + expect(created.manualInstruction).toBe(DEFAULT_RESIDUAL_MANUAL_INSTRUCTION); + }); + it('should create INTENDED_INCOMPLETE with id 0 and empty manualInstruction', () => { const list: CodeData[] = []; const created = addCode(list, 'INTENDED_INCOMPLETE', 'RW_MAXIMAL', orderOfCodeTypes) as CodeData; diff --git a/projects/ngx-coding-components/src/lib/services/schemer-code-ops.ts b/projects/ngx-coding-components/src/lib/services/schemer-code-ops.ts index 5d0a462..a971b2b 100644 --- a/projects/ngx-coding-components/src/lib/services/schemer-code-ops.ts +++ b/projects/ngx-coding-components/src/lib/services/schemer-code-ops.ts @@ -14,6 +14,15 @@ const residualTypes: CodeType[] = [ 'INTENDED_INCOMPLETE' ]; +export const DEFAULT_RESIDUAL_MANUAL_INSTRUCTION = + '

Alle anderen Antworten

'; + +export const ensureResidualAutoManualInstruction = (code: CodeData): boolean => { + if (code.type !== 'RESIDUAL_AUTO' || code.manualInstruction) return false; + code.manualInstruction = DEFAULT_RESIDUAL_MANUAL_INSTRUCTION; + return true; +}; + export const canEdit = (userRole: UserRoleType): boolean => ['RW_MINIMAL', 'RW_MAXIMAL'].includes(userRole); export const copySingleCode = (code: CodeData | null | undefined): CodeData | null => { @@ -72,10 +81,7 @@ export const addCode = ( score: 0, ruleSetOperatorAnd: true, ruleSets: [], - manualInstruction: - codeType === 'RESIDUAL_AUTO' ? - '' : - '

Alle anderen Antworten

' + manualInstruction: DEFAULT_RESIDUAL_MANUAL_INSTRUCTION }; codeList.push(newCode); diff --git a/projects/ngx-coding-components/src/lib/translations/de.json b/projects/ngx-coding-components/src/lib/translations/de.json index 55736fb..47c6963 100644 --- a/projects/ngx-coding-components/src/lib/translations/de.json +++ b/projects/ngx-coding-components/src/lib/translations/de.json @@ -274,7 +274,7 @@ "title": "Instruktionen für manuelles Kodieren", "prompt-edit": "Instruktionen für manuelles Kodieren ändern", "wipe": "Instruktionen komplett löschen", - "error-residual-auto": "Wenn ein automatischer Code für 'Alle anderen Antworten' definiert ist, werden manuelle Instruktionen nie genutzt.", + "error-residual-auto": "Im normalen automatischen Fall für 'Alle anderen Antworten' werden manuelle Instruktionen nicht genutzt.", "error-intended-incomplete": "Wenn ein automatischer Code für 'Absichtlich unvollständig' definiert ist, werden manuelle Instruktionen nie genutzt." }, "coding": { diff --git a/projects/ngx-coding-components/src/lib/var-coding/code-instruction.component.ts b/projects/ngx-coding-components/src/lib/var-coding/code-instruction.component.ts index 9316e35..de49ab9 100644 --- a/projects/ngx-coding-components/src/lib/var-coding/code-instruction.component.ts +++ b/projects/ngx-coding-components/src/lib/var-coding/code-instruction.component.ts @@ -36,7 +36,11 @@ import { renderManualInstructionMath } from '../rich-text-editor/manual-instruct > edit - @if ((hasResidualAutoCode) && code.manualInstruction) { + @if ( + (hasResidualAutoCode) && + !suppressResidualAutoWarning && + code.manualInstruction + ) { @if (codeType === 'FULL_CREDIT') { done_all @@ -182,32 +182,32 @@ (codeRulesChanged)="setCodeChanged()" > - } @else if (codeModel === 'MANUAL_ONLY' && (code.type !== 'RESIDUAL_AUTO' && - code.type !== 'INTENDED_INCOMPLETE')) { + } @else if (codeModel === 'MANUAL_ONLY' && showManualOnlyInstruction()) { } - @if ((codeModel ?? 'NONE') === 'NONE' || codeModel === 'MANUAL_AND_RULES') { @if (code.type && (code.type === - 'RESIDUAL_AUTO' || code.type === 'INTENDED_INCOMPLETE') && - !code.manualInstruction) { -
- } @else { + @if ((codeModel ?? 'NONE') === 'NONE' || codeModel === 'MANUAL_AND_RULES') { + @if (showSideInstruction()) { + } @else { +
} }