Skip to content
Snippets Groups Projects
Commit b9f5e930 authored by HUSS THEOPHILE's avatar HUSS THEOPHILE
Browse files

:twisted_rightwards_arrows: merge Feature/47 route api community

Merge branch 'feature/47-route-api-community' into 'develop'
parents 809f8d45 ede7fea6
1 merge request!48Feature/47 route api community
Pipeline #303431 passed with stages
in 50 seconds
......@@ -2,12 +2,12 @@
<input (keyup)="filter()" [(ngModel)]="filterText" matInput type="text" placeholder="Search a quiz" />
<table mat-table [dataSource]="listQuizDataSource">
<ng-container matColumnDef="Component">
<td mat-cell *matCellDef="let quiz" (click)="clickOnQuiz(quiz.codeQuiz)">
<td mat-cell *matCellDef="let quiz" (click)="clickOnQuiz(quiz.id)">
<app-quiz-list-detail
[title]="quiz.title"
[nbQuestions]="quiz.nbQuestions"
[difficulty]="quiz.difficulty"
[creator]="quiz.creator"
[title]="quiz.id"
[nbQuestions]="quiz.questions.length"
[difficulty]="quiz.difficulty.name"
[creator]="quiz.author ?? 'Anonymous'"
></app-quiz-list-detail>
</td>
</ng-container>
......
......@@ -30,13 +30,13 @@ export class ListQuizComponent implements OnInit {
loadData() {
this.communityService.getCommunityQuiz(this.skip, this.take, this.filterText).subscribe({
next: (data: any) => {
this.listQuizDataSource.data = data.body.quizzes;
this.totalQuiz = data.body.total;
console.log('data: ', data);
this.listQuizDataSource.data = data;
this.totalQuiz = data.length;
},
});
}
clickOnQuiz(codeQuiz: string) {
console.log('codeQuiz: ', codeQuiz);
this.clickedQuiz = codeQuiz;
}
filter() {
......
......@@ -33,17 +33,17 @@ export class QuizDetailComponent implements OnInit, OnChanges {
loadQuizData() {
this.communityService.getQuizInformations(this.codeQuiz).subscribe({
next: (data: any) => {
this.title = data.body.title;
this.description = data.body.description;
this.nbQuestions = data.body.nbQuestions;
this.difficulty = data.body.difficulty;
this.nbPlayed = data.body.nbPlayed;
this.creator = data.body.creator;
this.title = data.name;
this.description = data.description;
this.nbQuestions = data.questions.length;
this.difficulty = data.difficulty.name;
this.nbPlayed = 12548;
this.creator = data.authorId ?? 'Anonymous';
},
});
this.showDetails = true;
}
playQuiz() {
this.router.navigate(['/play-quiz'], { queryParams: { code_quiz: this.codeQuiz } });
this.router.navigate(['/play-quiz'], { queryParams: { idQuiz: this.codeQuiz } });
}
}
......@@ -6,44 +6,12 @@ import { Observable, of } from 'rxjs';
providedIn: 'root',
})
export class CommunityService {
private apiUrl = 'http://klebert-host.com:33036';
private apiUrl = 'https://klebert-host.com:33037';
constructor(private http: HttpClient) {}
getCommunityQuiz(skip: number, take: number, filter: string) {
//return this.http.get(`${this.apiUrl}/quiz/`, { params: { skip: skip, take: take, filter: filter } });
return of({
body: {
quizzes: [
{
codeQuiz: 'AMSOE',
title: 'Titre du quiz',
nbQuestions: 20,
difficulty: 'hard',
creator: 'vexorit',
},
{
codeQuiz: 'JFOSKZ',
title: 'Titre du quiz2',
nbQuestions: 28,
difficulty: 'easy',
creator: 'vexorit',
},
],
total: 2,
},
});
return this.http.get(`${this.apiUrl}/quiz/all`, { params: { skip: skip, take: take, filter: filter } });
}
getQuizInformations(codeQuiz: string) {
//return this.http.get(`${this.apiUrl}/quiz/${codeQuiz}/short`);
return of({
body: {
codeQuiz: 'AMSOE',
title: 'Titre du quiz',
description: 'Ceci est un quiz avec une description',
nbQuestions: 20,
nbPlayed: 18293,
difficulty: 'hard',
creator: 'vexorit',
},
});
return this.http.post(`${this.apiUrl}/quiz/remaining`, { id: codeQuiz });
}
}
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