Newer
Older
ywb16155
committed
import {Injectable} from '@angular/core';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {HttpErrorService} from 'src/app/ErrorComponents/http-error.service';
ywb16155
committed
import {Observable} from 'rxjs';
import {catchError} from 'rxjs/operators';
import {MinutePaperWrapperDao} from 'src/app/dao/minute-paper-wrapper.dao';
import {environment} from '../../environments/environment';
ywb16155
committed
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
@Injectable()
export class LecturerInfoService {
constructor(private http$: HttpClient, private errorService: HttpErrorService) {
}
public getLecturerClasses(username: String): Observable<String | Object> {
return this.http$.post(environment.apiUrl + '/getLecturerClasses', {username: username}, httpOptions).pipe(
ywb16155
committed
catchError(this.errorService.handleError)
);
}
public getClassPapers(username: String, classCode: String): Observable<String | Object> {
return this.http$.post(environment.apiUrl + '/getClassPapers', {username: username, classCode: classCode}, httpOptions).pipe(
ywb16155
committed
catchError(this.errorService.handleError)
);
}
public getPaperQuestions(paperId: String): Observable<String | Object> {
return this.http$.post(environment.apiUrl + '/getPaperQuestions', {paperId: paperId}, httpOptions).pipe(
ywb16155
committed
catchError(this.errorService.handleError)
);
}
public getPaperAnswers(paperId: String): Observable<String | Object> {
return this.http$.post(environment.apiUrl + '/getPaperAnswers', {paperId: paperId}, httpOptions).pipe(
ywb16155
committed
catchError(this.errorService.handleError)
);
}
ywb16155
committed
public getTemplates(username: String): Observable<String | Object> {
return this.http$.post(environment.apiUrl + '/getTemplates', {username: username}, httpOptions).pipe(
catchError(this.errorService.handleError)
);
}
public createPaper(request: MinutePaperWrapperDao) {
return this.http$.post(environment.apiUrl + '/createPaper', request, httpOptions).pipe(
ywb16155
committed
catchError(this.errorService.handleError)
);
}
public deletePaper(paperId: String) {
return this.http$.post(environment.apiUrl + '/deletePaper', {paperId: paperId}, httpOptions).pipe(
ywb16155
committed
catchError(this.errorService.handleError)
);
}
public createTemplate(request: MinutePaperWrapperDao) {
return this.http$.post(environment.apiUrl + '/createTemplate', request, httpOptions).pipe(
ywb16155
committed
catchError(this.errorService.handleError)
);
}
public deleteTemplate(paperId: String) {
return this.http$.post(environment.apiUrl + '/deleteTemplate', {paperId: paperId}, httpOptions).pipe(
ywb16155
committed
catchError(this.errorService.handleError)
);
}
public getClassResponseData(username: String) {
return this.http$.post(environment.apiUrl + '/getResponseData', {username: username}, httpOptions).pipe(
catchError(this.errorService.handleError)
);
}