Commit 364f3cad authored by Ayush's avatar Ayush

user service

parent d3192b37
......@@ -33,8 +33,18 @@ export class RunCodeService {
// else {return throwError('error'); }
// }
verifyTestcase(title: string, out: string, ind: number): Observable<any> {
return this.httpClient.post(this.baseUrl + 'questions/check_output.php', {title, out, ind});
verifyTestcase(file: File, out: string, ind: number, isSubmit: number): Observable<any> {
return this.httpClient.post(this.baseUrl + 'questions/check_output.php', {
title: file.filename,
username: file.username,
out,
ind,
isSubmit
});
}
update(b: boolean): Observable<any> {
return this.httpClient.put(this.baseUrl + 'update_correct.php', {b});
}
compileQuestionFile(ques: Question, code: string[]): Observable<any> {
......
......@@ -32,9 +32,17 @@ export class SubmitTryCodeComponent implements OnInit {
this.runCodeService.executeFile(file, testcases[i])
.subscribe(ret => {
console.log(ret);
this.runCodeService.verifyTestcase(file.filename, ret, i)
let nc = 0;
this.runCodeService.verifyTestcase(file, ret, i, this.submitting)
.subscribe(data => {
this.status[i] = data === 1 ? 1 : -1;
nc += data === 1 ? 1 : 0;
if (nc === 2) {
this.runCodeService.update(true);
} else if (i === 1) {
this.runCodeService.update(false);
}
});
});
}
......
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