Skip to content
Snippets Groups Projects
Verified Commit c73a29a3 authored by Lukas Maximilian Kimpel's avatar Lukas Maximilian Kimpel
Browse files

Refactor id to contentId

Select first content (due to array as return paramter)
parent 94bc92cb
Branches
Tags
1 merge request!86Resolve "content types (classes)"
Pipeline #13454 passed with stage
in 33 seconds
...@@ -20,18 +20,12 @@ export class ContentAnswersListComponent implements OnInit { ...@@ -20,18 +20,12 @@ export class ContentAnswersListComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.route.params.subscribe(params => {
this.getContent(params['id']); this.getAnswerTexts(params['contentId']);
}); });
} }
getContent(id: string): void { getAnswerTexts(contentId: string): void {
this.contentService.getContent(id).subscribe(params => { this.contentAnswerService.getAnswerTexts(contentId)
this.getAnswerTexts(params['id']);
})
}
getAnswerTexts(id: string): void {
this.contentAnswerService.getAnswerTexts(id)
.subscribe(textAnswers => { .subscribe(textAnswers => {
this.textAnswers = textAnswers; this.textAnswers = textAnswers;
}); });
......
...@@ -24,6 +24,6 @@ export class ContentDetailComponent implements OnInit { ...@@ -24,6 +24,6 @@ export class ContentDetailComponent implements OnInit {
getContent(contentId: string): void { getContent(contentId: string): void {
this.contentService.getContent(contentId) this.contentService.getContent(contentId)
.subscribe(content => this.content = content); .subscribe(content => this.content = content[0]);
} }
} }
...@@ -29,10 +29,10 @@ export class ContentService extends ErrorHandlingService { ...@@ -29,10 +29,10 @@ export class ContentService extends ErrorHandlingService {
); );
} }
getContent(id: string): Observable<Content> { getContent(contentId: string): Observable<Content> {
const url = `${this.contentUrl}/${id}`; const url = `${this.contentUrl}/?contentId=${contentId}`;
return this.http.get<Content>(url).pipe( return this.http.get<Content>(url).pipe(
catchError(this.handleError<Content>(`getContent id=${id}`)) catchError(this.handleError<Content>(`getContent id=${contentId}`))
); );
} }
} }
...@@ -87,21 +87,21 @@ export class InMemoryDataService implements InMemoryDbService { ...@@ -87,21 +87,21 @@ export class InMemoryDataService implements InMemoryDbService {
const contents = [ const contents = [
{ {
id: '1', contentId: '1',
revision: '1', revision: '1',
roomId: '1', roomId: '1',
subject: 'Textaufgabe 1', subject: 'Text Content 1',
body: 'testcontent alpha beta', body: 'This is a body of a text content.',
round: 1, round: 1,
format: ContentType.TEXT format: ContentType.TEXT
}, },
{ {
id: '2', contentId: '2',
revision: '2', revision: '2',
roomId: '3', roomId: '3',
subject: 'Textaufgabe 2', subject: 'Text Content 2',
body: 'Ein Mann kauft 20 Melonen. Eine Melone wiegt jeweils 5kg. Berechnen Sie das Gesamtgewicht.', body: 'This is yet another body of a text content.',
round: 5, round: 2,
format: ContentType.TEXT format: ContentType.TEXT
} }
]; ];
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment