sungjin

Fix cpp, add level when making post.

This diff is collapsed. Click to expand it.
...@@ -18,12 +18,21 @@ export class PostService { ...@@ -18,12 +18,21 @@ export class PostService {
18 example: string, 18 example: string,
19 testinput: string[], 19 testinput: string[],
20 testoutput: string[], 20 testoutput: string[],
21 + difficulty: number,
21 ) { 22 ) {
22 const user = await this.auth.validateUser( 23 const user = await this.auth.validateUser(
23 ( 24 (
24 await this.auth.getUserFromToken(token) 25 await this.auth.getUserFromToken(token)
25 ).id, 26 ).id,
26 ); 27 );
28 + let level: Level;
29 + if (difficulty == 1) {
30 + level = 'LOW';
31 + } else if (difficulty == 2) {
32 + level = 'MEDIUM';
33 + } else {
34 + level = 'HIGH';
35 + }
27 const post = await this.prisma.post.create({ 36 const post = await this.prisma.post.create({
28 data: { 37 data: {
29 author: { 38 author: {
...@@ -37,6 +46,7 @@ export class PostService { ...@@ -37,6 +46,7 @@ export class PostService {
37 example: example, 46 example: example,
38 testinput: testinput, 47 testinput: testinput,
39 testoutput: testoutput, 48 testoutput: testoutput,
49 + level: level,
40 }, 50 },
41 }); 51 });
42 return post; 52 return post;
......
...@@ -85,7 +85,7 @@ export class RunnerService { ...@@ -85,7 +85,7 @@ export class RunnerService {
85 cpp(body: any, location: string) { 85 cpp(body: any, location: string) {
86 const output: Array<string> = []; 86 const output: Array<string> = [];
87 if (body.input == []) { 87 if (body.input == []) {
88 - const test = child_process.spawnSync('gcc', [location, '-o', 'tmp'], { 88 + const test = child_process.spawnSync('g++', [location, '-o', 'tmp'], {
89 encoding: 'utf8', 89 encoding: 'utf8',
90 shell: true, 90 shell: true,
91 }); 91 });
...@@ -101,7 +101,7 @@ export class RunnerService { ...@@ -101,7 +101,7 @@ export class RunnerService {
101 output.push(result.stdout as string); 101 output.push(result.stdout as string);
102 } 102 }
103 for (const ip of body.input) { 103 for (const ip of body.input) {
104 - const test = child_process.spawnSync('gcc', [location, '-o', 'tmp'], { 104 + const test = child_process.spawnSync('g++', [location, '-o', 'tmp'], {
105 encoding: 'utf8', 105 encoding: 'utf8',
106 shell: true, 106 shell: true,
107 }); 107 });
...@@ -176,7 +176,7 @@ export class RunnerService { ...@@ -176,7 +176,7 @@ export class RunnerService {
176 output.push(result.stdout as string); 176 output.push(result.stdout as string);
177 } 177 }
178 for (const ip of body.input) { 178 for (const ip of body.input) {
179 - const result = child_process.spawnSync('go', ['run', location], { 179 + const result = child_process.spawnSync('ts-node', ['run', location], {
180 encoding: 'utf8', 180 encoding: 'utf8',
181 shell: true, 181 shell: true,
182 input: ip, 182 input: ip,
......