diff --git a/apps/backend/src/app/database/services/person.service.ts b/apps/backend/src/app/database/services/person.service.ts index 16a58af69..6d85b323f 100644 --- a/apps/backend/src/app/database/services/person.service.ts +++ b/apps/backend/src/app/database/services/person.service.ts @@ -356,7 +356,6 @@ export class PersonService { private extractSubforms(parsedResponses: Chunk[]): TcMergeSubForms[] { return parsedResponses - .filter(chunk => chunk?.id === 'elementCodes') .map(chunk => { try { const chunkContent: TcMergeResponse[] = JSON.parse(chunk.content); @@ -417,7 +416,7 @@ export class PersonService { subforms, chunks: [ { - id: 'elementCodes', + id: parsedResponses[0]?.id || '', type: parsedResponses[0]?.responseType || '', ts: parsedResponses[0]?.ts || 0, variables: Array.from(variables) @@ -541,7 +540,6 @@ export class PersonService { ); } - // Process units if they exist if (Array.isArray(booklet.units) && booklet.units.length > 0) { // Process units in batches to improve performance const batchSize = 10; @@ -765,14 +763,6 @@ export class PersonService { return booklet; } - /** - * Process logs for persons - * @param persons The persons to process logs for - * @param unitLogs The unit logs to process - * @param bookletLogs The booklet logs to process - * @param overwriteExistingLogs Whether to overwrite existing logs - * @returns A summary of the processing results - */ async processPersonLogs( persons: Person[], unitLogs: any, diff --git a/apps/backend/src/app/database/services/workspace-test-results.service.ts b/apps/backend/src/app/database/services/workspace-test-results.service.ts index f9f3c9a92..e50cca701 100644 --- a/apps/backend/src/app/database/services/workspace-test-results.service.ts +++ b/apps/backend/src/app/database/services/workspace-test-results.service.ts @@ -288,45 +288,59 @@ export class WorkspaceTestResultsService { }, relations: ['responses'] }); - const mappedResponses = unit.responses - .filter(response => response.subform === 'elementCodes') - .map(response => { - let value = response.value; - if (typeof value === 'string') { - if (value.startsWith('[') && value.endsWith(']')) { - try { - value = JSON.parse(value); - } catch (e) { - // If parsing fails, keep the original value - this.logger.warn(`Failed to parse JSON array: ${value}`); - } - } else if (value.startsWith('{') && value.endsWith('}')) { - try { - const jsonArrayString = value.replace(/^\{/, '[').replace(/\}$/, ']'); - value = JSON.parse(jsonArrayString); - } catch (e) { - // If parsing fails, keep the original value - this.logger.warn(`Failed to parse curly brace array: ${value}`); - } + + const responsesBySubform = {}; + + unit.responses.forEach(response => { + let value = response.value; + if (typeof value === 'string') { + if (value.startsWith('[') && value.endsWith(']')) { + try { + value = JSON.parse(value); + } catch (e) { + // If parsing fails, keep the original value + this.logger.warn(`Failed to parse JSON array: ${value}`); + } + } else if (value.startsWith('{') && value.endsWith('}')) { + try { + const jsonArrayString = value.replace(/^\{/, '[').replace(/\}$/, ']'); + value = JSON.parse(jsonArrayString); + } catch (e) { + // If parsing fails, keep the original value + this.logger.warn(`Failed to parse curly brace array: ${value}`); } } + } - return { - id: response.variableid, - value: value, - status: response.status - }; - }); + const mappedResponse = { + id: response.variableid, + value: value, + status: response.status + }; - const uniqueResponses = mappedResponses.filter( - (response, index, self) => index === self.findIndex(r => r.id === response.id) - ); + const subformKey = response.subform || 'elementCodes'; - return { - responses: [{ - id: 'elementCodes', + if (!responsesBySubform[subformKey]) { + responsesBySubform[subformKey] = []; + } + + responsesBySubform[subformKey].push(mappedResponse); + }); + + // Create responses array with unique responses for each subform + const responsesArray = Object.keys(responsesBySubform).map(subform => { + const uniqueResponses = responsesBySubform[subform].filter( + (response, index, self) => index === self.findIndex(r => r.id === response.id) + ); + + return { + id: subform === 'default' ? 'elementCodes' : subform, content: uniqueResponses - }] + }; + }); + + return { + responses: responsesArray }; } @@ -449,7 +463,6 @@ export class WorkspaceTestResultsService { }); } - async deleteUnit( workspaceId: number, unitId: number diff --git a/apps/frontend/src/app/components/home/home.component.html b/apps/frontend/src/app/components/home/home.component.html index 1f2cd1a8f..dc4a4c794 100755 --- a/apps/frontend/src/app/components/home/home.component.html +++ b/apps/frontend/src/app/components/home/home.component.html @@ -9,7 +9,7 @@ [appTitle]="'Web application for coding'" [introHtml]="'appService.appConfig.introHtml'" [appName]="'IQB-Kodierbox'" - [appVersion]="'0.8.0'" + [appVersion]="'0.8.1'" [userName]="authData.userName" [userLongName]="appService.userProfile.firstName + ' ' + appService.userProfile.lastName" [isUserLoggedIn]="Number(authData.userId) > 0" diff --git a/apps/frontend/src/app/replay/components/unit-player/unit-player.component.ts b/apps/frontend/src/app/replay/components/unit-player/unit-player.component.ts index e56883fd4..49382344b 100755 --- a/apps/frontend/src/app/replay/components/unit-player/unit-player.component.ts +++ b/apps/frontend/src/app/replay/components/unit-player/unit-player.component.ts @@ -124,7 +124,6 @@ export class UnitPlayerComponent implements AfterViewInit, OnChanges, OnDestroy }, {} ); } - if (this.iFrameElement) { const unitPlayerContent = unitPlayerChange?.currentValue || this.unitPlayer() || ''; this.updateIframeContent(unitPlayerContent.replace(/"/g, '')); diff --git a/package-lock.json b/package-lock.json index d54ee07a7..0765b35bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coding-box", - "version": "0.8.0", + "version": "0.8.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coding-box", - "version": "0.8.0", + "version": "0.8.1", "license": "MIT", "dependencies": { "@angular/animations": "20.0.3", diff --git a/package.json b/package.json index a2fc0cb40..a394f8bef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coding-box", - "version": "0.8.0", + "version": "0.8.1", "author": "IQB - Institut zur Qualitätsentwicklung im Bildungswesen", "license": "MIT", "scripts": {