Uses correct url to deactivate a quiz when leaving it instead of removing it permanently

parent 9420e142
Pipeline #16329 passed with stages
in 5 minutes and 39 seconds
......@@ -144,6 +144,22 @@ describe('QuizApiService', () => {
expect(service).toBeTruthy();
}));
it('should deactivate an active quiz', inject([QuizApiService], (service: QuizApiService) => {
const quizName = 'test';
const quizDeactivateData = {
body: {
quizName,
privateKey: '123456789',
},
};
service.deactivateQuizAsOwner(quizDeactivateData).subscribe();
backend.expectOne(service.QUIZ_DEACTIVATE_DELETE_URL()).flush({});
expect(service).toBeTruthy();
}));
it('should generate a Demo Quiz', inject([QuizApiService], (service: QuizApiService) => {
const langKey = 'en';
......
......@@ -54,6 +54,10 @@ export class QuizApiService {
return `${DefaultSettings.httpApiEndpoint}/quiz`;
}
public QUIZ_DEACTIVATE_DELETE_URL(): string {
return `${DefaultSettings.httpApiEndpoint}/quiz/active`;
}
public QUIZ_GENERATE_DEMO_QUIZ_URL(languageKey: string): string {
return `${DefaultSettings.httpApiEndpoint}/quiz/generate/demo/${languageKey}`;
}
......@@ -118,6 +122,10 @@ export class QuizApiService {
return this.http.request<IMessage>('delete', this.QUIZ_DELETE_URL(), data);
}
public deactivateQuizAsOwner(data: object): Observable<IMessage> {
return this.http.request<IMessage>('delete', this.QUIZ_DEACTIVATE_DELETE_URL(), data);
}
public generateDemoQuiz(languageKey: string): Observable<IQuestionGroup> {
return this.http.get<IQuestionGroup>(this.QUIZ_GENERATE_DEMO_QUIZ_URL(languageKey));
}
......
......@@ -173,7 +173,7 @@ export class CurrentQuizService implements ICurrentQuiz {
public close(): Promise<any> {
return new Promise((resolve => {
if (isPlatformBrowser(this.platformId) && this._isOwner && this._quiz) {
this.quizApiService.deleteQuiz({
this.quizApiService.deactivateQuizAsOwner({
body: {
quizName: this._quiz.hashtag,
privateKey: window.localStorage.getItem('config.private_key'),
......
Markdown is supported
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