From 48ac5cd28716d5a39cb6c86c40ba7ee983420faf Mon Sep 17 00:00:00 2001 From: jurei733 <67505990+jurei733@users.noreply.github.com> Date: Mon, 19 Oct 2026 12:26:38 +0200 Subject: [PATCH 1/4] Expose partial credit options in Schemer 2.9.0 --- README.md | 22 +++++++ package-lock.json | 18 +++--- package.json | 6 +- projects/ngx-coding-components/package.json | 8 +-- .../src/lib/services/schemer.service.spec.ts | 42 ++++++++++++++ .../src/lib/services/schemer.service.ts | 21 +++++-- .../lib/services/source-processing-label.ts | 8 +++ ...it-source-parameters-dialog.component.html | 5 +- ...source-parameters-dialog.component.spec.ts | 22 ++++++- ...edit-source-parameters-dialog.component.ts | 9 ++- .../partial-credit-dialog.component.spec.ts | 58 +++++++++++++++++++ .../lib/var-coding/var-coding.component.html | 2 +- .../var-coding/var-coding.component.spec.ts | 9 +++ .../lib/var-coding/var-coding.component.ts | 6 ++ .../translations/de.json | 5 ++ projects/schemer/src/html_wrapper/index.html | 4 +- sample-data/coding-scheme-valid.json | 2 +- scripts/validate-coding-scheme.test.js | 12 ++++ src/assets/de.json | 5 ++ src/assets/en.json | 5 ++ 20 files changed, 242 insertions(+), 27 deletions(-) create mode 100644 projects/ngx-coding-components/src/lib/services/source-processing-label.ts create mode 100644 projects/ngx-coding-components/src/lib/var-coding/dialogs/partial-credit-dialog.component.spec.ts diff --git a/README.md b/README.md index dcdbc6a8..de69f6a5 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,28 @@ Additionally, this library exports multiple dialogs and helpers (see “Public A # Installation (Angular) +## Partial credit (Schemer 2.9.0) + +In the source/derivation parameters of `SUM_SCORE`, `SUM_CODE` and `CONCAT_CODE`, +two independent options allow displayed source responses or empty invalid source +responses to contribute to a partially answered task. Both are disabled by +default. They require at least one regularly coded answer; completely +unprocessed tasks retain their original status, and pending coding is deferred. + +The contribution is `0` for sums and `x` for concatenated codes (`0_x`, distinct +from `0_0`). Only `null`, empty text and an empty list count as empty invalid +answers; `false` and `0` remain values. Original source responses are preserved. +The options, descriptions and `x` combinations survive scheme import/export. +Existing SOLVER policies are unchanged. + +This feature requires the coordinated releases `@iqbspecs/coding-scheme@3.5.0` +and `@iqb/responses@5.4.0`. The prepared lockfile identifies the locally built +release tarballs; these versions must be published before a fresh registry-based +`npm ci` can succeed. Publish the specification first, then responses, and then +build/release the Schemer and Angular library. Refresh lockfile integrity if the +published tarballs differ from the prepared artifacts. Local verification uses +the built packages from sibling `coding-scheme` and `responses` checkouts. + ## Schemer viewport support The Schemer supports container widths of **320 CSS pixels and above**, including diff --git a/package-lock.json b/package-lock.json index 81220a38..aff07202 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,8 +18,8 @@ "@angular/platform-browser-dynamic": "^21.2.23", "@angular/router": "^21.2.23", "@iqb/mathlive": "^0.4.1", - "@iqb/responses": "5.3.1", - "@iqbspecs/coding-scheme": "^3.4.1", + "@iqb/responses": "^5.4.0", + "@iqbspecs/coding-scheme": "^3.5.0", "@iqbspecs/response": "^2.0.0", "@iqbspecs/variable-info": "^1.3.0", "@ngx-translate/core": "^15.0.0", @@ -3798,21 +3798,21 @@ } }, "node_modules/@iqb/responses": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/@iqb/responses/-/responses-5.3.1.tgz", - "integrity": "sha512-pP5NL1OC2NupC07sg/IYFYFtOjbAVusKL0XT9yt78LB13pfZTq0EuxZBMRe6ITctBlVw9sf3alqN0W2w01/lVg==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/@iqb/responses/-/responses-5.4.0.tgz", + "integrity": "sha512-F8ZhNMlwe3Wx34Cnb3WH2r13WU13s4jGakyMDfIQn+tWmBTlmjpFVTK07IWOcTOXPYlYMhtwyFEqwA23cOVLMA==", "license": "CC0 1.0", "dependencies": { - "@iqbspecs/coding-scheme": "^3.4.1", + "@iqbspecs/coding-scheme": "^3.5.0", "@iqbspecs/response": "^2.0.0", "@iqbspecs/variable-info": "^1.3.0", "mathjs": "^15.1.0" } }, "node_modules/@iqbspecs/coding-scheme": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/@iqbspecs/coding-scheme/-/coding-scheme-3.4.1.tgz", - "integrity": "sha512-HEDuYhHFb74q01TFHxeZk3IDZPokPCSH8TGmo0v8wT4wdi6ACmrcsuKDD3o/TjkQGJMHKpn06HahiWOCpa4k3A==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/@iqbspecs/coding-scheme/-/coding-scheme-3.5.0.tgz", + "integrity": "sha512-9xCtuhX19u/ajGLQaEGfPVCOs3CCsXI6sTIyZd+pD50FDGUIcjYnRdriGvWaCL0GQsWDOVjHDhurb8SQEg0IiA==", "license": "CC0 1.0" }, "node_modules/@iqbspecs/response": { diff --git a/package.json b/package.json index cda1f5f4..46398441 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coding-components", "config": { - "schemer_version": "2.9.0-alpha.2" + "schemer_version": "2.9.0" }, "scripts": { "ng": "ng", @@ -49,8 +49,8 @@ "@angular/platform-browser-dynamic": "^21.2.23", "@angular/router": "^21.2.23", "@iqb/mathlive": "^0.4.1", - "@iqb/responses": "5.3.1", - "@iqbspecs/coding-scheme": "^3.4.1", + "@iqb/responses": "^5.4.0", + "@iqbspecs/coding-scheme": "^3.5.0", "@iqbspecs/response": "^2.0.0", "@iqbspecs/variable-info": "^1.3.0", "@ngx-translate/core": "^15.0.0", diff --git a/projects/ngx-coding-components/package.json b/projects/ngx-coding-components/package.json index 58e0f590..bffbc7c9 100644 --- a/projects/ngx-coding-components/package.json +++ b/projects/ngx-coding-components/package.json @@ -4,8 +4,8 @@ "exports": { "./lib/ngx-coding-components.module": "./lib/ngx-coding-components.module.d.ts" }, - "version": "4.1.0-alpha.2", - "author": "IQB - Institut zur Qualit\u00e4tsentwicklung im Bildungswesen", + "version": "4.1.0", + "author": "IQB - Institut zur Qualitätsentwicklung im Bildungswesen", "license": "MIT", "description": "Angular components for coding responses in assessments of IQB.", "repository": { @@ -28,7 +28,7 @@ "@angular/platform-browser": "^21.0.0", "@angular/platform-browser-dynamic": "^21.0.0", "@angular/router": "^21.0.0", - "@iqbspecs/coding-scheme": "^3.4.1", + "@iqbspecs/coding-scheme": "^3.5.0", "@iqbspecs/response": "^1.5.1 || ^2.0.0", "@iqbspecs/variable-info": "^1.3.0", "@ngx-translate/core": "^15.0.0", @@ -59,7 +59,7 @@ "ngx-tiptap": "^12.0.0", "prosemirror-state": "^1.3.4", "rxjs": "~7.8.0", - "@iqb/responses": "^5.3.1" + "@iqb/responses": "^5.4.0" }, "devDependencies": { "@angular-devkit/build-angular": "^21.2.24", diff --git a/projects/ngx-coding-components/src/lib/services/schemer.service.spec.ts b/projects/ngx-coding-components/src/lib/services/schemer.service.spec.ts index 78df52ab..485f799e 100644 --- a/projects/ngx-coding-components/src/lib/services/schemer.service.spec.ts +++ b/projects/ngx-coding-components/src/lib/services/schemer.service.spec.ts @@ -1,6 +1,7 @@ import { CodeData, CodeType, + SourceProcessingType, VariableCodingData } from '@iqbspecs/coding-scheme/coding-scheme.interface'; import { CodingSchemeFactory, CodingSchemeProblem } from '@iqb/responses'; @@ -417,6 +418,26 @@ describe('SchemerService', () => { expect(values.length).toBeGreaterThanOrEqual(2); }); + it('should retain four-source CONCAT_CODE combinations when partial credit is enabled', () => { + const sources: VariableCodingData[] = ['a', 'b', 'c', 'd'].map(id => ({ + id, + sourceType: 'BASE', + codes: [{ id: 0, type: 'NO_CREDIT', score: 0 }, { id: 1, type: 'FULL_CREDIT', score: 1 }] + })); + service.setCodingScheme({ variableCodings: sources } as unknown as never); + const derived: VariableCodingData = { + id: 'partial', sourceType: 'CONCAT_CODE', deriveSources: sources.map(source => source.id) + }; + expect(service.getVarInfoByCoding(derived)?.values.length).toBe(16); + derived.sourceParameters = { processing: ['TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL'] }; + const values = service.getVarInfoByCoding(derived)?.values.map(value => value.value); + expect(values?.length).toBe(80); + expect(values).toContain('1_1_1_1'); + expect(values).toContain('1_1_1_x'); + expect(values).toContain('0_x_x_x'); + expect(values).not.toContain('x_x_x_x'); + }); + it('should return CONCAT_CODE info with empty values list when combinations exceed limit', () => { const manyCodes = Array.from({ length: 10 }).map((_, idx) => ({ id: idx + 1, @@ -447,6 +468,27 @@ describe('SchemerService', () => { expect((info as unknown as { values: unknown[] }).values.length).toBe(0); }); + ['TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL', 'TAKE_EMPTY_AS_ZERO_IF_PARTIAL'].forEach(option => { + it(`should include partial CONCAT_CODE values for ${option} without inventing x_x`, () => { + const source: VariableCodingData = { + id: 'zero', sourceType: 'BASE', codes: [{ id: 0, type: 'NO_CREDIT', score: 0 }] + }; + service.setCodingScheme({ variableCodings: [source, { ...source, id: 'other' }] } as unknown as never); + const info = service.getVarInfoByCoding({ + id: 'partial', + sourceType: 'CONCAT_CODE', + deriveSources: ['zero', 'other'], + sourceParameters: { processing: [option as SourceProcessingType] } + }); + const values = info?.values.map(v => v.value); + expect(values).toContain('0_x'); + expect(values).toContain('x_0'); + expect(values).toContain('0_0'); + expect(values).not.toContain('x_x'); + expect(source.codes).toEqual([{ id: 0, type: 'NO_CREDIT', score: 0 }]); + }); + }); + it( 'should return integer synthetic VariableInfo for derive sources (non CONCAT_CODE) and undefined otherwise', () => { diff --git a/projects/ngx-coding-components/src/lib/services/schemer.service.ts b/projects/ngx-coding-components/src/lib/services/schemer.service.ts index 953629fa..8262ebff 100644 --- a/projects/ngx-coding-components/src/lib/services/schemer.service.ts +++ b/projects/ngx-coding-components/src/lib/services/schemer.service.ts @@ -170,20 +170,26 @@ export class SchemerService { } } else if (varCoding.sourceType === 'CONCAT_CODE') { if (varCoding.deriveSources && varCoding.deriveSources.length > 0) { - const codes: (number | 'INVALID' | 'INTENDED_INCOMPLETE')[][] = []; + const codes: (number | 'INVALID' | 'INTENDED_INCOMPLETE' | 'x')[][] = []; + const partialCredit = varCoding.sourceParameters?.processing?.some(p => ( + p === 'TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL' || p === 'TAKE_EMPTY_AS_ZERO_IF_PARTIAL' + )); let totalCodesCount = 0; varCoding.deriveSources.forEach((s: string) => { if (this.codingScheme) { const coding = this.codingScheme.variableCodings.find( v => v.id === s ); - codes.push(coding ? (coding.codes || []).map(c => c.id) : []); - totalCodesCount += coding ? (coding.codes || []).length : 0; + const sourceCodes: (number | 'INVALID' | 'INTENDED_INCOMPLETE' | 'x')[] = + coding ? (coding.codes || []).map(c => c.id) : []; + totalCodesCount += sourceCodes.length; + if (coding && partialCredit) sourceCodes.push('x'); + codes.push(sourceCodes); } }); let resultArray: string[] = []; if (totalCodesCount < 10) { - codes.forEach((c: (number | 'INVALID' | 'INTENDED_INCOMPLETE')[]) => { + codes.forEach(c => { if (resultArray.length > 0) { resultArray = resultArray.flatMap(oldEntry => c .filter(cEntry => cEntry !== null) @@ -198,6 +204,13 @@ export class SchemerService { } }); } + if (partialCredit) { + resultArray = resultArray.filter(value => value.split(DeriveConcatDelimiter).some(code => code !== 'x')); + if (varCoding.sourceParameters?.processing?.includes('SORT')) { + resultArray = [...new Set(resultArray.map(value => value.split(DeriveConcatDelimiter) + .sort().join(DeriveConcatDelimiter)))]; + } + } return { id: varCoding.id, alias: varCoding.alias, diff --git a/projects/ngx-coding-components/src/lib/services/source-processing-label.ts b/projects/ngx-coding-components/src/lib/services/source-processing-label.ts new file mode 100644 index 00000000..f9947757 --- /dev/null +++ b/projects/ngx-coding-components/src/lib/services/source-processing-label.ts @@ -0,0 +1,8 @@ +import { SourceProcessingType, SourceType } from '@iqbspecs/coding-scheme'; + +export function sourceProcessingLabelKey(processingId: SourceProcessingType, sourceType?: SourceType): string { + const concatPartial = sourceType === 'CONCAT_CODE' && ( + processingId === 'TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL' || processingId === 'TAKE_EMPTY_AS_ZERO_IF_PARTIAL' + ); + return `derive-processing.${processingId}${concatPartial ? '_CONCAT_CODE' : ''}`; +} diff --git a/projects/ngx-coding-components/src/lib/var-coding/dialogs/edit-source-parameters-dialog.component.html b/projects/ngx-coding-components/src/lib/var-coding/dialogs/edit-source-parameters-dialog.component.html index c6f85ed7..034afd01 100644 --- a/projects/ngx-coding-components/src/lib/var-coding/dialogs/edit-source-parameters-dialog.component.html +++ b/projects/ngx-coding-components/src/lib/var-coding/dialogs/edit-source-parameters-dialog.component.html @@ -48,10 +48,13 @@

{{ (newVariableMode ? 'varList.add' : 'derive-processing.pr @for (p of possibleDeriveProcessing; track p) { - {{ 'derive-processing.' + p | translate }} + {{ processingLabelKey(p) | translate }} } } + @if (data.sourceType === 'SUM_SCORE' || data.sourceType === 'SUM_CODE' || data.sourceType === 'CONCAT_CODE') { +

{{ 'derive-processing.partial-credit-help' | translate }}

+ } @if (data.sourceType === 'SOLVER') { {{ 'derive-processing.SOLVER_EXPRESSION' | translate }} diff --git a/projects/ngx-coding-components/src/lib/var-coding/dialogs/edit-source-parameters-dialog.component.spec.ts b/projects/ngx-coding-components/src/lib/var-coding/dialogs/edit-source-parameters-dialog.component.spec.ts index a4ecf8da..cdd825f2 100644 --- a/projects/ngx-coding-components/src/lib/var-coding/dialogs/edit-source-parameters-dialog.component.spec.ts +++ b/projects/ngx-coding-components/src/lib/var-coding/dialogs/edit-source-parameters-dialog.component.spec.ts @@ -146,7 +146,9 @@ describe('EditSourceParametersDialog', () => { it('updatePossibleDeriveProcessing should set options based on sourceType', () => { const dialog = createDialog({ sourceType: 'CONCAT_CODE' }); - expect(dialog.possibleDeriveProcessing).toEqual(['SORT']); + expect(dialog.possibleDeriveProcessing).toEqual([ + 'SORT', 'TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL', 'TAKE_EMPTY_AS_ZERO_IF_PARTIAL' + ]); (dialog.data as unknown as { sourceType: string }).sourceType = 'UNIQUE_VALUES'; dialog.updatePossibleDeriveProcessing(); @@ -157,6 +159,24 @@ describe('EditSourceParametersDialog', () => { expect(dialog.possibleDeriveProcessing).toEqual([]); }); + ['SUM_SCORE', 'SUM_CODE', 'CONCAT_CODE'].forEach(sourceType => { + it(`should offer opt-in partial credit for ${sourceType} and preserve the original on cancel`, () => { + const original = { processing: [] as string[] }; + const dialog = createDialog({ sourceType, sourceParameters: original }); + const option: SourceProcessingType = 'TAKE_EMPTY_AS_ZERO_IF_PARTIAL'; + expect(dialog.data.sourceParameters.processing).toEqual([]); + expect(dialog.possibleDeriveProcessing).toContain(option); + expect(dialog.processingLabelKey(option)).toBe( + `derive-processing.${option}${sourceType === 'CONCAT_CODE' ? '_CONCAT_CODE' : ''}` + ); + dialog.alterProcessing(option, true); + expect(dialog.data.sourceParameters.processing).toEqual([option]); + expect(original.processing).toEqual([]); + dialog.alterProcessing(option, false); + expect(dialog.data.sourceParameters.processing).toEqual([]); + }); + }); + it('updatePossibleNewSources should exclude selfAlias and BASE_NO_VALUE and set selectedSources', () => { const dialog = createDialog({ selfAlias: 'V1', diff --git a/projects/ngx-coding-components/src/lib/var-coding/dialogs/edit-source-parameters-dialog.component.ts b/projects/ngx-coding-components/src/lib/var-coding/dialogs/edit-source-parameters-dialog.component.ts index 9b0bf3e5..9bc0ca9d 100644 --- a/projects/ngx-coding-components/src/lib/var-coding/dialogs/edit-source-parameters-dialog.component.ts +++ b/projects/ngx-coding-components/src/lib/var-coding/dialogs/edit-source-parameters-dialog.component.ts @@ -35,6 +35,7 @@ import { import { Response } from '@iqbspecs/response/response.interface'; import { CodingFactory, CodingSchemeFactory } from '@iqb/responses'; import { SchemerService } from '../../services/schemer.service'; +import { sourceProcessingLabelKey } from '../../services/source-processing-label'; import { isValidVariableIdentifier } from '../../services/variable-identifier-validation'; @@ -397,7 +398,9 @@ export class EditSourceParametersDialog { 'TO_NUMBER', 'TO_LOWER_CASE' ], - CONCAT_CODE: ['SORT'] + CONCAT_CODE: ['SORT', 'TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL', 'TAKE_EMPTY_AS_ZERO_IF_PARTIAL'], + SUM_CODE: ['TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL', 'TAKE_EMPTY_AS_ZERO_IF_PARTIAL'], + SUM_SCORE: ['TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL', 'TAKE_EMPTY_AS_ZERO_IF_PARTIAL'] }; this.possibleDeriveProcessing = @@ -405,6 +408,10 @@ export class EditSourceParametersDialog { this.clearSolverTestResult(); } + processingLabelKey(processingId: SourceProcessingType): string { + return sourceProcessingLabelKey(processingId, this.data.sourceType); + } + alterProcessing(processingId: SourceProcessingType, checked: boolean): void { const processingList = this.data.sourceParameters.processing; if (!processingList) return; diff --git a/projects/ngx-coding-components/src/lib/var-coding/dialogs/partial-credit-dialog.component.spec.ts b/projects/ngx-coding-components/src/lib/var-coding/dialogs/partial-credit-dialog.component.spec.ts new file mode 100644 index 00000000..65b75196 --- /dev/null +++ b/projects/ngx-coding-components/src/lib/var-coding/dialogs/partial-credit-dialog.component.spec.ts @@ -0,0 +1,58 @@ +import { TestBed } from '@angular/core/testing'; +import { provideNoopAnimations } from '@angular/platform-browser/animations'; +import { MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { TranslateModule, TranslateService } from '@ngx-translate/core'; +import { SourceType } from '@iqbspecs/coding-scheme'; +import translations from '../../../../translations/de.json'; +import { SchemerService } from '../../services/schemer.service'; +import { EditSourceParametersDialog, EditSourceParametersDialogData } from './edit-source-parameters-dialog.component'; + +describe('rendered partial-credit source parameters', () => { + (['SUM_SCORE', 'SUM_CODE', 'CONCAT_CODE'] as SourceType[]).forEach(sourceType => { + it(`renders, toggles and isolates partial-credit settings for ${sourceType}`, async () => { + const original: EditSourceParametersDialogData = { + selfId: 'derived', + selfAlias: 'derived', + sourceType, + deriveSources: ['a'], + sourceParameters: { processing: [] } + }; + const service = new SchemerService(); + service.setCodingScheme({ variableCodings: [{ id: 'a', sourceType: 'BASE', codes: [] }] } as never); + await TestBed.configureTestingModule({ + imports: [EditSourceParametersDialog, TranslateModule.forRoot()], + providers: [ + provideNoopAnimations(), + { provide: MAT_DIALOG_DATA, useValue: original }, + { provide: SchemerService, useValue: service } + ] + }).compileComponents(); + const translate = TestBed.inject(TranslateService); + translate.setTranslation('de', translations); + translate.use('de'); + const fixture = TestBed.createComponent(EditSourceParametersDialog); + fixture.detectChanges(); + await fixture.whenStable(); + + const element: HTMLElement = fixture.nativeElement; + const checkboxIndex = sourceType === 'CONCAT_CODE' ? 1 : 0; + const inputs = element.querySelectorAll('mat-checkbox input'); + expect(inputs.length).toBe(sourceType === 'CONCAT_CODE' ? 3 : 2); + expect(inputs[checkboxIndex].checked).toBeFalse(); + expect(element.textContent).toContain(sourceType === 'CONCAT_CODE' ? 'durch x ersetzen' : 'als 0 werten'); + expect(element.textContent).toContain('mindestens eine regulär kodierte Teilantwort'); + inputs[checkboxIndex].click(); + fixture.detectChanges(); + expect(fixture.componentInstance.data.sourceParameters.processing).toContain('TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL'); + expect(original.sourceParameters.processing).toEqual([]); + inputs[checkboxIndex].click(); + fixture.detectChanges(); + expect(fixture.componentInstance.data.sourceParameters.processing).toEqual([]); + fixture.componentInstance.data.sourceType = 'SOLVER'; + fixture.componentInstance.updatePossibleDeriveProcessing(); + fixture.detectChanges(); + expect(element.querySelectorAll('mat-checkbox').length).toBe(0); + fixture.destroy(); + }); + }); +}); diff --git a/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.html b/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.html index bdba2340..ba1bf611 100644 --- a/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.html +++ b/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.html @@ -65,7 +65,7 @@ {
check -
{{ "derive-processing." + p | translate }}
+
{{ processingLabelKey(p) | translate }}
} diff --git a/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.spec.ts b/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.spec.ts index 4367d636..0d3f0cd8 100644 --- a/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.spec.ts +++ b/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.spec.ts @@ -28,6 +28,15 @@ describe('VarCodingComponent', () => { let setCodingToTextModeSpy: jasmine.Spy; let isProtectedBaseVariableSpy: jasmine.Spy; + it('describes CONCAT_CODE partials with x in the saved parameter summary', () => { + component.varCoding = { id: 'derived', sourceType: 'CONCAT_CODE', codes: [] }; + expect(component.processingLabelKey('TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL')) + .toBe('derive-processing.TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL_CONCAT_CODE'); + component.varCoding = { id: 'derived', sourceType: 'SUM_SCORE', codes: [] }; + expect(component.processingLabelKey('TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL')) + .toBe('derive-processing.TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL'); + }); + beforeEach(async () => { dialogOpenSpy = jasmine.createSpy('open').and.returnValue({ afterClosed: () => of(false) diff --git a/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.ts b/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.ts index 551101fc..5393a33b 100644 --- a/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.ts +++ b/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.ts @@ -34,6 +34,7 @@ import { MatDivider } from '@angular/material/divider'; import { CodingFactory } from '@iqb/responses/coding-factory'; import { VariableCodingData, + SourceProcessingType, CodeType } from '@iqbspecs/coding-scheme/coding-scheme.interface'; import { VariableInfo } from '@iqbspecs/variable-info/variable-info.interface'; @@ -42,6 +43,7 @@ import { ConfirmDialogData } from '../dialogs/confirm-dialog.component'; import { SchemerService } from '../services/schemer.service'; +import { sourceProcessingLabelKey } from '../services/source-processing-label'; import { ensureResidualAutoManualInstruction } from '../services/schemer-code-ops'; import { GenerateCodingDialogComponent, @@ -485,6 +487,10 @@ export class VarCodingComponent implements OnInit, OnDestroy, OnChanges { }); } + processingLabelKey(processingId: SourceProcessingType): string { + return sourceProcessingLabelKey(processingId, this.varCoding?.sourceType); + } + editSourceParameters() { if (this.schemerService.userRole !== 'RO' && this.varCoding) { const dialogRef = this.editSourceParametersDialog.open( diff --git a/projects/ngx-coding-components/translations/de.json b/projects/ngx-coding-components/translations/de.json index 2cf1a6e9..34e52a43 100644 --- a/projects/ngx-coding-components/translations/de.json +++ b/projects/ngx-coding-components/translations/de.json @@ -278,6 +278,11 @@ "TAKE_DISPLAYED_AS_VALUE_CHANGED": "Angezeigt = Wert geändert", "TAKE_NOT_REACHED_AS_VALUE_CHANGED": "Nicht erreicht = Wert geändert", "TAKE_EMPTY_AS_VALID": "Leerer Antwortwert ist gültig", + "TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL": "Angezeigte Quellantworten bei begonnener Bearbeitung als 0 werten", + "TAKE_EMPTY_AS_ZERO_IF_PARTIAL": "Leere ungültige Quellantworten bei begonnener Bearbeitung als 0 werten", + "TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL_CONCAT_CODE": "Angezeigte Quellantworten bei begonnener Bearbeitung durch x ersetzen", + "TAKE_EMPTY_AS_ZERO_IF_PARTIAL_CONCAT_CODE": "Leere ungültige Quellantworten bei begonnener Bearbeitung durch x ersetzen", + "partial-credit-help": "Der Ersatz erfolgt nur innerhalb dieser Ableitung und setzt mindestens eine regulär kodierte Teilantwort voraus. Vollständig unbearbeitete oder ausschließlich leere ungültige Antworten werden nicht automatisch bewertet. Ausstehende Kodierungen bleiben ausstehend. Als leer gelten null, leerer Text und leere Listen; false und 0 sind keine leeren Antworten.", "SORT": "Sortiere Werte", "SOLVER_EXPRESSION": "Ausdruck für Solver", "solver-source-warning": { diff --git a/projects/schemer/src/html_wrapper/index.html b/projects/schemer/src/html_wrapper/index.html index d8076c03..6f290c0e 100644 --- a/projects/schemer/src/html_wrapper/index.html +++ b/projects/schemer/src/html_wrapper/index.html @@ -21,8 +21,8 @@ "email": "iqb-tbadev@hu-berlin.de" }, "description": { - "de": "Dieser Schemer erlaubt die Definition eines Coding Scheme iqb-standard@3.2", - "en": "This schemer is for editing coding schemes of type iqb-standard@3.2" + "de": "Dieser Schemer erlaubt die Definition eines Coding Scheme iqb-standard@3.5", + "en": "This schemer is for editing coding schemes of type iqb-standard@3.5" }, "version": "version-placeholder", "apiVersion": "3.4.1", diff --git a/sample-data/coding-scheme-valid.json b/sample-data/coding-scheme-valid.json index ae8175f6..cd7c0787 100644 --- a/sample-data/coding-scheme-valid.json +++ b/sample-data/coding-scheme-valid.json @@ -1,4 +1,4 @@ { - "version": "3.4", + "version": "3.5", "variableCodings": [] } diff --git a/scripts/validate-coding-scheme.test.js b/scripts/validate-coding-scheme.test.js index 51bf14d0..13e9dac6 100644 --- a/scripts/validate-coding-scheme.test.js +++ b/scripts/validate-coding-scheme.test.js @@ -38,6 +38,18 @@ test('validates one coding-scheme file and reports schema errors', async t => { })); assert.equal(await validateScheme(schemeFile, output), 0); assert.match(messages.at(-1), /valid against schema/); + fs.writeFileSync(schemeFile, JSON.stringify({ + version: schemaVersion, + variableCodings: [{ + id: 'derived', + sourceType: 'CONCAT_CODE', + deriveSources: ['a', 'b'], + sourceParameters: { + processing: ['TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL', 'TAKE_EMPTY_AS_ZERO_IF_PARTIAL'] + } + }] + })); + assert.equal(await validateScheme(schemeFile, output), 0); assert.equal( await validateScheme('sample-data/coding-scheme-valid.json', output), 0 diff --git a/src/assets/de.json b/src/assets/de.json index bf62b85e..54dcc9db 100644 --- a/src/assets/de.json +++ b/src/assets/de.json @@ -112,6 +112,11 @@ "TAKE_DISPLAYED_AS_VALUE_CHANGED": "Angezeigt = Wert geändert", "TAKE_NOT_REACHED_AS_VALUE_CHANGED": "Nicht erreicht = Wert geändert", "TAKE_EMPTY_AS_VALID": "Leerer Antwortwert ist gültig", + "TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL": "Angezeigte Quellantworten bei begonnener Bearbeitung als 0 werten", + "TAKE_EMPTY_AS_ZERO_IF_PARTIAL": "Leere ungültige Quellantworten bei begonnener Bearbeitung als 0 werten", + "TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL_CONCAT_CODE": "Angezeigte Quellantworten bei begonnener Bearbeitung durch x ersetzen", + "TAKE_EMPTY_AS_ZERO_IF_PARTIAL_CONCAT_CODE": "Leere ungültige Quellantworten bei begonnener Bearbeitung durch x ersetzen", + "partial-credit-help": "Der Ersatz erfolgt nur innerhalb dieser Ableitung und setzt mindestens eine regulär kodierte Teilantwort voraus. Vollständig unbearbeitete oder ausschließlich leere ungültige Antworten werden nicht automatisch bewertet. Ausstehende Kodierungen bleiben ausstehend. Als leer gelten null, leerer Text und leere Listen; false und 0 sind keine leeren Antworten.", "SORT": "Sortiere Werte", "SOLVER_EXPRESSION": "Ausdruck für Solver", "solver-source-warning": { diff --git a/src/assets/en.json b/src/assets/en.json index 0582ce09..bc04a881 100644 --- a/src/assets/en.json +++ b/src/assets/en.json @@ -39,6 +39,11 @@ "TAKE_DISPLAYED_AS_VALUE_CHANGED": "Displayed = value changed", "TAKE_NOT_REACHED_AS_VALUE_CHANGED": "Not reached = value changed", "TAKE_EMPTY_AS_VALID": "Empty response value is valid", + "TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL": "Treat displayed source responses as 0 after processing has started", + "TAKE_EMPTY_AS_ZERO_IF_PARTIAL": "Treat empty invalid source responses as 0 after processing has started", + "TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL_CONCAT_CODE": "Replace displayed source responses with x after processing has started", + "TAKE_EMPTY_AS_ZERO_IF_PARTIAL_CONCAT_CODE": "Replace empty invalid source responses with x after processing has started", + "partial-credit-help": "Replacement applies only within this derivation and requires at least one regularly coded response. Entirely unprocessed responses or only empty invalid responses are not scored automatically. Pending codings remain pending. Empty means null, empty text or an empty list; false and 0 are not empty responses.", "SORT": "Sort values", "SOLVER_EXPRESSION": "Expression for solver", "solver-source-warning": { From b077b33f7720b92a0b6433bc2c2f762169cc6b8c Mon Sep 17 00:00:00 2001 From: jurei733 <67505990+jurei733@users.noreply.github.com> Date: Mon, 19 Oct 2026 12:36:34 +0200 Subject: [PATCH 2/4] Refresh generation values after source parameter edits --- .../var-coding/var-coding.component.spec.ts | 33 +++++++++++++++++++ .../lib/var-coding/var-coding.component.ts | 1 + 2 files changed, 34 insertions(+) diff --git a/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.spec.ts b/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.spec.ts index 0d3f0cd8..a8d5dc1d 100644 --- a/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.spec.ts +++ b/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.spec.ts @@ -75,6 +75,7 @@ describe('VarCodingComponent', () => { varList: [], codingScheme: { variableCodings: [{ id: 'b1', sourceType: 'BASE' }, { id: 'b2', sourceType: 'BASE' }] }, codingToTextMode: 'EXTENDED', + getVarInfoByCoding: jasmine.createSpy('getVarInfoByCoding').and.returnValue(undefined), addCode: addCodeSpy, canPasteSingleCodeInto: canPasteSpy, getPasteSingleCodeWarningKeys: getPasteWarningsSpy, @@ -741,6 +742,38 @@ describe('VarCodingComponent', () => { }); }); + it('editSourceParameters should refresh generation values immediately after enabling partial credit', () => { + const bases: VariableCodingData[] = ['b1', 'b2'].map(id => ({ + id, sourceType: 'BASE', codes: [{ id: 0, type: 'RESIDUAL_AUTO', score: 0 }] + })); + const derived: VariableCodingData = { + id: 'derived', + alias: 'derived', + sourceType: 'CONCAT_CODE', + deriveSources: ['b1', 'b2'], + sourceParameters: { processing: [] }, + codes: [] + }; + const actualService = new SchemerService(); + const scheme = { variableCodings: [...bases, derived] }; + actualService.setCodingScheme(scheme as never); + (schemerService as unknown as { codingScheme: typeof scheme }).codingScheme = scheme; + schemerService.getVarInfoByCoding = coding => actualService.getVarInfoByCoding(coding); + component.varCoding = derived; + component.updateVarInfo(); + expect(component.varInfo?.values.map(value => value.value)).toEqual(['0_0']); + dialogOpenSpy.and.returnValue({ + afterClosed: () => of({ + selfAlias: 'derived', + sourceType: 'CONCAT_CODE', + deriveSources: ['b1', 'b2'], + sourceParameters: { processing: ['TAKE_DISPLAYED_AS_ZERO_IF_PARTIAL'] } + }) + }); + component.editSourceParameters(); + expect(component.varInfo?.values.map(value => value.value)).toEqual(['0_0', '0_x', 'x_0']); + }); + it('editSourceParameters should apply dialog result and emit', () => { const emitSpy = spyOn(component.varCodingChanged, 'emit'); (schemerService as unknown as { userRole: string }).userRole = 'RW_MAXIMAL'; diff --git a/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.ts b/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.ts index 5393a33b..75f0f83e 100644 --- a/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.ts +++ b/projects/ngx-coding-components/src/lib/var-coding/var-coding.component.ts @@ -557,6 +557,7 @@ export class VarCodingComponent implements OnInit, OnDestroy, OnChanges { }); this.applySolverResidualAutoInstructionDefault(); + this.updateVarInfo(); this.varCodingChanged.emit(this.varCoding); } }); From f9bc27569ee13c0535d577ec15ece915aeeb8b24 Mon Sep 17 00:00:00 2001 From: jurei733 <67505990+jurei733@users.noreply.github.com> Date: Mon, 19 Oct 2026 13:18:35 +0200 Subject: [PATCH 3/4] Adapt partial credit dialog tests to zoneless rendering --- .../var-coding/dialogs/partial-credit-dialog.component.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/ngx-coding-components/src/lib/var-coding/dialogs/partial-credit-dialog.component.spec.ts b/projects/ngx-coding-components/src/lib/var-coding/dialogs/partial-credit-dialog.component.spec.ts index 65b75196..87c98395 100644 --- a/projects/ngx-coding-components/src/lib/var-coding/dialogs/partial-credit-dialog.component.spec.ts +++ b/projects/ngx-coding-components/src/lib/var-coding/dialogs/partial-credit-dialog.component.spec.ts @@ -50,7 +50,8 @@ describe('rendered partial-credit source parameters', () => { expect(fixture.componentInstance.data.sourceParameters.processing).toEqual([]); fixture.componentInstance.data.sourceType = 'SOLVER'; fixture.componentInstance.updatePossibleDeriveProcessing(); - fixture.detectChanges(); + fixture.changeDetectorRef.markForCheck(); + await fixture.whenStable(); expect(element.querySelectorAll('mat-checkbox').length).toBe(0); fixture.destroy(); }); From 8d11d5d9193cebbfe231b12a5adb72d5cb652c81 Mon Sep 17 00:00:00 2001 From: jurei733 <67505990+jurei733@users.noreply.github.com> Date: Mon, 19 Oct 2026 13:44:33 +0200 Subject: [PATCH 4/4] Use the stable Responses 5.4.0 package integrity --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index aff07202..c9bd3727 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3800,7 +3800,7 @@ "node_modules/@iqb/responses": { "version": "5.4.0", "resolved": "https://registry.npmjs.org/@iqb/responses/-/responses-5.4.0.tgz", - "integrity": "sha512-F8ZhNMlwe3Wx34Cnb3WH2r13WU13s4jGakyMDfIQn+tWmBTlmjpFVTK07IWOcTOXPYlYMhtwyFEqwA23cOVLMA==", + "integrity": "sha512-R2zShBS9tWavyL4081JGUyiHyeXBGWrOrymxhee0dDmrbACZuawYSgNEODOzGxhTa80QDoaQWwgwSz3Ysb0bHg==", "license": "CC0 1.0", "dependencies": { "@iqbspecs/coding-scheme": "^3.5.0",