Skip to content
Snippets Groups Projects
Commit 4381dd5a authored by paflov's avatar paflov
Browse files

implement [PUT] /test endpoint

parent 6c9a5720
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ export interface LoginData { ...@@ -28,7 +28,7 @@ export interface LoginData {
costumTexts: KeyValuePair; // TODO when backend fixed then change here costumTexts: KeyValuePair; // TODO when backend fixed then change here
admintoken: string; admintoken: string;
workspaces: WorkspaceData[]; workspaces: WorkspaceData[];
is_superadmin: boolean is_superadmin: boolean;
} }
export interface BookletStatus { export interface BookletStatus {
...@@ -39,9 +39,9 @@ export interface BookletStatus { ...@@ -39,9 +39,9 @@ export interface BookletStatus {
label: string; label: string;
} }
export interface PersonTokenAndBookletDbId { export interface PersonTokenAndTestId {
persontoken: string; personToken: string;
bookletDbId: number; testId: number;
} }
export interface KeyValuePair { export interface KeyValuePair {
......
...@@ -3,7 +3,7 @@ import { Injectable, Inject } from '@angular/core'; ...@@ -3,7 +3,7 @@ import { Injectable, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import {catchError, switchMap} from 'rxjs/operators'; import {catchError, switchMap} from 'rxjs/operators';
import { LoginData, BookletStatus, PersonTokenAndBookletDbId, KeyValuePair } from './app.interfaces'; import { LoginData, BookletStatus, PersonTokenAndTestId, KeyValuePair } from './app.interfaces';
import {ErrorHandler, ServerError} from 'iqb-components'; import {ErrorHandler, ServerError} from 'iqb-components';
// ============================================================================ // ============================================================================
...@@ -87,22 +87,20 @@ export class BackendService { ...@@ -87,22 +87,20 @@ export class BackendService {
); );
} }
// BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
startBooklet(code: string, bookletid: string, bookletLabel: string): Observable<PersonTokenAndBookletDbId | ServerError> { startBooklet(code: string, bookletName: string, bookletLabel: string): Observable<PersonTokenAndTestId | ServerError> {
return this.http return this.http
.post<PersonTokenAndBookletDbId>(this.serverSlimUrl + 'startbooklet', {c: code, b: bookletid, bl: bookletLabel}) .put<PersonTokenAndTestId>(this.serverUrl2 + `test_tmp`, {code, bookletName, bookletLabel})
.pipe( .pipe(catchError(ErrorHandler.handle));
catchError(ErrorHandler.handle)
);
} }
// BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
addBookletLogClose(bookletDbId: number): Observable<boolean | ServerError> { addBookletLogClose(testId: number): Observable<boolean | ServerError> {
return this.http return this.http
.post<boolean>(this.serverSlimUrl_Close + 'log', {b: bookletDbId, t: Date.now(), e: 'BOOKLETLOCKEDbyTESTEE'}) .put<boolean>(this.serverUrl2 + `test/${testId}/log`, {timestamp: Date.now(), entry: 'BOOKLETLOCKEDbyTESTEE'})
.pipe( .pipe(catchError(ErrorHandler.handle));
catchError(ErrorHandler.handle)
);
} }
......
...@@ -3,7 +3,7 @@ import { Subscription, forkJoin } from 'rxjs'; ...@@ -3,7 +3,7 @@ import { Subscription, forkJoin } from 'rxjs';
import {CustomtextService, MessageDialogComponent, MessageDialogData, MessageType, ServerError} from 'iqb-components'; import {CustomtextService, MessageDialogComponent, MessageDialogData, MessageType, ServerError} from 'iqb-components';
import { MatDialog } from '@angular/material'; import { MatDialog } from '@angular/material';
import { BackendService } from '../backend.service'; import { BackendService } from '../backend.service';
import {PersonTokenAndBookletDbId, LoginData, WorkspaceData} from '../app.interfaces'; import {PersonTokenAndTestId, LoginData, WorkspaceData} from '../app.interfaces';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Component, OnInit, OnDestroy } from '@angular/core'; import { Component, OnInit, OnDestroy } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { FormGroup, FormBuilder, Validators } from '@angular/forms';
...@@ -265,13 +265,13 @@ export class StartComponent implements OnInit, OnDestroy { ...@@ -265,13 +265,13 @@ export class StartComponent implements OnInit, OnDestroy {
const e = startReturnUntyped as ServerError; const e = startReturnUntyped as ServerError;
this.mds.globalErrorMsg$.next(e); this.mds.globalErrorMsg$.next(e);
} else { } else {
const startReturn = startReturnUntyped as PersonTokenAndBookletDbId; const startReturn = startReturnUntyped as PersonTokenAndTestId;
this.mds.globalErrorMsg$.next(null); this.mds.globalErrorMsg$.next(null);
// ************************************************ // ************************************************
// by setting bookletDbId$ the test-controller will load the booklet // by setting bookletDbId$ the test-controller will load the booklet
this.dataLoading = true; this.dataLoading = true;
this.mds.setBookletDbId(startReturn.persontoken, startReturn.bookletDbId, b.label); this.mds.setBookletDbId(startReturn.personToken, startReturn.testId, b.label);
this.router.navigateByUrl('/t'); this.router.navigateByUrl('/t');
// ************************************************ // ************************************************
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment