Commit 7d0c1029 authored by Ayush's avatar Ayush

Minor bugfix

parent 97b3e363
...@@ -24,13 +24,13 @@ $input_data = $postData['input_data']; ...@@ -24,13 +24,13 @@ $input_data = $postData['input_data'];
$ret_stat = 0; $ret_stat = 0;
$template = strval(rand(1, 1000000)); $template = strval(rand(1, 1000000));
$in_fname = "../user_execs/" . $uname . "/temp/temp_in" . $template; $in_fname = "../user_execs/" . $uname . "//temp_sfcode_139213617964/temp_in" . $template;
$file = fopen($in_fname, 'w'); $file = fopen($in_fname, 'w');
file_put_contents($in_fname, $input_data); file_put_contents($in_fname, $input_data);
fclose($file); fclose($file);
$out_fname = "../user_execs/" . $uname . "/temp/temp_out" . $template; $out_fname = "../user_execs/" . $uname . "//temp_sfcode_139213617964/temp_out" . $template;
if (strcmp($language, ".cpp") == 0) { if (strcmp($language, ".cpp") == 0) {
system("./../user_execs/" . $uname . "/" . $f_path . "/" . $filename . " < " . $in_fname . " > " . $out_fname, $ret_stat); system("./../user_execs/" . $uname . "/" . $f_path . "/" . $filename . " < " . $in_fname . " > " . $out_fname, $ret_stat);
......
...@@ -15,10 +15,10 @@ include_once("database.php"); ...@@ -15,10 +15,10 @@ include_once("database.php");
$postData = file_get_contents("php://input"); $postData = file_get_contents("php://input");
if (isset($postData) && !empty($postData)) { if (isset($postData) && !empty($postData)) {
$request = json_decode($postData); /** \brief POST data decoded. */ $request = json_decode($postData); /** \brief POST data decoded. */
$name = trim($request->name); $name = trim($request->name);
$pwd = password_hash(mysqli_real_escape_string($mysqli, trim($request->pwd)), PASSWORD_DEFAULT); $pwd = password_hash(mysqli_real_escape_string($mysqli, trim($request->pwd)), PASSWORD_DEFAULT);
$email = mysqli_real_escape_string($mysqli, trim($request->email)); $email = mysqli_real_escape_string($mysqli, trim($request->email));
...@@ -35,7 +35,7 @@ if (isset($postData) && !empty($postData)) { ...@@ -35,7 +35,7 @@ if (isset($postData) && !empty($postData)) {
'username' => $username 'username' => $username
]; ];
mkdir('../users/' . $authData['username'], 0777, true); mkdir('../users/' . $authData['username'], 0777, true);
mkdir('../user_execs/' . $authData['username'] . "/temp", 0777, true); mkdir('../user_execs/' . $authData['username'] . "/temp_sfcode_139213617964", 0777, true);
$mysqli->query($sql1); $mysqli->query($sql1);
echo json_encode($authData); echo json_encode($authData);
} }
......
...@@ -13,4 +13,4 @@ ...@@ -13,4 +13,4 @@
<textarea id="editor" name="editor"></textarea> <textarea id="editor" name="editor"></textarea>
</div> </div>
<app-input (valueEmit)="customInput = $event"></app-input> <app-input (valueEmit)="customInput = $event"></app-input>
<!-- <app-submit-try-code [problem]="problem"></app-submit-try-code> --> <app-submit-try-code [problem]="question"></app-submit-try-code>
...@@ -8,4 +8,4 @@ export interface Question { ...@@ -8,4 +8,4 @@ export interface Question {
out2: string; out2: string;
stime: string; stime: string;
etime: string; etime: string;
} }
\ No newline at end of file
...@@ -33,8 +33,9 @@ export class RunCodeService { ...@@ -33,8 +33,9 @@ export class RunCodeService {
// else {return throwError('error'); } // else {return throwError('error'); }
// } // }
tryTestcase(prob: Problem, index: number): Observable<boolean> { tryTestcase(prob: Question, index: number): Observable<boolean> {
return of(Math.floor(Math.random() * 2) === 1); // return of(Math.floor(Math.random() * 2) === 1);
} }
compileQuestionFile(ques: Question, code: string[]): Observable<any> { compileQuestionFile(ques: Question, code: string[]): Observable<any> {
......
import {Component, Input, OnInit} from '@angular/core'; import {Component, Input, OnInit} from '@angular/core';
import {Problem} from '../problem'; // import {Problem} from '../problem';
import {RunCodeService} from '../run-code.service'; import {RunCodeService} from '../run-code.service';
import {Question} from '../question';
@Component({ @Component({
selector: 'app-submit-try-code', selector: 'app-submit-try-code',
...@@ -12,7 +13,7 @@ export class SubmitTryCodeComponent implements OnInit { ...@@ -12,7 +13,7 @@ export class SubmitTryCodeComponent implements OnInit {
isActive = false; isActive = false;
nts: number[]; nts: number[];
status: number[]; status: number[];
@Input() problem: Problem; @Input() problem: Question;
submitting = 0; submitting = 0;
constructor(public runCodeService: RunCodeService) { } constructor(public runCodeService: RunCodeService) { }
...@@ -20,8 +21,8 @@ export class SubmitTryCodeComponent implements OnInit { ...@@ -20,8 +21,8 @@ export class SubmitTryCodeComponent implements OnInit {
ngOnInit(): void { } ngOnInit(): void { }
reset(): void { reset(): void {
this.nts = Array(this.problem.n_testcases[this.submitting]).fill(1).map((x, i) => i); this.nts = [0, 1]; //Array(this.problem.n_testcases[this.submitting]).fill(1).map((x, i) => i);
this.status = Array(this.problem.n_testcases[this.submitting]).fill(0); this.status = [0, 0]; // Array(this.problem.n_testcases[this.submitting]).fill(0);
for (const i of this.nts) { for (const i of this.nts) {
this.runCodeService.tryTestcase(this.problem, i) this.runCodeService.tryTestcase(this.problem, i)
......
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